SeaWolf-AI commited on
Commit
b8523e8
·
verified ·
1 Parent(s): f819a98

Display: icon grid grows with readable labels

Browse files
Files changed (1) hide show
  1. display.js +26 -26
display.js CHANGED
@@ -1,26 +1,26 @@
1
- /* Display scaling: lay the desktop out at a virtual 1920x1080 and scale it to the viewport (0.7 to 1.0).
2
- Modes: auto (default), 1, 0.9, 0.8, 0.7. Phones (< 768 px) keep the mobile layout without scaling. */
3
- (() => {
4
- 'use strict';
5
- const KEY = 'vk_scale';
6
- const get = () => { try { return localStorage.getItem(KEY) || 'auto'; } catch (e) { return 'auto'; } };
7
- function apply() {
8
- const de = document.documentElement, b = document.body;
9
- if (!b) return;
10
- const vw = window.innerWidth, vh = window.innerHeight, m = get();
11
- let s = 1;
12
- if (vw >= 768) s = m === 'auto' ? Math.max(0.7, Math.min(1, Math.min(vw / 1920, vh / 1080))) : Math.max(0.7, Math.min(1, parseFloat(m) || 1));
13
- if (s >= 0.999) { de.style.zoom = ''; b.style.width = ''; b.style.height = ''; de.classList.remove('vk-scaled'); }
14
- else { de.style.zoom = String(s); b.style.width = (vw / s) + 'px'; b.style.height = (vh / s) + 'px'; de.classList.add('vk-scaled'); }
15
- de.style.setProperty('--vk-scale', String(s));
16
- window.VK_SCALE = s;
17
- }
18
- window.VK_DISPLAY = { get, set(v) { try { localStorage.setItem(KEY, v); } catch (e) {} apply(); window.dispatchEvent(new Event('vk-display')); }, apply, modes: ['auto', '1', '0.9', '0.8', '0.7'] };
19
- window.addEventListener('resize', apply);
20
- document.addEventListener('DOMContentLoaded', apply);
21
- apply();
22
- const css = document.createElement('style');
23
- /* keep small labels readable when scaled down (effective size about 11 px or more) */
24
- css.textContent = `html.vk-scaled .icon span{font-size:calc(11.5px / var(--vk-scale))}html.vk-scaled #menubar,html.vk-scaled .win .tb b{font-size:calc(11.5px / var(--vk-scale))}html.vk-scaled .win .body{font-size:calc(11.5px / var(--vk-scale))}`;
25
- document.head.append(css);
26
- })();
 
1
+ /* Display scaling: lay the desktop out at a virtual 1920x1080 and scale it to the viewport (0.7 to 1.0).
2
+ Modes: auto (default), 1, 0.9, 0.8, 0.7. Phones (< 768 px) keep the mobile layout without scaling. */
3
+ (() => {
4
+ 'use strict';
5
+ const KEY = 'vk_scale';
6
+ const get = () => { try { return localStorage.getItem(KEY) || 'auto'; } catch (e) { return 'auto'; } };
7
+ function apply() {
8
+ const de = document.documentElement, b = document.body;
9
+ if (!b) return;
10
+ const vw = window.innerWidth, vh = window.innerHeight, m = get();
11
+ let s = 1;
12
+ if (vw >= 768) s = m === 'auto' ? Math.max(0.7, Math.min(1, Math.min(vw / 1920, vh / 1080))) : Math.max(0.7, Math.min(1, parseFloat(m) || 1));
13
+ if (s >= 0.999) { de.style.zoom = ''; b.style.width = ''; b.style.height = ''; de.classList.remove('vk-scaled'); }
14
+ else { de.style.zoom = String(s); b.style.width = (vw / s) + 'px'; b.style.height = (vh / s) + 'px'; de.classList.add('vk-scaled'); }
15
+ de.style.setProperty('--vk-scale', String(s));
16
+ window.VK_SCALE = s;
17
+ }
18
+ window.VK_DISPLAY = { get, set(v) { try { localStorage.setItem(KEY, v); } catch (e) {} apply(); window.dispatchEvent(new Event('vk-display')); }, apply, modes: ['auto', '1', '0.9', '0.8', '0.7'] };
19
+ window.addEventListener('resize', apply);
20
+ document.addEventListener('DOMContentLoaded', apply);
21
+ apply();
22
+ const css = document.createElement('style');
23
+ /* keep small labels readable when scaled down (effective size about 11 px or more) */
24
+ css.textContent = `html.vk-scaled #icons{grid-template-rows:repeat(5,auto);row-gap:10px;grid-auto-columns:104px}html.vk-scaled .icon span{font-size:calc(11px / var(--vk-scale));line-height:1.15}html.vk-scaled #menubar,html.vk-scaled .win .tb b{font-size:calc(11.5px / var(--vk-scale))}html.vk-scaled .win .body{font-size:calc(11.5px / var(--vk-scale))}`;
25
+ document.head.append(css);
26
+ })();