mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-05 18:49:57 +08:00
web: fix the iOS New Tab button and make the phone themes' home bars easier to use
iOS: the + in a window's navigation bar now takes its presses (its wrapper's larger target covered it), and in a home screen app the status bar's controls no longer reach below its 24 pt row over the navigation bar. iOS and Android: the home bar's strip is taller, its target nearly the strip's width and only 10 px over the window, with no text selection or callout on a long press; a swipe up the browser cancels after it went far enough still goes home or to the switcher. Android: a folder's small icons fill their square cells instead of drawing as flat ovals.
This commit is contained in:
@@ -69,14 +69,15 @@
|
||||
--wm-shadow: 0 4px 8px 3px rgb(0 0 0 / 15%), 0 1px 3px rgb(0 0 0 / 30%);
|
||||
--wm-shadow-focus: 0 8px 12px 6px rgb(0 0 0 / 15%), 0 4px 4px rgb(0 0 0 / 30%);
|
||||
/* The bars, at SystemUI's dp: the status bar 28 dp where the page has no top inset of its own, else a 24 dp row
|
||||
under the system's; the gesture navigation bar 24 dp, or the bottom inset where there is one. */
|
||||
under the system's; the gesture navigation bar 30 dp, or the bottom inset and 14 dp more where there is one
|
||||
(wider than SystemUI's 24 dp: a page's handle is harder to find with the finger than the system's). */
|
||||
--tb-h: max(24px, calc(28px - var(--st)));
|
||||
--tb-solid: var(--md-surface);
|
||||
--dock-h: max(0px, calc(24px - var(--sb)));
|
||||
--dock-h: max(14px, calc(30px - var(--sb)));
|
||||
--m-icon: 56px;
|
||||
accent-color: var(--md-primary);
|
||||
}
|
||||
:root[data-desktop="android"] #app.compact, :root[data-desktop="android"] #app { --dock-h: max(0px, calc(24px - var(--sb))); }
|
||||
:root[data-desktop="android"] #app.compact, :root[data-desktop="android"] #app { --dock-h: max(14px, calc(30px - var(--sb))); }
|
||||
:root[data-desktop="android"][data-theme="light"] {
|
||||
/* Light scheme (ColorLightTokens). */
|
||||
--md-primary: #6750a4; --md-on-primary: #fff; --md-primary-container: #eaddff; --md-on-primary-container: #21005d;
|
||||
@@ -207,13 +208,13 @@
|
||||
border-radius: 2px; background: var(--md-primary);
|
||||
}
|
||||
:root[data-desktop="android"] .m-app:has(.m-label)[data-running]::after { top: calc(var(--m-icon) + 2px); }
|
||||
/* A folder: a round plate (surface container, tinted) with its first four apps. */
|
||||
/* A folder: a round plate (surface container, tinted) with its first four apps, each filling its square cell. */
|
||||
:root[data-desktop="android"] .m-folder-icon {
|
||||
display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; padding: 9px;
|
||||
display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; place-items: stretch; gap: 3px; padding: 9px;
|
||||
background: var(--md-surface-container-high); box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
|
||||
}
|
||||
:root[data-desktop="android"] .m-folder-icon > .m-mini:nth-child(n + 5) { display: none; }
|
||||
:root[data-desktop="android"] .m-mini { display: grid; place-items: center; border-radius: 50%; background: linear-gradient(160deg, var(--c0), var(--c1)); color: #fff; }
|
||||
:root[data-desktop="android"] .m-mini { display: grid; place-items: center; min-width: 0; min-height: 0; border-radius: 50%; background: linear-gradient(160deg, var(--c0), var(--c1)); color: #fff; }
|
||||
:root[data-desktop="android"] .m-mini > .m-glyph { width: 58%; height: 58%; }
|
||||
:root[data-desktop="android"] .m-mini .m-glyph-text { font-size: 8px; }
|
||||
:root[data-desktop="android"] .m-ring { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); }
|
||||
@@ -257,7 +258,8 @@
|
||||
@keyframes md-fade { from { opacity: 0; } }
|
||||
@keyframes md-grow { from { opacity: 0; transform: scale(.8); } }
|
||||
|
||||
/* ---- the gesture navigation handle (mobile/HomeBar.tsx; SystemUI: 108 x 4 dp, 10 dp from the bottom) ---- */
|
||||
/* ---- the gesture navigation handle (mobile/HomeBar.tsx; SystemUI: 108 x 4 dp): its target is most of the
|
||||
bar's width and 10 px over the window above it (the window's last row stays the window's) ---- */
|
||||
:root[data-desktop="android"] #dock.m-homebar {
|
||||
position: relative; z-index: var(--z-topbar); display: flex; justify-content: center; align-items: flex-end; padding: 0 0 var(--sb);
|
||||
background: var(--md-surface); transition: background-color .3s var(--md-emphasized);
|
||||
@@ -265,9 +267,10 @@
|
||||
:root[data-desktop="android"] #dock.m-homebar[data-home], :root[data-desktop="android"] #dock.m-homebar[data-switcher],
|
||||
:root[data-desktop="android"] #app:not(.compact) #dock.m-homebar { background: transparent; }
|
||||
:root[data-desktop="android"] .m-handle-hit {
|
||||
position: absolute; left: 50%; bottom: 0; width: min(240px, 64%); height: calc(var(--dock-h) + var(--sb) + 16px); transform: translateX(-50%);
|
||||
display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(var(--sb) + 10px);
|
||||
/* 10 dp from the bottom (navigation_handle_bottom) in a 24 dp bar. */ touch-action: none; cursor: grab;
|
||||
position: absolute; left: 50%; bottom: 0; width: min(420px, calc(100% - 32px)); height: calc(var(--dock-h) + var(--sb) + 10px); transform: translateX(-50%);
|
||||
display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(var(--sb) + (var(--dock-h) - 4px) / 2);
|
||||
touch-action: none; cursor: grab;
|
||||
-webkit-touch-callout: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
:root[data-desktop="android"] .m-handle { width: 108px; height: 4px; border-radius: 2px; background: var(--md-on-surface); opacity: .85; transition: width .35s var(--md-spring-fast), height .35s var(--md-spring-fast); }
|
||||
:root[data-desktop="android"] #dock.m-homebar:is([data-home], [data-switcher]) .m-handle, :root[data-desktop="android"] #app:not(.compact) .m-handle { background: #fff; }
|
||||
|
||||
@@ -45,11 +45,12 @@
|
||||
--wm-shadow: 0 18px 50px rgb(0 0 0 / 45%); --wm-shadow-focus: 0 26px 70px rgb(0 0 0 / 60%);
|
||||
/* The bars, at iOS's point sizes: the status bar 47 pt where the page has no
|
||||
top inset of its own, else a 24 pt row under the system's; the home
|
||||
indicator's strip 21 pt, or the bottom inset where there is one; the
|
||||
indicator's strip 30 pt, or the bottom inset and 14 pt more where there
|
||||
is one (above the bottom edge, where iOS takes swipes for itself); the
|
||||
navigation bar 44 pt. */
|
||||
--tb-h: max(24px, calc(47px - var(--st)));
|
||||
--tb-solid: var(--ios-bar);
|
||||
--dock-h: max(0px, calc(21px - var(--sb)));
|
||||
--dock-h: max(14px, calc(30px - var(--sb)));
|
||||
--ios-nav-h: 44px;
|
||||
/* The page's touch target height (style.css, coarse pointers: 40 px) as iOS's standard button, 34 pt. */
|
||||
--hit: 34px; --hit-pad: 14px;
|
||||
@@ -57,7 +58,7 @@
|
||||
--m-radius: 22.37%;
|
||||
accent-color: var(--ios-blue);
|
||||
}
|
||||
:root[data-desktop="ios"] #app.compact, :root[data-desktop="ios"] #app { --dock-h: max(0px, calc(21px - var(--sb))); }
|
||||
:root[data-desktop="ios"] #app.compact, :root[data-desktop="ios"] #app { --dock-h: max(14px, calc(30px - var(--sb))); }
|
||||
:root[data-desktop="ios"][data-theme="light"] {
|
||||
--ios-blue: #007aff; --ios-red: #ff3b30; --ios-green: #34c759; --ios-orange: #ff9500; --ios-yellow: #ffcc00;
|
||||
--ios-bg: #fff; --ios-grouped: #f2f2f7; --ios-cell: #fff; --ios-cell2: #e5e5ea; --ios-cell3: #d1d1d6;
|
||||
@@ -124,7 +125,7 @@
|
||||
:root[data-desktop="ios"] .m-st-wide { font-weight: 600; opacity: .9; }
|
||||
:root[data-desktop="ios"] .m-st-center { display: flex; justify-content: center; min-width: 0; }
|
||||
:root[data-desktop="ios"] .m-st-right {
|
||||
display: flex; align-items: center; height: 100%; min-height: 44px; padding: 0 8px 0 6px; margin-right: -6px;
|
||||
display: flex; align-items: center; height: 100%; min-height: min(44px, var(--tb-h)); padding: 0 8px 0 6px; margin-right: -6px;
|
||||
color: inherit; border-radius: 12px;
|
||||
}
|
||||
:root[data-desktop="ios"] .m-st-right:focus-visible { outline: 2px solid var(--ios-blue); outline-offset: -4px; }
|
||||
@@ -266,7 +267,8 @@
|
||||
@keyframes ios-fade { from { opacity: 0; } }
|
||||
@keyframes ios-zoom { from { opacity: 0; transform: scale(.85); } }
|
||||
|
||||
/* ---- the home indicator (mobile/HomeBar.tsx) ---- */
|
||||
/* ---- the home indicator (mobile/HomeBar.tsx): its target is most of the strip's width and
|
||||
10 px over the window above it (the window's last row stays the window's) ---- */
|
||||
:root[data-desktop="ios"] #dock.m-homebar {
|
||||
position: relative; z-index: var(--z-topbar); display: flex; justify-content: center; align-items: flex-end;
|
||||
padding: 0 0 var(--sb); background: var(--ios-bg); transition: background-color .25s;
|
||||
@@ -274,9 +276,10 @@
|
||||
:root[data-desktop="ios"] #dock.m-homebar[data-home], :root[data-desktop="ios"] #dock.m-homebar[data-switcher],
|
||||
:root[data-desktop="ios"] #app:not(.compact) #dock.m-homebar { background: transparent; }
|
||||
:root[data-desktop="ios"] .m-handle-hit {
|
||||
position: absolute; left: 50%; bottom: 0; width: min(220px, 60%); height: calc(var(--dock-h) + var(--sb) + 14px); transform: translateX(-50%);
|
||||
display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(var(--sb) + 8px);
|
||||
position: absolute; left: 50%; bottom: 0; width: min(420px, calc(100% - 2 * max(16px, var(--sc)))); height: calc(var(--dock-h) + var(--sb) + 10px); transform: translateX(-50%);
|
||||
display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(var(--sb) + (var(--dock-h) - 5px) / 2);
|
||||
touch-action: none; cursor: grab;
|
||||
-webkit-touch-callout: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
:root[data-desktop="ios"] .m-handle { width: 134px; height: 5px; border-radius: 3px; background: var(--ios-label); opacity: .9; transition: width .2s; }
|
||||
:root[data-desktop="ios"] #dock.m-homebar[data-home] .m-handle, :root[data-desktop="ios"] #dock.m-homebar[data-switcher] .m-handle,
|
||||
@@ -326,6 +329,10 @@
|
||||
:root[data-desktop="ios"] .ios-nav-new > .tab-new, :root[data-desktop="ios"] .ios-winbar-end > .tab-new {
|
||||
width: 100%; height: 100%; border-radius: 50%; color: var(--ios-blue); background: none;
|
||||
}
|
||||
/* New Tab's larger target is its button's own: the wrapper's would cover the button and take its presses. */
|
||||
:root[data-desktop="ios"] .ios-nav-new::after { content: none; }
|
||||
:root[data-desktop="ios"] .ios-nav-new > .tab-new { position: relative; }
|
||||
:root[data-desktop="ios"] .ios-nav-new > .tab-new::after { content: ""; position: absolute; inset: -4px; }
|
||||
:root[data-desktop="ios"] .ios-winbar-end > .tab-new { width: 30px; height: 30px; background: var(--ios-fill2); }
|
||||
:root[data-desktop="ios"] :is(.ios-nav-new, .ios-winbar-end) > .tab-new[data-off] { opacity: .4; }
|
||||
/* The tabs as a segmented control under the bar, with two tabs or more. */
|
||||
@@ -732,10 +739,11 @@
|
||||
|
||||
/* ---- the status bar's resources (mobile/StatusBar.tsx: the page's applet items, #tb-net, #tb-cpu, #tb-mem, #tb-disk)
|
||||
where a phone has its signal and battery: the glyph and its slim meter at the bar's size, in the bar's colour
|
||||
(amber or red when high, as the page's), a target the bar's height and 40 pt wide. ---- */
|
||||
:root[data-desktop="ios"] .m-st-tray { justify-self: end; display: flex; align-items: center; height: 100%; }
|
||||
(amber or red when high, as the page's), a target the bar's height and 40 pt wide. Nothing of it reaches
|
||||
below the bar (a home screen app's row is 24 pt: style.css --st), where the windows' navigation bars are. ---- */
|
||||
:root[data-desktop="ios"] .m-st-tray { justify-self: end; display: flex; align-items: center; height: 100%; overflow: clip; }
|
||||
:root[data-desktop="ios"] .m-st-tray > .tb-btn {
|
||||
display: inline-flex; gap: 3px; min-width: 38px; height: 30px; padding: 0 4px; border-radius: 15px; background: none; color: inherit;
|
||||
display: inline-flex; gap: 3px; min-width: 38px; height: min(30px, var(--tb-h)); padding: 0 4px; border-radius: 15px; background: none; color: inherit;
|
||||
}
|
||||
:root[data-desktop="ios"] .m-st-tray > .tb-btn::after { content: ""; position: absolute; inset: -8px 0; }
|
||||
:root[data-desktop="ios"] .m-st-tray > .tb-btn.tb-wide { display: inline-flex; }
|
||||
|
||||
@@ -67,6 +67,12 @@ export function attachHomeBar(el: HTMLElement, h: BarHandlers): () => void {
|
||||
clearTimeout(rest);
|
||||
if (-dy > REST_PX) rest = setTimeout(() => { if (p && !p.done && -p.dy > REST_PX) finish("switcher"); }, REST_MS);
|
||||
};
|
||||
const vertical = (q: NonNullable<typeof p>) => {
|
||||
const dt = performance.now() - q.t;
|
||||
const fast = -q.dy / Math.max(1, dt) > FLING;
|
||||
const rested = performance.now() - q.still > REST_MS * 0.6;
|
||||
finish(-q.dy > innerHeight * 0.45 || (rested && -q.dy > REST_PX && !fast) ? "switcher" : -q.dy > HOME_PX || fast ? "home" : "cancel");
|
||||
};
|
||||
const up = (e: PointerEvent) => {
|
||||
if (!p || e.pointerId !== p.id) return;
|
||||
const q = p, dt = performance.now() - q.t;
|
||||
@@ -82,15 +88,18 @@ export function attachHomeBar(el: HTMLElement, h: BarHandlers): () => void {
|
||||
} else if (q.axis === "h") {
|
||||
q.done = true;
|
||||
if (Math.abs(q.dx) > SIDE_PX) h.end(q.dx > 0 ? "back" : "forward");
|
||||
} else {
|
||||
const fast = -q.dy / Math.max(1, dt) > FLING;
|
||||
const rested = performance.now() - q.still > REST_MS * 0.6;
|
||||
finish(-q.dy > innerHeight * 0.45 || (rested && -q.dy > REST_PX && !fast) ? "switcher" : -q.dy > HOME_PX || fast ? "home" : "cancel");
|
||||
}
|
||||
} else vertical(q);
|
||||
}
|
||||
p = null;
|
||||
};
|
||||
const cancel = (e: PointerEvent) => { if (p && e.pointerId === p.id) { finish("cancel"); p = null; } };
|
||||
// The browser took the pointer (iOS does for its own gestures near the screen's edge, or a long press):
|
||||
// a swipe up that had gone far enough still counts, as it would on release.
|
||||
const cancel = (e: PointerEvent) => {
|
||||
if (!p || e.pointerId !== p.id) return;
|
||||
if (p.axis === "v") vertical(p);
|
||||
else finish("cancel");
|
||||
p = null;
|
||||
};
|
||||
el.addEventListener("pointerdown", down);
|
||||
el.addEventListener("pointermove", move);
|
||||
el.addEventListener("pointerup", up);
|
||||
|
||||
Reference in New Issue
Block a user