From 260646bbc05e16280125c6575aa576adb2bc0ffd Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:08:01 +0700 Subject: [PATCH 01/32] shell: the window follows a theme's corners and, for a bevelled theme, its edges Every radius in the chrome and the panel scales with the theme's own radius (--wb-c-rs = radius / 12, 0 to 1.5): a square theme gets a square window, a round one a rounder window; themes that keep the site's colors keep wayBetter's own corners. A theme built from raised and sunken edges (ChromeTheme edges: 'bevel') gets frame/edges.css on html[data-wb-edges=bevel], also from the first frame: a face color under tabs, toolbar, menus and the panel, 98.css's four edge lines derived from that face, the active title bar's gradient across the tab row, tabs as a tab control, small raised caption buttons, a sunken address field, selected menu rows in the title bar's color, raised and default buttons, etched group boxes and classic scrollbars in the panel. Co-Authored-By: Claude Opus 5.5 --- packages/shell/src/frame/Shell.tsx | 2 + packages/shell/src/frame/accountSwitcher.css | 12 +- packages/shell/src/frame/appMenu.css | 12 +- packages/shell/src/frame/boot.ts | 2 + packages/shell/src/frame/chromeTheme.ts | 47 +++++- packages/shell/src/frame/deck.css | 60 ++++---- packages/shell/src/frame/edges.css | 154 +++++++++++++++++++ packages/shell/src/frame/paneTheme.css | 2 +- packages/shell/src/frame/shell.css | 97 ++++++------ packages/shell/src/frame/themeStore.ts | 11 +- packages/shell/src/frame/workspaces.css | 22 +-- packages/shell/src/panel/backup.css | 2 +- packages/shell/src/panel/builder.css | 80 +++++----- packages/shell/src/panel/make.css | 10 +- packages/shell/src/panel/panel.css | 114 +++++++------- packages/shell/src/panel/plugins.css | 10 +- packages/shell/src/panel/strings.css | 2 +- packages/shell/tests/frame.test.ts | 26 +++- 18 files changed, 449 insertions(+), 216 deletions(-) create mode 100644 packages/shell/src/frame/edges.css diff --git a/packages/shell/src/frame/Shell.tsx b/packages/shell/src/frame/Shell.tsx index 3272fa0..ce76963 100644 --- a/packages/shell/src/frame/Shell.tsx +++ b/packages/shell/src/frame/Shell.tsx @@ -46,6 +46,8 @@ import { frameless, isTauri, onMaximizedChange, os } from './windowBinding.ts'; import { loadWorkspaces, restoreWorkspace, workspaceList, workspaces } from './workspaces.ts'; import { stepZoom, zoomTarget } from './zoomStore.ts'; import './shell.css'; +// After shell.css: a bevelled theme's edges (html[data-wb-edges]). +import './edges.css'; type Placement = { referencePanel: string; direction: 'within' | 'right' | 'below' }; diff --git a/packages/shell/src/frame/accountSwitcher.css b/packages/shell/src/frame/accountSwitcher.css index c3c8ebd..15d8af7 100644 --- a/packages/shell/src/frame/accountSwitcher.css +++ b/packages/shell/src/frame/accountSwitcher.css @@ -9,15 +9,15 @@ .bt-acct-head .bt-kbd { height: 16px; min-width: 0; font: 500 10.5px/1 var(--bt-ui); } /* One account: the whole row is the main action; "…" sits at the right edge. */ -.bt-acct-row { position: relative; display: flex; flex-direction: column; border-radius: 10px; } +.bt-acct-row { position: relative; display: flex; flex-direction: column; border-radius: calc(10px * var(--bt-rs, 1)); } .bt-acct-line { position: relative; display: flex; align-items: center; } .bt-acct-row.is-focused { background: rgb(var(--bt-accent-rgb) / .08); box-shadow: inset 0 0 0 1px rgb(var(--bt-accent-rgb) / .22); } .bt-acct-row.is-focused::before { - content: ''; position: absolute; inset-inline-start: -5px; top: 12px; height: 24px; width: 3px; border-start-start-radius: 0; border-start-end-radius: 3px; border-end-end-radius: 3px; border-end-start-radius: 0; background: var(--bt-accent); + content: ''; position: absolute; inset-inline-start: -5px; top: 12px; height: 24px; width: 3px; border-start-start-radius: 0; border-start-end-radius: calc(3px * var(--bt-rs, 1)); border-end-end-radius: calc(3px * var(--bt-rs, 1)); border-end-start-radius: 0; background: var(--bt-accent); } .bt-acct-row.is-open { background: rgb(var(--bt-text-rgb) / .035); } -.bt-menu .bt-acct-main { flex: 1; min-width: 0; height: auto; gap: 11px; padding-block: 8px; padding-inline: 8px 40px; border-radius: 10px; } +.bt-menu .bt-acct-main { flex: 1; min-width: 0; height: auto; gap: 11px; padding-block: 8px; padding-inline: 8px 40px; border-radius: calc(10px * var(--bt-rs, 1)); } .bt-menu .bt-acct-main:focus-visible { box-shadow: var(--bt-ring); } .bt-acct-avatar { position: relative; display: inline-grid; flex: none; } .bt-acct-avatar.is-signed-out .bt-avatar, .bt-acct-avatar.is-new .bt-avatar { filter: saturate(.35); opacity: .7; } @@ -32,7 +32,7 @@ .bt-acct-meta.is-signed-out, .bt-acct-meta.is-new { color: #f0b14a; } .bt-acct-count { color: var(--bt-muted); } .bt-acct-badge { - flex: none; padding: 2px 6px; border-radius: 999px; background: rgb(var(--bt-text-rgb) / .07); color: var(--bt-text-2); + flex: none; padding: 2px 6px; border-radius: calc(999px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .07); color: var(--bt-text-2); font: 500 10.5px/1.2 var(--bt-ui); letter-spacing: .01em; } @@ -65,7 +65,7 @@ .bt-menu .bt-acct-danger > .bt-glyph { color: #ff8a80; } .bt-acct-confirm { - display: flex; flex-direction: column; gap: 10px; margin: 2px 6px 6px; padding: 10px 12px; border-radius: 9px; + display: flex; flex-direction: column; gap: 10px; margin: 2px 6px 6px; padding: 10px 12px; border-radius: calc(9px * var(--bt-rs, 1)); background: rgba(229, 72, 77, .08); box-shadow: inset 0 0 0 1px rgba(229, 72, 77, .25); color: var(--bt-text-2); font: 400 12.5px/1.45 var(--bt-ui); } .bt-acct-confirm strong { color: var(--bt-text); font-weight: 600; } @@ -75,7 +75,7 @@ .bt-menu .bt-acct-remove:hover:not(:disabled), .bt-menu .bt-acct-remove:focus-visible { background: #d93d42; } .bt-menu .bt-acct-cancel { background: var(--bt-hover); } -.bt-menu .bt-acct-add { height: auto; gap: 11px; padding: 8px; border-radius: 10px; } +.bt-menu .bt-acct-add { height: auto; gap: 11px; padding: 8px; border-radius: calc(10px * var(--bt-rs, 1)); } .bt-menu .bt-acct-add:focus-visible { box-shadow: var(--bt-ring); } .bt-acct-add .bt-acct-name { color: var(--bt-text-2); } .bt-acct-add-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--bt-line-strong); color: var(--bt-muted); } diff --git a/packages/shell/src/frame/appMenu.css b/packages/shell/src/frame/appMenu.css index d5e00c8..be2067d 100644 --- a/packages/shell/src/frame/appMenu.css +++ b/packages/shell/src/frame/appMenu.css @@ -5,7 +5,7 @@ /* The button: the last thing before the caption buttons. */ .bt-app-button { align-self: center; display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; margin-right: 8px; padding: 0; box-sizing: border-box; /* rtl-ok: titlebar */ - border: 1px solid transparent; border-radius: 15px; background: transparent; color: var(--bt-text-2); cursor: pointer; + border: 1px solid transparent; border-radius: calc(15px * var(--bt-rs, 1)); background: transparent; color: var(--bt-text-2); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-app-button:hover { background: var(--bt-hover); border-color: var(--bt-line-soft); color: var(--bt-text); } @@ -22,7 +22,7 @@ html:not(:has(.bt-app-button)) { --bt-tb-menu: 0px; } img.bt-titlebar-logo { width: 20px; height: 20px; margin: 12px 14px 12px 16px; flex: 0 0 20px; -webkit-user-drag: none; } /* rtl-ok: titlebar */ button.bt-titlebar-logo { align-self: center; display: inline-grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; margin: 0 9px 0 11px; padding: 0; box-sizing: border-box; /* rtl-ok: titlebar */ - border: 1px solid transparent; border-radius: 9px; background: transparent; cursor: pointer; -webkit-user-drag: none; + border: 1px solid transparent; border-radius: calc(9px * var(--bt-rs, 1)); background: transparent; cursor: pointer; -webkit-user-drag: none; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease); } button.bt-titlebar-logo img { display: block; width: 20px; height: 20px; pointer-events: none; -webkit-user-drag: none; } @@ -76,14 +76,14 @@ button.bt-titlebar-logo:focus-visible { outline: 0; box-shadow: var(--bt-ring); .bt-app-zoom { display: flex; align-items: center; gap: 10px; height: 36px; flex: none; padding-inline: 10px 3px; color: var(--bt-text); } .bt-app-zoom > .bt-glyph { color: var(--bt-muted); } .bt-app-zoom.is-off > .bt-glyph, .bt-app-zoom.is-off .bt-menu-label, .bt-app-zoom.is-off .bt-app-zoom-value { color: var(--bt-faint); } -.bt-app-zoom-step { display: flex; align-items: center; flex: none; height: 28px; border-radius: 9px; direction: ltr; background: rgb(var(--bt-text-rgb) / .04); box-shadow: inset 0 0 0 1px var(--bt-line); } -.bt-app-menu .bt-app-zoom button { width: 30px; height: 28px; flex: none; padding: 0; justify-content: center; border-radius: 8px; color: var(--bt-text-2); } +.bt-app-zoom-step { display: flex; align-items: center; flex: none; height: 28px; border-radius: calc(9px * var(--bt-rs, 1)); direction: ltr; background: rgb(var(--bt-text-rgb) / .04); box-shadow: inset 0 0 0 1px var(--bt-line); } +.bt-app-menu .bt-app-zoom button { width: 30px; height: 28px; flex: none; padding: 0; justify-content: center; border-radius: calc(8px * var(--bt-rs, 1)); color: var(--bt-text-2); } .bt-app-menu .bt-app-zoom button > .bt-glyph { width: 14px; height: 14px; color: inherit; } .bt-app-menu .bt-app-zoom button:focus { color: var(--bt-text); } .bt-app-menu .bt-app-zoom button[aria-disabled=true] { color: var(--bt-faint); cursor: default; } .bt-app-menu .bt-app-zoom button[aria-disabled=true]:active { background: var(--bt-hover); } .bt-app-zoom-value { min-width: 50px; padding: 0 2px; text-align: center; color: var(--bt-text); font: 500 12px/1 var(--bt-mono); font-variant-numeric: tabular-nums; } -.bt-app-menu .bt-app-zoom .bt-app-zoom-reset { width: 28px; border-radius: 9px; } +.bt-app-menu .bt-app-zoom .bt-app-zoom-reset { width: 28px; border-radius: calc(9px * var(--bt-rs, 1)); } /* Words that are not a choice: the mode question, an empty list, an error. */ .bt-app-note { display: flex; flex-direction: column; gap: 3px; max-width: 288px; padding: 8px 10px 7px; box-sizing: border-box; } @@ -92,7 +92,7 @@ button.bt-titlebar-logo:focus-visible { outline: 0; box-shadow: var(--bt-ring); .bt-app-note.is-error span { color: var(--bt-danger); } /* The account menu's last row: the way here from where the account name is. */ -.bt-menu .bt-acct-settings { flex: none; height: 34px; gap: 11px; padding: 0 8px; border-radius: 10px; color: var(--bt-text-2); } +.bt-menu .bt-acct-settings { flex: none; height: 34px; gap: 11px; padding: 0 8px; border-radius: calc(10px * var(--bt-rs, 1)); color: var(--bt-text-2); } .bt-menu .bt-acct-settings > .bt-glyph { width: 32px; height: 15px; } .bt-menu .bt-acct-settings:focus-visible { box-shadow: var(--bt-ring); } diff --git a/packages/shell/src/frame/boot.ts b/packages/shell/src/frame/boot.ts index 2f2e1b5..51d0848 100644 --- a/packages/shell/src/frame/boot.ts +++ b/packages/shell/src/frame/boot.ts @@ -26,6 +26,8 @@ export function bootScript(options: { label?: string } = {}): string { for (const [name, value] of Object.entries(vars)) { if (/^--wb-[a-z]-[a-z0-9-]+$/.test(name) && typeof value === 'string' && value.length < 400) root.style.setProperty(name, value); } + // The edge style (frame/edges.css) from the first frame too, like chromeEdges() in themeStore. + if (vars['--wb-c-edges'] === 'bevel') root.dataset.wbEdges = 'bevel'; // shell.css (loaded with the shell's modules) paints the same ground; this rule only covers // the frames before it, and \`html.bt-raised\` (more specific) still clears it. const style = document.createElement('style'); diff --git a/packages/shell/src/frame/chromeTheme.ts b/packages/shell/src/frame/chromeTheme.ts index 372c178..931807f 100644 --- a/packages/shell/src/frame/chromeTheme.ts +++ b/packages/shell/src/frame/chromeTheme.ts @@ -9,7 +9,16 @@ export const SHELL_MONO_FONT = "'Geist Mono Variable', ui-monospace, monospace"; /** A theme as the chrome needs it: seven colors (none: the site's own colors) and two font stacks. */ export type ChromeTheme = { - colors?: { bg: string; surface: string; elevated: string; border: string; text: string; muted: string; accent: string } | null; + /** `page`, `inverse` and `onInverse` are optional: a bevelled chrome builds its face and title bar from them. */ + colors?: { bg: string; surface: string; elevated: string; border: string; text: string; muted: string; accent: string; page?: string; inverse?: string; onInverse?: string } | null; + /** The theme's corner radius in px: every chrome radius scales by radius / 12 (0 to 1.5, `--wb-c-rs`). Absent: wayBetter's own. */ + radius?: number | null; + /** + * How the chrome's edges are drawn. `bevel`: raised and sunken edges after 98.css (MIT, Jordan + * Scales), square corners, a face color under tabs, menus and dialogs, a title-bar gradient + * (frame/edges.css, keyed on `html[data-wb-edges]`). Absent: wayBetter's own soft edges. + */ + edges?: 'bevel' | null; /** The chrome's font stack when the theme sets one other than SHELL_UI_FONT. */ chromeFont?: string | null; /** The mono font stack when the theme sets one. */ @@ -46,7 +55,8 @@ function legible(color: string, surface: string, ratio: number): string { /** * CSS custom properties for the chrome in `theme`. A theme that keeps the site's colors changes - * only the fonts; `own` keeps wayBetter's own style entirely (empty result). + * only the fonts (and keeps wayBetter's own corners and edges); `own` keeps wayBetter's own style + * entirely (empty result). */ export function chromeVars(theme: ChromeTheme, own = false): Record { if (own) return {}; @@ -56,6 +66,10 @@ export function chromeVars(theme: ChromeTheme, own = false): Record): Record { + const face = colors.page ?? colors.elevated; + const from = colors.inverse ?? colors.accent; + const titleText = colors.onInverse && contrast(colors.onInverse, from) >= 4.5 && contrast(colors.onInverse, colors.accent) >= 3 ? colors.onInverse + : contrast('#ffffff', from) >= contrast('#000000', from) ? '#ffffff' : '#000000'; + return { + '--wb-c-edges': 'bevel', '--wb-c-face': face, '--wb-c-face-text': legible(colors.text, face, 7), + '--wb-c-bevel-hi': mix(face, '#ffffff', 1), '--wb-c-bevel-lt': mix(face, '#ffffff', 0.49), + '--wb-c-bevel-sh': mix(face, '#000000', 0.335), '--wb-c-bevel-dk': mix(face, '#000000', 0.95), + '--wb-c-title-from': from, '--wb-c-title-to': colors.accent, '--wb-c-title-text': titleText, + // Selected rows (menus, lists): the title bar's own color, as in a 98 menu. + '--wb-c-select': from, '--wb-c-select-text': titleText, + }; +} + /** Every variable chromeVars may set (to clear them when a pane returns to the global theme). */ export const CHROME_VAR_NAMES = Object.keys(chromeVars({ colors: { bg: '#000000', surface: '#111111', elevated: '#222222', border: '#333333', text: '#ffffff', muted: '#999999', accent: '#1d9bf0' }, - chromeFont: 'A', monoFont: 'B', + chromeFont: 'A', monoFont: 'B', radius: 12, edges: 'bevel', })).concat('--wb-c-shadow-pop'); + +/** The edge style a set of chrome variables asks for (`html[data-wb-edges]`), or null. */ +export function chromeEdges(vars: Record): string | null { + return vars['--wb-c-edges'] === 'bevel' ? 'bevel' : null; +} diff --git a/packages/shell/src/frame/deck.css b/packages/shell/src/frame/deck.css index ffbb448..525a973 100644 --- a/packages/shell/src/frame/deck.css +++ b/packages/shell/src/frame/deck.css @@ -6,25 +6,25 @@ .bt-deck { position: relative; height: 100%; display: flex; flex-direction: column; background: var(--bt-ground); color: var(--bt-text); overflow: hidden; } /* The deck's dockview tab: unread total. */ -.bt-tab-unread { flex: none; min-width: 16px; height: 16px; padding: 0 5px; box-sizing: border-box; border-radius: 999px; background: var(--bt-accent); color: #fff; font: 700 10px/16px var(--bt-mono); text-align: center; } +.bt-tab-unread { flex: none; min-width: 16px; height: 16px; padding: 0 5px; box-sizing: border-box; border-radius: calc(999px * var(--bt-rs, 1)); background: var(--bt-accent); color: #fff; font: 700 10px/16px var(--bt-mono); text-align: center; } /* Deck bar ---------------------------------------------------------------------------------- */ .bt-deck-bar { flex: none; display: flex; align-items: center; gap: 10px; height: 40px; padding-block: 0; padding-inline: 14px 10px; } -.bt-deck-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, rgba(79, 107, 255, .28), rgba(34, 211, 238, .18)); box-shadow: inset 0 0 0 1px rgba(159, 211, 255, .18); color: #bfe0ff; } +.bt-deck-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: calc(7px * var(--bt-rs, 1)); background: linear-gradient(135deg, rgba(79, 107, 255, .28), rgba(34, 211, 238, .18)); box-shadow: inset 0 0 0 1px rgba(159, 211, 255, .18); color: #bfe0ff; } .bt-deck-mark .bt-glyph { width: 13px; height: 13px; } .bt-deck-name { font: 650 13.5px/1 var(--bt-ui); letter-spacing: -.01em; } .bt-deck-count { color: var(--bt-faint); font: 500 11.5px/1 var(--bt-ui); } -.bt-deck-total { padding: 4px 8px; border-radius: 999px; background: var(--bt-accent-soft); color: var(--bt-accent-ink); font: 600 11px/1 var(--bt-mono); box-shadow: inset 0 0 0 1px rgba(29, 155, 240, .28); } +.bt-deck-total { padding: 4px 8px; border-radius: calc(999px * var(--bt-rs, 1)); background: var(--bt-accent-soft); color: var(--bt-accent-ink); font: 600 11px/1 var(--bt-mono); box-shadow: inset 0 0 0 1px rgba(29, 155, 240, .28); } .bt-deck-fill { flex: 1; } -.bt-deck-pager { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 999px; background: var(--bt-field); box-shadow: inset 0 0 0 1px var(--bt-line-soft); } -.bt-deck-pager .bt-icon { width: 24px; height: 24px; border-radius: 999px; } +.bt-deck-pager { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: calc(999px * var(--bt-rs, 1)); background: var(--bt-field); box-shadow: inset 0 0 0 1px var(--bt-line-soft); } +.bt-deck-pager .bt-icon { width: 24px; height: 24px; border-radius: calc(999px * var(--bt-rs, 1)); } .bt-deck-pager .bt-glyph { width: 13px; height: 13px; } .bt-deck-dot { width: 18px; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer; position: relative; } -.bt-deck-dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 999px; background: var(--bt-line-strong); transition: width var(--bt-t2) var(--bt-ease-out), margin var(--bt-t2) var(--bt-ease-out), background-color var(--bt-t1) var(--bt-ease); } +.bt-deck-dot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: calc(999px * var(--bt-rs, 1)); background: var(--bt-line-strong); transition: width var(--bt-t2) var(--bt-ease-out), margin var(--bt-t2) var(--bt-ease-out), background-color var(--bt-t1) var(--bt-ease); } .bt-deck-dot:hover::after { background: var(--bt-muted); } .bt-deck-dot.is-on::after { width: 14px; margin-left: -7px; background: var(--bt-accent); } /* rtl-ok: centred with left: 50% */ -.bt-deck-memory { color: var(--bt-muted); font: 500 11px/1 var(--bt-mono); padding: 5px 8px; border-radius: 7px; background: rgba(238, 240, 247, .04); } -.bt-deck-action { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding-block: 0; padding-inline: 9px 11px; border: 0; border-radius: 8px; background: rgba(238, 240, 247, .05); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .06); color: var(--bt-text-2); font: 550 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } +.bt-deck-memory { color: var(--bt-muted); font: 500 11px/1 var(--bt-mono); padding: 5px 8px; border-radius: calc(7px * var(--bt-rs, 1)); background: rgba(238, 240, 247, .04); } +.bt-deck-action { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding-block: 0; padding-inline: 9px 11px; border: 0; border-radius: calc(8px * var(--bt-rs, 1)); background: rgba(238, 240, 247, .05); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .06); color: var(--bt-text-2); font: 550 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-deck-action .bt-glyph { width: 14px; height: 14px; } .bt-deck-action:hover { background: rgba(238, 240, 247, .09); color: var(--bt-text); } .bt-deck-action.is-on { background: var(--bt-accent-soft); box-shadow: inset 0 0 0 1px rgba(29, 155, 240, .38); color: var(--bt-accent-ink); } @@ -35,7 +35,7 @@ .bt-deck-row { position: relative; flex: 1; min-height: 0; margin: 0 8px; } .bt-col, .bt-compose { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; box-sizing: border-box; - border-radius: 12px 12px 0 0; background: var(--bt-chrome); box-shadow: inset 0 0 0 1px var(--bt-line-soft); + border-radius: calc(12px * var(--bt-rs, 1)) calc(12px * var(--bt-rs, 1)) 0 0; background: var(--bt-chrome); box-shadow: inset 0 0 0 1px var(--bt-line-soft); --bt-col-account: var(--bt-accent); } /* Motion never transforms a column's body: the webview is placed on the body's rectangle, so only @@ -50,12 +50,12 @@ .bt-col-head, .bt-compose-head { position: relative; flex: none; display: flex; align-items: center; gap: 8px; height: 46px; padding-block: 0; padding-inline: 8px 6px; - border-radius: 12px 12px 0 0; border-bottom: 1px solid var(--bt-line-soft); + border-radius: calc(12px * var(--bt-rs, 1)) calc(12px * var(--bt-rs, 1)) 0 0; border-bottom: 1px solid var(--bt-line-soft); background: linear-gradient(180deg, rgba(238, 240, 247, .025), transparent); } /* The focused column: an accent line on top and a lifted header. */ .bt-col-head::before, .bt-compose-head::before { - content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 2px; border-radius: 0 0 2px 2px; + content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 2px; border-radius: 0 0 calc(2px * var(--bt-rs, 1)) calc(2px * var(--bt-rs, 1)); background: var(--bt-brush); opacity: 0; transform: scaleX(.6); transition: opacity var(--bt-t2) var(--bt-ease), transform var(--bt-t3) var(--bt-ease-out); } .bt-col.is-focused .bt-col-head::before, .bt-compose-head::before { opacity: 1; transform: none; } @@ -63,7 +63,7 @@ .bt-col.is-focused .bt-col-head { background: linear-gradient(180deg, rgba(29, 155, 240, .08), rgba(29, 155, 240, 0)); } .bt-col-glyph { - display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px; padding: 0; border: 0; + display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: calc(8px * var(--bt-rs, 1)); padding: 0; border: 0; background: color-mix(in srgb, var(--bt-col-account) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bt-col-account) 30%, transparent); color: color-mix(in srgb, var(--bt-col-account) 55%, #ffffff); } @@ -75,15 +75,15 @@ .bt-col-titles span { color: var(--bt-muted); font: 450 11.5px/1.1 var(--bt-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .bt-col-fill { flex: 1; min-width: 4px; } .bt-col-unread { - flex: none; min-width: 22px; height: 20px; padding: 0 7px; box-sizing: border-box; border: 0; border-radius: 999px; cursor: pointer; + flex: none; min-width: 22px; height: 20px; padding: 0 7px; box-sizing: border-box; border: 0; border-radius: calc(999px * var(--bt-rs, 1)); cursor: pointer; background: var(--bt-accent); color: #fff; font: 700 11px/20px var(--bt-mono); letter-spacing: -.02em; box-shadow: 0 0 0 3px rgba(29, 155, 240, .16), 0 4px 12px -4px rgba(29, 155, 240, .8); animation: bt-unread-in var(--bt-t3) var(--bt-ease-out); } .bt-col-unread:hover { filter: brightness(1.12); } @keyframes bt-unread-in { from { transform: scale(.6); opacity: 0; } } -.bt-col-account { display: grid; place-items: center; flex: none; padding: 2px; border-radius: 999px; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--bt-col-account) 70%, transparent); } -.bt-col-btn { width: 28px; height: 28px; border-radius: 8px; color: var(--bt-muted); } +.bt-col-account { display: grid; place-items: center; flex: none; padding: 2px; border-radius: calc(999px * var(--bt-rs, 1)); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--bt-col-account) 70%, transparent); } +.bt-col-btn { width: 28px; height: 28px; border-radius: calc(8px * var(--bt-rs, 1)); color: var(--bt-muted); } .bt-col-btn .bt-glyph { width: 15px; height: 15px; } .bt-col-btn:hover { color: var(--bt-text); } .bt-col-btn.is-active { color: var(--bt-accent-ink); background: var(--bt-accent-soft); } @@ -99,8 +99,8 @@ .bt-compose { right: 0; animation: bt-fade-in var(--bt-t3) var(--bt-ease-out) both; box-shadow: inset 0 0 0 1px rgba(29, 155, 240, .28), -18px 0 40px -24px rgba(0, 0, 0, .8); } .bt-compose > .bt-compose-head { animation: bt-slide-in var(--bt-t3) var(--bt-ease-out) both; } .bt-compose-glyph { --bt-col-account: var(--bt-accent); } -.bt-compose-accounts { display: flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--bt-field); } -.bt-compose-accounts button { display: grid; place-items: center; padding: 2px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; opacity: .55; transition: opacity var(--bt-t1) var(--bt-ease); } +.bt-compose-accounts { display: flex; gap: 2px; padding: 2px; border-radius: calc(999px * var(--bt-rs, 1)); background: var(--bt-field); } +.bt-compose-accounts button { display: grid; place-items: center; padding: 2px; border: 0; border-radius: calc(999px * var(--bt-rs, 1)); background: transparent; cursor: pointer; opacity: .55; transition: opacity var(--bt-t1) var(--bt-ease); } .bt-compose-accounts button:hover { opacity: .9; } .bt-compose-accounts button.is-on { opacity: 1; box-shadow: 0 0 0 1.5px var(--bt-accent); } @@ -111,18 +111,18 @@ .bt-deck-pop-head strong { font: 650 13px/1 var(--bt-ui); } .bt-deck-pop-head span { margin-inline-start: auto; color: var(--bt-faint); font: 500 11.5px/1 var(--bt-ui); max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .bt-deck-terms { display: flex; flex-direction: column; gap: 8px; padding: 0 4px 6px; } -.bt-deck-input { height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--bt-field); box-shadow: inset 0 0 0 1px var(--bt-line); color: var(--bt-text); font: 450 12.5px/1 var(--bt-mono); outline: none; user-select: text; } +.bt-deck-input { height: 32px; padding: 0 10px; border: 0; border-radius: calc(8px * var(--bt-rs, 1)); background: var(--bt-field); box-shadow: inset 0 0 0 1px var(--bt-line); color: var(--bt-text); font: 450 12.5px/1 var(--bt-mono); outline: none; user-select: text; } .bt-deck-input:focus { box-shadow: var(--bt-ring); } .bt-deck-chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 120px; overflow-y: auto; scrollbar-width: thin; } -.bt-deck-chip { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; height: 24px; padding-block: 0; padding-inline: 9px 2px; border-radius: 999px; background: rgba(238, 240, 247, .06); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .07); font: 500 12px/1 var(--bt-ui); } +.bt-deck-chip { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; height: 24px; padding-block: 0; padding-inline: 9px 2px; border-radius: calc(999px * var(--bt-rs, 1)); background: rgba(238, 240, 247, .06); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .07); font: 500 12px/1 var(--bt-ui); } .bt-deck-chip > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .bt-deck-chip.is-regex { font-family: var(--bt-mono); color: #d7c6ff; background: rgba(168, 85, 247, .12); box-shadow: inset 0 0 0 1px rgba(168, 85, 247, .25); } -.bt-menu .bt-deck-chip button { width: 20px; height: 20px; padding: 0; justify-content: center; border-radius: 999px; } +.bt-menu .bt-deck-chip button { width: 20px; height: 20px; padding: 0; justify-content: center; border-radius: calc(999px * var(--bt-rs, 1)); } .bt-deck-chip .bt-glyph { width: 11px; height: 11px; } -.bt-deck-check { display: flex; align-items: flex-start; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; } +.bt-deck-check { display: flex; align-items: flex-start; gap: 10px; padding: 7px 8px; border-radius: calc(8px * var(--bt-rs, 1)); cursor: pointer; } .bt-deck-check:hover { background: var(--bt-hover); } .bt-deck-check input { position: absolute; opacity: 0; pointer-events: none; } -.bt-deck-check-box { display: grid; place-items: center; flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 5px; box-shadow: inset 0 0 0 1.5px var(--bt-line-strong); color: transparent; transition: background-color var(--bt-t1) var(--bt-ease); } +.bt-deck-check-box { display: grid; place-items: center; flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: calc(5px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1.5px var(--bt-line-strong); color: transparent; transition: background-color var(--bt-t1) var(--bt-ease); } .bt-deck-check-box .bt-glyph { width: 11px; height: 11px; stroke-width: 2.4; } .bt-deck-check input:checked + .bt-deck-check-box { background: var(--bt-accent); box-shadow: none; color: #fff; } .bt-deck-check input:focus-visible + .bt-deck-check-box { box-shadow: var(--bt-ring); } @@ -131,12 +131,12 @@ .bt-deck-check-text small { color: var(--bt-muted); font: 400 11.5px/1.2 var(--bt-ui); } .bt-deck-widths { display: flex; align-items: center; gap: 2px; padding-block: 4px; padding-inline: 10px 6px; color: var(--bt-muted); font: 500 12px/1 var(--bt-ui); } .bt-deck-widths > span { margin-inline-end: auto; } -.bt-menu .bt-deck-widths button { height: 24px; padding: 0 6px; border-radius: 6px; color: var(--bt-muted); font: 500 11px/1 var(--bt-mono); } +.bt-menu .bt-deck-widths button { height: 24px; padding: 0 6px; border-radius: calc(6px * var(--bt-rs, 1)); color: var(--bt-muted); font: 500 11px/1 var(--bt-mono); } .bt-menu .bt-deck-widths button.is-on { background: var(--bt-accent-soft); color: var(--bt-accent-ink); } /* Buttons ----------------------------------------------------------------------------------- */ .bt-deck-primary, .bt-deck-secondary { - display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border: 0; border-radius: 9px; cursor: pointer; + display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border: 0; border-radius: calc(9px * var(--bt-rs, 1)); cursor: pointer; font: 600 13px/1 var(--bt-ui); transition: filter var(--bt-t1) var(--bt-ease), background-color var(--bt-t1) var(--bt-ease); } .bt-deck-primary { background: var(--bt-accent); color: #fff; box-shadow: 0 6px 18px -8px rgba(29, 155, 240, .9), inset 0 1px 0 rgba(255, 255, 255, .18); } @@ -155,7 +155,7 @@ .bt-deck-empty-keys { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; justify-content: center; margin-top: 10px !important; font-size: 12px !important; color: var(--bt-faint) !important; } .bt-deck-empty-keys > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; } .bt-deck-empty-art { display: flex; gap: 6px; height: 64px; align-items: flex-end; } -.bt-deck-empty-art span { width: 30px; border-radius: 7px 7px 2px 2px; background: linear-gradient(180deg, rgba(79, 107, 255, .5), rgba(34, 211, 238, .12)); box-shadow: inset 0 0 0 1px rgba(159, 211, 255, .2); animation: bt-rise var(--bt-t3) var(--bt-ease-out) both; } +.bt-deck-empty-art span { width: 30px; border-radius: calc(7px * var(--bt-rs, 1)) calc(7px * var(--bt-rs, 1)) calc(2px * var(--bt-rs, 1)) calc(2px * var(--bt-rs, 1)); background: linear-gradient(180deg, rgba(79, 107, 255, .5), rgba(34, 211, 238, .12)); box-shadow: inset 0 0 0 1px rgba(159, 211, 255, .2); animation: bt-rise var(--bt-t3) var(--bt-ease-out) both; } .bt-deck-empty-art span:nth-child(1) { height: 64px; } .bt-deck-empty-art span:nth-child(2) { height: 52px; } .bt-deck-empty-art span:nth-child(3) { height: 58px; } @@ -169,7 +169,7 @@ .bt-addcol-head .bt-icon { margin-inline-start: auto; align-self: center; } .bt-addcol-types { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 10px 16px 6px; } .bt-addcol-type { - display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 96px; padding: 12px; border: 0; border-radius: 11px; cursor: pointer; text-align: start; + display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 96px; padding: 12px; border: 0; border-radius: calc(11px * var(--bt-rs, 1)); cursor: pointer; text-align: start; background: rgba(238, 240, 247, .035); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .06); color: var(--bt-text-2); transition: background-color var(--bt-t1) var(--bt-ease), box-shadow var(--bt-t1) var(--bt-ease), transform var(--bt-t2) var(--bt-ease-out); } @@ -178,24 +178,24 @@ .bt-addcol-type.is-on { background: var(--bt-accent-soft); box-shadow: inset 0 0 0 1.5px rgba(29, 155, 240, .6); color: var(--bt-text); } .bt-addcol-type strong { font: 650 13.5px/1.1 var(--bt-ui); color: var(--bt-text); } .bt-addcol-type small { color: var(--bt-muted); font: 400 11.5px/1.35 var(--bt-ui); } -.bt-addcol-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(238, 240, 247, .06); color: var(--bt-muted); } +.bt-addcol-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: calc(8px * var(--bt-rs, 1)); background: rgba(238, 240, 247, .06); color: var(--bt-muted); } .bt-addcol-type.is-on .bt-addcol-icon { background: rgba(29, 155, 240, .22); color: #bfe0ff; } .bt-addcol-icon .bt-glyph { width: 15px; height: 15px; } .bt-addcol-value { display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 4px; } .bt-addcol-value label, .bt-addcol-label { color: var(--bt-faint); font: 600 10.5px/1 var(--bt-ui); letter-spacing: .08em; text-transform: uppercase; } -.bt-addcol-field { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 10px; background: var(--bt-field); box-shadow: inset 0 0 0 1px var(--bt-line); } +.bt-addcol-field { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: calc(10px * var(--bt-rs, 1)); background: var(--bt-field); box-shadow: inset 0 0 0 1px var(--bt-line); } .bt-addcol-field:focus-within { box-shadow: var(--bt-ring); } .bt-addcol-field.is-bad { box-shadow: 0 0 0 1px rgba(229, 72, 77, .7); } .bt-addcol-field .bt-glyph { color: var(--bt-muted); } .bt-addcol-field input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--bt-text); font: 500 14px/1 var(--bt-mono); outline: none; user-select: text; } .bt-addcol-field input::placeholder { color: var(--bt-faint); } .bt-addcol-chips { display: flex; flex-wrap: wrap; gap: 6px; } -.bt-addcol-chips button { height: 26px; padding: 0 10px; border: 0; border-radius: 999px; background: rgba(238, 240, 247, .06); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .08); color: var(--bt-text-2); font: 500 12px/1 var(--bt-mono); cursor: pointer; } +.bt-addcol-chips button { height: 26px; padding: 0 10px; border: 0; border-radius: calc(999px * var(--bt-rs, 1)); background: rgba(238, 240, 247, .06); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .08); color: var(--bt-text-2); font: 500 12px/1 var(--bt-mono); cursor: pointer; } .bt-addcol-chips button[aria-selected=true] { background: var(--bt-accent-soft); color: var(--bt-accent-ink); box-shadow: inset 0 0 0 1px rgba(29, 155, 240, .35); } .bt-addcol-error { margin: 0; color: #ff9a9e; font-size: 12px; } .bt-addcol-accounts { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 8px; } .bt-addcol-accounts > div { display: flex; flex-wrap: wrap; gap: 6px; } -.bt-addcol-account { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding-block: 0; padding-inline: 6px 12px; border: 0; border-radius: 999px; cursor: pointer; background: rgba(238, 240, 247, .04); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .07); color: var(--bt-text-2); font: 550 12.5px/1 var(--bt-ui); } +.bt-addcol-account { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding-block: 0; padding-inline: 6px 12px; border: 0; border-radius: calc(999px * var(--bt-rs, 1)); cursor: pointer; background: rgba(238, 240, 247, .04); box-shadow: inset 0 0 0 1px rgba(238, 240, 247, .07); color: var(--bt-text-2); font: 550 12.5px/1 var(--bt-ui); } .bt-addcol-account:hover { background: rgba(238, 240, 247, .08); } .bt-addcol-account.is-on { box-shadow: inset 0 0 0 1.5px var(--bt-col-account); color: var(--bt-text); background: color-mix(in srgb, var(--bt-col-account) 12%, transparent); } .bt-addcol-account em { color: var(--bt-faint); font: italic 400 11px/1 var(--bt-ui); } diff --git a/packages/shell/src/frame/edges.css b/packages/shell/src/frame/edges.css new file mode 100644 index 0000000..0761e8b --- /dev/null +++ b/packages/shell/src/frame/edges.css @@ -0,0 +1,154 @@ +/* + * Bevelled chrome: the app's own window drawn like the theme it shows when that theme is built from + * raised and sunken edges (a Windows 98 theme). chromeVars() sets `--wb-c-edges: bevel` and the edge + * colors; themeStore (and boot.js on the first frame) mirror it on `html[data-wb-edges=bevel]`. + * + * The edges are 98.css's (MIT, (c) Jordan Scales, https://github.com/jdan/98.css): a raised part has a + * highlight and a light line on its top and left and a shadow and a near-black line on its bottom and + * right; a sunken field has the same four lines the other way round. Here they come from the theme's + * own face color (--wb-c-face, --wb-c-bevel-*), so any palette can be bevelled. + * + * Square corners come from the radius scale (the theme's radius 0 makes --bt-rs 0); this file only + * draws faces, edges, the title bar and selection. Global only: a pane with another theme keeps its + * colors, fonts and radii under these edges. + */ +html[data-wb-edges=bevel] { + --bt-bv-face: var(--wb-c-face, #c0c0c0); --bt-bv-text: var(--wb-c-face-text, #000000); + --bt-bv-hi: var(--wb-c-bevel-hi, #ffffff); --bt-bv-lt: var(--wb-c-bevel-lt, #dfdfdf); --bt-bv-sh: var(--wb-c-bevel-sh, #808080); --bt-bv-dk: var(--wb-c-bevel-dk, #0a0a0a); + --bt-bv-out: inset -1px -1px var(--bt-bv-dk), inset 1px 1px var(--bt-bv-hi), inset -2px -2px var(--bt-bv-sh), inset 2px 2px var(--bt-bv-lt); + --bt-bv-window: inset -1px -1px var(--bt-bv-dk), inset 1px 1px var(--bt-bv-lt), inset -2px -2px var(--bt-bv-sh), inset 2px 2px var(--bt-bv-hi); + --bt-bv-in: inset -1px -1px var(--bt-bv-hi), inset 1px 1px var(--bt-bv-sh), inset -2px -2px var(--bt-bv-lt), inset 2px 2px var(--bt-bv-dk); + --bt-bv-pressed: inset -1px -1px var(--bt-bv-hi), inset 1px 1px var(--bt-bv-dk), inset -2px -2px var(--bt-bv-lt), inset 2px 2px var(--bt-bv-sh); + --bt-bv-etched: inset -1px -1px var(--bt-bv-hi), inset 1px 1px var(--bt-bv-sh), inset -2px -2px var(--bt-bv-sh), inset 2px 2px var(--bt-bv-hi); + --bt-bv-title: linear-gradient(90deg, var(--wb-c-title-from, #000080), var(--wb-c-title-to, #1084d0)); + --bt-bv-title-text: var(--wb-c-title-text, #ffffff); + --bt-bv-select: var(--wb-c-select, #000080); --bt-bv-select-text: var(--wb-c-select-text, #ffffff); + /* The shell's surfaces become the face; text fields stay the theme's background. */ + --bt-ground: var(--bt-bv-face); --bt-chrome: var(--bt-bv-face); --bt-field: var(--wb-c-ground, #ffffff); --bt-raised: var(--bt-bv-face); --bt-raised-2: var(--bt-bv-face); + --bt-text: var(--bt-bv-text); --bt-text-2: var(--bt-bv-text); + --bt-hover: transparent; --bt-press: transparent; --bt-shadow-pop: var(--bt-bv-window); + --bt-ring: 0 0 0 1px var(--bt-bv-dk); +} +html[data-wb-edges=bevel] :where(.bt-shell, .bt-menu, .bt-palette, .bt-media, .btp) :focus-visible { outline: 1px dotted var(--bt-bv-text); outline-offset: -4px; } + +/* ------------------------------------------------------------------------------------------------ + * Title bar: the active window's gradient across the tab row; tabs are a tab control on its floor. */ +html[data-wb-edges=bevel] .bt-shell { background: var(--bt-bv-title) top / 100% var(--bt-titlebar-h) no-repeat, var(--bt-bv-face); } +html[data-wb-edges=bevel] .bt-shell--empty .bt-titlebar { background: var(--bt-bv-title); } +html[data-wb-edges=bevel] .bt-shell .bt-group--in-titlebar > .dv-tabs-and-actions-container { background: transparent; } +html[data-wb-edges=bevel] .bt-shell .dv-tabs-and-actions-container { background: var(--bt-bv-face); } +html[data-wb-edges=bevel] .bt-shell .dv-tabs-container .dv-tab { + --bt-tab-bg: var(--bt-bv-face); --bt-tab-fg: var(--bt-bv-text); + height: 28px; margin: 8px 2px 0 0; box-shadow: inset -1px 0 var(--bt-bv-dk), inset 1px 1px var(--bt-bv-hi), inset -2px 0 var(--bt-bv-sh), inset 2px 2px var(--bt-bv-lt); +} +html[data-wb-edges=bevel] .bt-shell .bt-group--in-titlebar .dv-tabs-container .dv-tab { height: 30px; margin-top: 14px; } +html[data-wb-edges=bevel] .bt-shell .dv-tabs-container .dv-tab.dv-inactive-tab:hover { --bt-tab-bg: var(--bt-bv-face); --bt-tab-fg: var(--bt-bv-text); } +/* The selected tab stands 2px taller and runs into the toolbar under it, like a 98 tab control. */ +html[data-wb-edges=bevel] .bt-shell .dv-tabs-container .dv-tab.dv-active-tab, +html[data-wb-edges=bevel] .bt-shell .dv-groupview.dv-inactive-group .dv-tabs-container .dv-tab.dv-active-tab { + --bt-tab-bg: var(--bt-bv-face); --bt-tab-fg: var(--bt-bv-text); z-index: 1; font-weight: 700; + box-shadow: inset -1px 0 var(--bt-bv-dk), inset 1px 1px var(--bt-bv-hi), inset -2px 0 var(--bt-bv-sh), inset 2px 2px var(--bt-bv-lt); +} +html[data-wb-edges=bevel] .bt-shell .bt-group--in-titlebar .dv-tabs-container .dv-tab.dv-active-tab { height: 32px; margin-top: 12px; } +html[data-wb-edges=bevel] .bt-shell .dv-tabs-container .dv-tab.dv-active-tab::after { display: none; } +html[data-wb-edges=bevel] .bt-shell .dv-groupview.dv-inactive-group .dv-tabs-container .dv-tab.dv-active-tab { font-weight: 400; } +html[data-wb-edges=bevel] .bt-shell .dv-tabs-container .dv-tab:has(.bt-tab--pinned) + .dv-tab:not(:has(.bt-tab--pinned))::before { background: var(--bt-bv-sh); } +html[data-wb-edges=bevel] .bt-tab-close { color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .bt-tab-close:hover { background: transparent; box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] .bt-tab-close:active { box-shadow: var(--bt-bv-pressed); } +/* Things drawn straight on the title bar take its label color. */ +html[data-wb-edges=bevel] .bt-group--in-titlebar .bt-group-actions .bt-icon, +html[data-wb-edges=bevel] .bt-shell .bt-group--in-titlebar .dv-tabs-overflow-dropdown-default { color: var(--bt-bv-title-text); } +html[data-wb-edges=bevel] .bt-group--in-titlebar .bt-group-actions .bt-icon:hover { color: var(--bt-bv-text); background: var(--bt-bv-face); box-shadow: var(--bt-bv-out); } +/* Caption buttons: three small raised buttons, the close one apart. */ +html[data-wb-edges=bevel] .bt-captions { align-items: center; gap: 2px; padding-inline-end: 6px; } +html[data-wb-edges=bevel] .bt-caption { width: 22px; height: 20px; color: var(--bt-bv-text); background: var(--bt-bv-face); box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] .bt-caption:hover { background: var(--bt-bv-face); color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .bt-caption:active { box-shadow: var(--bt-bv-pressed); } +html[data-wb-edges=bevel] .bt-caption--close { margin-inline-start: 2px; } +html[data-wb-edges=bevel] .bt-caption--close:hover, html[data-wb-edges=bevel] .bt-caption--close:active { background: var(--bt-bv-face); color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .bt-shell .bt-caption svg { width: 8px; height: 8px; stroke-width: 2; } +/* Titlebar buttons (account switcher, update chip, workspaces) are raised buttons on the title bar. */ +html[data-wb-edges=bevel] :is(.bt-profile-switcher, .bt-update-chip, .bt-ws-button) { border: 0; background: var(--bt-bv-face); color: var(--bt-bv-text); box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] :is(.bt-profile-switcher, .bt-update-chip, .bt-ws-button):hover { background: var(--bt-bv-face); } +html[data-wb-edges=bevel] :is(.bt-profile-switcher[aria-expanded=true], .bt-update-chip:active, .bt-ws-button[aria-expanded=true]) { box-shadow: var(--bt-bv-pressed); } + +/* ------------------------------------------------------------------------------------------------ + * Toolbar: flat buttons that rise under the pointer, a sunken address field, the wB button raised. */ +html[data-wb-edges=bevel] .bt-addressbar { background: var(--bt-bv-face); border-bottom: 0; box-shadow: inset 0 -1px var(--bt-bv-sh), inset 0 -2px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .bt-icon { color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .bt-icon:hover:not(:disabled) { background: transparent; box-shadow: inset -1px -1px var(--bt-bv-sh), inset 1px 1px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .bt-icon:active:not(:disabled) { box-shadow: inset -1px -1px var(--bt-bv-hi), inset 1px 1px var(--bt-bv-sh); } +html[data-wb-edges=bevel] .bt-icon:disabled { color: var(--bt-bv-sh); } +html[data-wb-edges=bevel] .bt-omni { border: 0; background: var(--bt-field); box-shadow: var(--bt-bv-in); padding-inline: 6px; } +html[data-wb-edges=bevel] .bt-omni:hover { box-shadow: var(--bt-bv-in); } +html[data-wb-edges=bevel] .bt-omni:focus-within, html[data-wb-edges=bevel] .bt-omni:focus-visible { box-shadow: var(--bt-bv-in); } +html[data-wb-edges=bevel] .bt-omni-progress { background: var(--bt-bv-select); } +html[data-wb-edges=bevel] .bt-brand-button { border: 0; background: var(--bt-bv-face); box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] .bt-brand-button:hover { border: 0; background: var(--bt-bv-face); } +html[data-wb-edges=bevel] .bt-brand-button:active, html[data-wb-edges=bevel] .bt-pane-menu[aria-expanded=true] { background: var(--bt-bv-face); box-shadow: var(--bt-bv-pressed); } +html[data-wb-edges=bevel] .bt-brand-button:hover .bt-wb { transform: none; } + +/* ------------------------------------------------------------------------------------------------ + * Menus, the palette, popovers: a window edge on the face; the row under the pointer is selected. */ +html[data-wb-edges=bevel] :is(.bt-menu, .bt-palette) { border: 0; background: var(--bt-bv-face); box-shadow: var(--bt-bv-window); color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .bt-menu { padding: 3px; } +html[data-wb-edges=bevel] .bt-menu button { height: 26px; } +html[data-wb-edges=bevel] .bt-menu button:hover:not(:disabled), html[data-wb-edges=bevel] .bt-menu button:focus-visible, +html[data-wb-edges=bevel] .bt-menu button[aria-expanded=true] { background: var(--bt-bv-select); color: var(--bt-bv-select-text); outline: 0; } +html[data-wb-edges=bevel] .bt-menu button:hover:not(:disabled) :is(.bt-glyph, .bt-menu-keys, small, svg), +html[data-wb-edges=bevel] .bt-menu button:focus-visible :is(.bt-glyph, .bt-menu-keys, small, svg), +html[data-wb-edges=bevel] .bt-menu button[aria-expanded=true] :is(.bt-glyph, .bt-menu-keys, small, svg) { color: var(--bt-bv-select-text); } +html[data-wb-edges=bevel] .bt-menu button > .bt-glyph { color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .bt-menu button:disabled { color: var(--bt-bv-sh); text-shadow: 1px 1px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .bt-menu-keys { color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .bt-menu hr { border-top: 1px solid var(--bt-bv-sh); border-bottom: 1px solid var(--bt-bv-hi); margin: 3px 2px; } +html[data-wb-edges=bevel] .bt-palette::before { display: none; } +html[data-wb-edges=bevel] .bt-palette-field { border-bottom: 0; box-shadow: inset 0 -1px var(--bt-bv-sh), inset 0 -2px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .bt-palette-backdrop { background: transparent; } +html[data-wb-edges=bevel] .bt-kbd { background: var(--bt-bv-face); box-shadow: var(--bt-bv-out); color: var(--bt-bv-text); } +/* Text fields and steppers inside menus are sunken. */ +html[data-wb-edges=bevel] .bt-menu :is(input[type=text], input:not([type]), .bt-app-zoom-step, .bt-deck-input) { border: 0; background: var(--bt-field); box-shadow: var(--bt-bv-in); } + +/* ------------------------------------------------------------------------------------------------ + * The settings panel: a dialog face, etched group boxes, raised buttons, sunken fields, a selected + * section in the title bar's color. */ +html[data-wb-edges=bevel] .btp { + --c-ground: var(--bt-bv-face); --c-chrome: var(--bt-bv-face); --c-card: var(--bt-bv-face); --c-raise: var(--bt-bv-face); --c-popover: var(--bt-bv-face); + --c-text: var(--bt-bv-text); --c-line: var(--bt-bv-sh); --c-line-soft: var(--bt-bv-sh); --c-line-strong: var(--bt-bv-dk); + --c-accent: var(--bt-bv-select); --c-accent-ink: var(--bt-bv-select-text); --c-brush: var(--bt-bv-title); + letter-spacing: 0; -webkit-font-smoothing: auto; +} +html[data-wb-edges=bevel] .btp-head { background: var(--bt-bv-face); } +html[data-wb-edges=bevel] .btp-head::after { opacity: 1; height: 2px; background: none; box-shadow: inset 0 1px var(--bt-bv-sh), inset 0 -1px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .btp-nav { border-bottom: 0; box-shadow: inset 0 -1px var(--bt-bv-sh), inset 0 -2px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .btp-nav button { color: var(--bt-bv-text); } +html[data-wb-edges=bevel] .btp-nav button:hover { background: transparent; box-shadow: inset -1px -1px var(--bt-bv-sh), inset 1px 1px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .btp-nav button.is-on { background: var(--bt-bv-select); color: var(--bt-bv-select-text); box-shadow: none; } +html[data-wb-edges=bevel] .btp-nav button.is-on svg { color: var(--bt-bv-select-text); } +html[data-wb-edges=bevel] .btp .bt-card { border: 0; box-shadow: var(--bt-bv-etched); padding: 2px; } +html[data-wb-edges=bevel] .btp :is(.bt-btn, .bt-select-button, .bt-stepper button, .bt-inputrow button) { border: 0; background: var(--bt-bv-face); color: var(--bt-bv-text); box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] .btp :is(.bt-btn, .bt-select-button, .bt-stepper button, .bt-inputrow button):hover:not(:disabled) { border: 0; background: var(--bt-bv-face); } +html[data-wb-edges=bevel] .btp :is(.bt-btn, .bt-stepper button, .bt-inputrow button):active:not(:disabled) { transform: none; box-shadow: var(--bt-bv-pressed); } +/* The default button carries the extra dark frame of a 98 dialog's default button. */ +html[data-wb-edges=bevel] .btp .bt-btn.is-primary { box-shadow: inset 0 0 0 1px var(--bt-bv-dk), inset -2px -2px var(--bt-bv-dk), inset 2px 2px var(--bt-bv-hi), inset -3px -3px var(--bt-bv-sh), inset 3px 3px var(--bt-bv-lt); } +html[data-wb-edges=bevel] .btp .bt-btn.is-ghost { box-shadow: none; } +html[data-wb-edges=bevel] .btp .bt-btn.is-ghost:hover:not(:disabled) { box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] .btp .bt-btn:disabled { opacity: 1; color: var(--bt-bv-sh); text-shadow: 1px 1px var(--bt-bv-hi); } +html[data-wb-edges=bevel] .btp .bt-btn.is-danger { background: var(--bt-bv-face); color: var(--c-danger); } +html[data-wb-edges=bevel] .btp :is(.bt-input, .btp-input, .bt-inputrow, .bt-search, .bt-hex, .bt-code, .wb-builder-name) { border: 0; background: var(--wb-c-ground, #ffffff); box-shadow: var(--bt-bv-in); } +html[data-wb-edges=bevel] .btp :is(.bt-input, .btp-input, .bt-inputrow, .bt-search):is(:focus, :focus-within) { box-shadow: var(--bt-bv-in); } +html[data-wb-edges=bevel] .btp .bt-seg { border: 0; background: var(--bt-bv-face); box-shadow: var(--bt-bv-in); } +html[data-wb-edges=bevel] .btp .bt-seg-thumb { background: var(--bt-bv-face); box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] .btp .bt-toggle { box-shadow: var(--bt-bv-in); } +html[data-wb-edges=bevel] .btp .bt-toggle-knob { box-shadow: var(--bt-bv-out); background: var(--bt-bv-face); } +html[data-wb-edges=bevel] .btp :is(.bt-select-list, .bt-popover) { border: 0; background: var(--bt-bv-face); box-shadow: var(--bt-bv-window); } +html[data-wb-edges=bevel] .btp .bt-select-list li.is-active { background: var(--bt-bv-select); color: var(--bt-bv-select-text); } + +/* Classic scrollbars: a dithered track, raised thumb and arrows. */ +html[data-wb-edges=bevel] :is(.bt-shell, .bt-menu, .bt-palette, .btp) * { scrollbar-width: auto; scrollbar-color: auto; } +html[data-wb-edges=bevel] ::-webkit-scrollbar { width: 16px; height: 16px; } +html[data-wb-edges=bevel] ::-webkit-scrollbar-track { background: repeating-conic-gradient(var(--bt-bv-face) 0 25%, var(--bt-bv-hi) 0 50%) 0 0 / 2px 2px; } +html[data-wb-edges=bevel] ::-webkit-scrollbar-thumb { background: var(--bt-bv-face); box-shadow: var(--bt-bv-out); border-radius: 0; } +html[data-wb-edges=bevel] ::-webkit-scrollbar-button:single-button { display: block; width: 16px; height: 16px; background: var(--bt-bv-face); box-shadow: var(--bt-bv-out); } +html[data-wb-edges=bevel] ::-webkit-scrollbar-corner { background: var(--bt-bv-face); } diff --git a/packages/shell/src/frame/paneTheme.css b/packages/shell/src/frame/paneTheme.css index a39ba11..d094f33 100644 --- a/packages/shell/src/frame/paneTheme.css +++ b/packages/shell/src/frame/paneTheme.css @@ -1,5 +1,5 @@ /* Theme swatches (page, text, accent) and the "Theme for this pane" menu. */ -.wb-dots { display: inline-flex; align-items: center; gap: 3px; flex: none; height: 18px; padding: 0 5px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgb(127 127 127 / .28); } +.wb-dots { display: inline-flex; align-items: center; gap: 3px; flex: none; height: 18px; padding: 0 5px; border-radius: calc(6px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1px rgb(127 127 127 / .28); } .wb-dots i { width: 7px; height: 7px; border-radius: 50%; } .wb-pane-menu { width: 272px; } .wb-pane-menu-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px 6px; color: var(--bt-muted); font: 600 11px/1 var(--bt-ui); letter-spacing: .04em; text-transform: uppercase; } diff --git a/packages/shell/src/frame/shell.css b/packages/shell/src/frame/shell.css index 913dbbe..3254f84 100644 --- a/packages/shell/src/frame/shell.css +++ b/packages/shell/src/frame/shell.css @@ -20,6 +20,10 @@ --bt-ring: 0 0 0 1px rgb(var(--bt-accent-rgb) / .55), 0 0 0 4px rgb(var(--bt-accent-rgb) / .16); --bt-shadow-pop: var(--wb-c-shadow-pop, 0 18px 44px -14px rgba(0, 0, 0, .75), 0 3px 10px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .035)); --bt-ui: var(--wb-f-chrome, 'Geist Variable', system-ui, sans-serif); --bt-mono: var(--wb-f-mono, 'Geist Mono Variable', ui-monospace, monospace); + /* Radii scale with the theme's corners (chromeVars: --wb-c-rs, the theme radius / 12): every px + radius in the chrome is calc( * var(--bt-rs, 1)), so a square theme gets a square window. */ + --bt-rs: var(--wb-c-rs, 1); + --bt-r1: calc(6px * var(--bt-rs)); --bt-r2: calc(8px * var(--bt-rs)); --bt-r3: calc(10px * var(--bt-rs)); --bt-r4: calc(12px * var(--bt-rs)); --bt-r5: calc(14px * var(--bt-rs)); color-scheme: var(--wb-c-scheme, dark); } .wb-pane-theme { --bt-bg: var(--bt-ground); --bt-surface: var(--bt-chrome); --bt-surface-2: var(--bt-field); } @@ -27,7 +31,6 @@ --bt-danger: #e5484d; --bt-brush: linear-gradient(90deg, #4f6bff, #22d3ee 55%, #a855f7); --bt-s1: 4px; --bt-s2: 8px; --bt-s3: 12px; --bt-s4: 16px; --bt-s5: 24px; --bt-s6: 32px; - --bt-r1: 6px; --bt-r2: 8px; --bt-r3: 10px; --bt-r4: 12px; --bt-r5: 14px; --bt-ease: cubic-bezier(.2, .7, .2, 1); --bt-ease-out: cubic-bezier(.16, 1, .3, 1); --bt-t1: 120ms; --bt-t2: 180ms; --bt-t3: 320ms; --bt-titlebar-h: 44px; --bt-toolbar-h: 48px; --bt-resize-border: 5px; @@ -57,13 +60,13 @@ html, body, #root { height: 100%; margin: 0; overflow: hidden; background: var(- :where(.bt-shell, .bt-menu, .bt-palette, .bt-media) :focus-visible { outline: 2px solid rgb(var(--bt-accent-rgb) / .8); outline-offset: 1px; } :where(.bt-palette-list, .bt-profile-menu, .bt-start, .bt-media-body, .dv-tabs-overflow-container) { scrollbar-width: thin; scrollbar-color: var(--bt-line-strong) transparent; } -.bt-kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 5px; background: rgb(var(--bt-text-rgb) / .06); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .07), inset 0 -1px 0 rgb(var(--bt-text-rgb) / .05); color: var(--bt-text-2); font: 500 10.5px/1 var(--bt-mono); } +.bt-kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: calc(5px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .06); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .07), inset 0 -1px 0 rgb(var(--bt-text-rgb) / .05); color: var(--bt-text-2); font: 500 10.5px/1 var(--bt-mono); } .bt-kbd + .bt-kbd { margin-inline-start: 3px; } .bt-avatar--image { overflow: hidden; position: relative; } .bt-avatar--image img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; } .bt-avatar--image::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); } -.bt-profile-signin { margin-inline-start: auto; font: 600 12px/1 var(--bt-ui); color: var(--bt-accent); background: rgb(var(--bt-accent-rgb) / .12); border: 0; border-radius: 999px; padding: 6px 10px; cursor: pointer; } +.bt-profile-signin { margin-inline-start: auto; font: 600 12px/1 var(--bt-ui); color: var(--bt-accent); background: rgb(var(--bt-accent-rgb) / .12); border: 0; border-radius: calc(999px * var(--bt-rs, 1)); padding: 6px 10px; cursor: pointer; } .bt-profile-signin:hover { background: rgb(var(--bt-accent-rgb) / .2); } .bt-avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-family: var(--bt-ui); font-weight: 650; line-height: 1; letter-spacing: 0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), inset 0 -6px 10px -6px rgba(0, 0, 0, .25); user-select: none; } @@ -111,7 +114,7 @@ html[data-update] { --bt-tb-right: calc(138px + 48px + 184px + 184px + var(--bt- html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + var(--bt-tb-menu) + var(--bt-tb-extra, 0px)); } .bt-update-chip { align-self: center; display: inline-flex; align-items: center; gap: 8px; height: 28px; margin-right: 8px; padding: 0 12px 0 10px; /* rtl-ok: titlebar */ - border: 1px solid transparent; border-radius: 14px; color: var(--bt-text); font: 500 12px/1 var(--bt-ui); white-space: nowrap; cursor: pointer; + border: 1px solid transparent; border-radius: calc(14px * var(--bt-rs, 1)); color: var(--bt-text); font: 500 12px/1 var(--bt-ui); white-space: nowrap; cursor: pointer; background: linear-gradient(var(--bt-field), var(--bt-field)) padding-box, var(--bt-brush) border-box; transition: background var(--bt-t1) var(--bt-ease); } @@ -127,7 +130,7 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va /* Account switcher (titlebar). Width is reserved in --bt-tb-right. */ .bt-profile-switcher { align-self: center; display: inline-flex; align-items: center; gap: 8px; max-width: 176px; height: 30px; margin-right: 8px; padding: 0 9px 0 4px; box-sizing: border-box; /* rtl-ok: titlebar */ - border: 1px solid var(--bt-line-soft); border-radius: 15px; background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-text); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; + border: 1px solid var(--bt-line-soft); border-radius: calc(15px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-text); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease); } .bt-profile-switcher:hover { background: var(--bt-hover); border-color: var(--bt-line-strong); } @@ -191,7 +194,7 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va * Tabs: floating pills. They shrink to 52px (favicon only), then the strip scrolls and dockview adds its "N more" list. */ .bt-shell .dv-tabs-container .dv-tab { --bt-tab-bg: var(--bt-ground); --bt-tab-fg: var(--bt-muted); - height: 30px; margin: 5px 2px 0 0; padding: 0; border-radius: 9px; box-sizing: border-box; + height: 30px; margin: 5px 2px 0 0; padding: 0; border-radius: calc(9px * var(--bt-rs, 1)); box-sizing: border-box; width: 224px; min-width: 52px; flex: 0 1 auto; /* Dockview colors tabs with higher-specificity rules; the pill states below only set these two variables. */ color: var(--bt-tab-fg) !important; background-color: var(--bt-tab-bg) !important; box-shadow: none; @@ -205,7 +208,7 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va } /* The brush marks the focused pane's tab; other panes keep a plain raised pill. */ .bt-shell .dv-tabs-container .dv-tab.dv-active-tab::after { - content: ''; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; border-radius: 2px 2px 0 0; + content: ''; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; border-radius: calc(2px * var(--bt-rs, 1)) calc(2px * var(--bt-rs, 1)) 0 0; background: var(--bt-brush); opacity: .95; pointer-events: none; } .bt-shell .dv-groupview.dv-inactive-group .dv-tabs-container .dv-tab.dv-active-tab { --bt-tab-bg: var(--bt-field); --bt-tab-fg: var(--bt-text-2); } @@ -223,13 +226,13 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va .bt-tab { container-type: inline-size; height: 100%; width: 100%; box-sizing: border-box; display: flex; align-items: center; gap: 8px; padding-block: 0; padding-inline: 10px 5px; min-width: 0; user-select: none; font: 500 12.5px/1 var(--bt-ui); letter-spacing: .005em; } .bt-tab--pinned { justify-content: center; padding: 0; } .bt-tab-icon { position: relative; display: grid; place-items: center; width: 16px; height: 16px; flex: 0 0 16px; } -.bt-favicon { width: 16px !important; height: 16px !important; flex: 0 0 16px; border-radius: 4px; color: var(--bt-muted); } +.bt-favicon { width: 16px !important; height: 16px !important; flex: 0 0 16px; border-radius: calc(4px * var(--bt-rs, 1)); color: var(--bt-muted); } .bt-favicon--img { animation: bt-fade-in var(--bt-t2) var(--bt-ease); } .bt-shell .bt-favicon--glyph { width: 15px !important; height: 15px !important; } .bt-tab-account { position: absolute; inset-inline-end: -3px; bottom: -3px; width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bt-tab-bg, var(--bt-raised)); transition: box-shadow var(--bt-t1) var(--bt-ease); } .bt-tab-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; line-height: 16px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent); } .bt-tab--loading .bt-tab-title { color: var(--bt-text-2); } -.bt-tab-close { flex: 0 0 20px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--bt-muted); cursor: pointer; opacity: 0; transition: opacity var(--bt-t1) var(--bt-ease), background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } +.bt-tab-close { flex: 0 0 20px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 0; border-radius: calc(6px * var(--bt-rs, 1)); background: transparent; color: var(--bt-muted); cursor: pointer; opacity: 0; transition: opacity var(--bt-t1) var(--bt-ease), background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-shell .bt-tab-close svg { width: 13px; height: 13px; stroke-width: 2; } .dv-tab:hover .bt-tab-close, .dv-active-tab .bt-tab-close, .bt-tab-close:focus-visible { opacity: 1; } .dv-inactive-tab .bt-tab-close { color: var(--bt-faint); } @@ -253,7 +256,7 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va .bt-group-actions { height: 100%; display: flex; align-items: center; padding: 0 4px 0 2px; } .bt-group--in-titlebar .bt-group-actions { padding-top: 0; } -.bt-group-actions .bt-icon { width: 28px; height: 28px; flex-basis: 28px; border-radius: 8px; } +.bt-group-actions .bt-icon { width: 28px; height: 28px; flex-basis: 28px; border-radius: calc(8px * var(--bt-rs, 1)); } .bt-group--in-titlebar .bt-group-actions .bt-icon { margin-top: 0; } .bt-shell .bt-newtab svg { width: 15px; height: 15px; } @@ -263,7 +266,7 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va } .bt-shell .dv-tabs-overflow-dropdown-root { display: flex; align-items: center; height: 100%; } .bt-shell .dv-tabs-overflow-dropdown-default { - height: 26px; margin: 0 2px 0 4px; padding: 0 8px 0 6px; gap: 2px; box-sizing: border-box; border-radius: 8px; + height: 26px; margin: 0 2px 0 4px; padding: 0 8px 0 6px; gap: 2px; box-sizing: border-box; border-radius: calc(8px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .04); box-shadow: inset 0 0 0 1px var(--bt-line); color: var(--bt-text-2); font: 500 11.5px/1 var(--bt-mono); font-variant-numeric: tabular-nums; transition: background-color var(--bt-t1) var(--bt-ease); } @@ -306,14 +309,14 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va .bt-omni--edit { padding-inline-start: 10px; gap: 8px; } .bt-shell .bt-omni-lead { width: 15px; height: 15px; color: var(--bt-muted); } .bt-chip-site { - display: inline-flex; align-items: center; gap: 6px; height: 24px; padding-block: 0; padding-inline: 6px 8px; margin-inline-end: 2px; flex: 0 0 auto; border: 0; border-radius: 7px; + display: inline-flex; align-items: center; gap: 6px; height: 24px; padding-block: 0; padding-inline: 6px 8px; margin-inline-end: 2px; flex: 0 0 auto; border: 0; border-radius: calc(7px * var(--bt-rs, 1)); background: var(--bt-accent-soft); color: var(--bt-accent-ink); font: 600 12.5px/1 var(--bt-ui); letter-spacing: .005em; cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease); } .bt-chip-site:hover { background: rgb(var(--bt-accent-rgb) / .22); } -.bt-chip-site img { width: 14px; height: 14px; border-radius: 3px; } -.bt-chip-insecure { display: inline-flex; align-items: center; flex: 0 0 auto; height: 22px; margin-inline-end: 2px; padding: 0 8px; border-radius: 6px; background: rgba(245, 158, 11, .12); color: #fbbf24; font: 600 11.5px/1 var(--bt-ui); } -.bt-seg { display: inline-flex; align-items: center; height: 24px; padding: 0 6px; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; border-radius: 6px; border: 0; background: transparent; color: var(--bt-text-2); font: 500 13px/1 var(--bt-ui); white-space: nowrap; cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } +.bt-chip-site img { width: 14px; height: 14px; border-radius: calc(3px * var(--bt-rs, 1)); } +.bt-chip-insecure { display: inline-flex; align-items: center; flex: 0 0 auto; height: 22px; margin-inline-end: 2px; padding: 0 8px; border-radius: calc(6px * var(--bt-rs, 1)); background: rgba(245, 158, 11, .12); color: #fbbf24; font: 600 11.5px/1 var(--bt-ui); } +.bt-seg { display: inline-flex; align-items: center; height: 24px; padding: 0 6px; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; border-radius: calc(6px * var(--bt-rs, 1)); border: 0; background: transparent; color: var(--bt-text-2); font: 500 13px/1 var(--bt-ui); white-space: nowrap; cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-seg:hover { background: var(--bt-hover); color: var(--bt-text); } .bt-seg[aria-current] { cursor: text; background: none; color: var(--bt-text); font-weight: 600; } .bt-seg--mono { font: 500 12.5px/1 var(--bt-mono); color: var(--bt-text-2); } @@ -321,7 +324,7 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va .bt-sep { flex: 0 0 auto; color: var(--bt-faint); font: 400 14px/1 var(--bt-ui); padding: 0 1px; opacity: .8; } .bt-omni-raw { flex: 1; min-width: 0; padding-inline-start: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 12.5px var(--bt-mono); color: var(--bt-muted); } .bt-omni-fill { flex: 1; min-width: 8px; align-self: stretch; } -.bt-omni-action { width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--bt-faint); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } +.bt-omni-action { width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: calc(7px * var(--bt-rs, 1)); background: transparent; color: var(--bt-faint); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-omni:hover .bt-omni-action { color: var(--bt-muted); } .bt-omni-action:hover { background: var(--bt-hover); color: var(--bt-text) !important; } .bt-shell .bt-omni-action svg { width: 14px; height: 14px; } @@ -329,22 +332,22 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va .bt-omni input:focus-visible { outline: 0; } .bt-omni input::selection { background: rgb(var(--bt-accent-rgb) / .35); } .bt-omni-ops { display: flex; gap: 4px; flex: 0 1 auto; min-width: 0; overflow: hidden; } -.bt-omni-op { flex: 0 0 auto; height: 22px; padding: 0 8px; border: 1px solid var(--bt-line); border-radius: 6px; background: var(--bt-chrome); color: var(--bt-muted); font: 500 11.5px var(--bt-mono); cursor: pointer; } +.bt-omni-op { flex: 0 0 auto; height: 22px; padding: 0 8px; border: 1px solid var(--bt-line); border-radius: calc(6px * var(--bt-rs, 1)); background: var(--bt-chrome); color: var(--bt-muted); font: 500 11.5px var(--bt-mono); cursor: pointer; } .bt-omni-op[aria-selected=true] { color: var(--bt-accent-ink); border-color: rgb(var(--bt-accent-rgb) / .5); background: var(--bt-accent-soft); } .bt-omni-op:hover { color: var(--bt-text); border-color: var(--bt-accent); } -.bt-omni-progress { position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; border-radius: 2px; background: var(--bt-brush); transform-origin: left; animation: bt-load 1.2s ease-in-out infinite; pointer-events: none; } +.bt-omni-progress { position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; border-radius: calc(2px * var(--bt-rs, 1)); background: var(--bt-brush); transform-origin: left; animation: bt-load 1.2s ease-in-out infinite; pointer-events: none; } @keyframes bt-load { 0% { transform: scaleX(.05); } 60% { transform: scaleX(.7); } 100% { transform: scaleX(.95); opacity: .3; } } @media (prefers-reduced-motion: reduce) { .bt-omni-progress { animation: none; transform: scaleX(.6); } } /* split + wayBetter buttons */ .bt-split { position: relative; display: flex; align-items: center; } -.bt-split .bt-split-main { border-start-start-radius: 8px; border-start-end-radius: 0; border-end-end-radius: 0; border-end-start-radius: 8px; } -.bt-split .bt-split-more { width: 18px; flex-basis: 18px; border-start-start-radius: 0; border-start-end-radius: 8px; border-end-end-radius: 8px; border-end-start-radius: 0; } +.bt-split .bt-split-main { border-start-start-radius: calc(8px * var(--bt-rs, 1)); border-start-end-radius: 0; border-end-end-radius: 0; border-end-start-radius: calc(8px * var(--bt-rs, 1)); } +.bt-split .bt-split-more { width: 18px; flex-basis: 18px; border-start-start-radius: 0; border-start-end-radius: calc(8px * var(--bt-rs, 1)); border-end-end-radius: calc(8px * var(--bt-rs, 1)); border-end-start-radius: 0; } .bt-shell .bt-split-more svg { width: 12px; height: 12px; } .bt-menu.bt-split-menu { position: absolute; top: 40px; inset-inline-end: 0; z-index: 20; min-width: 200px; } .bt-brand-button { display: inline-flex; align-items: center; gap: 7px; height: 32px; margin-inline-start: 6px; padding-block: 0; padding-inline: 9px 12px; flex: 0 0 auto; - border: 1px solid var(--bt-line); border-radius: 9px; background: rgb(var(--bt-text-rgb) / .02); color: var(--bt-text); font: 600 12.5px/1 var(--bt-ui); cursor: pointer; + border: 1px solid var(--bt-line); border-radius: calc(9px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .02); color: var(--bt-text); font: 600 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease); } .bt-brand-button:hover { background: var(--bt-hover); border-color: var(--bt-line-strong); } @@ -357,7 +360,7 @@ html[data-os=macos][data-update] { --bt-tb-right: calc(48px + 184px + 184px + va @container pane (max-width: 640px) { .bt-brand-button { padding: 0; width: 36px; min-width: 36px; } .bt-split .bt-split-more { display: none; } - .bt-split .bt-split-main { border-radius: 8px; } + .bt-split .bt-split-main { border-radius: calc(8px * var(--bt-rs, 1)); } } @container pane (max-width: 420px) { .bt-addressbar > .bt-icon[aria-label=Forward], .bt-split { display: none; } @@ -405,7 +408,7 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: border-radius: var(--bt-r4); background: var(--bt-raised); border: 1px solid var(--bt-line-strong); box-shadow: var(--bt-shadow-pop); color: var(--bt-text); font: 500 13px/1.3 var(--bt-ui); user-select: none; } -.bt-menu button { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--bt-text); font: inherit; text-align: start; cursor: pointer; transition: background-color 80ms var(--bt-ease); } +.bt-menu button { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border: 0; border-radius: calc(7px * var(--bt-rs, 1)); background: transparent; color: var(--bt-text); font: inherit; text-align: start; cursor: pointer; transition: background-color 80ms var(--bt-ease); } .bt-menu button:hover:not(:disabled), .bt-menu button:focus-visible { background: var(--bt-hover); outline: 0; } .bt-menu button:active:not(:disabled) { background: var(--bt-press); } .bt-menu button:disabled { color: var(--bt-faint); cursor: default; } @@ -421,9 +424,9 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-profile-menu-head { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px 10px; } .bt-profile-menu-head strong { font: 600 13px/1.2 var(--bt-ui); color: var(--bt-text); } .bt-profile-menu-head span { font: 400 12px/1.3 var(--bt-ui); color: var(--bt-muted); } -.bt-profile-row { position: relative; display: flex; align-items: center; border-radius: 9px; } +.bt-profile-row { position: relative; display: flex; align-items: center; border-radius: calc(9px * var(--bt-rs, 1)); } .bt-profile-row.is-active { background: rgb(var(--bt-text-rgb) / .035); } -.bt-menu .bt-profile-pick { flex: 1; min-width: 0; height: auto; gap: 11px; padding: 7px 8px; border-radius: 9px; } +.bt-menu .bt-profile-pick { flex: 1; min-width: 0; height: auto; gap: 11px; padding: 7px 8px; border-radius: calc(9px * var(--bt-rs, 1)); } .bt-profile-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; } .bt-profile-name { font: 600 13.5px/1.15 var(--bt-ui); color: var(--bt-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bt-profile-meta { font: 400 12px/1.2 var(--bt-ui); color: var(--bt-muted); font-variant-numeric: tabular-nums; } @@ -437,9 +440,9 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-menu .bt-profile-action { width: 28px; height: 28px; padding: 0; justify-content: center; color: var(--bt-muted); } .bt-menu .bt-profile-action:hover:not(:disabled) { color: var(--bt-text); background: var(--bt-press); } .bt-profile-action .bt-glyph { width: 15px; height: 15px; } -.bt-profile-edit { display: flex; flex-direction: column; gap: 10px; padding: 7px 8px 9px; border-radius: 9px; background: rgb(var(--bt-text-rgb) / .035); } +.bt-profile-edit { display: flex; flex-direction: column; gap: 10px; padding: 7px 8px 9px; border-radius: calc(9px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .035); } .bt-profile-edit-row { display: flex; align-items: center; gap: 11px; } -.bt-profile-name-input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; box-sizing: border-box; border: 0; border-radius: 8px; background: var(--bt-field); box-shadow: var(--bt-ring); color: var(--bt-text); font: 500 13.5px/1 var(--bt-ui); outline: none; user-select: text; } +.bt-profile-name-input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; box-sizing: border-box; border: 0; border-radius: calc(8px * var(--bt-rs, 1)); background: var(--bt-field); box-shadow: var(--bt-ring); color: var(--bt-text); font: 500 13.5px/1 var(--bt-ui); outline: none; user-select: text; } .bt-profile-swatches { display: flex; flex-wrap: wrap; gap: 8px; padding-inline-start: 41px; } .bt-menu .bt-profile-swatch { width: 18px; height: 18px; padding: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); transition: transform var(--bt-t1) var(--bt-ease); } .bt-menu .bt-profile-swatch:hover { transform: scale(1.12); background-color: revert; } @@ -449,7 +452,7 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-profile-add-icon .bt-glyph { width: 14px; height: 14px; } .bt-menu .bt-profile-add:hover .bt-profile-add-icon { box-shadow: inset 0 0 0 1px rgb(var(--bt-accent-rgb) / .6); color: var(--bt-accent-ink); } .bt-profile-foot { margin: 2px 10px 6px; color: var(--bt-faint); font: 400 11.5px/1.4 var(--bt-ui); } -.bt-profile-confirm { display: flex; flex-direction: column; gap: 10px; margin: 1px 0; padding: 10px 12px; border-radius: 9px; background: rgba(229, 72, 77, .08); box-shadow: inset 0 0 0 1px rgba(229, 72, 77, .25); color: var(--bt-text-2); font: 400 12.5px/1.45 var(--bt-ui); } +.bt-profile-confirm { display: flex; flex-direction: column; gap: 10px; margin: 1px 0; padding: 10px 12px; border-radius: calc(9px * var(--bt-rs, 1)); background: rgba(229, 72, 77, .08); box-shadow: inset 0 0 0 1px rgba(229, 72, 77, .25); color: var(--bt-text-2); font: 400 12.5px/1.45 var(--bt-ui); } .bt-profile-confirm strong { color: var(--bt-text); font-weight: 600; } .bt-profile-confirm div { display: flex; gap: 6px; } .bt-menu .bt-profile-confirm button { height: 28px; padding: 0 12px; font-weight: 600; font-size: 12.5px; } @@ -475,15 +478,15 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-palette-list { flex: 1; overflow-y: auto; padding: 6px; } .bt-palette-group { padding: 12px 10px 6px; color: var(--bt-faint); font: 600 10.5px/1 var(--bt-ui); letter-spacing: .08em; text-transform: uppercase; } .bt-palette-group:first-child { padding-top: 6px; } -.bt-palette-item { display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px; box-sizing: border-box; border-radius: 9px; cursor: pointer; color: var(--bt-text-2); } +.bt-palette-item { display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px; box-sizing: border-box; border-radius: calc(9px * var(--bt-rs, 1)); cursor: pointer; color: var(--bt-text-2); } .bt-palette-item[aria-selected=true] { background: rgb(var(--bt-text-rgb) / .055); color: var(--bt-text); } -.bt-palette-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 7px; background: rgb(var(--bt-text-rgb) / .04); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .05); color: var(--bt-muted); transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } -.bt-palette-icon img { width: 16px; height: 16px; border-radius: 4px; } +.bt-palette-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: calc(7px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .04); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .05); color: var(--bt-muted); transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } +.bt-palette-icon img { width: 16px; height: 16px; border-radius: calc(4px * var(--bt-rs, 1)); } .bt-palette-icon .bt-glyph { width: 15px; height: 15px; } .bt-palette-item[aria-selected=true] .bt-palette-icon { background: var(--bt-accent-soft); box-shadow: inset 0 0 0 1px rgb(var(--bt-accent-rgb) / .3); color: var(--bt-accent-ink); } .bt-palette-label { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; } .bt-palette-hint { margin-inline-start: auto; color: var(--bt-faint); font: 400 11.5px/1.2 var(--bt-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; flex-shrink: 0; } -.bt-palette-hint--tag { padding: 3px 7px; border-radius: 6px; background: rgb(var(--bt-text-rgb) / .06); color: var(--bt-muted); font: 500 11px/1.2 var(--bt-ui); } +.bt-palette-hint--tag { padding: 3px 7px; border-radius: calc(6px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .06); color: var(--bt-muted); font: 500 11px/1.2 var(--bt-ui); } .bt-palette-hint--tag.is-match { background: var(--bt-accent-soft); color: var(--bt-accent-ink); } .bt-palette-enter { width: 14px; flex: none; color: var(--bt-muted); font: 500 12px/1 var(--bt-mono); opacity: 0; } .bt-palette-item[aria-selected=true] .bt-palette-enter { opacity: .8; } @@ -503,11 +506,11 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: var(--bt-ground); } .bt-start-inner { max-width: 660px; margin: 0 auto; padding: clamp(40px, 13vh, 132px) 20px 40px; display: flex; flex-direction: column; align-items: center; gap: 24px; } -.bt-start-mark { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: linear-gradient(180deg, var(--bt-raised-2), var(--bt-chrome)); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .07), inset 0 1px 0 rgb(var(--bt-text-rgb) / .06), 0 24px 60px -24px rgba(79, 107, 255, .65); } -.bt-start-mark img { border-radius: 9px; -webkit-user-drag: none; } +.bt-start-mark { display: grid; place-items: center; width: 60px; height: 60px; border-radius: calc(18px * var(--bt-rs, 1)); background: linear-gradient(180deg, var(--bt-raised-2), var(--bt-chrome)); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .07), inset 0 1px 0 rgb(var(--bt-text-rgb) / .06), 0 24px 60px -24px rgba(79, 107, 255, .65); } +.bt-start-mark img { border-radius: calc(9px * var(--bt-rs, 1)); -webkit-user-drag: none; } .bt-start-search { width: 100%; height: 52px; display: flex; align-items: center; gap: 12px; padding-block: 0; padding-inline: 17px 12px; box-sizing: border-box; - border-radius: 14px; background: var(--bt-chrome); border: 1px solid var(--bt-line); box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .9); + border-radius: calc(14px * var(--bt-rs, 1)); background: var(--bt-chrome); border: 1px solid var(--bt-line); box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .9); transition: border-color var(--bt-t1) var(--bt-ease), box-shadow var(--bt-t2) var(--bt-ease); } .bt-start-search:hover { border-color: var(--bt-line-strong); } @@ -523,7 +526,7 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-start-accounts .bt-start-label { margin-inline-end: 6px; } .bt-start-account { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding-block: 0; padding-inline: 5px 12px; box-sizing: border-box; - border: 1px solid var(--bt-line-soft); border-radius: 15px; background: transparent; color: var(--bt-muted); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; + border: 1px solid var(--bt-line-soft); border-radius: calc(15px * var(--bt-rs, 1)); background: transparent; color: var(--bt-muted); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-start-account:hover { background: var(--bt-hover); color: var(--bt-text-2); } @@ -537,16 +540,16 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: border: 1px solid var(--bt-line-soft); border-radius: var(--bt-r4); background: rgb(var(--bt-text-rgb) / .02); color: var(--bt-text-2); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease), transform var(--bt-t2) var(--bt-ease-out); } -.bt-start-link-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--bt-field); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .05); color: var(--bt-muted); transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } +.bt-start-link-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: calc(11px * var(--bt-rs, 1)); background: var(--bt-field); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .05); color: var(--bt-muted); transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-start-link-icon .bt-glyph { width: 18px; height: 18px; } .bt-start-link-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bt-start-link:hover { background: rgb(var(--bt-text-rgb) / .045); border-color: var(--bt-line); color: var(--bt-text); transform: translateY(-1px); } .bt-start-link:hover .bt-start-link-icon { background: var(--bt-accent-soft); color: var(--bt-accent-ink); } .bt-start-link:active { transform: translateY(0) scale(.985); } .bt-start-recent { list-style: none; margin: 0; padding: 4px; border: 1px solid var(--bt-line-soft); border-radius: var(--bt-r4); background: rgb(var(--bt-text-rgb) / .015); } -.bt-start-row { display: flex; align-items: center; gap: 11px; width: 100%; height: 38px; padding: 0 10px; box-sizing: border-box; border: 0; border-radius: 8px; background: transparent; color: var(--bt-text-2); font: 500 13px/1 var(--bt-ui); text-align: start; cursor: pointer; transition: background-color 80ms var(--bt-ease), color 80ms var(--bt-ease); } +.bt-start-row { display: flex; align-items: center; gap: 11px; width: 100%; height: 38px; padding: 0 10px; box-sizing: border-box; border: 0; border-radius: calc(8px * var(--bt-rs, 1)); background: transparent; color: var(--bt-text-2); font: 500 13px/1 var(--bt-ui); text-align: start; cursor: pointer; transition: background-color 80ms var(--bt-ease), color 80ms var(--bt-ease); } .bt-start-row:hover { background: var(--bt-hover); color: var(--bt-text); } -.bt-start-row-icon { display: grid; place-items: center; width: 16px; height: 16px; flex: none; border-radius: 4px; color: var(--bt-muted); } +.bt-start-row-icon { display: grid; place-items: center; width: 16px; height: 16px; flex: none; border-radius: calc(4px * var(--bt-rs, 1)); color: var(--bt-muted); } .bt-start-row-icon .bt-glyph { width: 15px; height: 15px; } .bt-start-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bt-start-row-host { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bt-faint); font: 400 11.5px/1 var(--bt-mono); } @@ -561,8 +564,8 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-media { width: min(380px, 100%); height: 100%; display: flex; flex-direction: column; background: var(--bt-raised); border-inline-start: 1px solid var(--bt-line); box-shadow: -24px 0 60px rgba(0, 0, 0, .45); font: 14px/1.3 var(--bt-ui); color: var(--bt-text); animation: bt-slide-in var(--bt-t2) var(--bt-ease-out); } [dir="rtl"] .bt-media { box-shadow: 24px 0 60px rgba(0, 0, 0, .45); animation-name: bt-slide-in-rtl; } .bt-media-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 52px; padding-block: 0; padding-inline: 12px 10px; box-sizing: border-box; border-bottom: 1px solid var(--bt-line); } -.bt-media-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgb(var(--bt-text-rgb) / .045); } -.bt-media-tabs button { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--bt-muted); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } +.bt-media-tabs { display: flex; gap: 2px; padding: 3px; border-radius: calc(10px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .045); } +.bt-media-tabs button { height: 28px; padding: 0 12px; border: 0; border-radius: calc(7px * var(--bt-rs, 1)); background: transparent; color: var(--bt-muted); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-media-tabs button:hover { color: var(--bt-text-2); } .bt-media-tabs button.active { color: var(--bt-text); background: var(--bt-raised-2); box-shadow: inset 0 0 0 1px rgb(var(--bt-text-rgb) / .07), 0 1px 2px rgba(0, 0, 0, .4); } .bt-media .bt-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; } @@ -571,33 +574,33 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-media-empty { color: var(--bt-muted); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 12px 2px; } .bt-media-empty p { margin: 0; } .bt-media-folders { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; } -.bt-media-link { border: 0; background: transparent; color: var(--bt-muted); cursor: pointer; font: 600 12px/1 var(--bt-ui); padding: 4px 6px; border-radius: 6px; } +.bt-media-link { border: 0; background: transparent; color: var(--bt-muted); cursor: pointer; font: 600 12px/1 var(--bt-ui); padding: 4px 6px; border-radius: calc(6px * var(--bt-rs, 1)); } .bt-media-link:hover { color: var(--bt-text); background: var(--bt-hover); } .bt-media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .bt-media-tile { position: relative; aspect-ratio: 1; padding: 0; border: 1px solid var(--bt-line-soft); border-radius: var(--bt-r2); overflow: hidden; background: rgb(var(--bt-text-rgb) / .03); cursor: pointer; transition: border-color var(--bt-t1) var(--bt-ease), transform var(--bt-t2) var(--bt-ease-out); } .bt-media-tile:hover, .bt-media-tile:focus-visible { border-color: rgb(var(--bt-text-rgb) / .5); outline: none; transform: scale(1.02); } .bt-media-tile img, .bt-media-clip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; } .bt-media-thumb-empty { display: block; width: 100%; height: 100%; } -.bt-media-caption { position: absolute; inset-inline-end: 4px; bottom: 4px; padding: 2px 5px; border-radius: 5px; background: rgba(0, 0, 0, .62); color: #fff; font: 500 10.5px/1.3 var(--bt-mono); } +.bt-media-caption { position: absolute; inset-inline-end: 4px; bottom: 4px; padding: 2px 5px; border-radius: calc(5px * var(--bt-rs, 1)); background: rgba(0, 0, 0, .62); color: #fff; font: 500 10.5px/1.3 var(--bt-mono); } .bt-media-clips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; } .bt-media-clip { display: flex; align-items: center; gap: 4px; } .bt-media-clip-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: var(--bt-r2); background: transparent; color: var(--bt-text); text-align: start; cursor: pointer; font: inherit; font-size: 13px; } .bt-media-clip-main:hover, .bt-media-clip-main:focus-visible { background: var(--bt-hover); outline: none; } .bt-media-clip-main small { margin-inline-start: auto; color: var(--bt-faint); font: 500 11px/1 var(--bt-mono); } .bt-media-clip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.bt-media-clip-thumb { width: 48px; height: 48px; flex: none; border-radius: 7px; overflow: hidden; } +.bt-media-clip-thumb { width: 48px; height: 48px; flex: none; border-radius: calc(7px * var(--bt-rs, 1)); overflow: hidden; } /* ------------------------------------------------------------------------------------------------ * Link drag (a link dragged out of a tab, or in from another app): drop zones with labels. */ .bt-shell--link-drag .dv-drop-target > .dv-drop-target-dropzone > .dv-drop-target-selection, .bt-shell--link-drag .dv-drop-target-container .dv-drop-target-anchor { display: grid; place-items: center; overflow: hidden; box-sizing: border-box; - background: rgb(var(--bt-accent-rgb) / .1); border: 1.5px solid rgb(var(--bt-accent-rgb) / .85); border-radius: 12px; + background: rgb(var(--bt-accent-rgb) / .1); border: 1.5px solid rgb(var(--bt-accent-rgb) / .85); border-radius: calc(12px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04), inset 0 0 60px rgb(var(--bt-accent-rgb) / .12); } .bt-shell--link-drag .dv-drop-target-selection::after, .bt-shell--link-drag .dv-drop-target-anchor::after { - content: 'Open as tab'; padding: 8px 13px; border-radius: 999px; background: var(--bt-raised); color: var(--bt-text); + content: 'Open as tab'; padding: 8px 13px; border-radius: calc(999px * var(--bt-rs, 1)); background: var(--bt-raised); color: var(--bt-text); font: 600 12px/1 var(--bt-ui); letter-spacing: .01em; white-space: nowrap; box-shadow: inset 0 0 0 1px var(--bt-line-strong), 0 10px 30px -10px rgba(0, 0, 0, .8); animation: bt-pop-in var(--bt-t2) var(--bt-ease-out); @@ -607,7 +610,7 @@ html.bt-raised .bt-deck :is(.bt-col-head, .bt-compose-head) { background-color: .bt-shell--link-drag .dv-drop-target-selection.dv-drop-target-top::after, .bt-shell--link-drag .dv-drop-target-anchor.dv-drop-target-top::after { content: '\2191 Split up'; } .bt-shell--link-drag .dv-drop-target-selection.dv-drop-target-bottom::after, .bt-shell--link-drag .dv-drop-target-anchor.dv-drop-target-bottom::after { content: '\2193 Split down'; } /* Tab strip and the empty titlebar part of it: a new tab in that group. */ -.bt-shell--link-drag .dv-tabs-and-actions-container .dv-drop-target-selection { border-radius: 8px; } +.bt-shell--link-drag .dv-tabs-and-actions-container .dv-drop-target-selection { border-radius: calc(8px * var(--bt-rs, 1)); } .bt-shell--link-drag .dv-tabs-and-actions-container .dv-drop-target-selection::after { content: '+ New tab'; padding: 4px 9px; font-size: 11px; } .bt-shell--link-drag .dv-drop-target-small-vertical::after, .bt-shell--link-drag .dv-drop-target-small-horizontal::after { content: none; } diff --git a/packages/shell/src/frame/themeStore.ts b/packages/shell/src/frame/themeStore.ts index 9aff821..0bc2292 100644 --- a/packages/shell/src/frame/themeStore.ts +++ b/packages/shell/src/frame/themeStore.ts @@ -10,7 +10,7 @@ import { setChromeIconPack } from './iconPack.tsx'; import type { DockviewApi } from 'dockview'; import { BOOT_CACHE_KEY } from './boot.ts'; import { invoke } from './bridge.ts'; -import { CHROME_VAR_NAMES, chromeVars, type ChromeTheme } from './chromeTheme.ts'; +import { CHROME_VAR_NAMES, chromeEdges, chromeVars, type ChromeTheme } from './chromeTheme.ts'; import { SCOPES_DEFAULT, normalizeScopes, prunePanes, themeIdFor, type ScopeSource, type ThemeScopes } from './themeScopes.ts'; import { safe } from './safeStore.ts'; import { shell, type TabParams } from './state.ts'; @@ -192,6 +192,12 @@ export function createThemeStore(adapter: ThemeAd for (const [name, value] of Object.entries(vars)) element.style.setProperty(name, value); } + /** The window's edge style (frame/edges.css). Global only: a pane theme brings its colors, fonts and radii, not its edges. */ + function setEdges(edges: string | null) { + if (edges) document.documentElement.dataset.wbEdges = edges; + else delete document.documentElement.dataset.wbEdges; + } + function chromeFontsFor(theme: Spec) { for (const family of adapter.googleFonts(theme, ['chrome', 'mono'])) if (isInstalled(family)) void ensureShellFont(family); } @@ -201,13 +207,14 @@ export function createThemeStore(adapter: ThemeAd if (typeof document === 'undefined') return; // Safe mode: the frame's own look, whatever the theme (a theme may be what broke the chrome). The // first-frame cache is left alone, so the next normal start paints the owner's theme again. - if (safe.active) { setVars(document.documentElement, {}); syncGroups(); return; } + if (safe.active) { setVars(document.documentElement, {}); setEdges(null); syncGroups(); return; } if (!state.ready) return; const own = state.scopes.chrome === 'own'; const global = state.preview ?? adapter.resolve(state.choice); chromeFontsFor(global); const vars = chromeVars(adapter.chrome(global), own); setVars(document.documentElement, vars); + setEdges(chromeEdges(vars)); try { setChromeIconPack(own ? null : adapter.iconPack?.(global, state.choice) ?? null); } catch { setChromeIconPack(null); } // The next start paints these from its first frame (boot.ts); an editor's draft is not kept. if (!state.preview) { try { localStorage.setItem(BOOT_CACHE_KEY, JSON.stringify(vars)); } catch { /* Best effort. */ } } diff --git a/packages/shell/src/frame/workspaces.css b/packages/shell/src/frame/workspaces.css index 3aab2e0..7031235 100644 --- a/packages/shell/src/frame/workspaces.css +++ b/packages/shell/src/frame/workspaces.css @@ -5,7 +5,7 @@ .bt-ws-button { display: inline-flex; align-items: center; gap: 7px; height: 30px; max-width: 170px; padding-block: 0; padding-inline: 8px 10px; box-sizing: border-box; - border: 1px solid var(--bt-line-soft); border-radius: 15px; background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-text-2); + border: 1px solid var(--bt-line-soft); border-radius: calc(15px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-text-2); font: 500 12.5px/1 var(--bt-ui); cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease), color var(--bt-t1) var(--bt-ease); } .bt-ws-button:not(:has(.bt-ws-button-name)) { width: 30px; padding: 0; justify-content: center; } @@ -19,16 +19,16 @@ .bt-ws-head { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; } .bt-ws-head strong { font: 600 13px/1.2 var(--bt-ui); color: var(--bt-text); } .bt-ws-head span { font: 400 12px/1.35 var(--bt-ui); color: var(--bt-muted); } -.bt-ws-empty { margin: 2px 6px 6px; padding: 10px 12px; border-radius: 9px; background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-muted); font: 400 12.5px/1.45 var(--bt-ui); } +.bt-ws-empty { margin: 2px 6px 6px; padding: 10px 12px; border-radius: calc(9px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-muted); font: 400 12.5px/1.45 var(--bt-ui); } -.bt-ws-row { position: relative; display: flex; align-items: center; border-radius: 10px; } +.bt-ws-row { position: relative; display: flex; align-items: center; border-radius: calc(10px * var(--bt-rs, 1)); } .bt-ws-row.is-active { background: rgb(var(--bt-accent-rgb) / .08); box-shadow: inset 0 0 0 1px rgb(var(--bt-accent-rgb) / .22); } -.bt-ws-row.is-active::before { content: ''; position: absolute; inset-inline-start: -5px; top: 10px; height: 22px; width: 3px; border-start-start-radius: 0; border-start-end-radius: 3px; border-end-end-radius: 3px; border-end-start-radius: 0; background: var(--bt-accent); } -.bt-menu .bt-ws-main { flex: 1; min-width: 0; height: auto; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 10px; border-radius: 10px; } +.bt-ws-row.is-active::before { content: ''; position: absolute; inset-inline-start: -5px; top: 10px; height: 22px; width: 3px; border-start-start-radius: 0; border-start-end-radius: calc(3px * var(--bt-rs, 1)); border-end-end-radius: calc(3px * var(--bt-rs, 1)); border-end-start-radius: 0; background: var(--bt-accent); } +.bt-menu .bt-ws-main { flex: 1; min-width: 0; height: auto; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 10px; border-radius: calc(10px * var(--bt-rs, 1)); } .bt-menu .bt-ws-main:focus-visible, .bt-menu .bt-ws-save:focus-visible { box-shadow: var(--bt-ring); } .bt-ws-name { display: flex; align-items: center; gap: 6px; max-width: 100%; font: 600 13.5px/1.15 var(--bt-ui); color: var(--bt-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bt-ws-meta { font: 400 12px/1.2 var(--bt-ui); color: var(--bt-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; } -.bt-ws-badge { flex: none; padding: 2px 6px; border-radius: 999px; background: rgb(var(--bt-accent-rgb) / .14); color: var(--bt-accent-ink); font: 500 10.5px/1.2 var(--bt-ui); } +.bt-ws-badge { flex: none; padding: 2px 6px; border-radius: calc(999px * var(--bt-rs, 1)); background: rgb(var(--bt-accent-rgb) / .14); color: var(--bt-accent-ink); font: 500 10.5px/1.2 var(--bt-ui); } .bt-ws-actions { display: flex; gap: 1px; padding-inline-end: 4px; opacity: 0; transition: opacity var(--bt-t1) var(--bt-ease); } .bt-ws-row:hover .bt-ws-actions, .bt-ws-row:focus-within .bt-ws-actions, .bt-ws-row.is-active .bt-ws-actions { opacity: 1; } @@ -36,8 +36,8 @@ .bt-menu .bt-ws-icon .bt-glyph { width: 14px; height: 14px; } .bt-menu .bt-ws-icon[aria-pressed=true] { color: var(--bt-accent-ink); } -.bt-menu .bt-ws-save { height: auto; gap: 11px; padding: 8px; border-radius: 10px; } -.bt-ws-save-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9px; box-shadow: inset 0 0 0 1px var(--bt-line-strong); color: var(--bt-muted); } +.bt-menu .bt-ws-save { height: auto; gap: 11px; padding: 8px; border-radius: calc(10px * var(--bt-rs, 1)); } +.bt-ws-save-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: calc(9px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1px var(--bt-line-strong); color: var(--bt-muted); } .bt-ws-save-icon .bt-glyph { width: 15px; height: 15px; } .bt-menu .bt-ws-save:hover .bt-ws-save-icon { box-shadow: inset 0 0 0 1px rgb(var(--bt-accent-rgb) / .6); color: var(--bt-accent-ink); } .bt-ws-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; } @@ -45,7 +45,7 @@ .bt-ws-form { display: flex; gap: 6px; padding: 6px; } .bt-ws-input { - flex: 1; min-width: 0; height: 30px; padding: 0 10px; box-sizing: border-box; border: 1px solid var(--bt-line-strong); border-radius: 8px; + flex: 1; min-width: 0; height: 30px; padding: 0 10px; box-sizing: border-box; border: 1px solid var(--bt-line-strong); border-radius: calc(8px * var(--bt-rs, 1)); background: var(--bt-field); color: var(--bt-text); font: 500 13px/1 var(--bt-ui); outline: 0; } .bt-ws-input:focus { border-color: rgb(var(--bt-accent-rgb) / .6); box-shadow: 0 0 0 3px rgb(var(--bt-accent-rgb) / .14); } @@ -54,7 +54,7 @@ .bt-menu .bt-ws-primary:disabled { background: var(--bt-hover); color: var(--bt-faint); } .bt-ws-confirm { - display: flex; flex-direction: column; gap: 10px; margin: 2px 6px 6px; padding: 10px 12px; border-radius: 9px; + display: flex; flex-direction: column; gap: 10px; margin: 2px 6px 6px; padding: 10px 12px; border-radius: calc(9px * var(--bt-rs, 1)); background: rgba(229, 72, 77, .08); box-shadow: inset 0 0 0 1px rgba(229, 72, 77, .25); color: var(--bt-text-2); font: 400 12.5px/1.45 var(--bt-ui); } .bt-ws-confirm strong { color: var(--bt-text); font-weight: 600; } @@ -68,7 +68,7 @@ /* Quiet chips: only while there is something to say. */ .bt-tb-chip { display: inline-flex; align-items: center; gap: 7px; height: 28px; max-width: 220px; padding-block: 0; padding-inline: 9px 11px; box-sizing: border-box; - border: 1px solid var(--bt-line-soft); border-radius: 14px; background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-text-2); + border: 1px solid var(--bt-line-soft); border-radius: calc(14px * var(--bt-rs, 1)); background: rgb(var(--bt-text-rgb) / .035); color: var(--bt-text-2); font: 500 12px/1 var(--bt-ui); white-space: nowrap; cursor: pointer; transition: background-color var(--bt-t1) var(--bt-ease), border-color var(--bt-t1) var(--bt-ease); } .bt-tb-chip:hover { background: var(--bt-hover); border-color: var(--bt-line-strong); color: var(--bt-text); } diff --git a/packages/shell/src/panel/backup.css b/packages/shell/src/panel/backup.css index a28fda0..ce50b67 100644 --- a/packages/shell/src/panel/backup.css +++ b/packages/shell/src/panel/backup.css @@ -22,7 +22,7 @@ .btb-pass .bt-input { width: 200px; } .btb-error { color: #ff8a80; font-size: 12px; } .btb-snapshots { display: flex; flex-direction: column; gap: 6px; width: 100%; } -.btb-snapshot { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; background: rgba(127, 127, 127, .06); } +.btb-snapshot { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: calc(9px * var(--bt-rs, 1)); background: rgba(127, 127, 127, .06); } .btb-snapshot.is-fresh { background: rgb(var(--c-accent-rgb) / .1); box-shadow: inset 0 0 0 1px rgb(var(--c-accent-rgb) / .3); } .btb-snapshot-device { font-weight: 600; font-size: 12.5px; } .btb-snapshot-when { flex: 1; color: var(--c-muted); font-size: 12px; font-variant-numeric: tabular-nums; } diff --git a/packages/shell/src/panel/builder.css b/packages/shell/src/panel/builder.css index f19dd84..c91625b 100644 --- a/packages/shell/src/panel/builder.css +++ b/packages/shell/src/panel/builder.css @@ -8,16 +8,16 @@ .btp-page:has(.wb-builder) { max-width: 1320px; } .wb-builder-bar { position: sticky; top: -18px; z-index: 12; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; - margin: 0 -4px; padding: 10px 12px; border: 1px solid var(--c-line); border-radius: 14px; + margin: 0 -4px; padding: 10px 12px; border: 1px solid var(--c-line); border-radius: calc(14px * var(--bt-rs, 1)); background: color-mix(in srgb, var(--c-card) 88%, transparent); backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .6); } -.wb-builder-name { flex: 1 1 200px; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--c-text); font: 650 17px/1 var(--f-ui); letter-spacing: -.02em; } +.wb-builder-name { flex: 1 1 200px; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid transparent; border-radius: calc(9px * var(--bt-rs, 1)); background: transparent; color: var(--c-text); font: 650 17px/1 var(--f-ui); letter-spacing: -.02em; } .wb-builder-name:hover { border-color: var(--c-line); } .wb-builder-name:focus { outline: none; border-color: var(--c-accent); background: var(--c-field); } .wb-builder-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; } .wb-divider { width: 1px; height: 20px; margin: 0 4px; background: var(--c-line); } -.wb-icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); color: var(--c-text); cursor: pointer; transition: background-color .15s, border-color .15s; } +.wb-icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); cursor: pointer; transition: background-color .15s, border-color .15s; } .wb-icon-button:hover:not(:disabled) { border-color: var(--c-line-strong); background: var(--c-raise); } .wb-icon-button:disabled { opacity: .38; cursor: default; } .wb-live { display: inline-flex; align-items: center; gap: 8px; margin-inline-end: 4px; color: var(--c-muted); font-size: 12px; font-weight: 520; } @@ -30,11 +30,11 @@ .wb-builder-preview { order: 0; position: sticky; top: 52px; } } -.wb-card { padding: 16px 16px 14px; border: 1px solid var(--c-line-soft); border-radius: 14px; background: var(--c-card); } +.wb-card { padding: 16px 16px 14px; border: 1px solid var(--c-line-soft); border-radius: calc(14px * var(--bt-rs, 1)); background: var(--c-card); } .wb-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; } .wb-card h3 { margin: 0; font-size: 14px; font-weight: 640; letter-spacing: -.01em; } .wb-card header p { margin: 3px 0 0; max-width: 62ch; color: var(--c-muted); font-size: 12px; line-height: 1.45; } -.wb-ok { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; background: color-mix(in srgb, var(--c-ok) 14%, transparent); color: var(--c-ok); font-size: 12px; font-weight: 600; white-space: nowrap; } +.wb-ok { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: calc(999px * var(--bt-rs, 1)); background: color-mix(in srgb, var(--c-ok) 14%, transparent); color: var(--c-ok); font-size: 12px; font-weight: 600; white-space: nowrap; } .wb-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px 18px; margin-top: 14px; } .wb-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; } @@ -43,37 +43,37 @@ /* Base colors */ .wb-base { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; } -.wb-base-item { display: flex; flex-direction: column; gap: 9px; padding: 10px; border: 1px solid var(--c-line-soft); border-radius: 12px; background: var(--c-ground); } -.wb-base-swatch { position: relative; display: flex; align-items: flex-end; justify-content: space-between; height: 62px; padding: 10px 11px; border-radius: 9px; box-shadow: inset 0 0 0 1px rgb(127 127 127 / .22); } +.wb-base-item { display: flex; flex-direction: column; gap: 9px; padding: 10px; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); background: var(--c-ground); } +.wb-base-swatch { position: relative; display: flex; align-items: flex-end; justify-content: space-between; height: 62px; padding: 10px 11px; border-radius: calc(9px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1px rgb(127 127 127 / .22); } .wb-base-swatch span { font-size: 13px; font-weight: 650; letter-spacing: -.01em; } -.wb-base-swatch code { padding: 2px 6px; border: 0; border-radius: 6px; background: rgb(0 0 0 / .32); color: #fff; font: 500 11px/1.4 var(--f-mono); } +.wb-base-swatch code { padding: 2px 6px; border: 0; border-radius: calc(6px * var(--bt-rs, 1)); background: rgb(0 0 0 / .32); color: #fff; font: 500 11px/1.4 var(--f-mono); } .wb-base-item .bt-color { flex-wrap: wrap; gap: 6px; } .wb-base-item .bt-swatch { width: 22px; height: 22px; } /* Derived palette */ .wb-palette { margin-top: 12px; } .wb-palette-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; } -.wb-chip { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px 9px; border: 1px solid var(--c-line-soft); border-radius: 10px; background: var(--c-ground); color: var(--c-text); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } +.wb-chip { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px 9px; border: 1px solid var(--c-line-soft); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-ground); color: var(--c-text); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } .wb-chip:hover { border-color: var(--c-line-strong); } .wb-chip.is-on { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); } -.wb-chip-swatch { flex: none; width: 22px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgb(127 127 127 / .3); } +.wb-chip-swatch { flex: none; width: 22px; height: 22px; border-radius: calc(6px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1px rgb(127 127 127 / .3); } .wb-chip-copy { display: flex; flex-direction: column; min-width: 0; } .wb-chip-copy b { font-size: 12px; font-weight: 600; } .wb-chip-copy small { overflow: hidden; color: var(--c-muted); font: 10.5px/1.4 var(--f-mono); white-space: nowrap; text-overflow: ellipsis; } -.wb-palette-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; padding: 10px; border-radius: 10px; background: var(--c-field); } +.wb-palette-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; padding: 10px; border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-field); } .wb-palette-edit > span { font-size: 12px; font-weight: 600; } /* Contrast */ .wb-contrast { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; } -.wb-contrast li { display: grid; grid-template-columns: 40px 1fr auto auto 76px; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 9px; } +.wb-contrast li { display: grid; grid-template-columns: 40px 1fr auto auto 76px; align-items: center; gap: 12px; padding: 6px 8px; border-radius: calc(9px * var(--bt-rs, 1)); } .wb-contrast li:hover { background: var(--c-field); } .wb-contrast li.is-fail { background: color-mix(in srgb, var(--c-danger) 7%, transparent); } -.wb-contrast-sample { display: grid; place-items: center; width: 40px; height: 28px; border-radius: 7px; box-shadow: inset 0 0 0 1px rgb(127 127 127 / .25); font-size: 14px; font-weight: 700; } +.wb-contrast-sample { display: grid; place-items: center; width: 40px; height: 28px; border-radius: calc(7px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1px rgb(127 127 127 / .25); font-size: 14px; font-weight: 700; } .wb-contrast-label { font-size: 12.5px; } .wb-contrast-ratio { font: 12px/1 var(--f-mono); color: var(--c-muted); } .wb-contrast-ratio b { color: var(--c-text); font-weight: 600; } .wb-contrast-need { color: var(--c-faint); font-size: 11.5px; } -.wb-contrast-badge { justify-self: end; padding: 3px 7px; border-radius: 6px; font: 600 10.5px/1.2 var(--f-mono); text-align: center; } +.wb-contrast-badge { justify-self: end; padding: 3px 7px; border-radius: calc(6px * var(--bt-rs, 1)); font: 600 10.5px/1.2 var(--f-mono); text-align: center; } .wb-contrast-badge.is-pass { background: color-mix(in srgb, var(--c-ok) 14%, transparent); color: var(--c-ok); } .wb-contrast-badge.is-fail { background: color-mix(in srgb, var(--c-danger) 16%, transparent); color: var(--c-danger); } @container panel (max-width: 560px) { @@ -85,48 +85,48 @@ .wb-bg .bt-seg { margin-bottom: 2px; } /* Preview column */ -.wb-preview-frame { overflow: hidden; border: 1px solid var(--c-line); border-radius: 14px; background: var(--c-ground); box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .7); } +.wb-preview-frame { overflow: hidden; border: 1px solid var(--c-line); border-radius: calc(14px * var(--bt-rs, 1)); background: var(--c-ground); box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .7); } .wb-preview-frame .tp { border-radius: 0; } .wb-preview-note { display: flex; align-items: center; gap: 8px; margin: 0 2px; color: var(--c-muted); font-size: 12px; line-height: 1.4; } .wb-live-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c-ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-ok) 22%, transparent); animation: wb-pulse 2.4s ease-in-out infinite; } @keyframes wb-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c-ok) 0%, transparent); } } @media (prefers-reduced-motion: reduce) { .wb-live-dot { animation: none; } } -.wb-meta { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--c-line-soft); border-radius: 12px; background: var(--c-card); } +.wb-meta { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); background: var(--c-card); } .wb-meta label { display: flex; flex-direction: column; gap: 5px; } .wb-meta span { color: var(--c-muted); font-size: 11.5px; font-weight: 560; } -.wb-meta input, .wb-meta textarea { padding: 7px 9px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-field); color: var(--c-text); font: 13px/1.4 var(--f-ui); resize: vertical; } +.wb-meta input, .wb-meta textarea { padding: 7px 9px; border: 1px solid var(--c-line); border-radius: calc(8px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); font: 13px/1.4 var(--f-ui); resize: vertical; } .wb-meta input:focus, .wb-meta textarea:focus { outline: none; border-color: var(--c-accent); } /* The chrome in the draft (tokens straight from chromeVars, Night Ink fallbacks). */ -.wb-chrome-preview { padding: 7px 8px 0; background: var(--wb-c-ground, #07080c); font-family: var(--wb-f-chrome, 'Geist Variable', system-ui, sans-serif); } +.wb-chrome-preview { --bt-rs: var(--wb-c-rs, 1); padding: 7px 8px 0; background: var(--wb-c-ground, #07080c); font-family: var(--wb-f-chrome, 'Geist Variable', system-ui, sans-serif); } .wb-cp-tabs { display: flex; gap: 4px; } -.wb-cp-tab { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 12px; border-radius: 8px 8px 0 0; color: var(--wb-c-muted, #8a90a6); font-size: 11.5px; font-weight: 520; } -.wb-cp-tab i { width: 10px; height: 10px; border-radius: 3px; background: var(--wb-c-line-strong, #2a3044); } +.wb-cp-tab { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 12px; border-radius: calc(8px * var(--bt-rs, 1)) calc(8px * var(--bt-rs, 1)) 0 0; color: var(--wb-c-muted, #8a90a6); font-size: 11.5px; font-weight: 520; } +.wb-cp-tab i { width: 10px; height: 10px; border-radius: calc(3px * var(--bt-rs, 1)); background: var(--wb-c-line-strong, #2a3044); } .wb-cp-tab.is-on { background: var(--wb-c-chrome, #0d1017); color: var(--wb-c-text, #eef0f7); } .wb-cp-tab.is-on i { background: var(--wb-c-accent, #1d9bf0); } .wb-cp-bar { display: flex; align-items: center; gap: 8px; margin: 0 -8px; padding: 7px 10px; background: var(--wb-c-chrome, #0d1017); border-bottom: 1px solid var(--wb-c-line-soft, #161a26); } .wb-cp-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--wb-c-raised, #141823); } -.wb-cp-omni { flex: 1; display: flex; align-items: center; gap: 7px; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--wb-c-field, #11141c); color: var(--wb-c-text, #eef0f7); font-size: 11.5px; } -.wb-cp-omni b { padding: 2px 7px; border-radius: 5px; background: rgb(var(--wb-c-accent-rgb, 29 155 240) / .16); color: var(--wb-c-accent-ink, #cfe6ff); font-weight: 600; } +.wb-cp-omni { flex: 1; display: flex; align-items: center; gap: 7px; height: 24px; padding: 0 9px; border-radius: calc(7px * var(--bt-rs, 1)); background: var(--wb-c-field, #11141c); color: var(--wb-c-text, #eef0f7); font-size: 11.5px; } +.wb-cp-omni b { padding: 2px 7px; border-radius: calc(5px * var(--bt-rs, 1)); background: rgb(var(--wb-c-accent-rgb, 29 155 240) / .16); color: var(--wb-c-accent-ink, #cfe6ff); font-weight: 600; } .wb-cp-omni em { color: var(--wb-c-faint, #5d6379); font-style: normal; } -.wb-cp-brand { width: 26px; height: 16px; border-radius: 5px; background: linear-gradient(90deg, #4f6bff, #22d3ee 55%, #a855f7); opacity: .85; } +.wb-cp-brand { width: 26px; height: 16px; border-radius: calc(5px * var(--bt-rs, 1)); background: linear-gradient(90deg, #4f6bff, #22d3ee 55%, #a855f7); opacity: .85; } /* --------------------------------------------------------------------------------------------- * Font roles */ -.wb-roles { display: flex; flex-direction: column; border: 1px solid var(--c-line-soft); border-radius: 12px; overflow: hidden; } +.wb-roles { display: flex; flex-direction: column; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); overflow: hidden; } .wb-role + .wb-role { border-top: 1px solid var(--c-line-soft); } .wb-role-main { display: grid; grid-template-columns: minmax(130px, .8fr) minmax(0, 1.4fr) auto; align-items: center; gap: 12px; padding-block: 9px; padding-inline: 14px 10px; } .wb-role-copy { display: flex; flex-direction: column; min-width: 0; } .wb-role-copy strong { font-size: 13px; font-weight: 600; } .wb-role-copy small { color: var(--c-muted); font-size: 11.5px; line-height: 1.35; } -.wb-role-font { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; padding: 7px 11px; border: 1px solid var(--c-line); border-radius: 10px; background: var(--c-field); color: var(--c-text); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } +.wb-role-font { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; padding: 7px 11px; border: 1px solid var(--c-line); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } .wb-role-font:hover { border-color: var(--c-line-strong); background: var(--c-raise); } .wb-role-font.is-inherited { border-style: dashed; background: transparent; } .wb-role-sample { max-width: 100%; overflow: hidden; font-size: 17px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; } .wb-role-name { display: inline-flex; align-items: center; gap: 6px; color: var(--c-muted); font-size: 11px; } -.wb-role-name em { padding: 1px 5px; border-radius: 4px; background: var(--c-accent-soft); color: var(--c-accent); font: 600 9.5px/1.3 var(--f-mono); font-style: normal; letter-spacing: .02em; text-transform: uppercase; } +.wb-role-name em { padding: 1px 5px; border-radius: calc(4px * var(--bt-rs, 1)); background: var(--c-accent-soft); color: var(--c-accent); font: 600 9.5px/1.3 var(--f-mono); font-style: normal; letter-spacing: .02em; text-transform: uppercase; } .wb-role-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-width: 96px; } -.wb-role-tune { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--c-muted); cursor: pointer; } +.wb-role-tune { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: calc(8px * var(--bt-rs, 1)); background: transparent; color: var(--c-muted); cursor: pointer; } .wb-role-tune:hover, .wb-role-tune[aria-expanded=true] { border-color: var(--c-line); background: var(--c-field); color: var(--c-text); } .wb-role-tune.is-tuned { color: var(--c-accent); } .wb-role-tuning { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 18px; padding: 4px 14px 14px; } @@ -142,21 +142,21 @@ /* --------------------------------------------------------------------------------------------- * Sheets (font browser): cover the panel, not the window (X panes are native webviews). */ .wb-sheet-backdrop { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgb(0 0 0 / .5); backdrop-filter: blur(4px); animation: bt-pop .16s var(--ease); } -.wb-sheet { display: flex; flex-direction: column; width: min(1040px, 100%); height: min(720px, 100%); overflow: hidden; border: 1px solid var(--c-line-strong); border-radius: 16px; background: var(--c-card); box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgb(0 0 0 / .3); } +.wb-sheet { display: flex; flex-direction: column; width: min(1040px, 100%); height: min(720px, 100%); overflow: hidden; border: 1px solid var(--c-line-strong); border-radius: calc(16px * var(--bt-rs, 1)); background: var(--c-card); box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgb(0 0 0 / .3); } .wb-sheet-head { display: flex; align-items: center; gap: 14px; padding-block: 16px 12px; padding-inline: 20px 16px; border-bottom: 1px solid var(--c-line-soft); } .wb-sheet-head > div:first-child { flex: 1; min-width: 0; } .wb-sheet-head .bt-seg { flex: none; } .wb-sheet-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.02em; } .wb-sheet-head h2 span { color: var(--c-muted); font-weight: 450; } .wb-sheet-head p { margin: 3px 0 0; color: var(--c-muted); font-size: 12px; } -.wb-sheet-close { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); color: var(--c-muted); cursor: pointer; } +.wb-sheet-close { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-muted); cursor: pointer; } .wb-sheet-close:hover { color: var(--c-text); border-color: var(--c-line-strong); } .wb-sheet-foot { padding: 10px 20px 12px; border-top: 1px solid var(--c-line-soft); color: var(--c-faint); font-size: 11px; line-height: 1.5; } .wb-fb-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 20px; } .wb-fb-search { flex: 1 1 260px; } .wb-fb-cats { display: flex; flex-wrap: wrap; gap: 4px; } -.wb-fb-cats button { height: 28px; padding: 0 11px; border: 1px solid var(--c-line); border-radius: 999px; background: transparent; color: var(--c-muted); font-size: 12px; font-weight: 540; cursor: pointer; transition: color .15s, background-color .15s, border-color .15s; } +.wb-fb-cats button { height: 28px; padding: 0 11px; border: 1px solid var(--c-line); border-radius: calc(999px * var(--bt-rs, 1)); background: transparent; color: var(--c-muted); font-size: 12px; font-weight: 540; cursor: pointer; transition: color .15s, background-color .15s, border-color .15s; } .wb-fb-cats button:hover { color: var(--c-text); border-color: var(--c-line-strong); } .wb-fb-cats button.is-on { background: var(--c-text); border-color: var(--c-text); color: var(--c-ground); } .wb-fb-cats .wb-fb-installed { margin-inline-start: 6px; } @@ -166,13 +166,13 @@ @container panel (max-width: 760px) { .wb-fb-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } .wb-fb-detail { max-height: 50%; border-inline-start: 0 !important; border-top: 1px solid var(--c-line-soft); } } .wb-fb-list { margin: 0; padding: 6px; overflow-y: auto; list-style: none; scrollbar-width: thin; scrollbar-color: var(--c-line) transparent; outline: none; } .wb-fb-list:focus-visible { box-shadow: inset 0 0 0 2px var(--c-accent); } -.wb-fb-list li[role=option] { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'name tags' 'meta tags'; align-items: center; column-gap: 10px; padding: 8px 12px; border-radius: 10px; cursor: pointer; } +.wb-fb-list li[role=option] { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'name tags' 'meta tags'; align-items: center; column-gap: 10px; padding: 8px 12px; border-radius: calc(10px * var(--bt-rs, 1)); cursor: pointer; } .wb-fb-list li.is-active { background: var(--c-field); } .wb-fb-list li.is-on { background: var(--c-accent-soft); box-shadow: inset 0 0 0 1px rgb(var(--c-accent-rgb) / .45); } .wb-fb-name { grid-area: name; overflow: hidden; font-size: 21px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; transition: opacity .2s; } .wb-fb-name.is-loading { opacity: .45; } .wb-fb-meta { grid-area: meta; color: var(--c-muted); font-size: 11px; } -.wb-fb-tag { grid-area: tags; justify-self: end; padding: 2px 7px; border-radius: 6px; background: var(--c-field); color: var(--c-muted); font: 600 10px/1.4 var(--f-mono); letter-spacing: .02em; } +.wb-fb-tag { grid-area: tags; justify-self: end; padding: 2px 7px; border-radius: calc(6px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-muted); font: 600 10px/1.4 var(--f-mono); letter-spacing: .02em; } .wb-fb-tag.is-accent { background: var(--c-accent-soft); color: var(--c-accent); } .wb-fb-tag + .wb-fb-tag { grid-row: 2; } .wb-fb-empty { padding: 30px 14px; color: var(--c-muted); text-align: center; } @@ -183,34 +183,34 @@ .wb-fb-hero { display: flex; flex-direction: column; gap: 4px; } .wb-fb-hero-name { font-size: 40px; line-height: 1.1; letter-spacing: -.01em; overflow-wrap: anywhere; } .wb-fb-hero-meta { color: var(--c-muted); font-size: 12px; } -.wb-fb-sample { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--c-line-soft); border-radius: 12px; background: var(--c-card); } +.wb-fb-sample { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); background: var(--c-card); } .wb-fb-sample-text { min-height: 2.6em; font-size: 24px; line-height: 1.3; overflow-wrap: anywhere; } -.wb-fb-sample textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-field); color: var(--c-text); font: 12.5px/1.45 var(--f-ui); resize: none; } +.wb-fb-sample textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--c-line); border-radius: calc(8px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); font: 12.5px/1.45 var(--f-ui); resize: none; } .wb-fb-sample textarea:focus { outline: none; border-color: var(--c-accent); } .wb-fb-samples { display: flex; flex-wrap: wrap; gap: 4px; } -.wb-fb-samples button { height: 24px; padding: 0 9px; border: 1px solid var(--c-line); border-radius: 999px; background: transparent; color: var(--c-muted); font-size: 11px; cursor: pointer; } +.wb-fb-samples button { height: 24px; padding: 0 9px; border: 1px solid var(--c-line); border-radius: calc(999px * var(--bt-rs, 1)); background: transparent; color: var(--c-muted); font-size: 11px; cursor: pointer; } .wb-fb-samples button.is-on, .wb-fb-samples button:hover { color: var(--c-text); border-color: var(--c-line-strong); } .wb-fb-field { display: flex; flex-direction: column; gap: 8px; } .wb-fb-field > span { color: var(--c-muted); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; } .wb-fb-field > small { color: var(--c-faint); font-size: 11.5px; line-height: 1.45; } .wb-fb-range { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .wb-fb-weights { display: flex; flex-wrap: wrap; gap: 4px; } -.wb-fb-weights button { min-width: 44px; height: 28px; padding: 0 9px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-field); color: var(--c-muted); font: 500 11.5px/1 var(--f-mono); cursor: pointer; } +.wb-fb-weights button { min-width: 44px; height: 28px; padding: 0 9px; border: 1px solid var(--c-line); border-radius: calc(8px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-muted); font: 500 11.5px/1 var(--f-mono); cursor: pointer; } .wb-fb-weights button.is-on { border-color: var(--c-accent); background: var(--c-accent-soft); color: var(--c-text); } .wb-fb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; } -.wb-fb-error { margin: 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--c-danger) 12%, transparent); color: var(--c-danger); font-size: 12px; } +.wb-fb-error { margin: 0; padding: 8px 10px; border-radius: calc(8px * var(--bt-rs, 1)); background: color-mix(in srgb, var(--c-danger) 12%, transparent); color: var(--c-danger); font-size: 12px; } .wb-fb-system { flex: 1; overflow-y: auto; padding: 16px 20px; } .wb-fb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; } -.wb-fb-grid button { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 14px; border: 1px solid var(--c-line-soft); border-radius: 12px; background: var(--c-ground); color: var(--c-text); text-align: start; cursor: pointer; } +.wb-fb-grid button { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 14px; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); background: var(--c-ground); color: var(--c-text); text-align: start; cursor: pointer; } .wb-fb-grid button:hover { border-color: var(--c-line-strong); } .wb-fb-grid button.is-on { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); } .wb-fb-grid span { font-size: 18px; } .wb-fb-grid small { color: var(--c-muted); font-size: 12px; } -.wb-fb-custom { display: flex; align-items: flex-end; gap: 10px; padding: 14px; border: 1px dashed var(--c-line-strong); border-radius: 12px; } +.wb-fb-custom { display: flex; align-items: flex-end; gap: 10px; padding: 14px; border: 1px dashed var(--c-line-strong); border-radius: calc(12px * var(--bt-rs, 1)); } .wb-fb-custom label { flex: 1; display: flex; flex-direction: column; gap: 6px; } .wb-fb-custom label span { color: var(--c-muted); font-size: 12px; } -.wb-fb-custom input { height: 34px; padding: 0 10px; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); color: var(--c-text); font-size: 15px; } +.wb-fb-custom input { height: 34px; padding: 0 10px; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); font-size: 15px; } .wb-fb-custom input:focus { outline: none; border-color: var(--c-accent); } /* --------------------------------------------------------------------------------------------- diff --git a/packages/shell/src/panel/make.css b/packages/shell/src/panel/make.css index e28529d..2a25c1b 100644 --- a/packages/shell/src/panel/make.css +++ b/packages/shell/src/panel/make.css @@ -4,7 +4,7 @@ .bmk-intro p { margin: 0 0 10px; max-width: 70ch; line-height: 1.55; } .bmk-muted, .bmk-intro .bmk-muted { color: var(--c-muted); font-size: 12px; } .bmk-commands { display: grid; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; } -.bmk-commands li { display: grid; grid-template-columns: minmax(120px, 190px) 1fr auto; align-items: center; gap: 10px; padding-block: 6px; padding-inline: 12px 6px; border: 1px solid var(--c-line-soft); border-radius: 10px; background: var(--c-card); } +.bmk-commands li { display: grid; grid-template-columns: minmax(120px, 190px) 1fr auto; align-items: center; gap: 10px; padding-block: 6px; padding-inline: 12px 6px; border: 1px solid var(--c-line-soft); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-card); } .bmk-commands li > span { color: var(--c-muted); font-size: 12px; } .bmk-commands li > code { overflow-x: auto; white-space: nowrap; background: transparent; border: 0; padding: 0; color: var(--c-text); scrollbar-width: none; } @container panel (max-width: 560px) { .bmk-commands li { grid-template-columns: 1fr auto; } .bmk-commands li > span { grid-column: 1 / -1; } } @@ -14,7 +14,7 @@ /* Example picker + editor */ .bmk-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; padding: 10px; } -.bmk-example { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--c-line-soft); border-radius: 10px; background: var(--c-field); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } +.bmk-example { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--c-line-soft); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-field); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } .bmk-example strong { font-size: 12.5px; font-weight: 620; } .bmk-example span { color: var(--c-muted); font-size: 11.5px; line-height: 1.45; } .bmk-example:hover { border-color: var(--c-line-strong); } @@ -40,9 +40,9 @@ .bmk-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 14px; color: var(--c-text-2); font: 11.5px var(--f-mono); } .bmk-facts b { color: var(--c-muted); font-weight: 500; margin-inline-end: 4px; } .bmk-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; padding: 0 10px 12px; } -.bmk-swatch { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border: 1px solid var(--c-line-soft); border-radius: 10px; background: var(--c-field); text-align: start; cursor: copy; } +.bmk-swatch { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border: 1px solid var(--c-line-soft); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-field); text-align: start; cursor: copy; } .bmk-swatch:hover { border-color: var(--c-line-strong); } -.bmk-chip { flex: 0 0 30px; height: 30px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 0 0 1px rgba(0, 0, 0, .25); } +.bmk-chip { flex: 0 0 30px; height: 30px; border-radius: calc(8px * var(--bt-rs, 1)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 0 0 1px rgba(0, 0, 0, .25); } .bmk-swatch-text { display: flex; flex-direction: column; min-width: 0; } .bmk-swatch-text b { font-size: 12px; font-weight: 600; } .bmk-swatch-text code { align-self: flex-start; margin: 2px 0; } @@ -66,7 +66,7 @@ .bmk-doc ul, .bmk-doc ol { padding-inline-start: 20px; } .bmk-doc li + li { margin-top: 4px; } .bmk-doc .bt-snippet { margin: 8px 0 14px; } -.bmk-doc-table { overflow-x: auto; margin: 6px 0 14px; border: 1px solid var(--c-line-soft); border-radius: 10px; } +.bmk-doc-table { overflow-x: auto; margin: 6px 0 14px; border: 1px solid var(--c-line-soft); border-radius: calc(10px * var(--bt-rs, 1)); } .bmk-doc table { width: 100%; border-collapse: collapse; font-size: 12px; } .bmk-doc th, .bmk-doc td { padding: 7px 10px; text-align: start; vertical-align: top; border-top: 1px solid var(--c-line-soft); } .bmk-doc th { border-top: 0; background: var(--c-chrome); color: var(--c-text); font-weight: 600; } diff --git a/packages/shell/src/panel/panel.css b/packages/shell/src/panel/panel.css index c4a758a..30304c1 100644 --- a/packages/shell/src/panel/panel.css +++ b/packages/shell/src/panel/panel.css @@ -19,8 +19,8 @@ .btp-root { position: absolute; inset: 0; container-type: inline-size; container-name: panel; } .btp *, .btp *::before, .btp *::after { box-sizing: border-box; } .btp button { font: inherit; color: inherit; } -.btp code { padding: 1px 5px; border-radius: 5px; background: var(--c-field); border: 1px solid var(--c-line-soft); font: 11.5px var(--f-mono); color: var(--c-text-2); } -.btp mark { background: var(--c-accent-soft); color: var(--c-text); border-radius: 3px; box-shadow: 0 0 0 1px rgb(var(--c-accent-rgb) / .35); } +.btp code { padding: 1px 5px; border-radius: calc(5px * var(--bt-rs, 1)); background: var(--c-field); border: 1px solid var(--c-line-soft); font: 11.5px var(--f-mono); color: var(--c-text-2); } +.btp mark { background: var(--c-accent-soft); color: var(--c-text); border-radius: calc(3px * var(--bt-rs, 1)); box-shadow: 0 0 0 1px rgb(var(--c-accent-rgb) / .35); } .btp :focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; } .btp :is(.bt-search, .bt-inputrow) input:focus-visible, .btp .bt-hex:focus-visible, .btp .bt-code textarea:focus-visible, .btp .btp-input:focus-visible, .btp .bt-input:focus-visible { outline: none; } @@ -28,14 +28,14 @@ .btp-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 16px; } .btp-head::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--c-brush); opacity: .38; } .btp-brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; } -.btp-brand img { border-radius: 6px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .06); } +.btp-brand img { border-radius: calc(6px * var(--bt-rs, 1)); box-shadow: 0 0 0 1px rgba(255, 255, 255, .06); } .btp-brand strong { font-size: 13.5px; font-weight: 650; letter-spacing: -.015em; } .btp-head .bt-search { margin-inline-start: auto; width: min(320px, 100%); } /* Section nav: a scrolling strip in a narrow pane, a rail in a wide one */ .btp-nav { display: flex; gap: 2px; padding: 8px 10px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--c-line-soft); background: var(--c-chrome); } .btp-nav::-webkit-scrollbar { display: none; } -.btp-nav button { position: relative; flex: 0 0 auto; display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--c-muted); font-weight: 520; cursor: pointer; transition: color .15s, background-color .15s; } +.btp-nav button { position: relative; flex: 0 0 auto; display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border: 0; border-radius: calc(8px * var(--bt-rs, 1)); background: transparent; color: var(--c-muted); font-weight: 520; cursor: pointer; transition: color .15s, background-color .15s; } .btp-nav button svg { flex: none; opacity: .8; } .btp-nav button:hover { color: var(--c-text); background: var(--c-field); } .btp-nav button.is-on { color: var(--c-text); background: var(--c-raise); } @@ -51,7 +51,7 @@ .btp-head { grid-column: 1 / -1; padding: 12px 20px; } .btp-nav { flex-direction: column; gap: 1px; padding: 14px 10px; border-bottom: 0; border-inline-end: 1px solid var(--c-line-soft); overflow: visible; } .btp-nav button { height: auto; min-height: 32px; padding: 6px 10px; text-align: start; line-height: 1.25; } - .btp-nav button.is-on::before { content: ''; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px; width: 2px; border-start-start-radius: 0; border-start-end-radius: 2px; border-end-end-radius: 2px; border-end-start-radius: 0; background: var(--c-accent); } + .btp-nav button.is-on::before { content: ''; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px; width: 2px; border-start-start-radius: 0; border-start-end-radius: calc(2px * var(--bt-rs, 1)); border-end-end-radius: calc(2px * var(--bt-rs, 1)); border-end-start-radius: 0; background: var(--c-accent); } .btp-page { padding: 26px 32px 72px; } .btp-title { font-size: 22px; margin-bottom: 18px; } } @@ -63,7 +63,7 @@ .bt-section-head h2 { margin: 0; font-size: 13px; font-weight: 620; letter-spacing: -.005em; } .bt-section-head p { margin: 2px 0 0; color: var(--c-muted); font-size: 12px; line-height: 1.45; max-width: 62ch; } .bt-section-action { flex: 0 0 auto; } -.bt-card { border: 1px solid var(--c-line-soft); border-radius: 12px; background: var(--c-card); box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset; } +.bt-card { border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); background: var(--c-card); box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset; } .bt-card:empty { display: none; } .bt-card > .bt-gallery, .bt-card > .bt-import { padding: 12px; } @@ -85,15 +85,15 @@ .bt-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } .bt-stack { display: flex; flex-direction: column; gap: 10px; width: 100%; } -.bt-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; background: var(--c-field); border: 1px solid var(--c-line-soft); color: var(--c-muted); font: 500 10.5px/1 var(--f-mono); letter-spacing: 0; } +.bt-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: calc(5px * var(--bt-rs, 1)); background: var(--c-field); border: 1px solid var(--c-line-soft); color: var(--c-muted); font: 500 10.5px/1 var(--f-mono); letter-spacing: 0; } .bt-badge.is-accent { color: var(--c-accent); border-color: rgb(var(--c-accent-rgb) / .3); background: var(--c-accent-soft); } .bt-status { color: var(--c-muted); font: 11.5px var(--f-mono); } .bt-status.is-warn { color: var(--c-warn); } -.bt-alert { margin: 12px; padding: 10px 12px; border: 1px solid rgba(255, 92, 108, .35); border-radius: 10px; background: rgba(255, 92, 108, .08); font-size: 12px; } +.bt-alert { margin: 12px; padding: 10px 12px; border: 1px solid rgba(255, 92, 108, .35); border-radius: calc(10px * var(--bt-rs, 1)); background: rgba(255, 92, 108, .08); font-size: 12px; } /* Buttons */ -.bt-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 13px; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); color: var(--c-text); font-weight: 540; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, transform .1s; } -.bt-btn.is-sm { height: 28px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; } +.bt-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 13px; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); font-weight: 540; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, transform .1s; } +.bt-btn.is-sm { height: 28px; padding: 0 11px; font-size: 12.5px; border-radius: calc(8px * var(--bt-rs, 1)); } .bt-btn:hover:not(:disabled) { border-color: var(--c-line-strong); background: var(--c-raise); } .bt-btn:active:not(:disabled) { transform: translateY(.5px); } .bt-btn:disabled { opacity: .42; cursor: default; } @@ -104,16 +104,16 @@ .bt-btn.is-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; } /* Toggle */ -.bt-toggle { position: relative; flex: 0 0 auto; width: 36px; height: 21px; padding: 0; border: 1px solid var(--c-line-strong); border-radius: 999px; background: var(--c-track); cursor: pointer; transition: background-color .18s var(--ease), border-color .18s; } +.bt-toggle { position: relative; flex: 0 0 auto; width: 36px; height: 21px; padding: 0; border: 1px solid var(--c-line-strong); border-radius: calc(999px * var(--bt-rs, 1)); background: var(--c-track); cursor: pointer; transition: background-color .18s var(--ease), border-color .18s; } .bt-toggle-knob { position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--c-knob); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); transition: transform .2s var(--ease), background-color .18s; } .bt-toggle.is-on { background: var(--c-accent); border-color: var(--c-accent); } .bt-toggle.is-on .bt-toggle-knob { transform: translateX(15px); background: #fff; } .bt-toggle:disabled { opacity: .45; cursor: default; } /* Segmented */ -.bt-seg { position: relative; display: inline-flex; flex-wrap: nowrap; max-width: 100%; padding: 3px; border: 1px solid var(--c-line); border-radius: 10px; background: var(--c-ground); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35); isolation: isolate; } -.bt-seg-thumb { position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 3px; border-radius: 7px; background: var(--c-thumb); box-shadow: 0 0 0 1px var(--c-line-strong), 0 2px 6px rgba(0, 0, 0, .35); transition: transform .22s var(--ease), width .22s var(--ease), opacity .15s; } -.bt-seg button { position: relative; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--c-muted); font-weight: 520; white-space: nowrap; cursor: pointer; transition: color .15s; } +.bt-seg { position: relative; display: inline-flex; flex-wrap: nowrap; max-width: 100%; padding: 3px; border: 1px solid var(--c-line); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-ground); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35); isolation: isolate; } +.bt-seg-thumb { position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 3px; border-radius: calc(7px * var(--bt-rs, 1)); background: var(--c-thumb); box-shadow: 0 0 0 1px var(--c-line-strong), 0 2px 6px rgba(0, 0, 0, .35); transition: transform .22s var(--ease), width .22s var(--ease), opacity .15s; } +.bt-seg button { position: relative; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 12px; border: 0; border-radius: calc(7px * var(--bt-rs, 1)); background: transparent; color: var(--c-muted); font-weight: 520; white-space: nowrap; cursor: pointer; transition: color .15s; } .bt-seg.is-sm button { padding: 0 10px; font-size: 12.5px; } .bt-seg button:hover { color: var(--c-text); } .bt-seg button.is-on { color: var(--c-text); } @@ -121,13 +121,13 @@ /* Select */ .bt-select { position: relative; min-width: 150px; } -.bt-select-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; height: 32px; padding-block: 0; padding-inline: 11px 10px; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); text-align: start; cursor: pointer; transition: border-color .15s; } +.bt-select-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; height: 32px; padding-block: 0; padding-inline: 11px 10px; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); text-align: start; cursor: pointer; transition: border-color .15s; } .bt-select-button:hover, .bt-select.is-open .bt-select-button { border-color: var(--c-line-strong); } .bt-select-button svg { flex: 0 0 auto; color: var(--c-muted); transition: transform .18s var(--ease); } .bt-select.is-open .bt-select-button svg { transform: rotate(180deg); } .bt-select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.bt-select-list { position: absolute; z-index: 30; top: calc(100% + 6px); inset-inline-end: 0; min-width: 100%; width: max-content; max-width: 300px; max-height: 300px; margin: 0; padding: 5px; overflow-y: auto; list-style: none; border: 1px solid var(--c-line-strong); border-radius: 11px; background: var(--c-popover); box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .4); animation: bt-pop .14s var(--ease); scrollbar-width: thin; } -.bt-select-list li { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 32px; padding-block: 5px; padding-inline: 9px 28px; border-radius: 7px; cursor: pointer; } +.bt-select-list { position: absolute; z-index: 30; top: calc(100% + 6px); inset-inline-end: 0; min-width: 100%; width: max-content; max-width: 300px; max-height: 300px; margin: 0; padding: 5px; overflow-y: auto; list-style: none; border: 1px solid var(--c-line-strong); border-radius: calc(11px * var(--bt-rs, 1)); background: var(--c-popover); box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .4); animation: bt-pop .14s var(--ease); scrollbar-width: thin; } +.bt-select-list li { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 32px; padding-block: 5px; padding-inline: 9px 28px; border-radius: calc(7px * var(--bt-rs, 1)); cursor: pointer; } .bt-select-list li.bt-select-group { min-height: 0; margin-top: 4px; padding-block: 7px 3px; color: var(--c-muted); font-size: 11px; font-weight: 600; cursor: default; pointer-events: none; } .bt-select-list li.bt-select-group:first-child { margin-top: 0; } .bt-select-list li.is-active { background: var(--c-raise); } @@ -140,32 +140,32 @@ /* Slider */ .bt-slider { display: flex; align-items: center; gap: 12px; width: min(260px, 100%); } .bt-slider input { --pct: 50%; flex: 1; min-width: 0; height: 20px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; } -.bt-slider input::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--c-accent) var(--pct), var(--c-line) var(--pct)); } +.bt-slider input::-webkit-slider-runnable-track { height: 4px; border-radius: calc(4px * var(--bt-rs, 1)); background: linear-gradient(90deg, var(--c-accent) var(--pct), var(--c-line) var(--pct)); } .bt-slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgb(var(--c-accent-rgb) / .22), 0 1px 3px rgba(0, 0, 0, .5); transition: box-shadow .15s; } .bt-slider input:hover::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgb(var(--c-accent-rgb) / .25), 0 1px 3px rgba(0, 0, 0, .5); } -.bt-slider input::-moz-range-track { height: 4px; border-radius: 4px; background: var(--c-line); } -.bt-slider input::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--c-accent); } +.bt-slider input::-moz-range-track { height: 4px; border-radius: calc(4px * var(--bt-rs, 1)); background: var(--c-line); } +.bt-slider input::-moz-range-progress { height: 4px; border-radius: calc(4px * var(--bt-rs, 1)); background: var(--c-accent); } .bt-slider input::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; } -.bt-slider output { flex: 0 0 auto; min-width: 54px; padding: 3px 6px; border: 1px solid var(--c-line-soft); border-radius: 6px; background: var(--c-chrome); color: var(--c-text); font: 500 11.5px var(--f-mono); text-align: center; } +.bt-slider output { flex: 0 0 auto; min-width: 54px; padding: 3px 6px; border: 1px solid var(--c-line-soft); border-radius: calc(6px * var(--bt-rs, 1)); background: var(--c-chrome); color: var(--c-text); font: 500 11.5px var(--f-mono); text-align: center; } /* Color */ .bt-color { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; } .bt-swatch { position: relative; flex: 0 0 auto; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: var(--sw, transparent); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s; } .bt-swatch:hover { transform: scale(1.08); } .bt-swatch.is-on { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 0 0 2px var(--c-card), 0 0 0 4px var(--c-text); } -.bt-swatch.is-auto { width: auto; height: 26px; padding: 0 11px; border-radius: 999px; background: var(--c-field); box-shadow: inset 0 0 0 1px var(--c-line); color: var(--c-muted); font-size: 12px; font-weight: 540; } +.bt-swatch.is-auto { width: auto; height: 26px; padding: 0 11px; border-radius: calc(999px * var(--bt-rs, 1)); background: var(--c-field); box-shadow: inset 0 0 0 1px var(--c-line); color: var(--c-muted); font-size: 12px; font-weight: 540; } .bt-swatch.is-auto.is-on { color: var(--c-text); box-shadow: inset 0 0 0 1px var(--c-line-strong), 0 0 0 2px var(--c-card), 0 0 0 4px var(--c-text); } .bt-swatch.is-picker { display: inline-grid; place-items: center; overflow: hidden; background: conic-gradient(from 90deg, #ff5f6d, #ffd400, #3ddc97, #1d9bf0, #7856ff, #f91880, #ff5f6d); } .bt-swatch.is-picker.is-on { background: var(--sw); } .bt-swatch.is-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; } -.bt-hex { width: 84px; height: 28px; margin-inline-start: 2px; padding: 0 8px; border: 1px solid var(--c-line); border-radius: 7px; background: var(--c-field); color: var(--c-text); font: 12px var(--f-mono); outline: none; } +.bt-hex { width: 84px; height: 28px; margin-inline-start: 2px; padding: 0 8px; border: 1px solid var(--c-line); border-radius: calc(7px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); font: 12px var(--f-mono); outline: none; } .bt-hex:focus { border-color: var(--c-accent); } /* Inputs */ -.bt-input, .btp-input { width: 100%; height: 32px; padding: 0 11px; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); color: var(--c-text); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; } +.bt-input, .btp-input { width: 100%; height: 32px; padding: 0 11px; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-text); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; } .bt-input.is-mono { font-family: var(--f-mono); font-size: 12px; } .bt-input:focus, .btp-input:focus { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); } -.bt-inputrow { display: flex; width: min(420px, 100%); border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); overflow: hidden; transition: border-color .15s, box-shadow .15s; } +.bt-inputrow { display: flex; width: min(420px, 100%); border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); overflow: hidden; transition: border-color .15s, box-shadow .15s; } .bt-inputrow:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); } .bt-inputrow input { flex: 1; min-width: 0; height: 32px; padding: 0 11px; border: 0; background: transparent; color: var(--c-text); font: inherit; outline: none; } .bt-inputrow input.is-mono { font: 12px var(--f-mono); } @@ -173,23 +173,23 @@ .bt-inputrow button:hover:not(:disabled) { background: var(--c-raise); } .bt-inputrow button:disabled { color: var(--c-faint); cursor: default; } -.bt-search { position: relative; display: flex; align-items: center; height: 30px; padding-block: 0; padding-inline: 10px 8px; gap: 7px; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); color: var(--c-muted); transition: border-color .15s, box-shadow .15s; } +.bt-search { position: relative; display: flex; align-items: center; height: 30px; padding-block: 0; padding-inline: 10px 8px; gap: 7px; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-muted); transition: border-color .15s, box-shadow .15s; } .bt-search:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); color: var(--c-text); } .bt-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--c-text); font: inherit; outline: none; } .bt-search input::-webkit-search-cancel-button { display: none; } .bt-search input::placeholder { color: var(--c-faint); } -.bt-search button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px; background: var(--c-raise); color: var(--c-muted); line-height: 1; cursor: pointer; } +.bt-search button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: calc(5px * var(--bt-rs, 1)); background: var(--c-raise); color: var(--c-muted); line-height: 1; cursor: pointer; } /* Chips */ .bt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; } -.bt-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; max-width: 100%; padding-block: 0; padding-inline: 10px 4px; border: 1px solid var(--c-line); border-radius: 999px; background: var(--c-field); font-size: 12.5px; animation: bt-pop .16s var(--ease); } +.bt-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; max-width: 100%; padding-block: 0; padding-inline: 10px 4px; border: 1px solid var(--c-line); border-radius: calc(999px * var(--bt-rs, 1)); background: var(--c-field); font-size: 12.5px; animation: bt-pop .16s var(--ease); } .bt-chip > svg { flex: 0 0 auto; color: var(--c-muted); } .bt-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bt-chip button { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--c-muted); cursor: pointer; } .bt-chip button:hover { background: rgba(255, 92, 108, .16); color: var(--c-danger); } .bt-chips-empty { margin: 0; color: var(--c-faint); font-size: 12px; } -.bt-stepper { display: inline-flex; align-items: center; height: 30px; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-field); overflow: hidden; } +.bt-stepper { display: inline-flex; align-items: center; height: 30px; border: 1px solid var(--c-line); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-field); overflow: hidden; } .bt-stepper button { width: 30px; height: 100%; border: 0; background: transparent; color: var(--c-muted); font-size: 15px; cursor: pointer; } .bt-stepper button:hover:not(:disabled) { background: var(--c-raise); color: var(--c-text); } .bt-stepper button:disabled { opacity: .35; cursor: default; } @@ -198,25 +198,25 @@ /* Empty state */ .bt-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 20px 28px; text-align: center; } -.bt-empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 6px; border: 1px solid var(--c-line); border-radius: 13px; background: linear-gradient(180deg, var(--c-raise), var(--c-field)); color: var(--c-muted); } +.bt-empty-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 6px; border: 1px solid var(--c-line); border-radius: calc(13px * var(--bt-rs, 1)); background: linear-gradient(180deg, var(--c-raise), var(--c-field)); color: var(--c-muted); } .bt-empty strong { font-size: 13.5px; font-weight: 600; } .bt-empty p { max-width: 44ch; margin: 0; color: var(--c-muted); font-size: 12.5px; line-height: 1.5; } .bt-empty-action { margin-top: 10px; } -.bt-snippet { margin: 8px 0 2px; padding: 10px 14px; border: 1px solid var(--c-line-soft); border-radius: 9px; background: var(--c-ground); color: var(--c-text-2); font: 11.5px/1.6 var(--f-mono); text-align: start; white-space: pre; overflow-x: auto; max-width: 100%; } +.bt-snippet { margin: 8px 0 2px; padding: 10px 14px; border: 1px solid var(--c-line-soft); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-ground); color: var(--c-text-2); font: 11.5px/1.6 var(--f-mono); text-align: start; white-space: pre; overflow-x: auto; max-width: 100%; } /* Code editor (Custom CSS, theme JSON) */ .bt-code { display: flex; flex-direction: column; } -.bt-code textarea { width: 100%; min-height: 200px; padding: 14px 16px; border: 0; border-radius: 12px 12px 0 0; background: transparent; color: var(--c-text-2); font: 12px/1.65 var(--f-mono); resize: vertical; outline: none; tab-size: 2; } +.bt-code textarea { width: 100%; min-height: 200px; padding: 14px 16px; border: 0; border-radius: calc(12px * var(--bt-rs, 1)) calc(12px * var(--bt-rs, 1)) 0 0; background: transparent; color: var(--c-text-2); font: 12px/1.65 var(--f-mono); resize: vertical; outline: none; tab-size: 2; } .bt-code.is-compact textarea { min-height: 110px; border: 1px solid var(--c-line); border-bottom: 0; background: var(--c-chrome); } .bt-code-bar { display: flex; align-items: center; gap: 8px; padding-block: 8px; padding-inline: 16px 10px; border-top: 1px solid var(--c-line-soft); } -.bt-code.is-compact .bt-code-bar { border: 1px solid var(--c-line); border-radius: 0 0 10px 10px; background: var(--c-chrome); } +.bt-code.is-compact .bt-code-bar { border: 1px solid var(--c-line); border-radius: 0 0 calc(10px * var(--bt-rs, 1)) calc(10px * var(--bt-rs, 1)); background: var(--c-chrome); } .bt-code-bar small { margin-inline-end: auto; color: var(--c-faint); font-size: 11.5px; } .bt-code-bar small.is-error { color: var(--c-danger); font-family: var(--f-ui); font-size: 12px; } /* Theme gallery */ .bt-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; } .bt-theme { position: relative; } -.bt-theme-hit { display: flex; flex-direction: column; width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--c-line); border-radius: 13px; background: var(--c-chrome); text-align: start; cursor: pointer; transition: border-color .18s, box-shadow .18s, transform .18s var(--ease); } +.bt-theme-hit { display: flex; flex-direction: column; width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--c-line); border-radius: calc(13px * var(--bt-rs, 1)); background: var(--c-chrome); text-align: start; cursor: pointer; transition: border-color .18s, box-shadow .18s, transform .18s var(--ease); } .bt-theme-hit:hover { border-color: var(--c-line-strong); transform: translateY(-1px); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); } .bt-theme.is-on .bt-theme-hit { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent), 0 12px 36px rgba(59, 90, 200, .22); } .bt-theme-hit .tp { border-bottom: 1px solid var(--c-line-soft); } @@ -226,14 +226,14 @@ .bt-theme-check { display: grid; place-items: center; width: 18px; height: 18px; margin-inline-start: auto; border-radius: 50%; background: var(--c-accent); color: var(--c-accent-ink); } .bt-theme-info small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--c-muted); font-size: 12px; line-height: 1.4; } .bt-theme-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; } -.bt-theme-tags em { padding: 1px 6px; border-radius: 5px; background: var(--c-field); color: var(--c-muted); font: normal 500 10.5px/16px var(--f-mono); } +.bt-theme-tags em { padding: 1px 6px; border-radius: calc(5px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-muted); font: normal 500 10.5px/16px var(--f-mono); } .bt-theme-tags em.is-accent { color: var(--c-accent); background: var(--c-accent-soft); } -.bt-theme-remove { position: absolute; top: 8px; inset-inline-end: 8px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid rgba(255, 255, 255, .12); border-radius: 8px; background: rgba(7, 8, 12, .72); color: #fff; backdrop-filter: blur(6px); opacity: 0; cursor: pointer; transition: opacity .15s; } +.bt-theme-remove { position: absolute; top: 8px; inset-inline-end: 8px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid rgba(255, 255, 255, .12); border-radius: calc(8px * var(--bt-rs, 1)); background: rgba(7, 8, 12, .72); color: #fff; backdrop-filter: blur(6px); opacity: 0; cursor: pointer; transition: opacity .15s; } .bt-theme:hover .bt-theme-remove, .bt-theme-remove:focus-visible { opacity: 1; } .bt-theme-remove:hover { background: var(--c-danger); border-color: var(--c-danger); } .bt-import { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; border-bottom: 1px solid var(--c-line-soft); } -.bt-import-drop { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px dashed var(--c-line-strong); border-radius: 11px; background: repeating-linear-gradient(135deg, rgba(123, 156, 255, .03) 0 8px, transparent 8px 16px); } +.bt-import-drop { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px dashed var(--c-line-strong); border-radius: calc(11px * var(--bt-rs, 1)); background: repeating-linear-gradient(135deg, rgba(123, 156, 255, .03) 0 8px, transparent 8px 16px); } .bt-import-drop strong { font-size: 13px; font-weight: 600; } .bt-import-drop p { margin: 0 0 6px; color: var(--c-muted); font-size: 12px; line-height: 1.5; } @container panel (min-width: 620px) { .bt-import { grid-template-columns: 1fr 1fr; } } @@ -253,7 +253,7 @@ .tp-tabs { display: flex; margin-top: 10px; } .tp-tabs span { flex: 1; padding: 12px 0 14px; color: var(--tp-muted); text-align: center; font-weight: 500; } .tp-tabs span.is-on { position: relative; color: var(--tp-text); font-weight: var(--tp-bold); } -.tp-tabs span.is-on::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 56px; height: 4px; margin-left: -28px; border-radius: 4px; background: var(--tp-accent); } /* rtl-ok: centred with left: 50% */ +.tp-tabs span.is-on::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 56px; height: 4px; margin-left: -28px; border-radius: calc(4px * var(--bt-rs, 1)); background: var(--tp-accent); } /* rtl-ok: centred with left: 50% */ .tp-feed.is-cards { padding: 6px 0; } .tp-post { display: flex; gap: 12px; padding: var(--tp-pad) 16px; border-bottom: 1px solid var(--tp-border); } .tp-feed.is-cards .tp-post { margin: calc(var(--tp-pad) / 2 + 2px) 12px; border: 1px solid var(--tp-border); border-radius: var(--tp-r); background: var(--tp-surface); } @@ -285,7 +285,7 @@ .btp-results .bt-section:first-child { margin-top: 0; } /* Toast */ -.btp-toast { position: absolute; left: 50%; bottom: 18px; z-index: 40; max-width: min(520px, calc(100% - 32px)); padding: 10px 14px; border: 1px solid var(--c-line-strong); border-radius: 11px; background: #141824; box-shadow: 0 16px 40px rgba(0, 0, 0, .55); font-size: 12.5px; cursor: pointer; transform: translateX(-50%); animation: bt-toast .22s var(--ease); } +.btp-toast { position: absolute; left: 50%; bottom: 18px; z-index: 40; max-width: min(520px, calc(100% - 32px)); padding: 10px 14px; border: 1px solid var(--c-line-strong); border-radius: calc(11px * var(--bt-rs, 1)); background: #141824; box-shadow: 0 16px 40px rgba(0, 0, 0, .55); font-size: 12.5px; cursor: pointer; transform: translateX(-50%); animation: bt-toast .22s var(--ease); } .btp-toast.is-error { border-color: rgba(255, 92, 108, .55); background: color-mix(in srgb, var(--c-danger) 12%, var(--c-card)); } @keyframes bt-toast { from { opacity: 0; transform: translate(-50%, 8px); } } @@ -298,25 +298,25 @@ .btp-group-head h2 { margin: 0; font-size: 13px; font-weight: 620; } .btp-group-head p { margin: 2px 0 0; color: var(--c-muted); font-size: 12px; } .btp-muted { color: var(--c-muted); font-size: 12px; margin-inline-end: auto; } -.btp-btn { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-field); cursor: pointer; font-weight: 540; white-space: nowrap; transition: border-color .15s, background-color .15s; } +.btp-btn { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--c-line); border-radius: calc(8px * var(--bt-rs, 1)); background: var(--c-field); cursor: pointer; font-weight: 540; white-space: nowrap; transition: border-color .15s, background-color .15s; } .btp-btn:hover:not(:disabled) { border-color: var(--c-line-strong); background: var(--c-raise); } .btp-btn:disabled { opacity: .42; cursor: default; } .btp-btn.is-primary { background: var(--c-text); border-color: var(--c-text); color: var(--c-ground); } .btp-btn.is-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; } .btp-link { border: 0; background: none; padding: 6px 0; color: var(--c-accent); cursor: pointer; font-weight: 540; } .btp-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; } -.btp-alert { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; padding: 10px 12px; border: 1px solid rgba(255, 92, 108, .35); border-radius: 10px; background: rgba(255, 92, 108, .08); font-size: 12px; } +.btp-alert { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; padding: 10px 12px; border: 1px solid rgba(255, 92, 108, .35); border-radius: calc(10px * var(--bt-rs, 1)); background: rgba(255, 92, 108, .08); font-size: 12px; } .btp-alert .btp-btn { margin-inline-start: auto; } .btp-toolbar { display: flex; gap: 8px; } -.btp-seg { display: inline-flex; gap: 2px; margin: 12px 0 8px; padding: 3px; border: 1px solid var(--c-line); border-radius: 10px; background: var(--c-chrome); } -.btp-seg button { height: 26px; padding: 0 11px; border: 0; border-radius: 7px; background: none; color: var(--c-muted); cursor: pointer; font-weight: 520; } +.btp-seg { display: inline-flex; gap: 2px; margin: 12px 0 8px; padding: 3px; border: 1px solid var(--c-line); border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-chrome); } +.btp-seg button { height: 26px; padding: 0 11px; border: 0; border-radius: calc(7px * var(--bt-rs, 1)); background: none; color: var(--c-muted); cursor: pointer; font-weight: 520; } .btp-seg button.is-on { background: var(--c-raise); color: var(--c-text); box-shadow: 0 0 0 1px var(--c-line-strong); } .btp-seg span { margin-inline-start: 5px; font: 11px var(--f-mono); opacity: .7; } .btp-list { display: flex; flex-direction: column; gap: 6px; } .btp-list-head { margin: 16px 2px 4px; color: var(--c-muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; } .btp-list-head span { font-family: var(--f-mono); } -.btp-empty { margin: 0; padding: 26px 16px; border: 1px dashed var(--c-line); border-radius: 12px; color: var(--c-muted); font-size: 12.5px; text-align: center; } -.btp-item { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 11px 13px; border: 1px solid var(--c-line-soft); border-radius: 11px; background: var(--c-card); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } +.btp-empty { margin: 0; padding: 26px 16px; border: 1px dashed var(--c-line); border-radius: calc(12px * var(--bt-rs, 1)); color: var(--c-muted); font-size: 12.5px; text-align: center; } +.btp-item { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 11px 13px; border: 1px solid var(--c-line-soft); border-radius: calc(11px * var(--bt-rs, 1)); background: var(--c-card); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s; } .btp-item:hover { border-color: var(--c-line); background: var(--c-field); } .btp-item.is-on { border-color: var(--c-accent); } .btp-item-top { display: flex; align-items: baseline; gap: 8px; } @@ -324,7 +324,7 @@ .btp-item-top small { flex: 0 0 auto; color: var(--c-muted); font: 11px var(--f-mono); } .btp-item-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--c-muted); font-size: 12px; white-space: pre-wrap; } .btp-item-meta { display: flex; gap: 6px; margin-top: 3px; } -.btp-item-meta em { padding: 0 6px; border-radius: 5px; background: var(--c-field); color: var(--c-muted); font: normal 10.5px/17px var(--f-mono); } +.btp-item-meta em { padding: 0 6px; border-radius: calc(5px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-muted); font: normal 10.5px/17px var(--f-mono); } .btp-item-meta em.is-warn { color: var(--c-warn); } .btp-draft { padding-top: 2px; } .btp-draft-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; } @@ -333,11 +333,11 @@ .btp-save.is-error, .btp-save.is-conflict { color: var(--c-danger); } .btp-draft-title { margin-bottom: 8px; font-weight: 600; } .btp-draft-text { height: auto; min-height: 200px; padding: 12px; resize: vertical; line-height: 1.55; } -.btp-diff pre { margin: 6px 0 0; padding: 8px 10px; max-height: 180px; overflow: auto; border: 1px solid var(--c-line-soft); border-radius: 9px; background: var(--c-card); font: 11.5px/1.5 var(--f-mono); white-space: pre-wrap; } +.btp-diff pre { margin: 6px 0 0; padding: 8px 10px; max-height: 180px; overflow: auto; border: 1px solid var(--c-line-soft); border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-card); font: 11.5px/1.5 var(--f-mono); white-space: pre-wrap; } .btp-diff pre span { display: block; } .btp-diff .is-del { background: rgba(255, 92, 108, .14); } .btp-diff .is-add { background: rgba(61, 220, 151, .14); } -.btp-account { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--c-line-soft); border-radius: 11px; background: var(--c-card); } +.btp-account { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--c-line-soft); border-radius: calc(11px * var(--bt-rs, 1)); background: var(--c-card); } .btp-account.is-on { border-color: var(--c-line-strong); } .btp-account .btp-input { flex: 1; } .btp-dot { flex: 0 0 auto; width: 14px; height: 14px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 3px var(--c-card), 0 0 0 4px var(--c-line); } @@ -345,36 +345,36 @@ .btp-account-name strong { font-weight: 600; } .btp-account-name small { color: var(--c-muted); font-size: 11.5px; } .btp-account.is-on .btp-account-name small { color: var(--c-accent); } -.btp-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--c-line-soft); border-radius: 12px; background: var(--c-card); } +.btp-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); background: var(--c-card); } .btp-card > div { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; } .btp-card small { color: var(--c-muted); font-size: 12px; } .btp-notes { margin: 6px 0 0; color: var(--c-muted); font-size: 12px; white-space: pre-wrap; } /* Home: the wayBetter hero, highlights and About */ -.btp-hero { position: relative; overflow: hidden; isolation: isolate; padding: 30px 24px 26px; border: 1px solid var(--c-line); border-radius: 18px; background: radial-gradient(120% 90% at 0% 0%, rgba(79, 107, 255, .16), transparent 60%), radial-gradient(90% 80% at 100% 10%, rgba(168, 85, 247, .14), transparent 60%), var(--c-card); } +.btp-hero { position: relative; overflow: hidden; isolation: isolate; padding: 30px 24px 26px; border: 1px solid var(--c-line); border-radius: calc(18px * var(--bt-rs, 1)); background: radial-gradient(120% 90% at 0% 0%, rgba(79, 107, 255, .16), transparent 60%), radial-gradient(90% 80% at 100% 10%, rgba(168, 85, 247, .14), transparent 60%), var(--c-card); } .btp-hero::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--c-brush); opacity: .9; } .btp-hero-glow { position: absolute; z-index: -1; inset-inline-end: -60px; bottom: -90px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(34, 211, 238, .16), transparent 70%); filter: blur(8px); } -.btp-hero-mark { display: inline-grid; place-items: center; width: 76px; height: 76px; margin-bottom: 18px; border-radius: 20px; background: linear-gradient(160deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02)); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 18px 40px -12px rgba(79, 107, 255, .55); } -.btp-hero-mark img { border-radius: 14px; } +.btp-hero-mark { display: inline-grid; place-items: center; width: 76px; height: 76px; margin-bottom: 18px; border-radius: calc(20px * var(--bt-rs, 1)); background: linear-gradient(160deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02)); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 18px 40px -12px rgba(79, 107, 255, .55); } +.btp-hero-mark img { border-radius: calc(14px * var(--bt-rs, 1)); } .btp-hero-kicker { margin: 0 0 6px; color: var(--c-muted); font-size: 12.5px; font-weight: 560; letter-spacing: .01em; } .btp-hero-name { background: var(--c-brush); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 720; } .btp-hero-title { margin: 0; font-size: clamp(24px, 6cqi, 34px); line-height: 1.08; font-weight: 700; letter-spacing: -.035em; } .btp-hero-title em { font-style: normal; background: var(--c-brush); -webkit-background-clip: text; background-clip: text; color: transparent; } .btp-hero-lede { max-width: 54ch; margin: 12px 0 0; color: var(--c-muted); font-size: 13.5px; line-height: 1.55; } .btp-hero-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; } -.btp-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border: 1px solid var(--c-line-strong); border-radius: 999px; background: rgba(255, 255, 255, .03); color: var(--c-text); font-size: 11.5px; font-weight: 560; font-variant-numeric: tabular-nums; } +.btp-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border: 1px solid var(--c-line-strong); border-radius: calc(999px * var(--bt-rs, 1)); background: rgba(255, 255, 255, .03); color: var(--c-text); font-size: 11.5px; font-weight: 560; font-variant-numeric: tabular-nums; } .btp-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; } -.btp-hero-actions .btp-btn { height: 34px; padding: 0 16px; border-radius: 10px; } +.btp-hero-actions .btp-btn { height: 34px; padding: 0 16px; border-radius: calc(10px * var(--bt-rs, 1)); } .btp-highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 12px 0 26px; } -.btp-highlight { display: grid; grid-template-columns: auto 1fr; column-gap: 9px; row-gap: 3px; align-items: center; padding: 13px 14px; border: 1px solid var(--c-line-soft); border-radius: 12px; background: var(--c-card); color: var(--c-text); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s, transform .15s; } +.btp-highlight { display: grid; grid-template-columns: auto 1fr; column-gap: 9px; row-gap: 3px; align-items: center; padding: 13px 14px; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); background: var(--c-card); color: var(--c-text); text-align: start; cursor: pointer; transition: border-color .15s, background-color .15s, transform .15s; } .btp-highlight:hover { border-color: var(--c-line-strong); background: var(--c-field); transform: translateY(-1px); } .btp-highlight svg { color: var(--c-accent); } .btp-highlight strong { font-size: 13px; font-weight: 640; } .btp-highlight span { grid-column: 1 / -1; color: var(--c-muted); font-size: 12px; line-height: 1.45; } .btp-about .btp-group-head p { max-width: 64ch; line-height: 1.55; font-size: 12.5px; margin-top: 4px; } -.btp-layers { display: grid; gap: 1px; margin: 12px 0 0; padding: 0; list-style: none; border: 1px solid var(--c-line-soft); border-radius: 12px; overflow: hidden; background: var(--c-line-soft); } +.btp-layers { display: grid; gap: 1px; margin: 12px 0 0; padding: 0; list-style: none; border: 1px solid var(--c-line-soft); border-radius: calc(12px * var(--bt-rs, 1)); overflow: hidden; background: var(--c-line-soft); } .btp-layers li { display: flex; gap: 14px; align-items: baseline; padding: 13px 16px; background: var(--c-card); } .btp-layers li div { display: grid; gap: 2px; } .btp-layers strong { font-size: 13px; font-weight: 640; } @@ -393,7 +393,7 @@ .wb-pack-facts dt { color: var(--c-text-2, inherit); opacity: .75; } .wb-pack-facts dd { margin: 0; overflow-wrap: anywhere; } .wb-pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 6px; padding: 8px 0; } -.wb-pack-grid span { display: grid; place-items: center; height: 32px; border-radius: 8px; background: rgba(127, 127, 127, .08); } +.wb-pack-grid span { display: grid; place-items: center; height: 32px; border-radius: calc(8px * var(--bt-rs, 1)); background: rgba(127, 127, 127, .08); } .wb-pack-grid .bt-glyph { width: 20px; height: 20px; } .wb-pack-warning { color: var(--c-warn, #d9a441); font-size: 12px; } .wb-pack-list { flex-wrap: wrap; margin-top: 6px; } diff --git a/packages/shell/src/panel/plugins.css b/packages/shell/src/panel/plugins.css index 966688d..cf0a885 100644 --- a/packages/shell/src/panel/plugins.css +++ b/packages/shell/src/panel/plugins.css @@ -12,7 +12,7 @@ /* Plugins list: permission and source badges (Extensions.tsx). */ .wbx-perms { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-inline-start: 6px; vertical-align: middle; } -.wbx-perms span { padding: 0 6px; height: 18px; display: inline-flex; align-items: center; border-radius: 5px; font: 500 10.5px/1 var(--f-mono, ui-monospace, monospace); color: var(--c-muted); background: var(--c-field); border: 1px solid var(--c-line-soft); } +.wbx-perms span { padding: 0 6px; height: 18px; display: inline-flex; align-items: center; border-radius: calc(5px * var(--bt-rs, 1)); font: 500 10.5px/1 var(--f-mono, ui-monospace, monospace); color: var(--c-muted); background: var(--c-field); border: 1px solid var(--c-line-soft); } .wbx-perms span.is-warn { color: var(--c-warn); border-color: color-mix(in srgb, var(--c-warn) 35%, transparent); } .wbx-perms span.is-ok { color: var(--c-ok); border-color: color-mix(in srgb, var(--c-ok) 30%, transparent); } .wbx-perms span.is-source { color: var(--c-accent); border-color: rgb(var(--c-accent-rgb) / .3); } @@ -20,12 +20,12 @@ /* Area plugins (PluginFeatures.tsx): one card per area, its features inside. */ .wbf-area + .wbf-area { border-top: 1px solid var(--c-line-soft); } .wbf-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 60px; } -.wbf-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--c-accent-soft); color: var(--c-accent); } +.wbf-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: calc(9px * var(--bt-rs, 1)); background: var(--c-accent-soft); color: var(--c-accent); } .wbf-area.is-off .wbf-icon { background: var(--c-field); color: var(--c-muted); } .wbf-title { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 8px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; } .wbf-title strong { font-size: 14px; font-weight: 620; } .wbf-title small { grid-column: 1 / -1; margin-top: 2px; color: var(--c-muted); font-size: 12px; line-height: 1.45; } -.wbf-title:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 4px; border-radius: 6px; } +.wbf-title:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 4px; border-radius: calc(6px * var(--bt-rs, 1)); } .wbf-title:disabled { cursor: default; } .wbf-caret { flex: none; display: grid; color: var(--c-muted); transition: transform .14s var(--ease, ease); } .wbf-caret.is-open { transform: rotate(180deg); } @@ -45,13 +45,13 @@ .wbm-onboarding h1 { margin: 8px 0 0; font-size: 24px; font-weight: 680; letter-spacing: -.01em; text-wrap: balance; } .wbm-onboarding > p { margin: 0; max-width: 58ch; color: var(--c-muted); font-size: 13px; line-height: 1.5; } .wbm-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; width: 100%; margin: 18px 0 6px; } -.wbm-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--c-line-soft); border-radius: 14px; background: var(--c-card); color: inherit; font: inherit; text-align: start; cursor: pointer; transition: border-color .12s var(--ease, ease), box-shadow .12s var(--ease, ease); } +.wbm-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--c-line-soft); border-radius: calc(14px * var(--bt-rs, 1)); background: var(--c-card); color: inherit; font: inherit; text-align: start; cursor: pointer; transition: border-color .12s var(--ease, ease), box-shadow .12s var(--ease, ease); } .wbm-card:hover { border-color: var(--c-line-strong); } .wbm-card.is-on { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); } .wbm-card:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 3px; } .wbm-card strong { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; font-weight: 640; } .wbm-card > span:last-child { color: var(--c-muted); font-size: 12.5px; line-height: 1.5; } -.wbm-art { display: grid; place-items: center; height: 72px; border-radius: 10px; background: var(--c-field); color: var(--c-muted); } +.wbm-art { display: grid; place-items: center; height: 72px; border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-field); color: var(--c-muted); } .wbm-card.is-on .wbm-art { color: var(--c-accent); } /* The shell's base glyph rule (16px icons) must not shrink a card's picture to a few dots. */ .wbm-art svg { width: 96px; height: 40px; } diff --git a/packages/shell/src/panel/strings.css b/packages/shell/src/panel/strings.css index 6f64a44..129f5ae 100644 --- a/packages/shell/src/panel/strings.css +++ b/packages/shell/src/panel/strings.css @@ -1,6 +1,6 @@ /* The Languages section (StringPacks.tsx): one row per installed string pack. */ .btp-strings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; } -.btp-strings-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--c-surface-2, var(--c-surface)); } +.btp-strings-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: calc(10px * var(--bt-rs, 1)); background: var(--c-surface-2, var(--c-surface)); } .btp-strings-row.is-on { box-shadow: inset 0 0 0 1px var(--c-accent); } .btp-strings-text { flex: 1; min-width: 0; display: grid; gap: 2px; } .btp-strings-text small { color: var(--c-text-2, var(--c-muted)); overflow-wrap: anywhere; } diff --git a/packages/shell/tests/frame.test.ts b/packages/shell/tests/frame.test.ts index 6b34b4d..4ee06bc 100644 --- a/packages/shell/tests/frame.test.ts +++ b/packages/shell/tests/frame.test.ts @@ -9,7 +9,7 @@ import test from 'node:test'; import { fileURLToPath } from 'node:url'; import { accountAction, accountStartUrl, tabsByAccount, type PaneInfo } from '../src/frame/accountModel.ts'; import { BOOT_CACHE_KEY, bootScript } from '../src/frame/boot.ts'; -import { CHROME_VAR_NAMES, chromeVars } from '../src/frame/chromeTheme.ts'; +import { CHROME_VAR_NAMES, chromeEdges, chromeVars } from '../src/frame/chromeTheme.ts'; import { defaultDeckSettings, normalizeDeckSettings } from '../src/frame/deckStore.ts'; import { FRAME_MESSAGES } from '../src/frame/frameMessages.ts'; import { attachTarget } from '../src/frame/mediaModel.ts'; @@ -111,6 +111,30 @@ test('chrome variables: none for the own style, fonts only without colors, every for (const name of Object.keys(vars)) assert.ok(CHROME_VAR_NAMES.includes(name), name); }); +test('chrome variables: radii scale with the theme, a bevelled theme gets 98-style edges from its own face', () => { + const colors = { bg: '#ffffff', surface: '#f4f4f4', elevated: '#dfdfdf', border: '#808080', text: '#000000', muted: '#3c3c3c', accent: '#0000a8', page: '#c0c0c0', inverse: '#000080', onInverse: '#ffffff' }; + assert.equal(chromeVars({ colors, radius: 0 })['--wb-c-rs'], '0'); + assert.equal(chromeVars({ colors, radius: 12 })['--wb-c-rs'], '1'); + assert.equal(chromeVars({ colors, radius: 40 })['--wb-c-rs'], '1.5'); + // A theme that keeps the site's colors keeps wayBetter's own corners and edges. + assert.deepEqual(chromeVars({ colors: null, radius: 0, edges: 'bevel' }), {}); + const flat = chromeVars({ colors, radius: 0 }); + assert.equal(chromeEdges(flat), null); + assert.equal(flat['--wb-c-face'], undefined); + const bevel = chromeVars({ colors, radius: 0, edges: 'bevel' }); + assert.equal(chromeEdges(bevel), 'bevel'); + // 98.css's four edge lines, from the theme's silver. + assert.equal(bevel['--wb-c-face'], '#c0c0c0'); + assert.equal(bevel['--wb-c-bevel-hi'], '#ffffff'); + assert.equal(bevel['--wb-c-bevel-sh'], '#808080'); + assert.equal(bevel['--wb-c-bevel-dk'], '#0a0a0a'); + assert.equal(bevel['--wb-c-title-from'], '#000080'); + assert.equal(bevel['--wb-c-title-text'], '#ffffff'); + for (const name of Object.keys(bevel)) assert.ok(CHROME_VAR_NAMES.includes(name), name); + // The first frame paints the edges too. + assert.ok(bootScript().includes("root.dataset.wbEdges = 'bevel'")); +}); + test('account switcher: a visible pane on the site first, else the feed or sign-in beside', () => { const settings = normalizeProfiles({ active: 'default', profiles: [ { id: 'default', name: 'Main', color: '#1d9bf0', account: { handle: 'me', name: 'Me', signedIn: true } }, From 82382293a2e9bb2cdcc8de7428b95db2ff78421f Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:10:43 +0700 Subject: [PATCH 02/32] host: site themes are the host's (AppConfig::with_themes, commands::THEME) theme_commands serves theme_get / theme_set / theme_preview / theme_scopes_get / theme_scopes_set (shell-only, each checks its caller first; testkit::assert_theme_guards) over the theme state the host now keeps: the owner's theme, account and pane themes, the Theme Builder preview. The app only names its built-in themes and the two files (ThemeConfig). apply() themes every site tab (script, cached Google font bytes, native background); page_scripts()/tab_background() serve a new document; set_theme/set_scopes/set_preview are the app's own writers (backup import, dev mode). A font install or removal re-themes the tabs in the host itself. Co-Authored-By: Claude Opus 5.5 --- crates/waybetter-host/src/app.rs | 23 +- crates/waybetter-host/src/commands.rs | 15 +- crates/waybetter-host/src/fonts_commands.rs | 1 + crates/waybetter-host/src/lib.rs | 2 + crates/waybetter-host/src/testkit.rs | 9 + crates/waybetter-host/src/theme_commands.rs | 233 ++++++++++++++++++++ 6 files changed, 276 insertions(+), 7 deletions(-) create mode 100644 crates/waybetter-host/src/theme_commands.rs diff --git a/crates/waybetter-host/src/app.rs b/crates/waybetter-host/src/app.rs index 8e1b1e5..088280e 100644 --- a/crates/waybetter-host/src/app.rs +++ b/crates/waybetter-host/src/app.rs @@ -96,6 +96,9 @@ pub struct AppConfig { /// [`commands::DEV`] and runs the watcher while it is on; the theme file is the app's /// ([`SiteHooks::dev_theme_apply`]). pub dev: bool, + /// Site themes (the owner's theme, account and pane themes, the live preview): serves + /// [`commands::THEME`]; the app names its built-in themes and the files they are saved in. + pub themes: Option<&'static crate::theme_commands::ThemeConfig>, /// Native updates and the hotfix channel: serves [`commands::UPDATE`] and runs the update loop. /// Needs `updater` (the plugin) and the `net` feature. #[cfg(feature = "net")] @@ -126,6 +129,7 @@ impl AppConfig { fonts: false, sync: false, dev: false, + themes: None, #[cfg(feature = "net")] updates: None, } @@ -144,6 +148,12 @@ impl AppConfig { self } + /// Serves the theme commands ([`commands::THEME`]) with these built-in themes. + pub const fn with_themes(mut self, themes: &'static crate::theme_commands::ThemeConfig) -> Self { + self.themes = Some(themes); + self + } + /// Serves the sync commands ([`commands::SYNC`]). pub const fn with_sync(mut self) -> Self { self.sync = true; @@ -246,8 +256,8 @@ pub trait SiteHooks: Send + Sync + 'static { /// A tab webview was created. fn tab_created(&self, _app: &AppHandle) {} - /// A Google font was installed or removed ([`commands::GFONTS`]): give the site tabs their - /// theme, and the font bytes, again. + /// A Google font was installed or removed ([`commands::GFONTS`]); the host has already given the + /// site tabs their theme, and the font bytes, again ([`crate::theme_commands::apply`]). fn fonts_changed(&self, _app: &AppHandle) {} /// The app's native settings as backup sections (themes, plugins, tweaks, ... keyed by section @@ -1246,6 +1256,11 @@ fn dev_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'st crate::dev_commands::handler() } +/// The theme commands ([`commands::THEME`]). +fn theme_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static { + crate::theme_commands::handler() +} + /// The workspaces and sync commands ([`commands::WORKSPACES`], [`commands::SYNC`]). fn sync_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static { crate::sync_commands::handler() @@ -1314,6 +1329,7 @@ impl App { let update_handler = update_handler(); let sync_handler = sync_handler(); let dev_handler = dev_handler(); + let theme_handler = theme_handler(); let backup_handler = backup_handler(); let builder = tauri::Builder::::default() // Must be first: a second launch focuses the running window instead of fighting over @@ -1397,6 +1413,7 @@ impl App { crate::media_commands::init(&handle); crate::sync_commands::init(&handle); crate::dev_commands::init(&handle); + crate::theme_commands::init(&handle); #[cfg(feature = "net")] crate::fonts_commands::init(&handle); #[cfg(feature = "net")] @@ -1429,6 +1446,8 @@ impl App { dev_handler(invoke) } else if commands::BACKUP.contains(&invoke.message.command()) { backup_handler(invoke) + } else if commands::THEME.contains(&invoke.message.command()) { + theme_handler(invoke) } else if commands::is_host(invoke.message.command()) { host_handler(invoke) } else { diff --git a/crates/waybetter-host/src/commands.rs b/crates/waybetter-host/src/commands.rs index b3927d2..7dba858 100644 --- a/crates/waybetter-host/src/commands.rs +++ b/crates/waybetter-host/src/commands.rs @@ -118,9 +118,14 @@ pub const DEV: &[&str] = &["dev_get", "dev_set", "dev_pick_theme", "dev_clear_th /// (`SiteHooks::backup_sections`, `backup_drafts`, `backup_apply`). pub const BACKUP: &[&str] = &["backup_collect", "backup_export_file", "backup_open_file", "backup_apply"]; +/// Shell-only, optional: site themes (the owner's theme, account and pane themes, the Theme +/// Builder's live preview), served when the app sets `AppConfig::themes`. An app that uses them +/// grants these to the shell (`testkit::Capabilities::assert_shell_only_group`). +pub const THEME: &[&str] = &["theme_get", "theme_set", "theme_preview", "theme_scopes_get", "theme_scopes_set"]; + /// Whether `command` is one of the host's (dispatched to the host, never to the app's handler). pub fn is_host(command: &str) -> bool { - SHELL.contains(&command) || TAB.contains(&command) || SITE.contains(&command) || STORE.contains(&command) || MEDIA.contains(&command) || GFONTS.contains(&command) || UPDATE.contains(&command) || WORKSPACES.contains(&command) || SYNC.contains(&command) || DEV.contains(&command) || BACKUP.contains(&command) + SHELL.contains(&command) || TAB.contains(&command) || SITE.contains(&command) || STORE.contains(&command) || MEDIA.contains(&command) || GFONTS.contains(&command) || UPDATE.contains(&command) || WORKSPACES.contains(&command) || SYNC.contains(&command) || DEV.contains(&command) || BACKUP.contains(&command) || THEME.contains(&command) } /// The capability permission tauri-build generates for `command` (`tabs_sync` → `allow-tabs-sync`). @@ -135,8 +140,8 @@ pub fn permission(command: &str) -> String { /// tauri_build::AppManifest::new().commands(waybetter_host::commands::manifest(&["draft_list"])) /// ``` pub fn manifest(app: &[&'static str]) -> &'static [&'static str] { - let mut all: Vec<&'static str> = Vec::with_capacity(app.len() + SHELL.len() + TAB.len() + SITE.len() + STORE.len() + MEDIA.len() + GFONTS.len() + UPDATE.len() + WORKSPACES.len() + SYNC.len() + DEV.len() + BACKUP.len()); - for command in app.iter().chain(SHELL).chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP) { + let mut all: Vec<&'static str> = Vec::with_capacity(app.len() + SHELL.len() + TAB.len() + SITE.len() + STORE.len() + MEDIA.len() + GFONTS.len() + UPDATE.len() + WORKSPACES.len() + SYNC.len() + DEV.len() + BACKUP.len() + THEME.len()); + for command in app.iter().chain(SHELL).chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP).chain(THEME) { if !all.contains(command) { all.push(command); } @@ -153,7 +158,7 @@ mod tests { let all = manifest(&["draft_list", "tabs_sync"]); assert_eq!(all[0], "draft_list"); assert_eq!(all.iter().filter(|c| **c == "tabs_sync").count(), 1); - for command in SHELL.iter().chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP) { + for command in SHELL.iter().chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP).chain(THEME) { assert!(all.contains(command), "{command}"); assert!(is_host(command)); } @@ -163,7 +168,7 @@ mod tests { #[test] fn shell_and_tab_commands_do_not_overlap() { - assert!(!SHELL.iter().any(|command| TAB.contains(command) || SITE.contains(command) || STORE.contains(command) || MEDIA.contains(command) || GFONTS.contains(command) || UPDATE.contains(command) || WORKSPACES.contains(command) || SYNC.contains(command) || DEV.contains(command) || BACKUP.contains(command))); + assert!(!SHELL.iter().any(|command| TAB.contains(command) || SITE.contains(command) || STORE.contains(command) || MEDIA.contains(command) || GFONTS.contains(command) || UPDATE.contains(command) || WORKSPACES.contains(command) || SYNC.contains(command) || DEV.contains(command) || BACKUP.contains(command) || THEME.contains(command))); assert!(!TAB.iter().any(|command| SITE.contains(command))); } } diff --git a/crates/waybetter-host/src/fonts_commands.rs b/crates/waybetter-host/src/fonts_commands.rs index c1423db..bd005de 100644 --- a/crates/waybetter-host/src/fonts_commands.rs +++ b/crates/waybetter-host/src/fonts_commands.rs @@ -23,6 +23,7 @@ pub(crate) fn init(app: &AppHandle) { } fn changed(app: &AppHandle) { + crate::theme_commands::apply(app); crate::app::hooks(app).fonts_changed(app); } diff --git a/crates/waybetter-host/src/lib.rs b/crates/waybetter-host/src/lib.rs index b61a5c0..1f64006 100644 --- a/crates/waybetter-host/src/lib.rs +++ b/crates/waybetter-host/src/lib.rs @@ -91,6 +91,8 @@ mod sync_commands; #[cfg(feature = "app")] mod dev_commands; #[cfg(feature = "app")] +pub mod theme_commands; +#[cfg(feature = "app")] mod backup_commands; #[cfg(all(feature = "app", feature = "net"))] mod fonts_commands; diff --git a/crates/waybetter-host/src/testkit.rs b/crates/waybetter-host/src/testkit.rs index db75681..f162739 100644 --- a/crates/waybetter-host/src/testkit.rs +++ b/crates/waybetter-host/src/testkit.rs @@ -259,6 +259,14 @@ pub fn assert_dev_guards() { } } +/// The theme commands' wrappers check their caller first. Runs against the host's source. +pub fn assert_theme_guards() { + let source = include_str!("theme_commands.rs"); + for command in commands::THEME { + assert_guarded(source, command, "shell_only(&webview)?"); + } +} + /// The backup commands' wrappers check their caller first. Runs against the host's source. pub fn assert_backup_guards() { let source = include_str!("backup_commands.rs"); @@ -280,6 +288,7 @@ mod tests { assert_sync_guards(); assert_dev_guards(); assert_backup_guards(); + assert_theme_guards(); } fn caps_with(shell_extra: &str, tab_extra: &str, site_extra: &str) -> Capabilities { diff --git a/crates/waybetter-host/src/theme_commands.rs b/crates/waybetter-host/src/theme_commands.rs new file mode 100644 index 0000000..4ead26e --- /dev/null +++ b/crates/waybetter-host/src/theme_commands.rs @@ -0,0 +1,233 @@ +//! Site themes, native side, for every app that sets [`crate::app::AppConfig::themes`]: the +//! shell-only `theme_*` commands ([`crate::commands::THEME`]) over [`crate::theme`]'s state (the +//! owner's theme, the account and pane themes, the Theme Builder's preview). The app only names +//! its built-in themes ([`ThemeConfig`]) and the two files they are saved in. +//! +//! Site tabs gain no command: native code evaluates the theme script (and the cached Google font +//! bytes it needs) in every site tab and sets each tab's native background to its theme's page color. +//! The app's own writers (a backup import, developer mode's theme file) use [`set_theme`], +//! [`set_scopes`] and [`set_preview`], then [`apply`]. + +use crate::app::{config, tab_profile}; +use crate::host::{data_file, read_json, shell_only, write_json}; +use crate::theme::{ThemeChoice, ThemeScopes, ThemeSite}; +use std::sync::{Mutex, MutexGuard}; +use tauri::{AppHandle, Manager, Webview}; + +/// What an app declares about its themes: the built-in ones and where the owner's choice is saved +/// (app data file names). +#[derive(Clone, Copy, Debug)] +pub struct ThemeConfig { + pub site: &'static ThemeSite, + /// The owner's theme choice (absent = the site's own look). + pub file: &'static str, + /// Account and pane themes and the chrome setting (absent = defaults). + pub scopes_file: &'static str, +} + +#[derive(Default)] +struct Themes { + theme: Option, + scopes: ThemeScopes, + /// The Theme Builder's unsaved draft, shown in every site tab until it ends. + preview: Option, +} + +struct ThemeState(Mutex); + +/// Loads the saved theme and scopes (anything that no longer validates is dropped). Does nothing +/// unless the app set [`crate::app::AppConfig::themes`]. +pub(crate) fn init(app: &AppHandle) { + let Some(themes) = config(app).themes else { return }; + let theme = read_json::(app, themes.file).filter(|theme| theme.validate(themes.site).is_ok()); + let scopes = read_json::(app, themes.scopes_file).filter(|scopes| scopes.validate().is_ok()).unwrap_or_default(); + app.manage(ThemeState(Mutex::new(Themes { theme, scopes, preview: None }))); +} + +fn themes(app: &AppHandle) -> Result<&'static ThemeConfig, String> { + config(app).themes.ok_or_else(|| "UNAVAILABLE: this app has no themes".to_owned()) +} + +fn state(app: &AppHandle) -> Result, String> { + app.try_state::() + .ok_or("DATABASE: theme state unavailable; restart safely")? + .inner() + .0 + .lock() + .map_err(|_| "DATABASE: theme state unavailable; restart safely".into()) +} + +/// The theme the owner chose (the site's own look when none). +pub fn current(app: &AppHandle) -> Result { + let themes = themes(app)?; + Ok(state(app)?.theme.clone().unwrap_or_else(|| ThemeChoice::default_for(themes.site))) +} + +/// Account and pane themes and the chrome setting. +pub fn scopes(app: &AppHandle) -> Result { + Ok(state(app)?.scopes.clone()) +} + +/// The theme for site tab webview `label`: the Theme Builder's preview while one is open, else its +/// pane's, its account's or the global theme. +fn tab_theme(app: &AppHandle, themes: &ThemeConfig, state: &Themes, label: &str) -> ThemeChoice { + let global = state.theme.clone().unwrap_or_else(|| ThemeChoice::default_for(themes.site)); + match &state.preview { + Some(preview) => preview.clone(), + None => { + let tab = crate::policy::tab_id(label).unwrap_or_default(); + state.scopes.for_tab(themes.site, &global, tab, tab_profile(app, label).as_deref()) + } + } +} + +fn background(theme: &ThemeChoice, themes: &ThemeConfig) -> Option { + theme.page_color(themes.site).map(|(r, g, b)| tauri::window::Color(r, g, b, 255)) +} + +fn scripts_for(app: &AppHandle, themes: &ThemeConfig, theme: &ThemeChoice) -> Vec { + let site = config(app).site; + let mut scripts = Vec::new(); + #[cfg(feature = "net")] + if let Some(fonts) = crate::fonts::page_script_for(site, &theme.google_fonts()) { + scripts.push(fonts); + } + if let Ok(script) = theme.script(themes.site, site) { + scripts.push(script); + } + scripts +} + +/// The native background of site tab `label` until its page paints: its theme's page color. +pub fn tab_background(app: &AppHandle, label: &str) -> Option { + let themes = config(app).themes?; + let state = state(app).ok()?; + background(&tab_theme(app, themes, &state, label), themes) +} + +/// The scripts a freshly loaded site document in tab `label` gets for its theme (and the font +/// bytes it needs); none while the site keeps its own look. +pub fn page_scripts(app: &AppHandle, label: &str) -> Vec { + let Some(themes) = config(app).themes else { return Vec::new() }; + let Ok(state) = state(app) else { return Vec::new() }; + if state.theme.is_none() && state.preview.is_none() && state.scopes.is_default() { + return Vec::new(); + } + scripts_for(app, themes, &tab_theme(app, themes, &state, label)) +} + +/// Sends every site tab its theme again (after the theme, the scopes, the preview or the fonts +/// changed). In safe mode site pages keep the site's own look; a theme chosen meanwhile applies +/// when safe mode is left. +pub fn apply(app: &AppHandle) { + if crate::safe::active() { + return; + } + let Some(themes) = config(app).themes else { return }; + let site = config(app).site; + let per_tab: Vec<(Webview, ThemeChoice)> = { + let Ok(state) = state(app) else { return }; + app.webviews() + .into_iter() + .filter(|(label, tab)| crate::policy::tab_id(label).is_some() && tab.url().is_ok_and(|url| site.is_origin(&url))) + .map(|(label, tab)| (tab, tab_theme(app, themes, &state, &label))) + .collect() + }; + for (tab, theme) in per_tab { + let _ = tab.set_background_color(background(&theme, themes)); + for script in scripts_for(app, themes, &theme) { + let _ = tab.eval(&script); + } + } +} + +/// Saves the owner's theme (checked against the built-in ones; `None` or an unchanged site look +/// removes the file). Does not apply it: call [`apply`]. +pub fn set_theme(app: &AppHandle, theme: Option) -> Result<(), String> { + let themes = themes(app)?; + let theme = theme.unwrap_or_else(|| ThemeChoice::default_for(themes.site)); + theme.validate(themes.site)?; + if theme.is_empty(themes.site) { + if let Some(path) = data_file(app, themes.file) { + let _ = std::fs::remove_file(path); + } + state(app)?.theme = None; + } else { + write_json(app, themes.file, &theme)?; + state(app)?.theme = Some(theme); + } + Ok(()) +} + +/// Saves the account and pane themes (bounded, ids checked). Does not apply them: call [`apply`]. +pub fn set_scopes(app: &AppHandle, scopes: ThemeScopes) -> Result<(), String> { + let themes = themes(app)?; + scopes.validate()?; + if scopes.is_default() { + if let Some(path) = data_file(app, themes.scopes_file) { + let _ = std::fs::remove_file(path); + } + } else { + write_json(app, themes.scopes_file, &scopes)?; + } + state(app)?.scopes = scopes; + Ok(()) +} + +/// Shows an unsaved theme in every site tab (not persisted); `None` ends the preview. Does not +/// apply it: call [`apply`]. +pub fn set_preview(app: &AppHandle, theme: Option) -> Result<(), String> { + let themes = themes(app)?; + if let Some(theme) = &theme { + theme.validate(themes.site)?; + } + state(app)?.preview = theme; + Ok(()) +} + +/// Applies a theme to every site tab and persists it. `None` (or the site's own preset without an +/// accent) restores the site's own look. +#[tauri::command] +pub(crate) async fn theme_set(webview: Webview, app: AppHandle, theme: Option) -> Result<(), String> { + shell_only(&webview)?; + set_theme(&app, theme)?; + apply(&app); + Ok(()) +} + +/// The persisted theme (the site's own look when none). +#[tauri::command] +pub(crate) async fn theme_get(webview: Webview, app: AppHandle) -> Result { + shell_only(&webview)?; + current(&app) +} + +/// Account and pane themes and the chrome setting. +#[tauri::command] +pub(crate) async fn theme_scopes_get(webview: Webview, app: AppHandle) -> Result { + shell_only(&webview)?; + scopes(&app) +} + +/// Saves account and pane themes and re-themes every site tab. +#[tauri::command] +pub(crate) async fn theme_scopes_set(webview: Webview, app: AppHandle, scopes: ThemeScopes) -> Result<(), String> { + shell_only(&webview)?; + set_scopes(&app, scopes)?; + apply(&app); + Ok(()) +} + +/// The Theme Builder's live preview: an unsaved theme shown in every site tab. `None` ends the +/// preview and gives every tab its own theme back. +#[tauri::command] +pub(crate) async fn theme_preview(webview: Webview, app: AppHandle, theme: Option) -> Result<(), String> { + shell_only(&webview)?; + set_preview(&app, theme)?; + apply(&app); + Ok(()) +} + +pub(crate) fn handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static { + tauri::generate_handler![theme_get, theme_set, theme_preview, theme_scopes_get, theme_scopes_set] +} From a7988f70f8c1b6ab262d436f3ed28335b20480c5 Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:13:53 +0700 Subject: [PATCH 03/32] macOS find: page matches drawn with the CSS Custom Highlight API (window.find showed nothing while the page was not the key view); --diag logs exit requests, window close/destroy and each native pane placement on macOS Co-Authored-By: Claude Opus 5.5 --- crates/waybetter-host/src/app.rs | 20 ++++- crates/waybetter-host/src/find.rs | 107 ++++++++++++++++++++------- crates/waybetter-host/src/host.rs | 20 +++-- packages/shell/src/frame/FindBar.tsx | 2 +- 4 files changed, 113 insertions(+), 36 deletions(-) diff --git a/crates/waybetter-host/src/app.rs b/crates/waybetter-host/src/app.rs index 088280e..be0539f 100644 --- a/crates/waybetter-host/src/app.rs +++ b/crates/waybetter-host/src/app.rs @@ -699,7 +699,7 @@ async fn tab_zoom(webview: Webview, app: AppHandle, id: String, factor: Option) -> Result<(), String> { shell_only(&webview)?; @@ -1454,8 +1454,22 @@ impl App { handler(invoke) } }) - .run(context) - .unwrap_or_else(|error| panic!("Failed to launch {}: {error}", config.title)); + .build(context) + .unwrap_or_else(|error| panic!("Failed to launch {}: {error}", config.title)) + .run(|_, event| log_run_event(&event)); + } +} + +/// Why the app is going away, for `--diag` ([`crate::diag`]): an exit request with its code (None is a +/// polite quit from outside: Cmd+Q, the Dock, or another app such as an auto-quitter closing the last +/// window), window close/destroy events and the final exit. Nothing is written without diagnostics. +fn log_run_event(event: &tauri::RunEvent) { + match event { + tauri::RunEvent::ExitRequested { code, .. } => crate::diag::log("host", &format!("exit requested code={code:?}")), + tauri::RunEvent::Exit => crate::diag::log("host", "exit"), + tauri::RunEvent::WindowEvent { label, event: tauri::WindowEvent::CloseRequested { .. }, .. } => crate::diag::log("host", &format!("window {label} close requested")), + tauri::RunEvent::WindowEvent { label, event: tauri::WindowEvent::Destroyed, .. } => crate::diag::log("host", &format!("window {label} destroyed")), + _ => {} } } diff --git a/crates/waybetter-host/src/find.rs b/crates/waybetter-host/src/find.rs index 9c648eb..fa37a90 100644 --- a/crates/waybetter-host/src/find.rs +++ b/crates/waybetter-host/src/find.rs @@ -6,7 +6,7 @@ //! (Windows, WebView2 Runtime with `ICoreWebView2_28`; its own find bar suppressed), which also //! reports the match count and the active match (`tab-find` events to the shell). Everywhere else //! (macOS, Linux, an older WebView2 Runtime) native code evaluates [`fallback_script`] in the tab: -//! the engine's `window.find`, which selects the next match and scrolls to it but counts nothing. +//! the page's matches drawn with the CSS Custom Highlight API (see [`fallback_script`]), which counts nothing. //! //! The query is data: it goes from the shell to the engine and is kept nowhere (no file, no log, //! no state in this crate). Tabs gain no command; a tab may only forward the key name `find` @@ -86,24 +86,80 @@ pub fn request(action: &str, query: Option<&str>) -> Result Ok(FindRequest { action, query: if action == FindAction::Stop { None } else { query } }) } -/// The script native code evaluates where the engine's find cannot be driven natively: the -/// engine's `window.find` (case-insensitive, wrapping), or clearing the selection for `stop`. -/// The query appears only as a JSON string literal; nothing is sent anywhere or stored in the page. +/// The script native code evaluates where the engine's find cannot be driven natively (macOS, +/// Linux, an old WebView2): the page's matches drawn with the CSS Custom Highlight API (every match +/// tinted, the active one stronger and scrolled into view; independent of window focus, which the +/// engine's selection-based `window.find` is not: it shows nothing while the page is not the key +/// view), or `window.find` where an engine lacks that API. `stop` removes the highlights. +/// The query appears only as a JSON string literal; nothing is sent anywhere or stored: the +/// matches live in the page's highlight registry until `stop`, the query nowhere. pub fn fallback_script(request: &FindRequest) -> String { - match (&request.action, &request.query) { - (FindAction::Stop, _) | (_, None) => { - "(()=>{try{const s=getSelection();if(s)s.removeAllRanges();}catch(e){}})();".to_owned() - } - (action, Some(query)) => { - let text = serde_json::to_string(query).unwrap_or_else(|_| "\"\"".into()); - // A new query starts from the top of the page; next/previous continue from the selection. - let restart = if *action == FindAction::Start { "const s=getSelection();if(s)s.removeAllRanges();" } else { "" }; - let backwards = *action == FindAction::Previous; - format!("(()=>{{try{{{restart}if(typeof window.find==='function')window.find({text},false,{backwards},true,false,false,false);}}catch(e){{}}}})();") - } - } + let action = match request.action { + FindAction::Start => "start", + FindAction::Next => "next", + FindAction::Previous => "previous", + FindAction::Stop => "stop", + }; + let query = request.query.as_ref().map_or_else(|| "null".to_owned(), |query| serde_json::to_string(query).unwrap_or_else(|_| "null".into())); + HIGHLIGHT_SCRIPT.replace("__ACTION__", action).replace("__QUERY__", &query) } +const HIGHLIGHT_SCRIPT: &str = r#"(()=>{try{ +const action="__ACTION__",query=__QUERY__; +const H=window.CSS&&CSS.highlights,ALL="wb-find",ACT="wb-find-active"; +const sheets=()=>document.adoptedStyleSheets||[]; +const stop=()=>{if(H){H.delete(ALL);H.delete(ACT);}try{document.adoptedStyleSheets=sheets().filter(s=>!s.__wbFind);}catch(e){}}; +if(action==="stop"||(action==="start"&&query===null)){stop();return;} +if(!H||typeof Highlight!=="function"){ + if(query!==null&&typeof window.find==="function"){if(action==="start"){const s=getSelection();if(s)s.removeAllRanges();}window.find(query,false,action==="previous",true,false,false,false);} + return; +} +const live=r=>r.startContainer.isConnected&&r.endContainer.isConnected; +const collect=q=>{ + const needle=q.toLowerCase(),out=[]; + if(!needle||needle.length!==q.length)return out; + const walker=document.createTreeWalker(document.body||document.documentElement,NodeFilter.SHOW_TEXT,{acceptNode:n=>{const p=n.parentElement;return !p||/^(SCRIPT|STYLE|NOSCRIPT|TEXTAREA)$/.test(p.tagName)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT;}}); + for(let n;(n=walker.nextNode())&&out.length<2000;){ + const t=n.nodeValue; + if(t.length=0&&out.length<2000;i=hay.indexOf(needle,i+needle.length)){ + const r=document.createRange();r.setStart(n,i);r.setEnd(n,i+needle.length);out.push(r); + } + } + return out; +}; +const active=H.get(ACT); +const current=active?[...active][0]:null; +let all,idx; +if(action==="start"){ + all=collect(query); + idx=all.findIndex(r=>r.getBoundingClientRect().bottom>0); + if(idx<0)idx=0; +}else{ + all=[...(H.get(ALL)||[])].filter(live); + if(!all.length&&query!==null)all=collect(query); + const at=current?all.indexOf(current):-1; + idx=!all.length?-1:action==="previous"?(at<=0?all.length-1:at-1):(at+1)%all.length; +} +H.set(ALL,new Highlight(...all)); +if(idx<0||!all.length){H.delete(ACT);} +else{ + const mark=new Highlight(all[idx]);mark.priority=1;H.set(ACT,mark); + const box=all[idx].getBoundingClientRect(); + if(box.top<0||box.bottom>innerHeight){const el=all[idx].startContainer.parentElement;if(el)el.scrollIntoView({block:"center",inline:"nearest"});} +} +if(!sheets().some(s=>s.__wbFind)){ + const sheet=new CSSStyleSheet(); + sheet.replaceSync("::highlight(wb-find){background-color:rgba(255,213,74,.55);color:inherit}::highlight(wb-find-active){background-color:#ff9632;color:#000}"); + sheet.__wbFind=true; + document.adoptedStyleSheets=[...sheets(),sheet]; +} +}catch(e){}})();"#; + #[cfg(test)] mod tests { use super::*; @@ -127,19 +183,16 @@ mod tests { #[test] fn the_fallback_script_carries_the_query_only_as_a_string_literal() { let script = fallback_script(&request("start", Some("it's \"quoted\" \\ ${x} `y`")).unwrap()); - assert!(script.contains(r#"window.find("it's \"quoted\" \\ ${x} `y`",false,false,true"#), "{script}"); - assert!(script.contains("removeAllRanges"), "a new query starts from the top"); + assert!(script.contains(r#"const action="start",query="it's \"quoted\" \\ ${x} `y`";"#), "{script}"); let next = fallback_script(&request("next", Some("a")).unwrap()); - assert!(next.contains(r#"window.find("a",false,false,true"#) && !next.contains("removeAllRanges")); - assert!(fallback_script(&request("previous", Some("a")).unwrap()).contains(r#"window.find("a",false,true,true"#)); - // Stop (and a step without a query) only clears the selection. - for request in [request("stop", None).unwrap(), request("next", None).unwrap()] { - let script = fallback_script(&request); - assert!(script.contains("removeAllRanges") && !script.contains("window.find"), "{script}"); - } - // Nothing leaves the page or stays in it: no network, storage, invoke or DOM writes. + assert!(next.contains(r#"const action="next",query="a";"#)); + assert!(fallback_script(&request("previous", Some("a")).unwrap()).contains(r#"action="previous""#)); + // Stop and a step without a query carry no query: stop clears the highlights, a step uses the page's matches. + assert!(fallback_script(&request("stop", None).unwrap()).contains(r#"action="stop",query=null;"#)); + assert!(fallback_script(&request("next", None).unwrap()).contains("query=null;")); + // Nothing leaves the page or stays in it: no network, storage, invoke or markup writes. for script in [script, next] { - for forbidden in ["fetch", "XMLHttpRequest", "localStorage", "sessionStorage", "invoke", "postMessage", "innerHTML", "document.cookie", "eval("] { + for forbidden in ["fetch", "XMLHttpRequest", "localStorage", "sessionStorage", "invoke", "postMessage", "innerHTML", "document.cookie", "eval(", "__ACTION__", "__QUERY__"] { assert!(!script.contains(forbidden), "{forbidden} in {script}"); } } diff --git a/crates/waybetter-host/src/host.rs b/crates/waybetter-host/src/host.rs index 489556a..b52768c 100644 --- a/crates/waybetter-host/src/host.rs +++ b/crates/waybetter-host/src/host.rs @@ -166,7 +166,7 @@ pub fn forget_tab_zoom(app: &AppHandle, id: &str) { /// `tab_find`: searches tab `id`'s page ([`crate::find`]). The engine's own find where this build /// can drive it (WebView2's `ICoreWebView2Find`, which reports counts through `tab-find` events); -/// otherwise the evaluated `window.find` fallback. The query is kept nowhere. +/// otherwise the evaluated Custom Highlight fallback ([`crate::find::fallback_script`]). The query is kept nowhere. pub fn tab_find(app: &AppHandle, id: &str, action: &str, query: Option<&str>) -> Result<(), String> { if !policy::valid_tab_id(id) { return Err("VALIDATION: invalid tab id".into()); @@ -451,10 +451,20 @@ pub fn place_child(webview: &Webview, x: f64, y: f64, width: f64, // One native move+resize: separate set_position/set_size calls were two WebView2 `SetBounds` // (the page re-laid out at the old size, then at the new one) and two main-thread messages. #[cfg(not(target_os = "linux"))] - let _ = webview.set_bounds(tauri::Rect { - position: tauri::LogicalPosition::new(x, y).into(), - size: tauri::LogicalSize::new(width, height).into(), - }); + { + let _ = webview.set_bounds(tauri::Rect { + position: tauri::LogicalPosition::new(x, y).into(), + size: tauri::LogicalSize::new(width, height).into(), + }); + #[cfg(target_os = "macos")] + if crate::diag::active() { + let actual = webview.bounds().map(|b| { + let (p, s) = (b.position.to_logical::(1.0), b.size.to_logical::(1.0)); + format!("{},{} {}x{}", p.x, p.y, s.width, s.height) + }); + crate::diag::log("host", &format!("place {} asked {x},{y} {width}x{height} now {actual:?}", webview.label())); + } + } } /// Linux: the shell webview becomes the base layer of a GtkOverlay filling the window, which diff --git a/packages/shell/src/frame/FindBar.tsx b/packages/shell/src/frame/FindBar.tsx index a22fe51..bf5d908 100644 --- a/packages/shell/src/frame/FindBar.tsx +++ b/packages/shell/src/frame/FindBar.tsx @@ -2,7 +2,7 @@ // pane's toolbar while it is open (so the page under it does not move and, in split view, the bar // is plainly the searched pane's). Native code does the searching (`tab_find`, shell-only): the // engine's own find where the build can drive it (WebView2: highlights and a match count, which -// arrive as `tab-find` events), else the engine's `window.find` evaluated by native code (next and +// arrive as `tab-find` events), else a Custom Highlight script evaluated by native code (next and // previous work, no count). Only what the page has rendered can be found, as in a browser: a // virtualized list (X's timeline) holds the posts near the viewport, not the whole feed. // From d47a77d95d7c984705937cc9de6d5fe0d64e937e Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:14:27 +0700 Subject: [PATCH 04/32] shell: the active tab's mark and the palette's edge take the theme's accent instead of wayBetter's brush Co-Authored-By: Claude Opus 5.5 --- packages/shell/src/frame/chromeTheme.ts | 2 ++ packages/shell/src/frame/shell.css | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/shell/src/frame/chromeTheme.ts b/packages/shell/src/frame/chromeTheme.ts index 931807f..5bea5e8 100644 --- a/packages/shell/src/frame/chromeTheme.ts +++ b/packages/shell/src/frame/chromeTheme.ts @@ -81,6 +81,8 @@ export function chromeVars(theme: ChromeTheme, own = false): Record * var(--bt-rs, 1)), so a square theme gets a square window. */ --bt-rs: var(--wb-c-rs, 1); + /* The active tab's mark and the palette's edge: wayBetter's brush, or the theme's own accent. */ + --bt-brush: var(--wb-c-brush, linear-gradient(90deg, #4f6bff, #22d3ee 55%, #a855f7)); --bt-r1: calc(6px * var(--bt-rs)); --bt-r2: calc(8px * var(--bt-rs)); --bt-r3: calc(10px * var(--bt-rs)); --bt-r4: calc(12px * var(--bt-rs)); --bt-r5: calc(14px * var(--bt-rs)); color-scheme: var(--wb-c-scheme, dark); } .wb-pane-theme { --bt-bg: var(--bt-ground); --bt-surface: var(--bt-chrome); --bt-surface-2: var(--bt-field); } :root { --bt-danger: #e5484d; - --bt-brush: linear-gradient(90deg, #4f6bff, #22d3ee 55%, #a855f7); --bt-s1: 4px; --bt-s2: 8px; --bt-s3: 12px; --bt-s4: 16px; --bt-s5: 24px; --bt-s6: 32px; --bt-ease: cubic-bezier(.2, .7, .2, 1); --bt-ease-out: cubic-bezier(.16, 1, .3, 1); --bt-t1: 120ms; --bt-t2: 180ms; --bt-t3: 320ms; From 1539cb68e1e211535d937012f7c5efa985ea988f Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:14:34 +0700 Subject: [PATCH 05/32] host: keyword alert settings are the host's (AppConfig::with_alerts, commands::ALERTS) alerts_commands keeps the owner's AlertSettings (saved in app data, validated by alerts), serves the shell-only alerts_get / alerts_set (testkit::assert_alerts_guards) and builds the script that hands the page runtime the keywords to watch. The app names the file and the runtime member (AlertsConfig); store()/script() are the app's own writers (backup import). Co-Authored-By: Claude Opus 5.5 --- crates/waybetter-host/src/alerts_commands.rs | 85 ++++++++++++++++++++ crates/waybetter-host/src/app.rs | 39 +++++---- crates/waybetter-host/src/commands.rs | 15 ++-- crates/waybetter-host/src/lib.rs | 2 + crates/waybetter-host/src/testkit.rs | 9 +++ 5 files changed, 128 insertions(+), 22 deletions(-) create mode 100644 crates/waybetter-host/src/alerts_commands.rs diff --git a/crates/waybetter-host/src/alerts_commands.rs b/crates/waybetter-host/src/alerts_commands.rs new file mode 100644 index 0000000..a27ea06 --- /dev/null +++ b/crates/waybetter-host/src/alerts_commands.rs @@ -0,0 +1,85 @@ +//! Keyword alert settings, native side, for every app that sets [`crate::app::AppConfig::alerts`]: +//! the shell-only `alerts_get` / `alerts_set` ([`crate::commands::ALERTS`]) over the owner's +//! [`AlertSettings`] (saved in app data, validated by [`crate::alerts`]). Site tabs gain no command +//! here: native code hands the page runtime the keywords to watch ([`script`]) at every page load +//! and whenever they change. What a match looks like and the notification are the app's. + +use crate::alerts::AlertSettings; +use crate::app::config; +use crate::host::{eval_in_site_tabs, read_json, shell_only, write_json}; +use crate::tabs::deliver_script; +use std::sync::{Mutex, MutexGuard}; +use tauri::{AppHandle, Manager, Webview}; + +/// What an app declares about its alerts: where they are saved and how the page runtime takes the +/// keywords (`window...set(keywords)`, else parked in `window.`). +#[derive(Clone, Copy, Debug)] +pub struct AlertsConfig { + pub file: &'static str, + pub member: &'static str, + pub queue: &'static str, +} + +struct AlertState(Mutex); + +/// Loads the saved settings. Does nothing unless the app set [`crate::app::AppConfig::alerts`]. +pub(crate) fn init(app: &AppHandle) { + let Some(alerts) = config(app).alerts else { return }; + let settings = read_json::(app, alerts.file).and_then(|settings| settings.validated().ok()).unwrap_or_default(); + app.manage(AlertState(Mutex::new(settings))); +} + +fn state(app: &AppHandle) -> Result, String> { + app.try_state::() + .ok_or("DATABASE: alert state unavailable; restart safely")? + .inner() + .0 + .lock() + .map_err(|_| "DATABASE: alert state unavailable; restart safely".into()) +} + +/// The owner's alert settings. +pub fn settings(app: &AppHandle) -> Result { + Ok(state(app)?.clone()) +} + +/// The script that hands the page runtime the keywords to watch (empty = alerts off). +pub fn script(app: &AppHandle) -> String { + let (Some(alerts), Ok(settings)) = (config(app).alerts, settings(app)) else { return String::new() }; + script_for(app, alerts, &settings) +} + +fn script_for(app: &AppHandle, alerts: &AlertsConfig, settings: &AlertSettings) -> String { + let keywords = serde_json::to_string(settings.active_keywords()).unwrap_or_else(|_| "[]".into()); + deliver_script(config(app).site.runtime_global, alerts.member, "set", alerts.queue, &keywords) +} + +/// Validates, saves and keeps the settings, and does not touch the tabs: for the app's own +/// writers (a backup import), which then evaluate [`script`] themselves. +pub fn store(app: &AppHandle, settings: AlertSettings) -> Result { + let alerts = config(app).alerts.ok_or_else(|| "UNAVAILABLE: this app has no alerts".to_owned())?; + let settings = settings.validated()?; + // The lock is held across the write so concurrent saves cannot leave disk and memory disagreeing. + let mut current = state(app)?; + write_json(app, alerts.file, &settings)?; + *current = settings.clone(); + Ok(settings) +} + +#[tauri::command] +pub(crate) async fn alerts_get(webview: Webview, app: AppHandle) -> Result { + shell_only(&webview)?; + settings(&app) +} + +#[tauri::command] +pub(crate) async fn alerts_set(webview: Webview, app: AppHandle, settings: AlertSettings) -> Result { + shell_only(&webview)?; + let settings = store(&app, settings)?; + eval_in_site_tabs(&app, config(&app).site, &script(&app)); + Ok(settings) +} + +pub(crate) fn handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static { + tauri::generate_handler![alerts_get, alerts_set] +} diff --git a/crates/waybetter-host/src/app.rs b/crates/waybetter-host/src/app.rs index be0539f..cb08c9d 100644 --- a/crates/waybetter-host/src/app.rs +++ b/crates/waybetter-host/src/app.rs @@ -99,6 +99,9 @@ pub struct AppConfig { /// Site themes (the owner's theme, account and pane themes, the live preview): serves /// [`commands::THEME`]; the app names its built-in themes and the files they are saved in. pub themes: Option<&'static crate::theme_commands::ThemeConfig>, + /// Keyword alert settings (saved in app data, handed to the page runtime): serves + /// [`commands::ALERTS`]; the match and the notification are the app's. + pub alerts: Option<&'static crate::alerts_commands::AlertsConfig>, /// Native updates and the hotfix channel: serves [`commands::UPDATE`] and runs the update loop. /// Needs `updater` (the plugin) and the `net` feature. #[cfg(feature = "net")] @@ -130,6 +133,7 @@ impl AppConfig { sync: false, dev: false, themes: None, + alerts: None, #[cfg(feature = "net")] updates: None, } @@ -154,6 +158,12 @@ impl AppConfig { self } + /// Serves the alert settings commands ([`commands::ALERTS`]). + pub const fn with_alerts(mut self, alerts: &'static crate::alerts_commands::AlertsConfig) -> Self { + self.alerts = Some(alerts); + self + } + /// Serves the sync commands ([`commands::SYNC`]). pub const fn with_sync(mut self) -> Self { self.sync = true; @@ -699,7 +709,7 @@ async fn tab_zoom(webview: Webview, app: AppHandle, id: String, factor: Option) -> Result<(), String> { shell_only(&webview)?; @@ -1256,6 +1266,11 @@ fn dev_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'st crate::dev_commands::handler() } +/// The alert settings commands ([`commands::ALERTS`]). +fn alerts_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static { + crate::alerts_commands::handler() +} + /// The theme commands ([`commands::THEME`]). fn theme_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static { crate::theme_commands::handler() @@ -1330,6 +1345,7 @@ impl App { let sync_handler = sync_handler(); let dev_handler = dev_handler(); let theme_handler = theme_handler(); + let alerts_handler = alerts_handler(); let backup_handler = backup_handler(); let builder = tauri::Builder::::default() // Must be first: a second launch focuses the running window instead of fighting over @@ -1414,6 +1430,7 @@ impl App { crate::sync_commands::init(&handle); crate::dev_commands::init(&handle); crate::theme_commands::init(&handle); + crate::alerts_commands::init(&handle); #[cfg(feature = "net")] crate::fonts_commands::init(&handle); #[cfg(feature = "net")] @@ -1448,28 +1465,16 @@ impl App { backup_handler(invoke) } else if commands::THEME.contains(&invoke.message.command()) { theme_handler(invoke) + } else if commands::ALERTS.contains(&invoke.message.command()) { + alerts_handler(invoke) } else if commands::is_host(invoke.message.command()) { host_handler(invoke) } else { handler(invoke) } }) - .build(context) - .unwrap_or_else(|error| panic!("Failed to launch {}: {error}", config.title)) - .run(|_, event| log_run_event(&event)); - } -} - -/// Why the app is going away, for `--diag` ([`crate::diag`]): an exit request with its code (None is a -/// polite quit from outside: Cmd+Q, the Dock, or another app such as an auto-quitter closing the last -/// window), window close/destroy events and the final exit. Nothing is written without diagnostics. -fn log_run_event(event: &tauri::RunEvent) { - match event { - tauri::RunEvent::ExitRequested { code, .. } => crate::diag::log("host", &format!("exit requested code={code:?}")), - tauri::RunEvent::Exit => crate::diag::log("host", "exit"), - tauri::RunEvent::WindowEvent { label, event: tauri::WindowEvent::CloseRequested { .. }, .. } => crate::diag::log("host", &format!("window {label} close requested")), - tauri::RunEvent::WindowEvent { label, event: tauri::WindowEvent::Destroyed, .. } => crate::diag::log("host", &format!("window {label} destroyed")), - _ => {} + .run(context) + .unwrap_or_else(|error| panic!("Failed to launch {}: {error}", config.title)); } } diff --git a/crates/waybetter-host/src/commands.rs b/crates/waybetter-host/src/commands.rs index 7dba858..de6826d 100644 --- a/crates/waybetter-host/src/commands.rs +++ b/crates/waybetter-host/src/commands.rs @@ -123,9 +123,14 @@ pub const BACKUP: &[&str] = &["backup_collect", "backup_export_file", "backup_op /// grants these to the shell (`testkit::Capabilities::assert_shell_only_group`). pub const THEME: &[&str] = &["theme_get", "theme_set", "theme_preview", "theme_scopes_get", "theme_scopes_set"]; +/// Shell-only, optional: the keyword alert settings (`alerts_get`, `alerts_set`), served when the app +/// sets `AppConfig::alerts`. An app that uses them grants these to the shell +/// (`testkit::Capabilities::assert_shell_only_group`). +pub const ALERTS: &[&str] = &["alerts_get", "alerts_set"]; + /// Whether `command` is one of the host's (dispatched to the host, never to the app's handler). pub fn is_host(command: &str) -> bool { - SHELL.contains(&command) || TAB.contains(&command) || SITE.contains(&command) || STORE.contains(&command) || MEDIA.contains(&command) || GFONTS.contains(&command) || UPDATE.contains(&command) || WORKSPACES.contains(&command) || SYNC.contains(&command) || DEV.contains(&command) || BACKUP.contains(&command) || THEME.contains(&command) + SHELL.contains(&command) || TAB.contains(&command) || SITE.contains(&command) || STORE.contains(&command) || MEDIA.contains(&command) || GFONTS.contains(&command) || UPDATE.contains(&command) || WORKSPACES.contains(&command) || SYNC.contains(&command) || DEV.contains(&command) || BACKUP.contains(&command) || THEME.contains(&command) || ALERTS.contains(&command) } /// The capability permission tauri-build generates for `command` (`tabs_sync` → `allow-tabs-sync`). @@ -140,8 +145,8 @@ pub fn permission(command: &str) -> String { /// tauri_build::AppManifest::new().commands(waybetter_host::commands::manifest(&["draft_list"])) /// ``` pub fn manifest(app: &[&'static str]) -> &'static [&'static str] { - let mut all: Vec<&'static str> = Vec::with_capacity(app.len() + SHELL.len() + TAB.len() + SITE.len() + STORE.len() + MEDIA.len() + GFONTS.len() + UPDATE.len() + WORKSPACES.len() + SYNC.len() + DEV.len() + BACKUP.len() + THEME.len()); - for command in app.iter().chain(SHELL).chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP).chain(THEME) { + let mut all: Vec<&'static str> = Vec::with_capacity(app.len() + SHELL.len() + TAB.len() + SITE.len() + STORE.len() + MEDIA.len() + GFONTS.len() + UPDATE.len() + WORKSPACES.len() + SYNC.len() + DEV.len() + BACKUP.len() + THEME.len() + ALERTS.len()); + for command in app.iter().chain(SHELL).chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP).chain(THEME).chain(ALERTS) { if !all.contains(command) { all.push(command); } @@ -158,7 +163,7 @@ mod tests { let all = manifest(&["draft_list", "tabs_sync"]); assert_eq!(all[0], "draft_list"); assert_eq!(all.iter().filter(|c| **c == "tabs_sync").count(), 1); - for command in SHELL.iter().chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP).chain(THEME) { + for command in SHELL.iter().chain(TAB).chain(SITE).chain(STORE).chain(MEDIA).chain(GFONTS).chain(UPDATE).chain(WORKSPACES).chain(SYNC).chain(DEV).chain(BACKUP).chain(THEME).chain(ALERTS) { assert!(all.contains(command), "{command}"); assert!(is_host(command)); } @@ -168,7 +173,7 @@ mod tests { #[test] fn shell_and_tab_commands_do_not_overlap() { - assert!(!SHELL.iter().any(|command| TAB.contains(command) || SITE.contains(command) || STORE.contains(command) || MEDIA.contains(command) || GFONTS.contains(command) || UPDATE.contains(command) || WORKSPACES.contains(command) || SYNC.contains(command) || DEV.contains(command) || BACKUP.contains(command) || THEME.contains(command))); + assert!(!SHELL.iter().any(|command| TAB.contains(command) || SITE.contains(command) || STORE.contains(command) || MEDIA.contains(command) || GFONTS.contains(command) || UPDATE.contains(command) || WORKSPACES.contains(command) || SYNC.contains(command) || DEV.contains(command) || BACKUP.contains(command) || THEME.contains(command) || ALERTS.contains(command))); assert!(!TAB.iter().any(|command| SITE.contains(command))); } } diff --git a/crates/waybetter-host/src/lib.rs b/crates/waybetter-host/src/lib.rs index 1f64006..17404b5 100644 --- a/crates/waybetter-host/src/lib.rs +++ b/crates/waybetter-host/src/lib.rs @@ -93,6 +93,8 @@ mod dev_commands; #[cfg(feature = "app")] pub mod theme_commands; #[cfg(feature = "app")] +pub mod alerts_commands; +#[cfg(feature = "app")] mod backup_commands; #[cfg(all(feature = "app", feature = "net"))] mod fonts_commands; diff --git a/crates/waybetter-host/src/testkit.rs b/crates/waybetter-host/src/testkit.rs index f162739..e2c1fa7 100644 --- a/crates/waybetter-host/src/testkit.rs +++ b/crates/waybetter-host/src/testkit.rs @@ -267,6 +267,14 @@ pub fn assert_theme_guards() { } } +/// The alert settings' wrappers check their caller first. Runs against the host's source. +pub fn assert_alerts_guards() { + let source = include_str!("alerts_commands.rs"); + for command in commands::ALERTS { + assert_guarded(source, command, "shell_only(&webview)?"); + } +} + /// The backup commands' wrappers check their caller first. Runs against the host's source. pub fn assert_backup_guards() { let source = include_str!("backup_commands.rs"); @@ -289,6 +297,7 @@ mod tests { assert_dev_guards(); assert_backup_guards(); assert_theme_guards(); + assert_alerts_guards(); } fn caps_with(shell_extra: &str, tab_extra: &str, site_extra: &str) -> Capabilities { From 6b37744226e545ac274e481f9cb036583c5e51c8 Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:19:36 +0700 Subject: [PATCH 06/32] String packs: rich-text entries, language conditions and word rewriting; theme doctor report; translate-mode words - Rich sentences (a link or button inside text) can be replaced by data: the inventory gives a rich entry `slots`, a pack value places the site's own elements with {e0}, {e1}, ... (each once, the last may be left out; no markup, plural or other parameters). The engine returns a pieces + element order template; the page inventory carries `rich` slot counts. - Packs may carry `when: { languages }` (applies only while the site shows one of them; `en` matches `en-GB`) and `rewrite: { words }` (whole-word rewording of the site's own text, messages keep their parameters' values; no sentences of the site in the pack). The hook tells the engine the site's language; a rewording pack makes the delivery carry the whole inventory. - Apps can ship built-in packs (BuiltInPacks) delivered before installed ones; syncStringPacks hands the tabs a delivery at start only when it changed. - Translate mode words are a function the app supplies (asked at each draw) and gain a `plural` word; host validates `when` and `rewrite` envelopes. - Theme doctor: every finding says where (token path or CSS rule), what and how to fix, as catalog keys wb.doctor.*; the Theme Builder shows the full report; the import hint is translated. Doctor words are in the 17 supported catalogs. - waybetter strings check describes conditions and rewrites. Co-Authored-By: Claude Opus 5.5 --- crates/waybetter-host/src/store/strings.rs | 43 +++- docs/STRING-PACKS.md | 52 ++++- packages/runtime/src/stringPackHook.ts | 4 +- packages/runtime/src/stringPackTranslate.ts | 14 +- packages/runtime/src/stringPacks.ts | 215 +++++++++++++++--- packages/runtime/src/themeDoctor.ts | 120 ++++++++-- .../runtime/tests/stringPacksRich.test.ts | 143 ++++++++++++ packages/runtime/tests/themeDoctor.test.ts | 33 ++- packages/shell/src/panel/Appearance.tsx | 26 ++- packages/shell/src/panel/StringPacks.tsx | 45 +++- packages/shell/src/panel/builder.css | 8 + packages/shell/src/panel/panelMessages.ts | 13 ++ packages/shell/src/stringPacksModel.ts | 8 +- packages/shell/tests/stringPacksModel.test.ts | 14 ++ packages/waybetter/cli/strings.mjs | 2 + packages/waybetter/locales/ar.json | 40 ++++ packages/waybetter/locales/de.json | 40 ++++ packages/waybetter/locales/en.json | 40 ++++ packages/waybetter/locales/es.json | 40 ++++ packages/waybetter/locales/fr.json | 40 ++++ packages/waybetter/locales/hi.json | 40 ++++ packages/waybetter/locales/id.json | 40 ++++ packages/waybetter/locales/it.json | 40 ++++ packages/waybetter/locales/ja.json | 40 ++++ packages/waybetter/locales/ko.json | 40 ++++ packages/waybetter/locales/nl.json | 40 ++++ packages/waybetter/locales/pt.json | 40 ++++ packages/waybetter/locales/ru.json | 40 ++++ packages/waybetter/locales/th.json | 40 ++++ packages/waybetter/locales/tr.json | 40 ++++ packages/waybetter/locales/vi.json | 40 ++++ packages/waybetter/locales/zh-Hant.json | 40 ++++ packages/waybetter/tests/strings-cli.test.mjs | 18 ++ 33 files changed, 1353 insertions(+), 85 deletions(-) create mode 100644 packages/runtime/tests/stringPacksRich.test.ts diff --git a/crates/waybetter-host/src/store/strings.rs b/crates/waybetter-host/src/store/strings.rs index d26ff58..856d9ac 100644 --- a/crates/waybetter-host/src/store/strings.rs +++ b/crates/waybetter-host/src/store/strings.rs @@ -101,7 +101,28 @@ pub fn validate_strings(bytes: &[u8]) -> Result { return Err(format!("VALIDATION: string {} is not plain text", id.chars().take(64).collect::())); } } - const KNOWN: &[&str] = &["$schema", "format", "site", "catalog", "language", "base", "name", "authors", "version", "description", "strings"]; + // Conditions and rewording rules are data too: shapes are checked here, words and values by the page runtime's own validator. + if let Some(when) = object.get("when") { + let ok = when.as_object().is_some_and(|w| { + w.keys().all(|key| key == "languages") + && w.get("languages").and_then(serde_json::Value::as_array).is_some_and(|list| !list.is_empty() && list.len() <= 16 && list.iter().all(|tag| tag.as_str().is_some_and(valid_language))) + }); + if !ok { + return Err("VALIDATION: invalid \"when\"".into()); + } + } + if let Some(rewrite) = object.get("rewrite") { + let ok = rewrite.as_object().is_some_and(|r| { + r.keys().all(|key| key == "words") + && r.get("words").and_then(serde_json::Value::as_object).is_some_and(|words| { + !words.is_empty() && words.len() <= 64 && words.iter().all(|(from, to)| from.chars().count() <= 40 && to.as_str().is_some_and(|to| plain(to, 40) && !to.contains(['<', '>', '{', '}'])) && !from.contains(['<', '>', '{', '}']) && !from.is_empty()) + }) + }); + if !ok { + return Err("VALIDATION: invalid \"rewrite\"".into()); + } + } + const KNOWN: &[&str] = &["$schema", "format", "site", "catalog", "language", "base", "when", "rewrite", "name", "authors", "version", "description", "strings"]; if let Some(key) = object.keys().find(|key| !KNOWN.contains(&key.as_str())) { return Err(format!("VALIDATION: unknown field \"{}\"", key.chars().take(40).collect::())); } @@ -361,6 +382,26 @@ mod tests { format!(r#"{{"format":1,"site":"x","catalog":"web","language":"eo","name":"Esperanto","authors":["A"],"version":"1.0.0","strings":{strings}}}"#).into_bytes() } + #[test] + fn conditions_and_rewording_rules_are_plain_data() { + let with = |extra: &str| format!(r#"{{"format":1,"site":"x","catalog":"web","language":"en-x-twitter","name":"W","authors":["A"],{extra},"strings":{{}}}}"#).into_bytes(); + let info = validate_strings(&with(r#""when":{"languages":["en","en-GB"]},"rewrite":{"words":{"Post":"Tweet","posts":"tweets"}}"#)).unwrap(); + assert_eq!((info.language.as_str(), info.strings), ("en-x-twitter", 0)); + for bad in [ + r#""when":{"languages":[]}"#, + r#""when":{"languages":["not a tag"]}"#, + r#""when":{"code":"x"}"#, + r#""when":"en""#, + r#""rewrite":{"words":{}}"#, + r#""rewrite":{"words":{"Post":"Tweet"}}"#, + r#""rewrite":{"words":{"Post":"{x}"}}"#, + r#""rewrite":{"words":{"Post":1}}"#, + r#""rewrite":{"words":{"Post":"Tweet"},"code":"x"}"#, + ] { + assert!(validate_strings(&with(bad)).is_err(), "{bad}"); + } + } + #[test] fn packs_are_plain_data_with_the_envelope() { let info = validate_strings(&pack(r#"{"a0000001":"Hejmo","b0000002":"{count, plural, one {# afiŝo} other {# afiŝoj}}"}"#)).unwrap(); diff --git a/docs/STRING-PACKS.md b/docs/STRING-PACKS.md index abd88f0..82b47fe 100644 --- a/docs/STRING-PACKS.md +++ b/docs/STRING-PACKS.md @@ -4,7 +4,9 @@ A string pack replaces the wrapped site's own UI strings with data: it adds a la does not offer, fixes its translation, or rewords it. The framework has the formats, the validator, the application engine, the hook interface, `waybetter strings check`, the Store kind `strings` with its install screen, the Languages section and translate mode. Sentences with element slots -(rich text) cannot be replaced yet. +(rich text) are replaced with `{e0}`, `{e1}` placeholders for the site's own elements. A pack can also +reword the site's own text by words (`rewrite`) and apply only while the site is in some languages +(`when`). ## Rules @@ -39,6 +41,16 @@ with its install screen, the Languages section and translate mode. Sentences wit - `language` is a BCP 47 tag; a private-use tag is fine. `base` is the language whose plural rules the pack follows when the runtime does not know `language`; without either, every number takes the `other` form. +- `when` (optional) is a condition: `{ "languages": ["en"] }` applies the pack only while the site + shows English (a tag matches itself and its regional forms: `en` matches `en-GB`; the match is + case-insensitive). The site's language is the one its catalog registers (`sink.matched`), so a + pack that rewords English never touches a Turkish page. Without `when` a pack always applies. +- `rewrite` (optional) rewords the site's own text instead of replacing keys: + `{ "words": { "Post": "Tweet", "posts": "tweets" } }`. Whole words only, case as written, 1 to 64 + entries of plain letters and digits; applied to the text of every inventory key (plain strings, the + result of messages, the pieces of rich sentences) that no later pack replaced. A parameter's value + is never reworded (a user named "Post" stays "Post"). The pack carries none of the site's sentences, + so it keeps working when the site rewords a string, and `strings` may be empty. - `strings` maps a key id to text. The ids are the inventory's; a pack never carries the site's own text. @@ -53,7 +65,13 @@ stays, when: - it uses a number or date format, `selectordinal` or a plural offset; - it contains `<` or `>` (unless the inventory gives the key tag slots; then exactly those tags); - it contains control or bidi-override characters, is empty or is longer than 2000 characters; -- the key's kind cannot be replaced by data yet (`rich`, `format`). +- the key's kind cannot be replaced by data yet (`format`, and `rich` entries the inventory gives no + `slots`). + +A `rich` value (a sentence with a link or button inside) uses the original's element slots: +`{e0}` … `{e}` stand for the site's own elements, each exactly once (the last one may be +left out: the element after the final piece is not always there), in any order your sentence needs. +No plural, select, parameter or markup. A pack never carries HTML; the elements are the site's. A parameter is inserted the way string concatenation would insert it (`String(value)`). @@ -65,7 +83,7 @@ A parameter is inserted the way string concatenation would insert it (`String(va "entries": { "a0000001": { "kind": "text", "hash": "0k3j…" }, "b0000002": { "kind": "message", "params": ["count"], "plural": ["count"], "hash": "…" }, - "c0000003": { "kind": "rich", "group": "rich", "hash": "…" } + "c0000003": { "kind": "rich", "slots": 2, "group": "rich", "hash": "…" } } } ``` @@ -74,10 +92,11 @@ A parameter is inserted the way string concatenation would insert it (`String(va |---|---|---| | `text` | a string | yes | | `message` | a function of parameters that returns a string | yes | -| `rich` | text with element slots | not yet | +| `rich` | text with element slots (`slots`) | yes, when the inventory knows `slots` | | `format` | a compiled number, date or currency formatter | no | -`hash` is a hash of the base-language value (`hashText`), for the drift report; the inventory holds +`slots` (rich) is the number of element positions of the site's sentence: piece n is followed by the +caller's element n. `hash` is a hash of the base-language value (`hashText`), for the drift report; the inventory holds no text of the site. `group` names the part of the catalog a key arrives with (default `main`). `driftReport(inventory, observed, loadedGroups)` compares an inventory with a newer build: `added`, @@ -96,8 +115,13 @@ const engine = createStringEngine(inventory, [compilePack(packA, inventory), com engine.resolve(id, siteValue); // packB's value, else packA's, else exactly siteValue ``` -`resolve` returns a string for a `text` key and a function with the original's call shape for a -`message` key (closures over the parsed message; nothing is evaluated). Feeding a value the engine +`resolve` returns a string for a `text` key, a function with the original's call shape for a +`message` key (closures over the parsed message; nothing is evaluated) and, for a `rich` key, a +`RichTemplate` `{ pieces, order }`: piece n is shown, then the site's element `order[n]` (the shape +X's own sentence renderer reads; wiring it into a site's renderer is the adapter's part). A pack's +`rewrite` is applied to whichever value results, so a reworded message is a function again. +`engine.setLanguage(language)` tells the engine which language the site shows (the hook does it when +the adapter reports `matched`); conditional packs wait for it. Feeding a value the engine produced back in returns the same value. It keeps the site's own value of every key it changed (`engine.originals()`), which is what a restore needs; `applyPacks` and `restoreCatalog` do both for a whole catalog object without changing it. A live value whose kind differs from the @@ -174,6 +198,16 @@ the site's scripts. The Languages section of the panel (`createStringPacksSection({ inventory })`) lists the installed packs with their coverage, turns them on and off, orders and removes them. +### Built-in packs + +An app can ship packs of its own (`BuiltInPacks` in `panel/StringPacks.tsx`: a function returning pack +documents as text). They are delivered before the installed packs, so an installed pack wins where both +change a word, they follow the app's settings and they are not listed or removable. `syncStringPacks` +hands the tabs the delivery at start only when it differs from the one they were last given (every tab +reloads for a change). wayBetter for X's Twitter wording (Post -> Tweet, Repost -> Retweet) is one: a +`rewrite` pack for English that is delivered while its setting is on. A delivery with a rewording pack +carries the whole page inventory (the engine needs every key's shape), not a slice. + ## Translate mode Switched on in the Languages section. The delivery then carries the whole inventory, packs or not, @@ -182,5 +216,7 @@ and the page runtime marks every replaceable string with an invisible marker nam with the key, the current text and its parameters. An edit is checked with the pack rules (`checkEdit`) and kept in the tab's draft (`wayBetter.translateDraft`), which applies as the last pack after a reload. "Copy pack file" copies the draft as a pack document. "Leave" turns the mode -off for that tab. The markers can reach places that compare text exactly (the window title), so the +off for that tab. The bar's and the editor's words are the app's own (`words` option of `installTranslateUi`, a function +that is asked again each time they are drawn, so a language switch shows at once); the English +defaults are `TRANSLATE_WORDS`. The markers can reach places that compare text exactly (the window title), so the mode is for authors only and is never on by default. diff --git a/packages/runtime/src/stringPackHook.ts b/packages/runtime/src/stringPackHook.ts index 79a7f50..8ee3d3b 100644 --- a/packages/runtime/src/stringPackHook.ts +++ b/packages/runtime/src/stringPackHook.ts @@ -99,7 +99,7 @@ export function installStringPacks(win: Window, setups: readonly CatalogSetup[], refused.push(error instanceof Error ? error.message : String(error)); } } - const usable = packs.filter(pack => pack.values.size > 0); + const usable = packs.filter(pack => pack.values.size > 0 || pack.rewrite); return { catalog: setup.adapter.catalog, adapter: setup.adapter, packs, refused, usable, engine: usable.length || options.mark ? createStringEngine(setup.inventory, usable) : null, @@ -134,7 +134,7 @@ export function installStringPacks(win: Window, setups: readonly CatalogSetup[], if (!engine) continue; const sink: CatalogSink = { seen(group = 'main') { state.seen[group] = (state.seen[group] ?? 0) + 1; }, - matched(language) { state.languages.add(String(language)); }, + matched(language) { state.languages.add(String(language)); engine.setLanguage(String(language)); }, resolve(id, original) { try { state.keys += 1; diff --git a/packages/runtime/src/stringPackTranslate.ts b/packages/runtime/src/stringPackTranslate.ts index 95a4030..abbd799 100644 --- a/packages/runtime/src/stringPackTranslate.ts +++ b/packages/runtime/src/stringPackTranslate.ts @@ -90,14 +90,14 @@ export function checkEdit(lookup: InventoryLookup, id: string, value: string): s export type TranslateWords = { bar: string; hint: string; edits(count: number): string; exportPack: string; copied: string; exit: string; reload: string; - key: string; original: string; parameters: string; save: string; cancel: string; remove: string; notTranslatable: string; choose: string; + key: string; original: string; parameters: string; plural: string; save: string; cancel: string; remove: string; notTranslatable: string; choose: string; }; /** English defaults (the app passes its own words). */ export const TRANSLATE_WORDS: TranslateWords = { bar: 'Translate mode', hint: 'Click a word to change it.', edits: count => `${count} ${count === 1 ? 'edit' : 'edits'}`, exportPack: 'Copy pack file', copied: 'Pack file copied', exit: 'Leave', reload: 'Reload to see it', - key: 'Key', original: 'Now', parameters: 'Parameters', save: 'Save', cancel: 'Cancel', remove: 'Remove edit', + key: 'Key', original: 'Now', parameters: 'Parameters', plural: 'plural', save: 'Save', cancel: 'Cancel', remove: 'Remove edit', notTranslatable: 'This string cannot be changed by a pack yet.', choose: 'Which one?', }; @@ -106,7 +106,8 @@ export type TranslateUiOptions = { marker: Marker; site: string; catalog: string; - words?: Partial; + /** The bar's and the editor's words; a function is asked again each time they are drawn (the app's language may change). */ + words?: Partial | (() => Partial); /** Leaves translate mode (the app drops the flag and reloads). */ exit(): void; }; @@ -132,7 +133,7 @@ button.primary { background: #2563eb; } */ export function installTranslateUi(win: Window, options: TranslateUiOptions): { dispose(): void } { const doc = win.document; - const words = { ...TRANSLATE_WORDS, ...options.words }; + const currentWords = (): TranslateWords => ({ ...TRANSLATE_WORDS, ...(typeof options.words === 'function' ? options.words() : options.words) }); const lookup = inventoryLookup(options.inventory); const storage = win.sessionStorage; const draft = (): TranslateDraft => readDraft(storage) ?? { language: '', name: '', strings: {} }; @@ -157,6 +158,7 @@ export function installTranslateUi(win: Window, options: TranslateUiOptions): { return el; }; const renderBar = () => { + const words = currentWords(); bar.replaceChildren(); const title = doc.createElement('b'); title.textContent = words.bar; @@ -173,6 +175,7 @@ export function installTranslateUi(win: Window, options: TranslateUiOptions): { const closePop = () => { pop?.remove(); pop = null; }; const edit = (id: string, x: number, y: number, now: string) => { + const words = currentWords(); closePop(); pop = doc.createElement('div'); pop.className = 'pop'; @@ -196,7 +199,7 @@ export function installTranslateUi(win: Window, options: TranslateUiOptions): { } if (shape.params?.length) { const params = doc.createElement('small'); - params.textContent = `${words.parameters}: ${shape.params.map(name => `{${name}}${shape.plural?.includes(name) ? ' (plural)' : ''}`).join(', ')}`; + params.textContent = `${words.parameters}: ${shape.params.map(name => `{${name}}${shape.plural?.includes(name) ? ` (${words.plural})` : ''}`).join(', ')}`; pop.append(params); } const input = doc.createElement('textarea'); @@ -234,6 +237,7 @@ export function installTranslateUi(win: Window, options: TranslateUiOptions): { return []; }; const onClick = (event: MouseEvent) => { + const words = currentWords(); if (event.composedPath().includes(host)) return; const found = keysAt(event.target as Element | null); if (!found.length) return; diff --git a/packages/runtime/src/stringPacks.ts b/packages/runtime/src/stringPacks.ts index f4e400e..65b310c 100644 --- a/packages/runtime/src/stringPacks.ts +++ b/packages/runtime/src/stringPacks.ts @@ -27,9 +27,11 @@ type Parts = ReturnType; * What the site's value for a key is: * - `text`: a plain string; * - `message`: a function of a parameter object that returns a string; - * - `rich`: text with element slots (not replaceable by data yet); + * - `rich`: text with element slots (a link or a button inside a sentence). It can be replaced when + * the inventory knows its slot count (`slots`): the pack value then places the site's own + * elements with `{e0}`, `{e1}`, …, each exactly once (the last may be left out); the value itself is still plain text; * - `format`: a compiled number/date/currency formatter (not text). - * Only `text` and `message` can be replaced by a pack. + * Only `text`, `message` and `rich` with known `slots` can be replaced by a pack. */ export type StringKind = 'text' | 'message' | 'rich' | 'format'; @@ -41,6 +43,8 @@ export type InventoryEntry = { plural?: string[]; /** Parameters the site's value selects on. */ select?: string[]; + /** Element slots of a `rich` value (`{e0}` … `{e}` in a pack value; the last may be left out). Without it the key is closed. */ + slots?: number; /** Tag slot names, for catalogs whose values carry `…` slots. */ tags?: string[]; /** Hash of the base-language value (`hashText`): drift detection; never the text itself. */ @@ -61,6 +65,22 @@ export type StringInventory = { entries: Record; }; +/** + * When a pack applies. Without a condition it always does. `languages`: only while the site shows + * one of these languages (a tag matches itself and its regional forms: `en` matches `en-GB`), for + * example a rewording of English that must not touch a Turkish page. + */ +export type PackCondition = { languages?: string[] }; + +/** + * A pack's rewording rule: whole words replaced inside the site's own text, wherever it appears + * (`{ "Post": "Tweet", "posts": "tweets" }`). It carries none of the site's sentences, so it keeps + * working when the site words a string differently, and it applies to a value of the site (or of an + * earlier pack) that no later pack replaced. Words are matched exactly (case as written), never + * inside a longer word, and never in a parameter's value (a user named "Post" stays "Post"). + */ +export type PackRewrite = { words: Record }; + /** A string pack document: metadata and `key id -> text`. */ export type StringPack = { format: 1; @@ -72,6 +92,10 @@ export type StringPack = { authors: string[]; /** A language whose plural rules the pack follows when the runtime does not know `language`. */ base?: string; + /** The pack applies only when this holds (default: always). */ + when?: PackCondition; + /** Rewords the site's text instead of (or besides) replacing keys. */ + rewrite?: PackRewrite; version?: string; description?: string; strings: Record; @@ -83,11 +107,23 @@ export const MAIN_GROUP = 'main'; const TAG = /^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/; const IDENT = /^[a-z][a-z0-9-]{0,31}$/; const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f‪-‮⁦-⁩]/; +const REWRITE_FROM = /^[\p{L}\p{N}]{1,40}$/u; +const REWRITE_TO = /^[\p{L}\p{N}][\p{L}\p{N}'’-]{0,39}$/u; +const MAX_REWRITES = 64; const CATEGORIES = new Set(['zero', 'one', 'two', 'few', 'many', 'other']); -/** Whether a pack can replace a value of this kind. */ -export function translatable(kind: StringKind): boolean { - return kind === 'text' || kind === 'message'; +/** Whether a pack can replace a value of this kind (a `rich` one only with known `slots`: pass the shape). */ +export function translatable(kind: StringKind | Pick): boolean { + const { kind: k, slots } = typeof kind === 'string' ? { kind, slots: undefined } : kind; + return k === 'text' || k === 'message' || (k === 'rich' && slots !== undefined); +} + +/** Whether `language` (the site's) satisfies a pack's `when`. */ +export function conditionHolds(when: PackCondition | undefined, language: string | undefined): boolean { + if (!when?.languages) return true; + if (!language) return false; + const have = language.toLowerCase(); + return when.languages.some(tag => { const want = tag.toLowerCase(); return have === want || have.startsWith(`${want}-`); }); } /** 53-bit hash of a text as 11 base-36 characters. Same result in every runtime. */ @@ -108,7 +144,7 @@ export function hashText(text: string): string { // Inventory lookup (the full inventory, or its compact page form) /** The facts the validator and the engine need about one key. */ -export type EntryShape = Pick; +export type EntryShape = Pick; export type InventoryLookup = (id: string) => EntryShape | undefined; /** @@ -122,6 +158,8 @@ export type PageInventory = { text: string; message: Record; closed: string; + /** Rich entries a pack can replace: id -> slot count. */ + rich?: Record; /** A slice: only the keys some pack names. A key missing from a slice is not a new key of the site. */ partial?: boolean; }; @@ -130,13 +168,15 @@ function compact(site: string, catalog: string, shapes: Iterable<[string, EntryS const text: string[] = []; const closed: string[] = []; const message: Record = {}; + const rich: Record = {}; for (const [id, entry] of shapes) { - if (entry.kind === 'text' && !entry.tags?.length) text.push(id); + if (entry.kind === 'rich' && entry.slots !== undefined && !entry.tags?.length) rich[id] = entry.slots; + else if (entry.kind === 'text' && !entry.tags?.length) text.push(id); else if (entry.kind === 'message' && !entry.tags?.length) { message[id] = (entry.params ?? []).map(name => `${name}${entry.plural?.includes(name) ? '*' : ''}${entry.select?.includes(name) ? '?' : ''}`).join(' '); } else closed.push(id); } - return { site, catalog, text: text.join(' '), message, closed: closed.join(' ') }; + return { site, catalog, text: text.join(' '), message, closed: closed.join(' '), ...(Object.keys(rich).length ? { rich } : {}) }; } export function packInventory(inventory: StringInventory): PageInventory { @@ -165,6 +205,7 @@ export function isPageInventory(input: unknown): input is PageInventory { return typeof input.site === 'string' && IDENT.test(input.site) && typeof input.catalog === 'string' && IDENT.test(input.catalog) && ids(input.text) && ids(input.closed) && isRecord(input.message) && Object.entries(input.message).every(([id, names]) => /^[\w$.-]+$/.test(id) && typeof names === 'string' && /^[\w$*? ]*$/.test(names)) + && (input.rich === undefined || (isRecord(input.rich) && Object.entries(input.rich).every(([id, n]) => /^[\w$.-]+$/.test(id) && Number.isInteger(n) && (n as number) >= 0 && (n as number) <= 32))) && (input.partial === undefined || typeof input.partial === 'boolean'); } @@ -182,6 +223,7 @@ export function inventoryLookup(inventory: StringInventory | PageInventory): Inv const map = new Map(); if (inventory.text) for (const id of inventory.text.split(' ')) map.set(id, TEXT_SHAPE); if (inventory.closed) for (const id of inventory.closed.split(' ')) map.set(id, CLOSED_SHAPE); + if (inventory.rich) for (const [id, slots] of Object.entries(inventory.rich)) map.set(id, { kind: 'rich', slots }); for (const [id, spec] of Object.entries(inventory.message)) { const names = spec ? spec.split(' ') : []; map.set(id, { @@ -221,13 +263,27 @@ export function checkPackShape(input: unknown): PackIssue[] { || input.authors.some(author => typeof author !== 'string' || !author.trim() || author.length > STRING_PACK_LIMITS.name || CONTROL.test(author) || /[<>]/.test(author))) { error(`"authors" must be a list of at most ${STRING_PACK_LIMITS.authors} plain-text names`); } + if (input.when !== undefined) { + const when = input.when; + if (!isRecord(when) || Object.keys(when).some(key => key !== 'languages')) error('"when" is an object with "languages"'); + else if (when.languages !== undefined && (!Array.isArray(when.languages) || !when.languages.length || when.languages.length > 16 + || when.languages.some(tag => typeof tag !== 'string' || !TAG.test(tag)))) error('"when.languages" must be a list of 1 to 16 language tags'); + } + if (input.rewrite !== undefined) { + const rewrite = input.rewrite; + const words = isRecord(rewrite) ? rewrite.words : undefined; + if (!isRecord(rewrite) || Object.keys(rewrite).some(key => key !== 'words') || !isRecord(words) || !Object.keys(words).length || Object.keys(words).length > MAX_REWRITES + || Object.entries(words).some(([from, to]) => !REWRITE_FROM.test(from) || typeof to !== 'string' || !REWRITE_TO.test(to))) { + error(`"rewrite" is { "words": { "Word": "Replacement" } } with 1 to ${MAX_REWRITES} plain words`); + } + } for (const field of ['version', 'description'] as const) { const value = input[field]; if (value !== undefined && (typeof value !== 'string' || value.length > 400 || CONTROL.test(value) || /[<>]/.test(value))) error(`"${field}" must be plain text`); } if (!isRecord(input.strings)) error('"strings" must be an object of key id -> text'); else if (Object.keys(input.strings).length > STRING_PACK_LIMITS.strings) error(`"strings" has more than ${STRING_PACK_LIMITS.strings} entries`); - const known = new Set(['$schema', 'format', 'site', 'catalog', 'language', 'base', 'name', 'authors', 'version', 'description', 'strings']); + const known = new Set(['$schema', 'format', 'site', 'catalog', 'language', 'base', 'when', 'rewrite', 'name', 'authors', 'version', 'description', 'strings']); for (const key of Object.keys(input)) if (!known.has(key)) issues.push({ level: 'warning', message: `unknown field "${key}" is ignored` }); return issues; } @@ -293,7 +349,7 @@ function checkParts(parts: Parts, shape: EntryShape): string | null { * reason it is refused (the original then stays). */ export function validateString(shape: EntryShape, value: unknown): { parts: Parts } | { reason: string } { - if (!translatable(shape.kind)) return { reason: `not translatable yet (${shape.kind})` }; + if (!translatable(shape)) return { reason: `not translatable yet (${shape.kind})` }; if (typeof value !== 'string') return { reason: 'the value must be text' }; if (!value) return { reason: 'the value is empty' }; if (value.length > STRING_PACK_LIMITS.value) return { reason: `longer than ${STRING_PACK_LIMITS.value} characters` }; @@ -306,6 +362,20 @@ export function validateString(shape: EntryShape, value: unknown): { parts: Part } catch (error) { return { reason: `invalid message syntax: ${error instanceof Error ? error.message : String(error)}` }; } + if (shape.kind === 'rich') { + // Element slots: `{e0}` … `{e}`, each exactly once (the last may be left out); no plural, select or other parameter. + const slots = Array.from({ length: shape.slots ?? 0 }, (_, index) => `e${index}`); + const bad = checkParts(parts, { kind: 'message', params: slots }); + if (bad) return { reason: bad }; + const used = parts.flatMap(part => (typeof part !== 'string' && part.kind === 'arg' ? [part.name] : [])); + for (const name of slots) { + const count = used.filter(item => item === name).length; + // The element after the last piece is not always there: that one slot may be left out. + if (count === 0 && name === slots[slots.length - 1] && slots.length > 0) continue; + if (count !== 1) return { reason: count ? `{${name}} (the original's element) must appear once, not ${count} times` : `the original's element {${name}} is missing` }; + } + return { parts }; + } const problem = checkParts(parts, shape.kind === 'message' ? shape : { kind: 'text' }); return problem ? { reason: problem } : { parts }; } @@ -313,7 +383,13 @@ export function validateString(shape: EntryShape, value: unknown): { parts: Part // ------------------------------------------------------------------------------------------- // Compiling a pack (validation against an inventory) -export type CompiledValue = { text: string } | { parts: Parts }; +/** + * A replaced `rich` value in the shape X's own renderer reads: piece `n` is shown, then the site's + * element `order[n]` (the last piece has no element after it). + */ +export type RichTemplate = { readonly pieces: readonly string[]; readonly order: readonly number[] }; + +export type CompiledValue = { text: string } | { parts: Parts } | { rich: RichTemplate }; export type PackReport = { /** Entries in the pack. */ @@ -330,6 +406,9 @@ export type CompiledPack = { name: string; language: string; base?: string; + when?: PackCondition; + /** The pack's word rewriting, ready to apply to a text. */ + rewrite?: (text: string) => string; site: string; catalog: string; values: ReadonlyMap; @@ -341,6 +420,28 @@ function literal(parts: Parts): string { return parts.map(part => (typeof part === 'string' ? part : '')).join(''); } +/** The word-for-word rewriting of a validated `rewrite` rule. */ +function compileRewrite(rule: PackRewrite): (text: string) => string { + const words = new Map(Object.entries(rule.words)); + // Words are letters and digits only (checked), so they need no escaping. + const alternatives = [...words.keys()].sort((a, b) => b.length - a.length).join('|'); + const pattern = new RegExp(String.raw`(? text.replace(pattern, word => words.get(word) ?? word); +} + +/** A validated rich value as pieces and element order. */ +function richTemplate(parts: Parts): RichTemplate { + const pieces: string[] = []; + const order: number[] = []; + let current = ''; + for (const part of parts) { + if (typeof part === 'string') current += part; + else if (part.kind === 'arg') { pieces.push(current); order.push(Number(part.name.slice(1))); current = ''; } + } + pieces.push(current); + return Object.freeze({ pieces: Object.freeze(pieces), order: Object.freeze(order) }); +} + /** * Validates a pack against an inventory. Throws on a malformed envelope or a pack for another * site/catalog; every other problem is per key and lands in `report`. @@ -361,10 +462,10 @@ export function compilePack(input: unknown, inventory: StringInventory | PageInv if (!shape) { report.unknown.push(id); continue; } const result = validateString(shape, value); if ('reason' in result) { report.rejected.push({ id, reason: result.reason }); continue; } - values.set(id, shape.kind === 'text' ? { text: literal(result.parts) } : { parts: result.parts }); + values.set(id, shape.kind === 'text' ? { text: literal(result.parts) } : shape.kind === 'rich' ? { rich: richTemplate(result.parts) } : { parts: result.parts }); report.valid += 1; } - return { name: pack.name, language: pack.language, base: pack.base, site: pack.site, catalog: pack.catalog, values, report }; + return { name: pack.name, language: pack.language, base: pack.base, when: pack.when, rewrite: pack.rewrite ? compileRewrite(pack.rewrite) : undefined, site: pack.site, catalog: pack.catalog, values, report }; } // ------------------------------------------------------------------------------------------- @@ -416,6 +517,45 @@ export function renderMessage(parts: Parts, params: Readonly string): unknown { + if (typeof value === 'string') return rewrite(value); + if (Array.isArray(value)) { + const mapped = value.map(piece => (typeof piece === 'string' ? rewrite(piece) : piece)); + return mapped.some((piece, index) => piece !== value[index]) ? mapped : value; + } + if (typeof value === 'function') { + const message = value as (this: unknown, params?: unknown) => unknown; + const plural = new Set(shape.plural ?? []); + return function (this: unknown, params?: unknown) { + const input = isRecord(params) ? params : {}; + // The parameters go through as private markers, so only the site's own words are reworded. + const forward: Record = { ...input }; + const held: [string, unknown][] = []; + for (const name of shape.params ?? []) { + if (plural.has(name) || !(name in input)) continue; + const marker = `\uE000${held.length}\uE001`; + held.push([marker, input[name]]); + forward[name] = marker; + } + try { + const out = message.call(this, forward); + if (typeof out !== 'string') return message.call(this, params); + let text = rewrite(out); + for (const [marker, original] of held) text = text.split(marker).join(String(original)); + return text; + } catch { + return message.call(this, params); + } + }; + } + if (typeof value === 'object' && value !== null && 'pieces' in value) { + const template = value as RichTemplate; + return Object.freeze({ pieces: Object.freeze(template.pieces.map(rewrite)), order: template.order }); + } + return value; +} + // ------------------------------------------------------------------------------------------- // The ordered application engine @@ -436,6 +576,11 @@ export type StringEngine = { * Feeding a value this engine produced back in returns the same value (idempotent). */ resolve(id: string, original: unknown): unknown; + /** + * The language the site shows (what packs with a `when.languages` condition are checked + * against). Set before the first `resolve`; until then conditional packs do not apply. + */ + setLanguage(language: string): void; /** The site's own values of the keys a pack changed: what restoring needs. */ originals(): ReadonlyMap; stats(): EngineStats; @@ -454,11 +599,13 @@ export function createStringEngine(inventory: StringInventory | PageInventory | const seen = new Set(); const unlisted = new Set(); const mismatched = new Set(); + let siteLanguage: string | undefined; - const winner = (id: string): { pack: CompiledPack; value: CompiledValue } | null => { + const winner = (id: string): { pack: CompiledPack; value: CompiledValue; index: number } | null => { for (let index = packs.length - 1; index >= 0; index -= 1) { + if (!conditionHolds(packs[index]!.when, siteLanguage)) continue; const value = packs[index]!.values.get(id); - if (value) return { pack: packs[index]!, value }; + if (value) return { pack: packs[index]!, value, index }; } return null; }; @@ -466,31 +613,38 @@ export function createStringEngine(inventory: StringInventory | PageInventory | const resolve = (id: string, incoming: unknown): unknown => { let original = incoming; // A value of ours coming back in (a second application): work from the site's own value again. - if (typeof incoming === 'function' && produced.has(incoming)) original = produced.get(incoming); + if ((typeof incoming === 'function' || (typeof incoming === 'object' && incoming !== null)) && produced.has(incoming)) original = produced.get(incoming); else if (typeof incoming === 'string' && applied.has(id) && applied.get(id) === incoming) original = originals.get(id); seen.add(id); const found = winner(id); - if (!found) { + // Word rewriting of the packs after the one whose text won (all of them when none did). + const rewrites = packs.flatMap((pack, index) => (index > (found?.index ?? -1) && pack.rewrite && conditionHolds(pack.when, siteLanguage) ? [pack.rewrite] : [])); + if (!found && !rewrites.length) { if (whole && unlisted.size < MAX_LISTED && !lookup(id)) unlisted.add(id); return original; } const shape = lookup(id); - if (!shape || !translatable(shape.kind)) return original; - if (shape.kind === 'text' ? typeof original !== 'string' : typeof original !== 'function') { + if (!shape || shape.kind === 'format' || (found && !translatable(shape))) return original; + if (shape.kind === 'text' ? typeof original !== 'string' : shape.kind === 'rich' ? !Array.isArray(original) : typeof original !== 'function') { if (mismatched.size < MAX_LISTED) mismatched.add(id); return original; } if (originals.has(id) && originals.get(id) === original) return applied.get(id); - let next: unknown; - if ('text' in found.value) { - next = found.value.text; - } else { - const parts = found.value.parts; - const languages = [found.pack.language, found.pack.base]; - const message = (params?: unknown): string => renderMessage(parts, isRecord(params) ? params : {}, languages); - produced.set(message, original); - next = message; + let next: unknown = original; + if (found) { + if ('text' in found.value) { + next = found.value.text; + } else if ('rich' in found.value) { + next = found.value.rich; + } else { + const parts = found.value.parts; + const languages = [found.pack.language, found.pack.base]; + next = (params?: unknown): string => renderMessage(parts, isRecord(params) ? params : {}, languages); + } } + for (const rewrite of rewrites) next = rewriteValue(shape, next, rewrite); + if (next === original) return original; + if (typeof next === 'function' || typeof next === 'object') produced.set(next as object, original as object); originals.set(id, original); applied.set(id, next); return next; @@ -498,6 +652,7 @@ export function createStringEngine(inventory: StringInventory | PageInventory | return { resolve, + setLanguage(language) { siteLanguage = language; }, originals: () => originals, stats: () => ({ seen: seen.size, applied: applied.size, unlisted: [...unlisted], mismatched: [...mismatched] }), }; @@ -539,7 +694,7 @@ export function coverage(inventory: StringInventory, pack: Pick.found` / `.fix`, English below), so a panel shows +// them in the owner's language and the CLI prints the English. import { contrastRatio } from './themeApi.ts'; import { ensureContrast, type ThemeSpec } from './themeSpec.ts'; @@ -9,49 +12,120 @@ import { ensureContrast, type ThemeSpec } from './themeSpec.ts'; export type DoctorAdvice = { /** `lighter`: a lighter mechanism would do; `performance`, `accessibility`, `contrast`: a cost. */ kind: 'lighter' | 'performance' | 'accessibility' | 'contrast'; - /** Stable id, for tests and translations (`wb.doctor.`). */ + /** Stable id of the finding, for tests (`css-radius`, `contrast-text`). */ id: string; - /** English text (the panel translates by id when it has the words). */ + /** Its words in the catalog: `wb.doctor..found` and `wb.doctor..fix` (`css-radius`, `contrast`). */ + key: string; + /** A token path of the theme (`colors.text`, `components.postText.fontSize`) or the CSS rule (`.card { border-radius }`). */ + where: string; + /** Values for the `{name}` slots of the words. */ + params: Record; + /** English: what was found. */ text: string; + /** English: how to fix it. */ + fix: string; }; -type Rule = { id: string; kind: DoctorAdvice['kind']; test: RegExp; text: string }; +/** The doctor's words in English (the source of `wb.doctor.*` in the catalogs). */ +export const DOCTOR_MESSAGES = { + 'wb.doctor.css-radius.found': 'This rule sets corner radii in CSS.', + 'wb.doctor.css-radius.fix': 'Set them with the radius of a part under components, or shape.radius for all of them: no CSS needed, and it keeps working when the site renames its classes.', + 'wb.doctor.css-bevel.found': 'This rule draws a bevelled edge with stacked inset shadows.', + 'wb.doctor.css-bevel.fix': 'Use borderStyle "bevel-out" or "bevel-in" on a part under components: it draws the bevel from the theme’s colors.', + 'wb.doctor.css-hide.found': 'This rule hides something with display: none.', + 'wb.doctor.css-hide.fix': 'Use visible on a part under components (avatars, counts, names) or a layout variant such as sidebar: hidden; the owner can then switch it back.', + 'wb.doctor.css-color.found': 'This rule uses a literal color.', + 'wb.doctor.css-color.fix': 'Name a role (text, muted, accent, surface…) in colors or in a component, so the contrast pass covers it.', + 'wb.doctor.css-font.found': 'This rule sets a font family.', + 'wb.doctor.css-font.fix': 'Use font.roles: it sets the post, heading, numbers and mono faces without CSS.', + 'wb.doctor.css-has.found': 'This rule uses :has(), which is matched again on every change of the page.', + 'wb.doctor.css-has.fix': 'Keep :has() off rules that repeat down a timeline, or anchor the rule on a part.', + 'wb.doctor.css-universal.found': 'This rule uses a universal selector (*), matched against every element.', + 'wb.doctor.css-universal.fix': 'Anchor the rule on a part instead.', + 'wb.doctor.css-blur.found': 'This rule blurs what is behind it (backdrop-filter), which is costly on parts that repeat.', + 'wb.doctor.css-blur.fix': 'Use the glass fill of bars and panels: it is the cheaper place for blur.', + 'wb.doctor.css-outline-none.found': 'This rule removes the focus outline, so keyboard focus is no longer visible.', + 'wb.doctor.css-outline-none.fix': 'Use decor.focusRing to draw a visible focus ring instead.', + 'wb.doctor.css-motion.found': 'This rule animates without checking for reduced motion.', + 'wb.doctor.css-motion.fix': 'Keep motion inside @media (prefers-reduced-motion: no-preference), or let decor.motion do it for you.', + 'wb.doctor.css-size.found': 'The CSS is more than 20,000 characters long.', + 'wb.doctor.css-size.fix': 'The site recalculates styles with every rule; tokens and component settings compile to fewer rules.', + 'wb.doctor.contrast.found': 'The {token} color was adjusted to stay readable ({ratio}:1 on the background).', + 'wb.doctor.contrast.fix': 'Pick a lighter or darker {token} color; until then the theme is shown with the adjusted one.', + 'wb.doctor.glass-post.found': 'Glass is set on posts, but it is not drawn: blur on every post of a timeline is too costly.', + 'wb.doctor.glass-post.fix': 'Use a solid or tinted fill for posts and keep glass for bars and panels.', + 'wb.doctor.small-post-text.found': 'Post text is {size}px, which is hard to read for many people.', + 'wb.doctor.small-post-text.fix': 'Use 14px or more for the post text size, or raise the text size of the whole theme.', + 'wb.doctor.nav-moved.found': 'The navigation is moved to the {position}, which changes where people look for it.', + 'wb.doctor.nav-moved.fix': 'It only applies on wide panes, and the owner can turn layout changes off. Keep the default position unless the layout needs it.', +} as const; + +const fill = (text: string, params: Record) => text.replace(/\{(\w+)\}/g, (_, name: string) => params[name] ?? ''); + +type Rule = { id: string; kind: DoctorAdvice['kind']; test: RegExp; property: string }; /** What a theme's free-form CSS does that a v2 group does without CSS. */ const CSS_RULES: Rule[] = [ - { id: 'css-radius', kind: 'lighter', test: /border-radius\s*:/i, text: 'Corner radii: components..radius (or shape.radius) sets them without CSS and keeps working when the site renames its classes.' }, - { id: 'css-bevel', kind: 'lighter', test: /box-shadow\s*:[^;{}]*inset[^;{}]*inset[^;{}]*inset/i, text: 'Bevelled edges: components..borderStyle "bevel-out" / "bevel-in" draws them from the theme\'s colors.' }, - { id: 'css-hide', kind: 'lighter', test: /display\s*:\s*none/i, text: 'Hiding a part: components..visible (avatars, counts, names) or a layout variant (sidebar: hidden) does it, and the owner can switch it back.' }, - { id: 'css-color', kind: 'lighter', test: /(?:^|[;{\s])(?:color|background(?:-color)?)\s*:\s*#[0-9a-f]{3,8}/i, text: 'Literal colors: name a role (text, muted, accent, surface…) in colors or in a component, so the contrast pass covers it.' }, - { id: 'css-font', kind: 'lighter', test: /font-family\s*:/i, text: 'Fonts: font.roles sets the post, heading, numbers and mono faces without CSS.' }, - { id: 'css-has', kind: 'performance', test: /:has\(/i, text: ':has() is matched again on every change of the page; keep it off rules that repeat down a timeline.' }, - { id: 'css-universal', kind: 'performance', test: /(?:^|[\s,>+~])\*\s*(?:[,{>+~:\[]|$)/m, text: 'A universal selector (*) is matched against every element; anchor the rule on a part.' }, - { id: 'css-blur', kind: 'performance', test: /backdrop-filter\s*:/i, text: 'Blur (backdrop-filter) is costly on parts that repeat; the glass fill of bars and panels is the cheaper place for it.' }, - { id: 'css-outline-none', kind: 'accessibility', test: /outline\s*:\s*(?:none|0)\b/i, text: 'Removing the outline hides where keyboard focus is; decor.focusRing draws a visible one instead.' }, - { id: 'css-motion', kind: 'accessibility', test: /(?:animation|transition)\s*:/i, text: 'Motion should stay inside @media (prefers-reduced-motion: no-preference); decor.motion does that for you.' }, + { id: 'css-radius', kind: 'lighter', test: /border-radius\s*:/gi, property: 'border-radius' }, + { id: 'css-bevel', kind: 'lighter', test: /box-shadow\s*:[^;{}]*inset[^;{}]*inset[^;{}]*inset/gi, property: 'box-shadow' }, + { id: 'css-hide', kind: 'lighter', test: /display\s*:\s*none/gi, property: 'display' }, + { id: 'css-color', kind: 'lighter', test: /(?:^|[;{\s])(?:color|background(?:-color)?)\s*:\s*#[0-9a-f]{3,8}/gi, property: 'color' }, + { id: 'css-font', kind: 'lighter', test: /font-family\s*:/gi, property: 'font-family' }, + { id: 'css-has', kind: 'performance', test: /:has\(/gi, property: ':has()' }, + { id: 'css-universal', kind: 'performance', test: /(?:^|[\s,>+~])\*\s*(?:[,{>+~:[]|$)/gm, property: '*' }, + { id: 'css-blur', kind: 'performance', test: /backdrop-filter\s*:/gi, property: 'backdrop-filter' }, + { id: 'css-outline-none', kind: 'accessibility', test: /outline\s*:\s*(?:none|0)\b/gi, property: 'outline' }, + { id: 'css-motion', kind: 'accessibility', test: /(?:animation|transition)\s*:/gi, property: 'transition' }, ]; -/** Advice for a theme document. Empty when there is nothing to say. */ +const MAX_PER_RULE = 25; + +/** The selector of the rule block a position of `css` is in (the text before its `{`), shortened. */ +function selectorAt(css: string, index: number): string { + const open = css.lastIndexOf('{', index); + if (open < 0) return ''; + const close = Math.max(css.lastIndexOf('}', open - 1), css.lastIndexOf(';', open - 1), css.lastIndexOf('{', open - 1)); + const selector = css.slice(close + 1, open).replace(/\s+/g, ' ').trim(); + return selector.length > 80 ? `${selector.slice(0, 79)}…` : selector; +} + +function advice(id: string, kind: DoctorAdvice['kind'], where: string, params: Record = {}, key = id): DoctorAdvice { + const words = DOCTOR_MESSAGES as Record; + return { kind, id, key, where, params, text: fill(words[`wb.doctor.${key}.found`]!, params), fix: fill(words[`wb.doctor.${key}.fix`]!, params) }; +} + +/** Advice for a theme document: every finding, with where it is. Empty when there is nothing to say. */ export function themeDoctor(theme: ThemeSpec): DoctorAdvice[] { const out: DoctorAdvice[] = []; const css = theme.css ?? ''; if (css.trim()) { - for (const rule of CSS_RULES) if (rule.test.test(css)) out.push({ kind: rule.kind, id: rule.id, text: rule.text }); - if (css.length > 20_000) out.push({ kind: 'performance', id: 'css-size', text: 'More than 20,000 characters of CSS: the site recalculates styles with every rule; tokens and component settings compile to fewer rules.' }); + for (const rule of CSS_RULES) { + const seen = new Set(); + for (const match of css.matchAll(rule.test)) { + const selector = selectorAt(css, match.index ?? 0) || 'css'; + const where = rule.id === 'css-universal' || rule.id === 'css-has' ? selector : `${selector} { ${rule.property} }`; + if (seen.has(where)) continue; + seen.add(where); + out.push(advice(rule.id, rule.kind, where)); + if (seen.size >= MAX_PER_RULE) break; + } + } + if (css.length > 20_000) out.push(advice('css-size', 'performance', 'css')); } if (theme.colors) { const fixed = ensureContrast(theme.colors); for (const role of ['text', 'muted', 'accent'] as const) { - if (fixed[role] !== theme.colors[role]) out.push({ kind: 'contrast', id: `contrast-${role}`, text: `The ${role} color was adjusted to stay readable (${contrastRatio(theme.colors[role], theme.colors.bg).toFixed(2)}:1 on the background).` }); + if (fixed[role] !== theme.colors[role]) { + out.push(advice(`contrast-${role}`, 'contrast', `colors.${role}`, { token: role, ratio: contrastRatio(theme.colors[role], theme.colors.bg).toFixed(2) }, 'contrast')); + } } } if (theme.components) { - const posts = theme.components.post; - if (posts?.fill === 'glass') out.push({ kind: 'performance', id: 'glass-post', text: 'Glass on posts is not drawn: blur on every post of a timeline is too costly.' }); - const text = theme.components.postText?.fontSize; - if (text !== undefined && text < 14) out.push({ kind: 'accessibility', id: 'small-post-text', text: 'Post text under 14px is hard to read for many people.' }); + if (theme.components.post?.fill === 'glass') out.push(advice('glass-post', 'performance', 'components.post.fill')); + const size = theme.components.postText?.fontSize; + if (size !== undefined && size < 14) out.push(advice('small-post-text', 'accessibility', 'components.postText.fontSize', { size: String(size) })); } if (theme.variants?.nav === 'top' || theme.variants?.nav === 'bottom') { - out.push({ kind: 'accessibility', id: 'nav-moved', text: 'Moving the navigation changes where people look for it; it only applies on wide panes, and the owner can turn layout changes off.' }); + out.push(advice('nav-moved', 'accessibility', 'variants.nav', { position: theme.variants.nav })); } return out; } diff --git a/packages/runtime/tests/stringPacksRich.test.ts b/packages/runtime/tests/stringPacksRich.test.ts new file mode 100644 index 0000000..7297f8a --- /dev/null +++ b/packages/runtime/tests/stringPacksRich.test.ts @@ -0,0 +1,143 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { + compilePack, conditionHolds, coverage, createStringEngine, driftReport, inventoryLookup, packInventory, sliceInventory, validateString, + checkPackShape, isPageInventory, type StringInventory, +} from '../src/stringPacks.ts'; + +const INVENTORY: StringInventory = { + format: 1, site: 'demo', catalog: 'web', base: 'en', + entries: { + t1: { kind: 'text', hash: 'h1' }, + r2: { kind: 'rich', slots: 2, hash: 'h2' }, + r0: { kind: 'rich', slots: 0, hash: 'h3' }, + rx: { kind: 'rich', hash: 'h4' }, + }, +}; +const pack = (strings: Record, extra: object = {}) => + ({ format: 1, site: 'demo', catalog: 'web', language: 'eo', name: 'P', authors: ['a'], strings, ...extra }); + +test('rich values: element slots {e0}..{n-1}, each once, in any order; nothing else', () => { + const shape = inventoryLookup(INVENTORY)('r2')!; + assert.ok('parts' in validateString(shape, 'Legu {e1} antaŭ {e0}.')); + assert.ok('parts' in validateString(shape, 'Legu {e0}.'), 'the last slot may be left out'); + assert.match((validateString(shape, 'Legu {e1}.') as { reason: string }).reason, /\{e0\}.*missing/); + assert.match((validateString(shape, '{e0} {e0} {e1}') as { reason: string }).reason, /once/); + assert.match((validateString(shape, '{e0} {e1} {e2}') as { reason: string }).reason, /not a parameter/); + assert.match((validateString(shape, '{e0} {e1, plural, other {x}}') as { reason: string }).reason, /not a plural/); + assert.match((validateString(shape, '{e0} {e1}') as { reason: string }).reason, /markup/); + assert.match((validateString(inventoryLookup(INVENTORY)('rx')!, 'x') as { reason: string }).reason, /not translatable yet/); + assert.ok('parts' in validateString(inventoryLookup(INVENTORY)('r0')!, 'Nur teksto')); +}); + +test('rich engine: pieces + element order, idempotent, original kept; a non-array original is left alone', () => { + const compiled = compilePack(pack({ r2: 'A {e1} B {e0} C', t1: 'Hejmo' }), INVENTORY); + assert.equal(compiled.report.valid, 2); + const engine = createStringEngine(INVENTORY, [compiled]); + const site = ['Read ', , ' now']; + const out = engine.resolve('r2', site) as { pieces: string[]; order: number[] }; + assert.deepEqual(out, { pieces: ['A ', ' B ', ' C'], order: [1, 0] }); + assert.equal(engine.resolve('r2', out), out, 'feeding the result back changes nothing'); + assert.equal(engine.originals().get('r2'), site); + assert.equal(engine.resolve('r2', 'not an array'), 'not an array'); + assert.deepEqual(engine.stats().mismatched, ['r2']); +}); + +test('page inventory carries rich slots; closed rich stays closed; coverage counts replaceable rich', () => { + const page = packInventory(INVENTORY); + assert.deepEqual(page.rich, { r2: 2, r0: 0 }); + assert.ok(isPageInventory(JSON.parse(JSON.stringify(page)))); + assert.ok(!isPageInventory({ ...page, rich: { r2: -1 } })); + assert.equal(inventoryLookup(page)('r2')!.slots, 2); + assert.equal(inventoryLookup(page)('rx')!.kind, 'rich'); + assert.equal(inventoryLookup(page)('rx')!.slots, undefined); + assert.deepEqual(sliceInventory(page, ['r2']).rich, { r2: 2 }); + const cover = coverage(INVENTORY, compilePack(pack({ r2: '{e0}{e1}' }), INVENTORY)); + assert.deepEqual(cover.all, { translatable: 3, translated: 1, closed: 1 }); + const drift = driftReport(INVENTORY, { r2: { kind: 'rich', slots: 3, hash: 'h2' } }, ['main']); + assert.deepEqual(drift.reshaped, ['r2']); +}); + +test('language condition: a pack with when.languages applies only on matching site languages', () => { + assert.equal(conditionHolds(undefined, undefined), true); + assert.equal(conditionHolds({ languages: ['en'] }, 'en'), true); + assert.equal(conditionHolds({ languages: ['en'] }, 'en-GB'), true); + assert.equal(conditionHolds({ languages: ['en'] }, 'EN-gb'), true); + assert.equal(conditionHolds({ languages: ['en'] }, 'tr'), false); + assert.equal(conditionHolds({ languages: ['en'] }, 'ent'), false); + assert.equal(conditionHolds({ languages: ['en'] }, undefined), false); + const compiled = compilePack(pack({ t1: 'Tweet' }, { when: { languages: ['en'] } }), INVENTORY); + const engine = createStringEngine(INVENTORY, [compiled]); + assert.equal(engine.resolve('t1', 'Post'), 'Post', 'no language yet: conditional pack waits'); + engine.setLanguage('tr'); + assert.equal(engine.resolve('t1', 'Gönderi'), 'Gönderi'); + const english = createStringEngine(INVENTORY, [compiled]); + english.setLanguage('en-GB'); + assert.equal(english.resolve('t1', 'Post'), 'Tweet'); + assert.equal(english.resolve('t1', 'Tweet'), 'Tweet'); +}); + +test('when is checked as part of the envelope', () => { + const errors = (when: unknown) => checkPackShape(pack({ t1: 'x' }, { when })).filter(issue => issue.level === 'error').length; + assert.equal(errors({ languages: ['en', 'en-GB'] }), 0); + assert.equal(errors({ languages: [] }), 1); + assert.equal(errors({ languages: [''] }), 1); + assert.equal(errors({ code: 'x' }), 1); + assert.equal(errors('en'), 1); +}); + +const REWRITE_INVENTORY: StringInventory = { + format: 1, site: 'demo', catalog: 'web', base: 'en', + entries: { + t1: { kind: 'text', hash: 'h' }, + m1: { kind: 'message', params: ['name', 'count'], plural: ['count'], hash: 'h' }, + r1: { kind: 'rich', slots: 2, hash: 'h' }, + f1: { kind: 'format', hash: 'h' }, + }, +}; +const WORDS = { Post: 'Tweet', Posts: 'Tweets', post: 'tweet', posts: 'tweets', Repost: 'Retweet' }; +const wording = (extra: object = {}) => pack({}, { rewrite: { words: WORDS }, when: { languages: ['en'] }, ...extra }); + +test('rewrite: whole words in the own text of the site, carrying none of its sentences', () => { + const compiled = compilePack(wording(), REWRITE_INVENTORY); + assert.equal(compiled.values.size, 0); + const engine = createStringEngine(REWRITE_INVENTORY, [compiled]); + engine.setLanguage('en'); + assert.equal(engine.resolve('t1', 'Post, Repost and Posts of the postal service; compost'), 'Tweet, Retweet and Tweets of the postal service; compost'); + assert.equal(engine.resolve('t1', 'Nothing here'), 'Nothing here'); + const site = (e: { name: string; count: number }) => `${e.name} has ${e.count} posts`; + const message = engine.resolve('m1', site) as (e: unknown) => string; + assert.equal(message({ name: 'Post Malone', count: 3 }), 'Post Malone has 3 tweets', 'a parameter value is never reworded'); + assert.equal(message({ name: 'Ann', count: 1 }), 'Ann has 1 tweets'); + assert.equal(engine.resolve('m1', message), message, 'feeding the result back changes nothing'); + assert.equal(engine.originals().get('m1'), site); + const rich = engine.resolve('r1', ['Your post ', , ' was a Repost']) as unknown[]; + assert.deepEqual(rich, ['Your tweet ', , ' was a Retweet']); + const same = ['No words']; + assert.equal(engine.resolve('r1', same), same, 'an unchanged value is the same object'); + assert.equal(engine.resolve('f1', 'Post'), 'Post', 'formatters are never touched'); + assert.equal(engine.resolve('zzz', 'Post'), 'Post', 'unknown keys are never touched'); +}); + +test('rewrite: language condition, order with replacing packs, and its own validation', () => { + const compiled = compilePack(wording(), REWRITE_INVENTORY); + const turkish = createStringEngine(REWRITE_INVENTORY, [compiled]); + turkish.setLanguage('tr'); + assert.equal(turkish.resolve('t1', 'Post'), 'Post'); + // A later pack's own text wins and is not reworded; an earlier pack's text is. + const later = compilePack(pack({ t1: 'Post office' }, { language: 'en-x-b' }), REWRITE_INVENTORY); + const earlier = compilePack(pack({ t1: 'Post office' }, { language: 'en-x-a' }), REWRITE_INVENTORY); + const a = createStringEngine(REWRITE_INVENTORY, [compiled, later]); + a.setLanguage('en'); + assert.equal(a.resolve('t1', 'Post'), 'Post office'); + const b = createStringEngine(REWRITE_INVENTORY, [earlier, compiled]); + b.setLanguage('en'); + assert.equal(b.resolve('t1', 'Post'), 'Tweet office'); + const bad = (rewrite: unknown) => checkPackShape(wording({ rewrite })).filter(issue => issue.level === 'error').length; + assert.equal(bad({ words: { Post: 'Tweet' } }), 0); + assert.equal(bad({ words: {} }), 1); + assert.equal(bad({ words: { Post: 'Tweet' } }), 1); + assert.equal(bad({ words: { 'two words': 'x' } }), 1); + assert.equal(bad({ words: { Post: 'Tweet' }, code: 1 }), 1); + assert.equal(bad({ words: Object.fromEntries(Array.from({ length: 65 }, (_, i) => [`w${i}`, 'x'])) }), 1); +}); diff --git a/packages/runtime/tests/themeDoctor.test.ts b/packages/runtime/tests/themeDoctor.test.ts index 291c46c..1551d99 100644 --- a/packages/runtime/tests/themeDoctor.test.ts +++ b/packages/runtime/tests/themeDoctor.test.ts @@ -1,6 +1,6 @@ import assert from 'node:assert/strict'; import test from 'node:test'; -import { themeDoctor } from '../src/themeDoctor.ts'; +import { DOCTOR_MESSAGES, themeDoctor } from '../src/themeDoctor.ts'; import { sanitizeSpec } from '../src/themeSpec.ts'; const ids = (raw: unknown) => themeDoctor(sanitizeSpec(raw)).map(advice => advice.id); @@ -42,3 +42,34 @@ test('unreadable colors are named with their contrast', () => { assert.equal(text.kind, 'contrast'); assert.match(text.text, /\d\.\d\d:1/); }); + +test('every finding says where it is (token or selector), what it found and how to fix it', () => { + const css = '.card { border-radius: 4px; }\n.row { border-radius: 2px; }\n.row { border-radius: 3px; }\n@media (min-width: 1px) { .nav a { display: none; } }\n* { margin: 0 }'; + const theme = sanitizeSpec({ name: 'Where', css, colors: { bg: '#000000', text: '#111111', accent: '#1d9bf0' }, components: { postText: { fontSize: 13 } }, variants: { nav: 'top' } }); + const found = themeDoctor(theme); + const radius = found.filter(item => item.id === 'css-radius').map(item => item.where); + assert.deepEqual(radius, ['.card { border-radius }', '.row { border-radius }'], 'one finding per rule, not per property'); + assert.ok(found.some(item => item.id === 'css-hide' && item.where === '.nav a { display }'), 'a rule inside @media names its own selector'); + assert.ok(found.some(item => item.id === 'css-universal')); + const token = found.find(item => item.id === 'contrast-text')!; + assert.equal(token.where, 'colors.text'); + assert.equal(token.key, 'contrast'); + assert.deepEqual(Object.keys(token.params), ['token', 'ratio']); + assert.match(token.text, /^The text color was adjusted/); + assert.ok(found.some(item => item.where === 'components.postText.fontSize' && item.params.size === '13')); + assert.ok(found.some(item => item.where === 'variants.nav' && item.params.position === 'top')); + for (const item of found) { + assert.ok(item.fix.length > 10, `${item.id} has a fix hint`); + assert.ok(`wb.doctor.${item.key}.found` in DOCTOR_MESSAGES && `wb.doctor.${item.key}.fix` in DOCTOR_MESSAGES, `${item.key} has catalog words`); + assert.ok(!/\{\w+\}/.test(item.text + item.fix), `${item.id}: every slot is filled`); + } +}); + +test('the doctor\'s words are plain text with only the slots its findings fill', () => { + for (const [key, text] of Object.entries(DOCTOR_MESSAGES)) { + assert.ok(!/[<>]/.test(text), `${key} has no markup`); + for (const slot of text.matchAll(/\{(\w+)\}/g)) assert.ok(['token', 'ratio', 'size', 'position'].includes(slot[1]!), `${key}: {${slot[1]}}`); + } + const ids = new Set(Object.keys(DOCTOR_MESSAGES).map(key => key.replace(/\.(found|fix)$/, ''))); + for (const id of ids) assert.ok(`${id}.found` in DOCTOR_MESSAGES && `${id}.fix` in DOCTOR_MESSAGES, id); +}); diff --git a/packages/shell/src/panel/Appearance.tsx b/packages/shell/src/panel/Appearance.tsx index a91800c..72f8b3e 100644 --- a/packages/shell/src/panel/Appearance.tsx +++ b/packages/shell/src/panel/Appearance.tsx @@ -16,10 +16,10 @@ import { ThemeDots } from '../frame/PaneTheme.tsx'; import { shell, type WebParams } from '../frame/state.ts'; import { assign } from '../frame/themeScopes.ts'; import { tabProfile } from '../profileModel.ts'; -import { Button, ColorField, Row, Section, Segmented, Select, Slider, Toggle, useSettingsQuery, type Option } from './controls.tsx'; +import { Badge, Button, ColorField, Row, Section, Segmented, Select, Slider, Toggle, useSettingsQuery, type Option } from './controls.tsx'; import { IconPackImport, IconPackReview } from './IconPackInstall.tsx'; import type { IconPack } from '../../../runtime/src/themeIcons.ts'; -import { themeDoctor } from '../../../runtime/src/themeDoctor.ts'; +import { themeDoctor, type DoctorAdvice } from '../../../runtime/src/themeDoctor.ts'; import { bytesLabel, defaultWeights, loadCatalog, weightsLabel } from './fonts/catalog.ts'; import { FontRoles } from './fonts/FontRoles.tsx'; import { CustomCssEditor } from './Plugins.tsx'; @@ -283,6 +283,8 @@ export function Appearance({ notify }: { notify: Notify }) { { void override({ css: { text } }); notify(t('wb.appearance.cssApplied', { name: base.name })); }}/> + +
@@ -299,6 +301,24 @@ export function Appearance({ notify }: { notify: Notify }) { } /** Theme choices for a scope row: follow (the level above) plus every theme with its swatch. */ +/** The theme doctor's full report on the theme as it is now: every finding, where it is, what it found, how to fix it. Advice only. */ +function DoctorReport({ theme }: { theme: ThemeSpec }) { + const t = useT(); + const advice = themeDoctor(theme); + const words = (item: DoctorAdvice, part: 'found' | 'fix') => t(`wb.doctor.${item.key}.${part}`, item.params); + return
{t('wb.doctor.count', { count: advice.length })}}> + {advice.length === 0 + ?

{t('wb.doctor.empty')}

+ :
    + {advice.map((item, index) =>
  • + {t(`wb.doctor.kind.${item.kind}`)}{words(item, 'found')} + {t('wb.doctor.where')}: {item.where} + {t('wb.doctor.fix')}: {words(item, 'fix')} +
  • )} +
} +
; +} + function scopeOptions(follow: string): Array> { // Called during render of components that use useT(), so the labels follow the language. return [{ value: '', label: follow }, ...panelThemes().store.allThemes().map(theme => ({ value: theme.id, label: theme.name, icon: }))]; @@ -408,7 +428,7 @@ function ImportPanel({ onImport, onCancel }: { onImport(theme: ThemeSpec, warnin if ('error' in parsed) { setError(parsed.error); return; } // The theme doctor: advice only (never a block); contrast is already in the warnings. const hints = themeDoctor(parsed.theme).filter(advice => advice.kind !== 'contrast'); - onImport(parsed.theme, hints.length ? [...parsed.warnings, t('wb.appearance.doctorHints', { count: hints.length, hint: hints[0]!.text })] : parsed.warnings); + onImport(parsed.theme, hints.length ? [...parsed.warnings, t('wb.appearance.doctorHints', { count: hints.length, hint: t(`wb.doctor.${hints[0]!.key}.found`, hints[0]!.params) })] : parsed.warnings); }; return
event.preventDefault()} diff --git a/packages/shell/src/panel/StringPacks.tsx b/packages/shell/src/panel/StringPacks.tsx index 6dda141..2ea6ec2 100644 --- a/packages/shell/src/panel/StringPacks.tsx +++ b/packages/shell/src/panel/StringPacks.tsx @@ -3,7 +3,7 @@ // site tabs the new delivery (`strings_apply`: the packs that are on, in order, with the inventory // slice their keys need); the tabs reload to show it. Packs are data only: nothing here runs code. import { useEffect, useState } from 'react'; -import type { PageInventory } from '../../../runtime/src/stringPacks.ts'; +import { hashText, type PageInventory } from '../../../runtime/src/stringPacks.ts'; import { invoke } from '../frame/bridge.ts'; import { useT } from '../frame/hooks.ts'; import { t as translate } from '../frame/i18n.ts'; @@ -20,16 +20,41 @@ const ICON = 'M2.5 3.5h7M6 2v1.5M8 3.5c-.6 2.9-2.6 5-5.4 6.1M4.6 6.2c.8 1.2 2 2. type Row = InstalledStrings & { summary: StringsSummary | null }; -/** Hands the site tabs the packs that are on (in `packs` order). */ -export async function applyStringPacks(inventory: PageInventory, packs?: InstalledStrings[]): Promise { +/** + * Packs the app itself provides (pack documents as text), applied before the installed ones, so an + * installed pack wins where both change a word. They follow the app's own settings (the Twitter + * wording is a pack that is only here while its setting is on); they are not listed or removable. + */ +export type BuiltInPacks = () => string[] | Promise; + +const DELIVERED_KEY = 'wayBetter.stringsDelivered'; +/** What the tabs were last handed ("none" for no delivery), so a start-up check can skip a reload. */ +const delivered = () => { try { return localStorage.getItem(DELIVERED_KEY) ?? 'none'; } catch { return 'none'; } }; + +async function deliveryOf(inventory: PageInventory, packs: InstalledStrings[] | undefined, builtIn: BuiltInPacks | undefined): Promise { const list = packs ?? (await invoke<{ packs: InstalledStrings[] }>('strings_list')).packs; - const texts: string[] = []; + const texts: string[] = [...(await builtIn?.() ?? [])]; for (const pack of list) if (pack.enabled) texts.push(await invoke('strings_read', { id: pack.id })); - await invoke('strings_apply', { delivery: buildDelivery(texts, inventory, { translate: translating() }) }); + return buildDelivery(texts, inventory, { translate: translating() }); } -export function createStringPacksSection(options: { inventory: PageInventory; id?: string; icon?: string }): PanelSection { - const { inventory } = options; +/** Hands the site tabs the packs that are on (built-in ones first, then `packs` in order). */ +export async function applyStringPacks(inventory: PageInventory, packs?: InstalledStrings[], builtIn?: BuiltInPacks): Promise { + const delivery = await deliveryOf(inventory, packs, builtIn); + await invoke('strings_apply', { delivery }); + try { localStorage.setItem(DELIVERED_KEY, delivery === null ? 'none' : hashText(delivery)); } catch { /* the next start-up check applies again */ } +} + +/** At start: hands the tabs the delivery only when it differs from the one they were last given (a tab reloads for each). */ +export async function syncStringPacks(inventory: PageInventory, builtIn?: BuiltInPacks): Promise { + const delivery = await deliveryOf(inventory, undefined, builtIn); + if ((delivery === null ? 'none' : hashText(delivery)) === delivered()) return false; + await applyStringPacks(inventory, undefined, builtIn); + return true; +} + +export function createStringPacksSection(options: { inventory: PageInventory; builtIn?: BuiltInPacks; id?: string; icon?: string }): PanelSection { + const { inventory, builtIn } = options; function StringPacks({ notify, openSection }: SectionProps) { const t = useT(); @@ -60,7 +85,7 @@ export function createStringPacksSection(options: { inventory: PageInventory; id setBusy(true); try { const { packs } = await invoke<{ packs: InstalledStrings[] }>('strings_set', { order: next.map(row => row.id), enabled: next.filter(row => row.enabled).map(row => row.id) }); - await applyStringPacks(inventory, packs); + await applyStringPacks(inventory, packs, builtIn); setRows(packs.map(pack => ({ ...pack, summary: next.find(row => row.id === pack.id)?.summary ?? null }))); notify(t('wb.strings.applied', { site: name })); } catch (error) { @@ -100,7 +125,7 @@ export function createStringPacksSection(options: { inventory: PageInventory; id @@ -112,7 +137,7 @@ export function createStringPacksSection(options: { inventory: PageInventory; id try { localStorage.setItem(TRANSLATE_KEY, checked ? '1' : '0'); } catch { /* it still applies once */ } setTranslate(checked); setBusy(true); - void applyStringPacks(inventory).then(() => notify(t('wb.strings.applied', { site: name }))).catch(error => notify(String(error), true)).finally(() => setBusy(false)); + void applyStringPacks(inventory, undefined, builtIn).then(() => notify(t('wb.strings.applied', { site: name }))).catch(error => notify(String(error), true)).finally(() => setBusy(false)); }}/>
{t('wb.strings.translate')}{t('wb.strings.translateHint', { site: name })}
diff --git a/packages/shell/src/panel/builder.css b/packages/shell/src/panel/builder.css index c91625b..904e56a 100644 --- a/packages/shell/src/panel/builder.css +++ b/packages/shell/src/panel/builder.css @@ -230,3 +230,11 @@ .wb-fontlist b { font-size: 17px; font-weight: 450; } .wb-fontlist small { color: var(--c-muted); font: 11px/1.4 var(--f-mono); } .wb-fontlist ul { margin: 0; padding: 0; list-style: none; } + +/* The theme doctor's full report (advice only). */ +.bt-doctor { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; } +.bt-doctor-item { display: grid; gap: 3px; padding: 9px 2px; } +.bt-doctor-item + .bt-doctor-item { border-block-start: 1px solid var(--c-line-soft); } +.bt-doctor-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; } +.bt-doctor-line { color: var(--c-muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; } +.bt-doctor-line code { font: 11.5px/1.4 var(--f-mono); color: var(--c-text); } diff --git a/packages/shell/src/panel/panelMessages.ts b/packages/shell/src/panel/panelMessages.ts index 014511b..aa47a97 100644 --- a/packages/shell/src/panel/panelMessages.ts +++ b/packages/shell/src/panel/panelMessages.ts @@ -3,6 +3,8 @@ // are counts, names and paths. The panel reads the translations through the app's i18n instance // (setShellI18n); tests/panel.test.ts checks that every key the panel uses is here. +import { DOCTOR_MESSAGES } from '../../../runtime/src/themeDoctor.ts'; + export const PANEL_MESSAGES = { 'wb.appearance.accent': 'Accent', 'wb.appearance.accentColor': 'Accent color', @@ -764,6 +766,17 @@ export const PANEL_MESSAGES = { 'wb.ui.select.placeholder': 'Choose…', 'wb.ui.stepper.decrease': 'Decrease {label}', 'wb.ui.stepper.increase': 'Increase {label}', + 'wb.doctor.title': 'Theme doctor', + 'wb.doctor.hint': 'Advice about this theme: lighter ways to do the same, costs and contrast. It only advises; nothing is blocked or changed.', + 'wb.doctor.empty': 'Nothing to report: the theme uses tokens and component settings, and nothing in it is costly.', + 'wb.doctor.count': '{count, plural, one {# finding} other {# findings}}', + 'wb.doctor.kind.lighter': 'A lighter way', + 'wb.doctor.kind.performance': 'Performance', + 'wb.doctor.kind.accessibility': 'Accessibility', + 'wb.doctor.kind.contrast': 'Contrast', + 'wb.doctor.where': 'Where', + 'wb.doctor.fix': 'Fix', + ...DOCTOR_MESSAGES, } as const; export type PanelKey = keyof typeof PANEL_MESSAGES; diff --git a/packages/shell/src/stringPacksModel.ts b/packages/shell/src/stringPacksModel.ts index aa0c001..17b0670 100644 --- a/packages/shell/src/stringPacksModel.ts +++ b/packages/shell/src/stringPacksModel.ts @@ -46,6 +46,7 @@ export function packSummary(text: string, inventory: PageInventory): StringsSumm // The page inventory lists every key once, in its groups: count what a pack can replace. for (const ids of [inventory.text, inventory.closed]) if (ids) for (const id of ids.split(' ')) { if (lookup(id) && translatable(lookup(id)!.kind)) translatableCount += 1; else closed += 1; } translatableCount += Object.keys(inventory.message).length; + translatableCount += Object.keys(inventory.rich ?? {}).length; if (record.catalog !== inventory.catalog) { return { language, translated: 0, translatable: translatableCount, closed, unknown: Object.keys(record.strings).length, refused: 0, sample: [], otherCatalog: true }; } @@ -73,12 +74,15 @@ export const coveragePercent = (summary: Pick(); + // A pack that rewords the site's own text needs the shape of every key, not a slice. + let rewording = false; for (const text of texts) { let pack: unknown; try { pack = JSON.parse(text); } catch { continue; } let compiled; try { compiled = compilePack(pack, inventory); } catch { continue; } - if (!compiled.values.size) continue; + if (!compiled.values.size && !compiled.rewrite) continue; + if (compiled.rewrite) rewording = true; packs.push(pack); for (const id of compiled.values.keys()) ids.add(id); if (packs.length >= 8) break; @@ -86,5 +90,5 @@ export function buildDelivery(texts: readonly string[], inventory: PageInventory // Translate mode: the whole inventory (the author may change any string), packs or not. if (options.translate) return JSON.stringify({ inventory, packs, translate: true }); if (!packs.length) return null; - return JSON.stringify({ inventory: sliceInventory(inventory, ids), packs }); + return JSON.stringify({ inventory: rewording ? inventory : sliceInventory(inventory, ids), packs }); } diff --git a/packages/shell/tests/stringPacksModel.test.ts b/packages/shell/tests/stringPacksModel.test.ts index f39e25b..9bb45c7 100644 --- a/packages/shell/tests/stringPacksModel.test.ts +++ b/packages/shell/tests/stringPacksModel.test.ts @@ -39,3 +39,17 @@ test('store model: string packs by file name and by install record', () => { assert.deepEqual(itemState(item, { ...context, records: { 'strings:esperanto': record } as never }), { state: 'update', version: '1.0.0' }); assert.deepEqual(itemState(item, { ...context, records: { 'strings:esperanto': { ...record, sha256: 'b'.repeat(64) } } as never }), { state: 'installed', version: '1.0.0' }); }); + +test('delivery: a rewording pack counts as usable and brings the whole inventory; rich keys with slots are translatable', () => { + const rich: PageInventory = { ...INVENTORY, rich: { d0000001: 2 } }; + const wording = pack({}, { name: 'Wording', language: 'en-x-twitter', when: { languages: ['en'] }, rewrite: { words: { Post: 'Tweet' } } }); + const delivery = JSON.parse(buildDelivery([wording, pack({ a0000001: 'Hejmo' })], rich)!); + assert.deepEqual(delivery.inventory, rich, 'the whole inventory, not a slice'); + assert.deepEqual(delivery.packs.map((p: { name: string }) => p.name), ['Wording', 'Esperanto']); + assert.equal(buildDelivery([wording], rich) !== null, true); + assert.equal(buildDelivery([pack({})], rich), null, 'a pack with neither strings nor a rule changes nothing'); + const summary = packSummary(pack({ d0000001: 'Legu {e1} antaŭ {e0}.', a0000001: 'Hejmo' }), rich)!; + assert.equal(summary.translatable, 5, 'the rich key with slots is counted as translatable'); + assert.equal(summary.translated, 2); + assert.equal(summary.refused, 0); +}); diff --git a/packages/waybetter/cli/strings.mjs b/packages/waybetter/cli/strings.mjs index 9b6ce38..2678540 100644 --- a/packages/waybetter/cli/strings.mjs +++ b/packages/waybetter/cli/strings.mjs @@ -77,6 +77,8 @@ export async function checkPack(packFile, inventories, { verbose = false } = {}) const coverage = rules.coverage(match.inventory, compiled); lines.push(`${pack.name} (${pack.language}) for ${pack.site}/${pack.catalog}, inventory build ${match.inventory.build ?? 'unknown'}`); lines.push(`${report.total} strings: ${report.valid} valid, ${report.rejected.length} refused, ${report.unknown.length} unknown`); + if (pack.when?.languages) lines.push(`Applies only while the site shows: ${pack.when.languages.join(', ')}`); + if (pack.rewrite) lines.push(`Rewords ${Object.keys(pack.rewrite.words).length} words inside the site's own text: ${Object.keys(pack.rewrite.words).slice(0, 6).join(', ')}${Object.keys(pack.rewrite.words).length > 6 ? ', …' : ''}`); const list = (items, render) => { for (const item of verbose ? items : items.slice(0, LISTED)) lines.push(` ${render(item)}`); if (!verbose && items.length > LISTED) lines.push(` … ${items.length - LISTED} more (--verbose lists all)`); diff --git a/packages/waybetter/locales/ar.json b/packages/waybetter/locales/ar.json index dbec730..8e5372b 100644 --- a/packages/waybetter/locales/ar.json +++ b/packages/waybetter/locales/ar.json @@ -1244,6 +1244,46 @@ "wb.appearance.icons.remove": "إزالة {name}", "wb.appearance.icons.removed": "أُزيلت حزمة الأيقونات «{name}».", "wb.appearance.icons.imported": "حزم الأيقونات المستوردة", + "wb.doctor.title": "طبيب السمة", + "wb.doctor.hint": "نصائح حول هذه السمة: طرق أخف لفعل الشيء نفسه، والتكاليف، والتباين. هو يقدّم النصح فقط؛ لا يُحظر شيء ولا يتغيّر شيء.", + "wb.doctor.empty": "لا شيء للإبلاغ عنه: السمة تستخدم الرموز وإعدادات المكوّنات، ولا شيء فيها مكلف.", + "wb.doctor.count": "{count, plural, zero {لا نتائج} one {نتيجة واحدة} two {نتيجتان} few {# نتائج} many {# نتيجة} other {# نتيجة}}", + "wb.doctor.kind.lighter": "طريقة أخف", + "wb.doctor.kind.performance": "الأداء", + "wb.doctor.kind.accessibility": "إمكانية الوصول", + "wb.doctor.kind.contrast": "التباين", + "wb.doctor.where": "أين", + "wb.doctor.fix": "الإصلاح", + "wb.doctor.css-radius.found": "تضبط هذه القاعدة أنصاف أقطار الزوايا في CSS.", + "wb.doctor.css-radius.fix": "اضبطها عبر radius لجزء ضمن components، أو shape.radius لها جميعًا: لا حاجة إلى CSS، ويستمر العمل حتى لو غيّر الموقع أسماء فئاته.", + "wb.doctor.css-bevel.found": "ترسم هذه القاعدة حافة مشطوفة بظلال داخلية متراكبة.", + "wb.doctor.css-bevel.fix": "استخدم borderStyle \"bevel-out\" أو \"bevel-in\" على جزء ضمن components: فهو يرسم الحافة المشطوفة من ألوان السمة.", + "wb.doctor.css-hide.found": "تخفي هذه القاعدة شيئًا باستخدام display: none.", + "wb.doctor.css-hide.fix": "استخدم visible على جزء ضمن components (الصور الرمزية، العدّادات، الأسماء) أو نمط تخطيط مثل sidebar: hidden؛ وبذلك يمكن للمالك إعادته.", + "wb.doctor.css-color.found": "تستخدم هذه القاعدة لونًا حرفيًا.", + "wb.doctor.css-color.fix": "سمِّ دورًا (text وmuted وaccent وsurface…) في colors أو في مكوّن، ليشمله فحص التباين.", + "wb.doctor.css-font.found": "تضبط هذه القاعدة عائلة خطوط.", + "wb.doctor.css-font.fix": "استخدم font.roles: فهو يضبط خطوط المنشورات والعناوين والأرقام والخط أحادي المسافة دون CSS.", + "wb.doctor.css-has.found": "تستخدم هذه القاعدة :has()، ويُعاد مطابقتها عند كل تغيير في الصفحة.", + "wb.doctor.css-has.fix": "تجنّب :has() في القواعد المتكررة على امتداد الخلاصة، أو اربط القاعدة بجزء.", + "wb.doctor.css-universal.found": "تستخدم هذه القاعدة محدِّدًا شاملًا (*) تتم مطابقته مع كل عنصر.", + "wb.doctor.css-universal.fix": "اربط القاعدة بجزء بدلًا من ذلك.", + "wb.doctor.css-blur.found": "تطمس هذه القاعدة ما خلفها (backdrop-filter)، وهو مكلف في الأجزاء المتكررة.", + "wb.doctor.css-blur.fix": "استخدم تعبئة الزجاج في الأشرطة واللوحات: فهي المكان الأرخص للطمس.", + "wb.doctor.css-outline-none.found": "تزيل هذه القاعدة مخطط التركيز، فلا يعود تركيز لوحة المفاتيح مرئيًا.", + "wb.doctor.css-outline-none.fix": "استخدم decor.focusRing لرسم حلقة تركيز مرئية بدلًا من ذلك.", + "wb.doctor.css-motion.found": "تحرّك هذه القاعدة العناصر دون التحقق من تفضيل تقليل الحركة.", + "wb.doctor.css-motion.fix": "أبقِ الحركة داخل @media (prefers-reduced-motion: no-preference)، أو دع decor.motion يتولى ذلك عنك.", + "wb.doctor.css-size.found": "يزيد طول CSS على 20,000 حرف.", + "wb.doctor.css-size.fix": "يعيد الموقع حساب الأنماط مع كل قاعدة؛ والرموز وإعدادات المكوّنات تُترجم إلى قواعد أقل.", + "wb.doctor.contrast.found": "تم تعديل لون {token} ليبقى مقروءًا ({ratio}:1 على الخلفية).", + "wb.doctor.contrast.fix": "اختر لون {token} أفتح أو أغمق؛ وإلى ذلك الحين تُعرض السمة باللون المعدَّل.", + "wb.doctor.glass-post.found": "تم ضبط الزجاج على المنشورات، لكنه لا يُرسم: الطمس على كل منشور في الخلاصة مكلف جدًا.", + "wb.doctor.glass-post.fix": "استخدم تعبئة صلبة أو ملوّنة للمنشورات، واحتفظ بالزجاج للأشرطة واللوحات.", + "wb.doctor.small-post-text.found": "حجم نص المنشور {size}px، وهو صعب القراءة على كثيرين.", + "wb.doctor.small-post-text.fix": "استخدم 14px أو أكثر لحجم نص المنشور، أو كبّر حجم النص في السمة كلها.", + "wb.doctor.nav-moved.found": "نُقل التنقل إلى {position}، مما يغيّر المكان الذي يبحث عنه الناس.", + "wb.doctor.nav-moved.fix": "ينطبق ذلك فقط على الأجزاء العريضة، ويمكن للمالك إيقاف تغييرات التخطيط. أبقِ الموضع الافتراضي ما لم يتطلب التخطيط غير ذلك.", "wb.setup.title": "مشاركة إعدادي", "wb.setup.hint": "سمتك وأيقوناتك ووضعك والميزات المفعّلة، في رابط واحد أو ملف صغير. يمكن لأي شخص استخدامه ليبدأ مما لديك.", "wb.setup.shareLabel": "إعدادك", diff --git a/packages/waybetter/locales/de.json b/packages/waybetter/locales/de.json index 9febcc1..cea4bfe 100644 --- a/packages/waybetter/locales/de.json +++ b/packages/waybetter/locales/de.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "{name} entfernen", "wb.appearance.icons.removed": "Das Symbolpaket „{name}“ ist entfernt.", "wb.appearance.icons.imported": "Importierte Symbolpakete", + "wb.doctor.title": "Theme-Doktor", + "wb.doctor.hint": "Hinweise zu diesem Theme: leichtere Wege zum selben Ergebnis, Kosten und Kontrast. Er rät nur; nichts wird blockiert oder geändert.", + "wb.doctor.empty": "Nichts zu melden: Das Theme nutzt Tokens und Komponenteneinstellungen, und nichts darin ist aufwendig.", + "wb.doctor.count": "{count, plural, one {# Befund} other {# Befunde}}", + "wb.doctor.kind.lighter": "Ein leichterer Weg", + "wb.doctor.kind.performance": "Leistung", + "wb.doctor.kind.accessibility": "Barrierefreiheit", + "wb.doctor.kind.contrast": "Kontrast", + "wb.doctor.where": "Wo", + "wb.doctor.fix": "Lösung", + "wb.doctor.css-radius.found": "Diese Regel legt Eckenradien in CSS fest.", + "wb.doctor.css-radius.fix": "Lege sie mit dem radius eines Teils unter components fest oder mit shape.radius für alle: Kein CSS nötig, und es funktioniert weiter, wenn die Seite ihre Klassen umbenennt.", + "wb.doctor.css-bevel.found": "Diese Regel zeichnet eine abgeschrägte Kante mit gestapelten inneren Schatten.", + "wb.doctor.css-bevel.fix": "Verwende borderStyle \"bevel-out\" oder \"bevel-in\" bei einem Teil unter components: Die Schräge wird aus den Farben des Themes gezeichnet.", + "wb.doctor.css-hide.found": "Diese Regel blendet etwas mit display: none aus.", + "wb.doctor.css-hide.fix": "Verwende visible bei einem Teil unter components (Avatare, Zähler, Namen) oder eine Layout-Variante wie sidebar: hidden; so kann der Besitzer es wieder einblenden.", + "wb.doctor.css-color.found": "Diese Regel verwendet eine feste Farbe.", + "wb.doctor.css-color.fix": "Nenne in colors oder in einer Komponente eine Rolle (text, muted, accent, surface …), damit die Kontrastprüfung sie erfasst.", + "wb.doctor.css-font.found": "Diese Regel legt eine Schriftfamilie fest.", + "wb.doctor.css-font.fix": "Verwende font.roles: Damit legst du die Schriften für Posts, Überschriften, Zahlen und Monospace ohne CSS fest.", + "wb.doctor.css-has.found": "Diese Regel verwendet :has(), das bei jeder Änderung der Seite erneut geprüft wird.", + "wb.doctor.css-has.fix": "Verwende :has() nicht in Regeln, die sich in einer Timeline wiederholen, oder verankere die Regel an einem Teil.", + "wb.doctor.css-universal.found": "Diese Regel verwendet einen Universalselektor (*), der mit jedem Element abgeglichen wird.", + "wb.doctor.css-universal.fix": "Verankere die Regel stattdessen an einem Teil.", + "wb.doctor.css-blur.found": "Diese Regel weichzeichnet, was dahinter liegt (backdrop-filter), was bei sich wiederholenden Teilen aufwendig ist.", + "wb.doctor.css-blur.fix": "Nutze die Glasfüllung von Leisten und Panels: Dort ist Weichzeichnen günstiger.", + "wb.doctor.css-outline-none.found": "Diese Regel entfernt den Fokusrahmen, sodass der Tastaturfokus nicht mehr sichtbar ist.", + "wb.doctor.css-outline-none.fix": "Verwende stattdessen decor.focusRing, um einen sichtbaren Fokusring zu zeichnen.", + "wb.doctor.css-motion.found": "Diese Regel animiert, ohne auf reduzierte Bewegung zu achten.", + "wb.doctor.css-motion.fix": "Halte Bewegung innerhalb von @media (prefers-reduced-motion: no-preference) oder lass decor.motion das für dich erledigen.", + "wb.doctor.css-size.found": "Das CSS ist länger als 20.000 Zeichen.", + "wb.doctor.css-size.fix": "Die Seite berechnet Stile für jede Regel neu; Tokens und Komponenteneinstellungen werden zu weniger Regeln kompiliert.", + "wb.doctor.contrast.found": "Die Farbe {token} wurde angepasst, damit sie lesbar bleibt ({ratio}:1 auf dem Hintergrund).", + "wb.doctor.contrast.fix": "Wähle eine hellere oder dunklere Farbe für {token}; bis dahin wird das Theme mit der angepassten angezeigt.", + "wb.doctor.glass-post.found": "Glas ist bei Posts gesetzt, wird aber nicht gezeichnet: Weichzeichnen bei jedem Post einer Timeline ist zu aufwendig.", + "wb.doctor.glass-post.fix": "Verwende für Posts eine einfarbige oder getönte Füllung und spare Glas für Leisten und Panels auf.", + "wb.doctor.small-post-text.found": "Der Posttext ist {size}px groß, was für viele schwer lesbar ist.", + "wb.doctor.small-post-text.fix": "Verwende für die Posttextgröße 14px oder mehr oder erhöhe die Textgröße des gesamten Themes.", + "wb.doctor.nav-moved.found": "Die Navigation wurde nach {position} verschoben, was ändert, wo man sie sucht.", + "wb.doctor.nav-moved.fix": "Das gilt nur bei breiten Bereichen, und der Besitzer kann Layoutänderungen abschalten. Behalte die Standardposition bei, außer das Layout braucht es anders.", "wb.setup.title": "Mein Setup teilen", "wb.setup.hint": "Dein Theme, deine Symbole, dein Modus und welche Funktionen an sind, als ein Link oder eine kleine Datei. Jeder kann damit dort anfangen, wo du bist.", "wb.setup.shareLabel": "Dein Setup", diff --git a/packages/waybetter/locales/en.json b/packages/waybetter/locales/en.json index 0b0f1c2..0b8a973 100644 --- a/packages/waybetter/locales/en.json +++ b/packages/waybetter/locales/en.json @@ -419,6 +419,46 @@ "wb.appearance.icons.removed": "Removed the icon pack “{name}”.", "wb.appearance.icons.imported": "Imported icon packs", "wb.appearance.doctorHints": "{count, plural, one {The theme doctor has a hint:} other {The theme doctor has # hints, the first:}} {hint}", + "wb.doctor.title": "Theme doctor", + "wb.doctor.hint": "Advice about this theme: lighter ways to do the same, costs and contrast. It only advises; nothing is blocked or changed.", + "wb.doctor.empty": "Nothing to report: the theme uses tokens and component settings, and nothing in it is costly.", + "wb.doctor.count": "{count, plural, one {# finding} other {# findings}}", + "wb.doctor.kind.lighter": "A lighter way", + "wb.doctor.kind.performance": "Performance", + "wb.doctor.kind.accessibility": "Accessibility", + "wb.doctor.kind.contrast": "Contrast", + "wb.doctor.where": "Where", + "wb.doctor.fix": "Fix", + "wb.doctor.css-radius.found": "This rule sets corner radii in CSS.", + "wb.doctor.css-radius.fix": "Set them with the radius of a part under components, or shape.radius for all of them: no CSS needed, and it keeps working when the site renames its classes.", + "wb.doctor.css-bevel.found": "This rule draws a bevelled edge with stacked inset shadows.", + "wb.doctor.css-bevel.fix": "Use borderStyle \"bevel-out\" or \"bevel-in\" on a part under components: it draws the bevel from the theme’s colors.", + "wb.doctor.css-hide.found": "This rule hides something with display: none.", + "wb.doctor.css-hide.fix": "Use visible on a part under components (avatars, counts, names) or a layout variant such as sidebar: hidden; the owner can then switch it back.", + "wb.doctor.css-color.found": "This rule uses a literal color.", + "wb.doctor.css-color.fix": "Name a role (text, muted, accent, surface…) in colors or in a component, so the contrast pass covers it.", + "wb.doctor.css-font.found": "This rule sets a font family.", + "wb.doctor.css-font.fix": "Use font.roles: it sets the post, heading, numbers and mono faces without CSS.", + "wb.doctor.css-has.found": "This rule uses :has(), which is matched again on every change of the page.", + "wb.doctor.css-has.fix": "Keep :has() off rules that repeat down a timeline, or anchor the rule on a part.", + "wb.doctor.css-universal.found": "This rule uses a universal selector (*), matched against every element.", + "wb.doctor.css-universal.fix": "Anchor the rule on a part instead.", + "wb.doctor.css-blur.found": "This rule blurs what is behind it (backdrop-filter), which is costly on parts that repeat.", + "wb.doctor.css-blur.fix": "Use the glass fill of bars and panels: it is the cheaper place for blur.", + "wb.doctor.css-outline-none.found": "This rule removes the focus outline, so keyboard focus is no longer visible.", + "wb.doctor.css-outline-none.fix": "Use decor.focusRing to draw a visible focus ring instead.", + "wb.doctor.css-motion.found": "This rule animates without checking for reduced motion.", + "wb.doctor.css-motion.fix": "Keep motion inside @media (prefers-reduced-motion: no-preference), or let decor.motion do it for you.", + "wb.doctor.css-size.found": "The CSS is more than 20,000 characters long.", + "wb.doctor.css-size.fix": "The site recalculates styles with every rule; tokens and component settings compile to fewer rules.", + "wb.doctor.contrast.found": "The {token} color was adjusted to stay readable ({ratio}:1 on the background).", + "wb.doctor.contrast.fix": "Pick a lighter or darker {token} color; until then the theme is shown with the adjusted one.", + "wb.doctor.glass-post.found": "Glass is set on posts, but it is not drawn: blur on every post of a timeline is too costly.", + "wb.doctor.glass-post.fix": "Use a solid or tinted fill for posts and keep glass for bars and panels.", + "wb.doctor.small-post-text.found": "Post text is {size}px, which is hard to read for many people.", + "wb.doctor.small-post-text.fix": "Use 14px or more for the post text size, or raise the text size of the whole theme.", + "wb.doctor.nav-moved.found": "The navigation is moved to the {position}, which changes where people look for it.", + "wb.doctor.nav-moved.fix": "It only applies on wide panes, and the owner can turn layout changes off. Keep the default position unless the layout needs it.", "wb.appearance.icons.site": "The site's own icons", "wb.appearance.accountTheme": "Account theme · {name}", "wb.appearance.accountsHint": "Every pane of an account shows its theme unless the pane has its own.", diff --git a/packages/waybetter/locales/es.json b/packages/waybetter/locales/es.json index 8dcb1f8..33fe859 100644 --- a/packages/waybetter/locales/es.json +++ b/packages/waybetter/locales/es.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "Quitar {name}", "wb.appearance.icons.removed": "Paquete de iconos «{name}» quitado.", "wb.appearance.icons.imported": "Paquetes de iconos importados", + "wb.doctor.title": "Doctor del tema", + "wb.doctor.hint": "Consejos sobre este tema: formas más ligeras de hacer lo mismo, costes y contraste. Solo aconseja; no bloquea ni cambia nada.", + "wb.doctor.empty": "Nada que informar: el tema usa tokens y ajustes de componentes, y nada en él es costoso.", + "wb.doctor.count": "{count, plural, one {# hallazgo} other {# hallazgos}}", + "wb.doctor.kind.lighter": "Una forma más ligera", + "wb.doctor.kind.performance": "Rendimiento", + "wb.doctor.kind.accessibility": "Accesibilidad", + "wb.doctor.kind.contrast": "Contraste", + "wb.doctor.where": "Dónde", + "wb.doctor.fix": "Solución", + "wb.doctor.css-radius.found": "Esta regla define radios de esquina en CSS.", + "wb.doctor.css-radius.fix": "Defínelos con el radius de una parte en components, o con shape.radius para todas: no hace falta CSS y sigue funcionando cuando el sitio cambia los nombres de sus clases.", + "wb.doctor.css-bevel.found": "Esta regla dibuja un borde biselado con sombras interiores apiladas.", + "wb.doctor.css-bevel.fix": "Usa borderStyle \"bevel-out\" o \"bevel-in\" en una parte de components: dibuja el bisel con los colores del tema.", + "wb.doctor.css-hide.found": "Esta regla oculta algo con display: none.", + "wb.doctor.css-hide.fix": "Usa visible en una parte de components (avatares, contadores, nombres) o una variante de diseño como sidebar: hidden; así el propietario puede volver a activarlo.", + "wb.doctor.css-color.found": "Esta regla usa un color literal.", + "wb.doctor.css-color.fix": "Indica un rol (text, muted, accent, surface…) en colors o en un componente, para que la revisión de contraste lo cubra.", + "wb.doctor.css-font.found": "Esta regla define una familia de fuentes.", + "wb.doctor.css-font.fix": "Usa font.roles: define las tipografías de publicaciones, títulos, números y monoespaciada sin CSS.", + "wb.doctor.css-has.found": "Esta regla usa :has(), que se vuelve a evaluar con cada cambio de la página.", + "wb.doctor.css-has.fix": "No uses :has() en reglas que se repiten a lo largo de una cronología, o ancla la regla a una parte.", + "wb.doctor.css-universal.found": "Esta regla usa un selector universal (*), que se compara con todos los elementos.", + "wb.doctor.css-universal.fix": "Ancla la regla a una parte en su lugar.", + "wb.doctor.css-blur.found": "Esta regla desenfoca lo que hay detrás (backdrop-filter), lo cual es costoso en partes que se repiten.", + "wb.doctor.css-blur.fix": "Usa el relleno de cristal de barras y paneles: es el lugar más económico para el desenfoque.", + "wb.doctor.css-outline-none.found": "Esta regla quita el contorno de enfoque, así que el foco del teclado deja de verse.", + "wb.doctor.css-outline-none.fix": "Usa decor.focusRing para dibujar un anillo de enfoque visible.", + "wb.doctor.css-motion.found": "Esta regla anima sin comprobar si se pidió reducir el movimiento.", + "wb.doctor.css-motion.fix": "Mantén el movimiento dentro de @media (prefers-reduced-motion: no-preference), o deja que decor.motion lo haga por ti.", + "wb.doctor.css-size.found": "El CSS tiene más de 20.000 caracteres.", + "wb.doctor.css-size.fix": "El sitio recalcula los estilos con cada regla; los tokens y los ajustes de componentes se compilan en menos reglas.", + "wb.doctor.contrast.found": "El color {token} se ajustó para que siga siendo legible ({ratio}:1 sobre el fondo).", + "wb.doctor.contrast.fix": "Elige un color {token} más claro u oscuro; hasta entonces el tema se muestra con el ajustado.", + "wb.doctor.glass-post.found": "Se definió cristal en las publicaciones, pero no se dibuja: el desenfoque en cada publicación de una cronología es demasiado costoso.", + "wb.doctor.glass-post.fix": "Usa un relleno sólido o teñido para las publicaciones y reserva el cristal para barras y paneles.", + "wb.doctor.small-post-text.found": "El texto de las publicaciones es de {size}px, difícil de leer para mucha gente.", + "wb.doctor.small-post-text.fix": "Usa 14px o más para el tamaño del texto de las publicaciones, o aumenta el tamaño del texto de todo el tema.", + "wb.doctor.nav-moved.found": "La navegación se movió a la posición {position}, lo que cambia dónde la busca la gente.", + "wb.doctor.nav-moved.fix": "Solo se aplica en paneles anchos, y el propietario puede desactivar los cambios de diseño. Mantén la posición predeterminada salvo que el diseño lo necesite.", "wb.setup.title": "Compartir mi configuración", "wb.setup.hint": "Tu tema, tus iconos, tu modo y qué funciones están activas, en un enlace o un archivo pequeño. Cualquiera puede usarlo para empezar desde lo que tienes.", "wb.setup.shareLabel": "Tu configuración", diff --git a/packages/waybetter/locales/fr.json b/packages/waybetter/locales/fr.json index aa34699..993f189 100644 --- a/packages/waybetter/locales/fr.json +++ b/packages/waybetter/locales/fr.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "Supprimer {name}", "wb.appearance.icons.removed": "Pack d'icônes « {name} » supprimé.", "wb.appearance.icons.imported": "Packs d'icônes importés", + "wb.doctor.title": "Docteur du thème", + "wb.doctor.hint": "Conseils sur ce thème : des moyens plus légers de faire la même chose, les coûts et le contraste. Il ne fait que conseiller ; rien n’est bloqué ni modifié.", + "wb.doctor.empty": "Rien à signaler : le thème utilise des tokens et des réglages de composants, et rien n’y est coûteux.", + "wb.doctor.count": "{count, plural, one {# constat} other {# constats}}", + "wb.doctor.kind.lighter": "Un moyen plus léger", + "wb.doctor.kind.performance": "Performance", + "wb.doctor.kind.accessibility": "Accessibilité", + "wb.doctor.kind.contrast": "Contraste", + "wb.doctor.where": "Où", + "wb.doctor.fix": "Correction", + "wb.doctor.css-radius.found": "Cette règle définit des rayons de coin en CSS.", + "wb.doctor.css-radius.fix": "Définissez-les avec le radius d’une partie sous components, ou shape.radius pour toutes : pas de CSS nécessaire, et cela continue de fonctionner quand le site renomme ses classes.", + "wb.doctor.css-bevel.found": "Cette règle dessine un bord biseauté avec des ombres internes empilées.", + "wb.doctor.css-bevel.fix": "Utilisez borderStyle \"bevel-out\" ou \"bevel-in\" sur une partie sous components : le biseau est dessiné à partir des couleurs du thème.", + "wb.doctor.css-hide.found": "Cette règle masque quelque chose avec display: none.", + "wb.doctor.css-hide.fix": "Utilisez visible sur une partie sous components (avatars, compteurs, noms) ou une variante de mise en page comme sidebar: hidden ; le propriétaire peut ensuite le réactiver.", + "wb.doctor.css-color.found": "Cette règle utilise une couleur littérale.", + "wb.doctor.css-color.fix": "Nommez un rôle (text, muted, accent, surface…) dans colors ou dans un composant, afin que la vérification du contraste le couvre.", + "wb.doctor.css-font.found": "Cette règle définit une famille de polices.", + "wb.doctor.css-font.fix": "Utilisez font.roles : cela définit les polices des posts, titres, nombres et à chasse fixe sans CSS.", + "wb.doctor.css-has.found": "Cette règle utilise :has(), qui est réévalué à chaque changement de la page.", + "wb.doctor.css-has.fix": "Évitez :has() dans les règles qui se répètent le long d’un fil, ou ancrez la règle sur une partie.", + "wb.doctor.css-universal.found": "Cette règle utilise un sélecteur universel (*), comparé à chaque élément.", + "wb.doctor.css-universal.fix": "Ancrez plutôt la règle sur une partie.", + "wb.doctor.css-blur.found": "Cette règle floute ce qui se trouve derrière (backdrop-filter), ce qui est coûteux sur des parties répétées.", + "wb.doctor.css-blur.fix": "Utilisez le remplissage verre des barres et des panneaux : c’est l’endroit le moins coûteux pour le flou.", + "wb.doctor.css-outline-none.found": "Cette règle supprime le contour de focus, si bien que le focus clavier n’est plus visible.", + "wb.doctor.css-outline-none.fix": "Utilisez decor.focusRing pour dessiner un anneau de focus visible.", + "wb.doctor.css-motion.found": "Cette règle anime sans vérifier la préférence de réduction des animations.", + "wb.doctor.css-motion.fix": "Gardez le mouvement dans @media (prefers-reduced-motion: no-preference), ou laissez decor.motion s’en charger.", + "wb.doctor.css-size.found": "Le CSS dépasse 20 000 caractères.", + "wb.doctor.css-size.fix": "Le site recalcule les styles à chaque règle ; les tokens et les réglages de composants se compilent en moins de règles.", + "wb.doctor.contrast.found": "La couleur {token} a été ajustée pour rester lisible ({ratio}:1 sur l’arrière-plan).", + "wb.doctor.contrast.fix": "Choisissez une couleur {token} plus claire ou plus sombre ; d’ici là, le thème s’affiche avec la couleur ajustée.", + "wb.doctor.glass-post.found": "Le verre est défini sur les posts, mais n’est pas dessiné : le flou sur chaque post d’un fil est trop coûteux.", + "wb.doctor.glass-post.fix": "Utilisez un remplissage uni ou teinté pour les posts et gardez le verre pour les barres et les panneaux.", + "wb.doctor.small-post-text.found": "Le texte des posts fait {size}px, ce qui est difficile à lire pour beaucoup de gens.", + "wb.doctor.small-post-text.fix": "Utilisez 14px ou plus pour la taille du texte des posts, ou augmentez la taille du texte de tout le thème.", + "wb.doctor.nav-moved.found": "La navigation est déplacée vers {position}, ce qui change l’endroit où l’on la cherche.", + "wb.doctor.nav-moved.fix": "Cela ne s’applique que sur les volets larges, et le propriétaire peut désactiver les changements de mise en page. Gardez la position par défaut sauf si la mise en page l’exige.", "wb.setup.title": "Partager ma configuration", "wb.setup.hint": "Votre thème, vos icônes, votre mode et les fonctions activées, en un lien ou un petit fichier. N'importe qui peut s'en servir pour partir de ce que vous avez.", "wb.setup.shareLabel": "Votre configuration", diff --git a/packages/waybetter/locales/hi.json b/packages/waybetter/locales/hi.json index da7c1a6..a77a65b 100644 --- a/packages/waybetter/locales/hi.json +++ b/packages/waybetter/locales/hi.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "{name} हटाएँ", "wb.appearance.icons.removed": "“{name}” आइकन पैक हटा दिया गया.", "wb.appearance.icons.imported": "इम्पोर्ट किए गए आइकन पैक", + "wb.doctor.title": "थीम डॉक्टर", + "wb.doctor.hint": "इस थीम के बारे में सलाह: वही काम करने के हल्के तरीके, लागत और कंट्रास्ट। यह केवल सलाह देता है; कुछ भी ब्लॉक या बदला नहीं जाता।", + "wb.doctor.empty": "बताने लायक कुछ नहीं: थीम टोकन और कॉम्पोनेंट सेटिंग्स का उपयोग करती है, और इसमें कुछ भी महँगा नहीं है।", + "wb.doctor.count": "{count, plural, one {# निष्कर्ष} other {# निष्कर्ष}}", + "wb.doctor.kind.lighter": "एक हल्का तरीका", + "wb.doctor.kind.performance": "परफ़ॉर्मेंस", + "wb.doctor.kind.accessibility": "एक्सेसिबिलिटी", + "wb.doctor.kind.contrast": "कंट्रास्ट", + "wb.doctor.where": "कहाँ", + "wb.doctor.fix": "समाधान", + "wb.doctor.css-radius.found": "यह नियम CSS में कोनों की त्रिज्या सेट करता है।", + "wb.doctor.css-radius.fix": "इन्हें components के अंतर्गत किसी हिस्से के radius से सेट करें, या सभी के लिए shape.radius से: CSS की ज़रूरत नहीं, और साइट के क्लास नाम बदलने पर भी यह काम करता रहता है।", + "wb.doctor.css-bevel.found": "यह नियम एक के ऊपर एक इनसेट शैडो से तिरछा किनारा बनाता है।", + "wb.doctor.css-bevel.fix": "components के अंतर्गत किसी हिस्से पर borderStyle \"bevel-out\" या \"bevel-in\" का उपयोग करें: यह थीम के रंगों से बेवल बनाता है।", + "wb.doctor.css-hide.found": "यह नियम display: none से कुछ छिपाता है।", + "wb.doctor.css-hide.fix": "components के अंतर्गत किसी हिस्से पर visible (अवतार, गिनती, नाम) या sidebar: hidden जैसे लेआउट वेरिएंट का उपयोग करें; फिर मालिक उसे वापस चालू कर सकता है।", + "wb.doctor.css-color.found": "यह नियम सीधा रंग मान इस्तेमाल करता है।", + "wb.doctor.css-color.fix": "colors में या किसी कॉम्पोनेंट में कोई भूमिका (text, muted, accent, surface…) चुनें, ताकि कंट्रास्ट जाँच उसे शामिल करे।", + "wb.doctor.css-font.found": "यह नियम फ़ॉन्ट फ़ैमिली सेट करता है।", + "wb.doctor.css-font.fix": "font.roles का उपयोग करें: यह CSS के बिना पोस्ट, शीर्षक, अंकों और मोनो के फ़ॉन्ट सेट करता है।", + "wb.doctor.css-has.found": "यह नियम :has() का उपयोग करता है, जिसे पेज में हर बदलाव पर फिर से मिलाया जाता है।", + "wb.doctor.css-has.fix": "टाइमलाइन में दोहराए जाने वाले नियमों में :has() का उपयोग न करें, या नियम को किसी हिस्से से जोड़ दें।", + "wb.doctor.css-universal.found": "यह नियम यूनिवर्सल सेलेक्टर (*) का उपयोग करता है, जिसे हर एलिमेंट से मिलाया जाता है।", + "wb.doctor.css-universal.fix": "इसके बजाय नियम को किसी हिस्से से जोड़ें।", + "wb.doctor.css-blur.found": "यह नियम अपने पीछे की चीज़ को धुँधला करता है (backdrop-filter), जो दोहराए जाने वाले हिस्सों पर महँगा है।", + "wb.doctor.css-blur.fix": "बार और पैनल की ग्लास फ़िल का उपयोग करें: धुँधलापन के लिए वही सस्ती जगह है।", + "wb.doctor.css-outline-none.found": "यह नियम फ़ोकस आउटलाइन हटा देता है, इसलिए कीबोर्ड फ़ोकस दिखना बंद हो जाता है।", + "wb.doctor.css-outline-none.fix": "इसके बजाय दिखने वाली फ़ोकस रिंग बनाने के लिए decor.focusRing का उपयोग करें।", + "wb.doctor.css-motion.found": "यह नियम कम मोशन की पसंद जाँचे बिना एनिमेशन चलाता है।", + "wb.doctor.css-motion.fix": "मोशन को @media (prefers-reduced-motion: no-preference) के भीतर रखें, या यह काम decor.motion को करने दें।", + "wb.doctor.css-size.found": "CSS 20,000 अक्षरों से लंबी है।", + "wb.doctor.css-size.fix": "साइट हर नियम के साथ स्टाइल दोबारा गिनती है; टोकन और कॉम्पोनेंट सेटिंग्स कम नियमों में कंपाइल होती हैं।", + "wb.doctor.contrast.found": "{token} रंग को पढ़ने योग्य रखने के लिए बदला गया ({ratio}:1 बैकग्राउंड पर)।", + "wb.doctor.contrast.fix": "{token} के लिए हल्का या गहरा रंग चुनें; तब तक थीम बदले हुए रंग के साथ दिखाई जाएगी।", + "wb.doctor.glass-post.found": "पोस्ट पर ग्लास सेट है, पर वह बनाया नहीं जाता: टाइमलाइन की हर पोस्ट पर धुँधलापन बहुत महँगा है।", + "wb.doctor.glass-post.fix": "पोस्ट के लिए ठोस या हल्के रंग की फ़िल का उपयोग करें और ग्लास को बार और पैनल के लिए रखें।", + "wb.doctor.small-post-text.found": "पोस्ट का टेक्स्ट {size}px है, जो कई लोगों के लिए पढ़ना कठिन है।", + "wb.doctor.small-post-text.fix": "पोस्ट के टेक्स्ट के आकार के लिए 14px या अधिक रखें, या पूरी थीम का टेक्स्ट आकार बढ़ाएँ।", + "wb.doctor.nav-moved.found": "नेविगेशन को {position} पर ले जाया गया है, जिससे लोगों के उसे खोजने की जगह बदल जाती है।", + "wb.doctor.nav-moved.fix": "यह केवल चौड़े पैन पर लागू होता है, और मालिक लेआउट बदलाव बंद कर सकता है। जब तक लेआउट को ज़रूरत न हो, डिफ़ॉल्ट स्थिति रखें।", "wb.setup.title": "मेरा सेटअप शेयर करें", "wb.setup.hint": "आपकी थीम, आइकन, मोड और कौन सी सुविधाएँ चालू हैं, एक लिंक या एक छोटी फ़ाइल में. कोई भी इससे आपके सेटअप से शुरुआत कर सकता है.", "wb.setup.shareLabel": "आपका सेटअप", diff --git a/packages/waybetter/locales/id.json b/packages/waybetter/locales/id.json index 4c9454f..bd20924 100644 --- a/packages/waybetter/locales/id.json +++ b/packages/waybetter/locales/id.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "Hapus {name}", "wb.appearance.icons.removed": "Paket ikon “{name}” dihapus.", "wb.appearance.icons.imported": "Paket ikon yang diimpor", + "wb.doctor.title": "Dokter tema", + "wb.doctor.hint": "Saran untuk tema ini: cara yang lebih ringan untuk hasil yang sama, biaya, dan kontras. Hanya memberi saran; tidak ada yang diblokir atau diubah.", + "wb.doctor.empty": "Tidak ada yang perlu dilaporkan: tema ini memakai token dan pengaturan komponen, dan tidak ada yang berat di dalamnya.", + "wb.doctor.count": "{count, plural, other {# temuan}}", + "wb.doctor.kind.lighter": "Cara yang lebih ringan", + "wb.doctor.kind.performance": "Performa", + "wb.doctor.kind.accessibility": "Aksesibilitas", + "wb.doctor.kind.contrast": "Kontras", + "wb.doctor.where": "Di mana", + "wb.doctor.fix": "Perbaikan", + "wb.doctor.css-radius.found": "Aturan ini mengatur radius sudut lewat CSS.", + "wb.doctor.css-radius.fix": "Atur dengan radius sebuah bagian di components, atau shape.radius untuk semuanya: tanpa CSS, dan tetap berfungsi saat situs mengganti nama kelasnya.", + "wb.doctor.css-bevel.found": "Aturan ini menggambar tepi miring dengan tumpukan bayangan inset.", + "wb.doctor.css-bevel.fix": "Gunakan borderStyle \"bevel-out\" atau \"bevel-in\" pada sebuah bagian di components: tepi miring digambar dari warna tema.", + "wb.doctor.css-hide.found": "Aturan ini menyembunyikan sesuatu dengan display: none.", + "wb.doctor.css-hide.fix": "Gunakan visible pada sebuah bagian di components (avatar, hitungan, nama) atau varian tata letak seperti sidebar: hidden; pemilik lalu bisa menampilkannya kembali.", + "wb.doctor.css-color.found": "Aturan ini memakai warna literal.", + "wb.doctor.css-color.fix": "Sebut sebuah peran (text, muted, accent, surface…) di colors atau di komponen, agar pemeriksaan kontras mencakupnya.", + "wb.doctor.css-font.found": "Aturan ini mengatur keluarga font.", + "wb.doctor.css-font.fix": "Gunakan font.roles: mengatur font postingan, judul, angka, dan mono tanpa CSS.", + "wb.doctor.css-has.found": "Aturan ini memakai :has(), yang dicocokkan ulang di setiap perubahan halaman.", + "wb.doctor.css-has.fix": "Jangan pakai :has() pada aturan yang berulang di sepanjang linimasa, atau tautkan aturan ke sebuah bagian.", + "wb.doctor.css-universal.found": "Aturan ini memakai selektor universal (*), yang dicocokkan dengan setiap elemen.", + "wb.doctor.css-universal.fix": "Tautkan aturan ke sebuah bagian saja.", + "wb.doctor.css-blur.found": "Aturan ini mengaburkan apa yang ada di belakangnya (backdrop-filter), yang berat pada bagian yang berulang.", + "wb.doctor.css-blur.fix": "Gunakan isian kaca pada bilah dan panel: itu tempat yang lebih murah untuk blur.", + "wb.doctor.css-outline-none.found": "Aturan ini menghapus outline fokus, sehingga fokus keyboard tidak terlihat lagi.", + "wb.doctor.css-outline-none.fix": "Gunakan decor.focusRing untuk menggambar cincin fokus yang terlihat.", + "wb.doctor.css-motion.found": "Aturan ini menganimasikan tanpa memeriksa preferensi kurangi gerakan.", + "wb.doctor.css-motion.fix": "Simpan gerakan di dalam @media (prefers-reduced-motion: no-preference), atau biarkan decor.motion yang mengurusnya.", + "wb.doctor.css-size.found": "CSS-nya lebih dari 20.000 karakter.", + "wb.doctor.css-size.fix": "Situs menghitung ulang gaya pada setiap aturan; token dan pengaturan komponen dikompilasi menjadi lebih sedikit aturan.", + "wb.doctor.contrast.found": "Warna {token} disesuaikan agar tetap terbaca ({ratio}:1 pada latar belakang).", + "wb.doctor.contrast.fix": "Pilih warna {token} yang lebih terang atau lebih gelap; sampai saat itu tema ditampilkan dengan warna yang sudah disesuaikan.", + "wb.doctor.glass-post.found": "Kaca diatur pada postingan, tetapi tidak digambar: blur pada setiap postingan di linimasa terlalu berat.", + "wb.doctor.glass-post.fix": "Gunakan isian solid atau berwarna untuk postingan dan simpan kaca untuk bilah dan panel.", + "wb.doctor.small-post-text.found": "Teks postingan berukuran {size}px, sulit dibaca bagi banyak orang.", + "wb.doctor.small-post-text.fix": "Gunakan 14px atau lebih untuk ukuran teks postingan, atau perbesar ukuran teks seluruh tema.", + "wb.doctor.nav-moved.found": "Navigasi dipindahkan ke {position}, yang mengubah tempat orang mencarinya.", + "wb.doctor.nav-moved.fix": "Ini hanya berlaku pada panel lebar, dan pemilik dapat mematikan perubahan tata letak. Pertahankan posisi bawaan kecuali tata letak membutuhkannya.", "wb.setup.title": "Bagikan pengaturanku", "wb.setup.hint": "Tema, ikon, mode, dan fitur mana yang aktif, sebagai satu tautan atau satu berkas kecil. Siapa pun bisa memakainya untuk mulai dari apa yang kamu punya.", "wb.setup.shareLabel": "Pengaturanmu", diff --git a/packages/waybetter/locales/it.json b/packages/waybetter/locales/it.json index 6d7b67e..0b4d721 100644 --- a/packages/waybetter/locales/it.json +++ b/packages/waybetter/locales/it.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "Rimuovi {name}", "wb.appearance.icons.removed": "Pacchetto di icone «{name}» rimosso.", "wb.appearance.icons.imported": "Pacchetti di icone importati", + "wb.doctor.title": "Dottore del tema", + "wb.doctor.hint": "Consigli su questo tema: modi più leggeri per ottenere lo stesso risultato, costi e contrasto. Dà solo consigli; nulla viene bloccato o modificato.", + "wb.doctor.empty": "Niente da segnalare: il tema usa token e impostazioni dei componenti, e nulla al suo interno è costoso.", + "wb.doctor.count": "{count, plural, one {# rilievo} other {# rilievi}}", + "wb.doctor.kind.lighter": "Un modo più leggero", + "wb.doctor.kind.performance": "Prestazioni", + "wb.doctor.kind.accessibility": "Accessibilità", + "wb.doctor.kind.contrast": "Contrasto", + "wb.doctor.where": "Dove", + "wb.doctor.fix": "Correzione", + "wb.doctor.css-radius.found": "Questa regola imposta i raggi degli angoli in CSS.", + "wb.doctor.css-radius.fix": "Impostali con il radius di una parte in components, oppure con shape.radius per tutte: nessun CSS necessario, e continua a funzionare quando il sito rinomina le sue classi.", + "wb.doctor.css-bevel.found": "Questa regola disegna un bordo smussato con ombre interne sovrapposte.", + "wb.doctor.css-bevel.fix": "Usa borderStyle \"bevel-out\" o \"bevel-in\" su una parte in components: disegna lo smusso con i colori del tema.", + "wb.doctor.css-hide.found": "Questa regola nasconde qualcosa con display: none.", + "wb.doctor.css-hide.fix": "Usa visible su una parte in components (avatar, contatori, nomi) oppure una variante di layout come sidebar: hidden; così il proprietario può riattivarla.", + "wb.doctor.css-color.found": "Questa regola usa un colore letterale.", + "wb.doctor.css-color.fix": "Indica un ruolo (text, muted, accent, surface…) in colors o in un componente, così il controllo del contrasto lo copre.", + "wb.doctor.css-font.found": "Questa regola imposta una famiglia di caratteri.", + "wb.doctor.css-font.fix": "Usa font.roles: imposta i caratteri di post, titoli, numeri e monospazio senza CSS.", + "wb.doctor.css-has.found": "Questa regola usa :has(), che viene valutato di nuovo a ogni modifica della pagina.", + "wb.doctor.css-has.fix": "Evita :has() nelle regole che si ripetono lungo una timeline, oppure ancora la regola a una parte.", + "wb.doctor.css-universal.found": "Questa regola usa un selettore universale (*), confrontato con ogni elemento.", + "wb.doctor.css-universal.fix": "Ancora invece la regola a una parte.", + "wb.doctor.css-blur.found": "Questa regola sfoca ciò che sta dietro (backdrop-filter), il che è costoso sulle parti che si ripetono.", + "wb.doctor.css-blur.fix": "Usa il riempimento vetro di barre e pannelli: è il posto più economico per la sfocatura.", + "wb.doctor.css-outline-none.found": "Questa regola rimuove il contorno di focus, quindi il focus da tastiera non è più visibile.", + "wb.doctor.css-outline-none.fix": "Usa decor.focusRing per disegnare invece un anello di focus visibile.", + "wb.doctor.css-motion.found": "Questa regola anima senza controllare la preferenza per il movimento ridotto.", + "wb.doctor.css-motion.fix": "Tieni il movimento dentro @media (prefers-reduced-motion: no-preference), oppure lascia che lo faccia decor.motion.", + "wb.doctor.css-size.found": "Il CSS supera i 20.000 caratteri.", + "wb.doctor.css-size.fix": "Il sito ricalcola gli stili a ogni regola; token e impostazioni dei componenti si compilano in meno regole.", + "wb.doctor.contrast.found": "Il colore {token} è stato regolato per restare leggibile ({ratio}:1 sullo sfondo).", + "wb.doctor.contrast.fix": "Scegli un colore {token} più chiaro o più scuro; fino ad allora il tema viene mostrato con quello regolato.", + "wb.doctor.glass-post.found": "Il vetro è impostato sui post, ma non viene disegnato: la sfocatura su ogni post di una timeline è troppo costosa.", + "wb.doctor.glass-post.fix": "Usa un riempimento pieno o tinto per i post e riserva il vetro a barre e pannelli.", + "wb.doctor.small-post-text.found": "Il testo dei post è di {size}px, difficile da leggere per molte persone.", + "wb.doctor.small-post-text.fix": "Usa 14px o più per la dimensione del testo dei post, oppure aumenta la dimensione del testo dell’intero tema.", + "wb.doctor.nav-moved.found": "La navigazione è stata spostata in {position}, il che cambia dove le persone la cercano.", + "wb.doctor.nav-moved.fix": "Vale solo sui riquadri larghi, e il proprietario può disattivare le modifiche al layout. Mantieni la posizione predefinita a meno che il layout non lo richieda.", "wb.setup.title": "Condividi la mia configurazione", "wb.setup.hint": "Il tuo tema, le icone, la modalità e quali funzioni sono attive, in un link o in un piccolo file. Chiunque può usarlo per partire da ciò che hai.", "wb.setup.shareLabel": "La tua configurazione", diff --git a/packages/waybetter/locales/ja.json b/packages/waybetter/locales/ja.json index 44607e2..1bbae24 100644 --- a/packages/waybetter/locales/ja.json +++ b/packages/waybetter/locales/ja.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "{name} を削除", "wb.appearance.icons.removed": "アイコンパック「{name}」を削除しました。", "wb.appearance.icons.imported": "読み込んだアイコンパック", + "wb.doctor.title": "テーマドクター", + "wb.doctor.hint": "このテーマに関するアドバイスです。同じことをもっと軽くする方法、負荷、コントラストを示します。助言のみで、ブロックや変更は行いません。", + "wb.doctor.empty": "報告することはありません。このテーマはトークンとコンポーネント設定を使っていて、負荷の高いものもありません。", + "wb.doctor.count": "{count, plural, other {# 件の指摘}}", + "wb.doctor.kind.lighter": "もっと軽い方法", + "wb.doctor.kind.performance": "パフォーマンス", + "wb.doctor.kind.accessibility": "アクセシビリティ", + "wb.doctor.kind.contrast": "コントラスト", + "wb.doctor.where": "場所", + "wb.doctor.fix": "修正", + "wb.doctor.css-radius.found": "このルールはCSSで角丸を設定しています。", + "wb.doctor.css-radius.fix": "components の各パーツの radius で個別に、または shape.radius ですべてまとめて設定してください。CSSは不要で、サイトがクラス名を変えても動き続けます。", + "wb.doctor.css-bevel.found": "このルールは重ねたインセットシャドウで面取りの縁を描いています。", + "wb.doctor.css-bevel.fix": "components のパーツで borderStyle \"bevel-out\" または \"bevel-in\" を使ってください。テーマの色から面取りを描きます。", + "wb.doctor.css-hide.found": "このルールは display: none で何かを隠しています。", + "wb.doctor.css-hide.fix": "components のパーツ(アバター、カウント、名前)の visible や、sidebar: hidden のようなレイアウトバリアントを使ってください。オーナーが元に戻すこともできます。", + "wb.doctor.css-color.found": "このルールはリテラルの色を使っています。", + "wb.doctor.css-color.fix": "colors またはコンポーネント内でロール(text、muted、accent、surface など)を指定してください。そうすればコントラスト調整の対象になります。", + "wb.doctor.css-font.found": "このルールはフォントファミリーを設定しています。", + "wb.doctor.css-font.fix": "font.roles を使ってください。CSSなしで、ポスト、見出し、数字、等幅の書体を設定できます。", + "wb.doctor.css-has.found": "このルールは :has() を使っており、ページが変わるたびに再評価されます。", + "wb.doctor.css-has.fix": "タイムラインで繰り返されるルールには :has() を使わないか、ルールをパーツに紐づけてください。", + "wb.doctor.css-universal.found": "このルールは全要素と照合されるユニバーサルセレクター (*) を使っています。", + "wb.doctor.css-universal.fix": "代わりにルールをパーツに紐づけてください。", + "wb.doctor.css-blur.found": "このルールは背面をぼかしており (backdrop-filter)、繰り返されるパーツでは負荷が高くなります。", + "wb.doctor.css-blur.fix": "バーやパネルのガラス塗りを使ってください。ぼかしにはそちらのほうが軽い場所です。", + "wb.doctor.css-outline-none.found": "このルールはフォーカスのアウトラインを消しているため、キーボードのフォーカスが見えなくなります。", + "wb.doctor.css-outline-none.fix": "代わりに decor.focusRing で見えるフォーカスリングを描いてください。", + "wb.doctor.css-motion.found": "このルールは視覚効果の軽減を確認せずにアニメーションさせています。", + "wb.doctor.css-motion.fix": "動きは @media (prefers-reduced-motion: no-preference) の中に入れるか、decor.motion に任せてください。", + "wb.doctor.css-size.found": "CSSが20,000文字を超えています。", + "wb.doctor.css-size.fix": "サイトはルールごとにスタイルを再計算します。トークンとコンポーネント設定のほうが少ないルールにコンパイルされます。", + "wb.doctor.contrast.found": "{token} の色は読みやすさを保つために調整されました(背景に対して {ratio}:1)。", + "wb.doctor.contrast.fix": "{token} の色をもっと明るく、または暗くしてください。それまではテーマは調整後の色で表示されます。", + "wb.doctor.glass-post.found": "ポストにガラスが設定されていますが、描画されません。タイムラインのすべてのポストにぼかしを使うと負荷が高すぎます。", + "wb.doctor.glass-post.fix": "ポストには単色または色付きの塗りを使い、ガラスはバーやパネル用にしてください。", + "wb.doctor.small-post-text.found": "ポストのテキストが {size}px で、多くの人には読みにくいサイズです。", + "wb.doctor.small-post-text.fix": "ポストのテキストサイズは 14px 以上にするか、テーマ全体のテキストサイズを上げてください。", + "wb.doctor.nav-moved.found": "ナビゲーションが {position} に移動されており、人が探す場所が変わります。", + "wb.doctor.nav-moved.fix": "広いペインでのみ適用され、オーナーはレイアウト変更をオフにできます。レイアウト上必要でなければ、既定の位置のままにしてください。", "wb.setup.title": "自分の設定を共有", "wb.setup.hint": "テーマ、アイコン、モード、オンにしている機能を、1 つのリンクまたは小さなファイルにまとめます。誰でもあなたの設定から始められます。", "wb.setup.shareLabel": "あなたの設定", diff --git a/packages/waybetter/locales/ko.json b/packages/waybetter/locales/ko.json index 0029c76..12d04d5 100644 --- a/packages/waybetter/locales/ko.json +++ b/packages/waybetter/locales/ko.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "{name} 삭제", "wb.appearance.icons.removed": "아이콘 팩 “{name}”을(를) 삭제했습니다.", "wb.appearance.icons.imported": "가져온 아이콘 팩", + "wb.doctor.title": "테마 닥터", + "wb.doctor.hint": "이 테마에 대한 조언: 같은 일을 더 가볍게 하는 방법, 비용, 대비. 조언만 할 뿐 아무것도 차단하거나 변경하지 않아요.", + "wb.doctor.empty": "보고할 내용이 없어요. 테마가 토큰과 컴포넌트 설정을 사용하고 있고, 비용이 큰 것도 없어요.", + "wb.doctor.count": "{count, plural, other {#건의 결과}}", + "wb.doctor.kind.lighter": "더 가벼운 방법", + "wb.doctor.kind.performance": "성능", + "wb.doctor.kind.accessibility": "접근성", + "wb.doctor.kind.contrast": "대비", + "wb.doctor.where": "위치", + "wb.doctor.fix": "해결", + "wb.doctor.css-radius.found": "이 규칙은 CSS로 모서리 반경을 설정해요.", + "wb.doctor.css-radius.fix": "components의 부분별 radius로, 또는 전체에 적용하는 shape.radius로 설정하세요. CSS가 필요 없고, 사이트가 클래스 이름을 바꿔도 계속 작동해요.", + "wb.doctor.css-bevel.found": "이 규칙은 겹쳐 쌓은 안쪽 그림자로 모따기 모서리를 그려요.", + "wb.doctor.css-bevel.fix": "components의 부분에 borderStyle \"bevel-out\" 또는 \"bevel-in\"을 사용하세요. 테마 색상으로 모따기를 그려요.", + "wb.doctor.css-hide.found": "이 규칙은 display: none으로 무언가를 숨겨요.", + "wb.doctor.css-hide.fix": "components의 부분(아바타, 개수, 이름)에 visible을 쓰거나 sidebar: hidden 같은 레이아웃 변형을 사용하세요. 그러면 소유자가 다시 켤 수 있어요.", + "wb.doctor.css-color.found": "이 규칙은 고정 색상 값을 사용해요.", + "wb.doctor.css-color.fix": "colors나 컴포넌트에서 역할(text, muted, accent, surface…)을 지정하세요. 그러면 대비 검사에 포함돼요.", + "wb.doctor.css-font.found": "이 규칙은 글꼴 계열을 설정해요.", + "wb.doctor.css-font.fix": "font.roles를 사용하세요. CSS 없이 게시물, 제목, 숫자, 고정폭 글꼴을 설정해요.", + "wb.doctor.css-has.found": "이 규칙은 :has()를 사용하며, 페이지가 바뀔 때마다 다시 매칭돼요.", + "wb.doctor.css-has.fix": "타임라인에서 반복되는 규칙에는 :has()를 쓰지 말거나, 규칙을 부분에 고정하세요.", + "wb.doctor.css-universal.found": "이 규칙은 모든 요소와 매칭되는 전체 선택자(*)를 사용해요.", + "wb.doctor.css-universal.fix": "대신 규칙을 부분에 고정하세요.", + "wb.doctor.css-blur.found": "이 규칙은 뒤에 있는 것을 흐리게 하며(backdrop-filter), 반복되는 부분에서는 비용이 커요.", + "wb.doctor.css-blur.fix": "바와 패널의 유리 채우기를 사용하세요. 흐림 효과에는 그쪽이 더 저렴해요.", + "wb.doctor.css-outline-none.found": "이 규칙은 포커스 윤곽선을 없애서 키보드 포커스가 보이지 않게 돼요.", + "wb.doctor.css-outline-none.fix": "대신 decor.focusRing으로 보이는 포커스 링을 그리세요.", + "wb.doctor.css-motion.found": "이 규칙은 동작 줄이기 설정을 확인하지 않고 애니메이션을 실행해요.", + "wb.doctor.css-motion.fix": "움직임은 @media (prefers-reduced-motion: no-preference) 안에 두거나, decor.motion에 맡기세요.", + "wb.doctor.css-size.found": "CSS가 20,000자를 넘어요.", + "wb.doctor.css-size.fix": "사이트는 규칙마다 스타일을 다시 계산해요. 토큰과 컴포넌트 설정은 더 적은 규칙으로 컴파일돼요.", + "wb.doctor.contrast.found": "{token} 색상은 읽기 쉽도록 조정되었어요(배경 대비 {ratio}:1).", + "wb.doctor.contrast.fix": "더 밝거나 어두운 {token} 색상을 고르세요. 그전까지는 조정된 색상으로 테마가 표시돼요.", + "wb.doctor.glass-post.found": "게시물에 유리가 설정되어 있지만 그려지지 않아요. 타임라인의 모든 게시물에 흐림 효과를 쓰면 비용이 너무 커요.", + "wb.doctor.glass-post.fix": "게시물에는 단색이나 색조 채우기를 사용하고, 유리는 바와 패널에 남겨 두세요.", + "wb.doctor.small-post-text.found": "게시물 텍스트가 {size}px로, 많은 사람이 읽기 어려워요.", + "wb.doctor.small-post-text.fix": "게시물 텍스트 크기는 14px 이상으로 하거나, 테마 전체의 텍스트 크기를 키우세요.", + "wb.doctor.nav-moved.found": "내비게이션이 {position}(으)로 옮겨져서 사람들이 찾는 위치가 달라져요.", + "wb.doctor.nav-moved.fix": "넓은 창에서만 적용되며, 소유자가 레이아웃 변경을 끌 수 있어요. 레이아웃에 꼭 필요하지 않다면 기본 위치를 유지하세요.", "wb.setup.title": "내 설정 공유", "wb.setup.hint": "테마, 아이콘, 모드, 켜 둔 기능을 링크 하나나 작은 파일 하나로. 누구나 여러분의 설정에서 시작할 수 있습니다.", "wb.setup.shareLabel": "내 설정", diff --git a/packages/waybetter/locales/nl.json b/packages/waybetter/locales/nl.json index 4a892a1..4394e29 100644 --- a/packages/waybetter/locales/nl.json +++ b/packages/waybetter/locales/nl.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "{name} verwijderen", "wb.appearance.icons.removed": "Pictogrammenpakket ‘{name}’ verwijderd.", "wb.appearance.icons.imported": "Geïmporteerde pictogrammenpakketten", + "wb.doctor.title": "Themadokter", + "wb.doctor.hint": "Advies over dit thema: lichtere manieren om hetzelfde te doen, kosten en contrast. Hij adviseert alleen; er wordt niets geblokkeerd of gewijzigd.", + "wb.doctor.empty": "Niets te melden: het thema gebruikt tokens en componentinstellingen, en niets erin is kostbaar.", + "wb.doctor.count": "{count, plural, one {# bevinding} other {# bevindingen}}", + "wb.doctor.kind.lighter": "Een lichtere manier", + "wb.doctor.kind.performance": "Prestaties", + "wb.doctor.kind.accessibility": "Toegankelijkheid", + "wb.doctor.kind.contrast": "Contrast", + "wb.doctor.where": "Waar", + "wb.doctor.fix": "Oplossing", + "wb.doctor.css-radius.found": "Deze regel stelt hoekradii in via CSS.", + "wb.doctor.css-radius.fix": "Stel ze in met de radius van een onderdeel onder components, of met shape.radius voor alle: geen CSS nodig, en het blijft werken als de site zijn klassen hernoemt.", + "wb.doctor.css-bevel.found": "Deze regel tekent een afgeschuinde rand met gestapelde inset-schaduwen.", + "wb.doctor.css-bevel.fix": "Gebruik borderStyle \"bevel-out\" of \"bevel-in\" op een onderdeel onder components: de afschuining wordt getekend met de kleuren van het thema.", + "wb.doctor.css-hide.found": "Deze regel verbergt iets met display: none.", + "wb.doctor.css-hide.fix": "Gebruik visible op een onderdeel onder components (avatars, tellers, namen) of een lay-outvariant zoals sidebar: hidden; de eigenaar kan het dan weer aanzetten.", + "wb.doctor.css-color.found": "Deze regel gebruikt een letterlijke kleur.", + "wb.doctor.css-color.fix": "Noem een rol (text, muted, accent, surface…) in colors of in een component, zodat de contrastcontrole het dekt.", + "wb.doctor.css-font.found": "Deze regel stelt een lettertypefamilie in.", + "wb.doctor.css-font.fix": "Gebruik font.roles: daarmee stel je de lettertypen voor posts, koppen, cijfers en mono in zonder CSS.", + "wb.doctor.css-has.found": "Deze regel gebruikt :has(), dat bij elke wijziging van de pagina opnieuw wordt vergeleken.", + "wb.doctor.css-has.fix": "Gebruik :has() niet in regels die zich door een tijdlijn heen herhalen, of verankeer de regel aan een onderdeel.", + "wb.doctor.css-universal.found": "Deze regel gebruikt een universele selector (*), die met elk element wordt vergeleken.", + "wb.doctor.css-universal.fix": "Verankeer de regel in plaats daarvan aan een onderdeel.", + "wb.doctor.css-blur.found": "Deze regel vervaagt wat erachter zit (backdrop-filter), wat kostbaar is bij onderdelen die zich herhalen.", + "wb.doctor.css-blur.fix": "Gebruik de glasvulling van balken en panelen: dat is de goedkopere plek voor vervaging.", + "wb.doctor.css-outline-none.found": "Deze regel verwijdert de focusomlijning, waardoor de toetsenbordfocus niet meer zichtbaar is.", + "wb.doctor.css-outline-none.fix": "Gebruik decor.focusRing om in plaats daarvan een zichtbare focusring te tekenen.", + "wb.doctor.css-motion.found": "Deze regel animeert zonder te controleren op verminderde beweging.", + "wb.doctor.css-motion.fix": "Houd beweging binnen @media (prefers-reduced-motion: no-preference), of laat decor.motion dat voor je doen.", + "wb.doctor.css-size.found": "De CSS is langer dan 20.000 tekens.", + "wb.doctor.css-size.fix": "De site berekent stijlen opnieuw bij elke regel; tokens en componentinstellingen worden gecompileerd tot minder regels.", + "wb.doctor.contrast.found": "De kleur {token} is aangepast zodat hij leesbaar blijft ({ratio}:1 op de achtergrond).", + "wb.doctor.contrast.fix": "Kies een lichtere of donkerdere kleur voor {token}; tot die tijd wordt het thema getoond met de aangepaste kleur.", + "wb.doctor.glass-post.found": "Glas is ingesteld op posts, maar wordt niet getekend: vervaging op elke post van een tijdlijn is te kostbaar.", + "wb.doctor.glass-post.fix": "Gebruik een effen of getinte vulling voor posts en bewaar glas voor balken en panelen.", + "wb.doctor.small-post-text.found": "De posttekst is {size}px, wat voor veel mensen moeilijk te lezen is.", + "wb.doctor.small-post-text.fix": "Gebruik 14px of meer voor de tekstgrootte van posts, of verhoog de tekstgrootte van het hele thema.", + "wb.doctor.nav-moved.found": "De navigatie is verplaatst naar {position}, waardoor mensen haar op een andere plek zoeken.", + "wb.doctor.nav-moved.fix": "Dit geldt alleen voor brede vensters, en de eigenaar kan lay-outwijzigingen uitzetten. Houd de standaardpositie aan tenzij de lay-out het nodig heeft.", "wb.setup.title": "Mijn instellingen delen", "wb.setup.hint": "Je thema, pictogrammen, modus en welke functies aan staan, als één link of één klein bestand. Iedereen kan het gebruiken om te beginnen bij wat jij hebt.", "wb.setup.shareLabel": "Jouw instellingen", diff --git a/packages/waybetter/locales/pt.json b/packages/waybetter/locales/pt.json index f5d1513..7ec8f87 100644 --- a/packages/waybetter/locales/pt.json +++ b/packages/waybetter/locales/pt.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "Remover {name}", "wb.appearance.icons.removed": "Pacote de ícones “{name}” removido.", "wb.appearance.icons.imported": "Pacotes de ícones importados", + "wb.doctor.title": "Médico de temas", + "wb.doctor.hint": "Conselhos sobre este tema: formas mais leves de fazer o mesmo, custos e contraste. Ele só aconselha; nada é bloqueado ou alterado.", + "wb.doctor.empty": "Nada a relatar: o tema usa tokens e configurações de componentes, e nada nele é pesado.", + "wb.doctor.count": "{count, plural, one {# achado} other {# achados}}", + "wb.doctor.kind.lighter": "Um jeito mais leve", + "wb.doctor.kind.performance": "Desempenho", + "wb.doctor.kind.accessibility": "Acessibilidade", + "wb.doctor.kind.contrast": "Contraste", + "wb.doctor.where": "Onde", + "wb.doctor.fix": "Correção", + "wb.doctor.css-radius.found": "Esta regra define raios de canto em CSS.", + "wb.doctor.css-radius.fix": "Defina-os com o radius de uma parte em components, ou com shape.radius para todas: sem CSS, e continua funcionando quando o site renomeia suas classes.", + "wb.doctor.css-bevel.found": "Esta regra desenha uma borda chanfrada com sombras internas empilhadas.", + "wb.doctor.css-bevel.fix": "Use borderStyle \"bevel-out\" ou \"bevel-in\" em uma parte de components: ele desenha o chanfro com as cores do tema.", + "wb.doctor.css-hide.found": "Esta regra oculta algo com display: none.", + "wb.doctor.css-hide.fix": "Use visible em uma parte de components (avatares, contagens, nomes) ou uma variante de layout como sidebar: hidden; assim o dono pode reativá-la.", + "wb.doctor.css-color.found": "Esta regra usa uma cor literal.", + "wb.doctor.css-color.fix": "Indique um papel (text, muted, accent, surface…) em colors ou em um componente, para que a verificação de contraste o cubra.", + "wb.doctor.css-font.found": "Esta regra define uma família de fonte.", + "wb.doctor.css-font.fix": "Use font.roles: ele define as fontes de posts, títulos, números e monoespaçada sem CSS.", + "wb.doctor.css-has.found": "Esta regra usa :has(), que é avaliado de novo a cada mudança da página.", + "wb.doctor.css-has.fix": "Evite :has() em regras que se repetem ao longo da linha do tempo, ou ancore a regra em uma parte.", + "wb.doctor.css-universal.found": "Esta regra usa um seletor universal (*), comparado com todos os elementos.", + "wb.doctor.css-universal.fix": "Ancore a regra em uma parte.", + "wb.doctor.css-blur.found": "Esta regra desfoca o que está atrás (backdrop-filter), o que é pesado em partes que se repetem.", + "wb.doctor.css-blur.fix": "Use o preenchimento de vidro de barras e painéis: é o lugar mais barato para o desfoque.", + "wb.doctor.css-outline-none.found": "Esta regra remove o contorno de foco, então o foco do teclado deixa de ser visível.", + "wb.doctor.css-outline-none.fix": "Use decor.focusRing para desenhar um anel de foco visível.", + "wb.doctor.css-motion.found": "Esta regra anima sem verificar a preferência por movimento reduzido.", + "wb.doctor.css-motion.fix": "Mantenha o movimento dentro de @media (prefers-reduced-motion: no-preference), ou deixe decor.motion fazer isso por você.", + "wb.doctor.css-size.found": "O CSS tem mais de 20.000 caracteres.", + "wb.doctor.css-size.fix": "O site recalcula os estilos a cada regra; tokens e configurações de componentes são compilados em menos regras.", + "wb.doctor.contrast.found": "A cor {token} foi ajustada para continuar legível ({ratio}:1 sobre o fundo).", + "wb.doctor.contrast.fix": "Escolha uma cor {token} mais clara ou mais escura; até lá o tema é exibido com a ajustada.", + "wb.doctor.glass-post.found": "O vidro está definido nos posts, mas não é desenhado: desfoque em cada post de uma linha do tempo é pesado demais.", + "wb.doctor.glass-post.fix": "Use um preenchimento sólido ou colorido para os posts e deixe o vidro para barras e painéis.", + "wb.doctor.small-post-text.found": "O texto dos posts tem {size}px, o que é difícil de ler para muita gente.", + "wb.doctor.small-post-text.fix": "Use 14px ou mais para o tamanho do texto dos posts, ou aumente o tamanho do texto de todo o tema.", + "wb.doctor.nav-moved.found": "A navegação foi movida para {position}, o que muda onde as pessoas a procuram.", + "wb.doctor.nav-moved.fix": "Isso só vale em painéis largos, e o dono pode desativar mudanças de layout. Mantenha a posição padrão, a menos que o layout precise.", "wb.setup.title": "Compartilhar minha configuração", "wb.setup.hint": "Seu tema, ícones, modo e quais recursos estão ligados, em um link ou um arquivo pequeno. Qualquer pessoa pode usar para começar do que você tem.", "wb.setup.shareLabel": "Sua configuração", diff --git a/packages/waybetter/locales/ru.json b/packages/waybetter/locales/ru.json index fdd3884..ac58246 100644 --- a/packages/waybetter/locales/ru.json +++ b/packages/waybetter/locales/ru.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "Удалить {name}", "wb.appearance.icons.removed": "Набор значков «{name}» удалён.", "wb.appearance.icons.imported": "Импортированные наборы значков", + "wb.doctor.title": "Доктор темы", + "wb.doctor.hint": "Советы по этой теме: более лёгкие способы сделать то же самое, затраты и контраст. Он только советует; ничего не блокируется и не меняется.", + "wb.doctor.empty": "Сообщать не о чем: тема использует токены и настройки компонентов, и ничего ресурсоёмкого в ней нет.", + "wb.doctor.count": "{count, plural, one {# замечание} few {# замечания} many {# замечаний} other {# замечания}}", + "wb.doctor.kind.lighter": "Более лёгкий способ", + "wb.doctor.kind.performance": "Производительность", + "wb.doctor.kind.accessibility": "Доступность", + "wb.doctor.kind.contrast": "Контраст", + "wb.doctor.where": "Где", + "wb.doctor.fix": "Исправление", + "wb.doctor.css-radius.found": "Это правило задаёт радиусы углов в CSS.", + "wb.doctor.css-radius.fix": "Задайте их через radius части в components или через shape.radius для всех сразу: CSS не нужен, и это продолжает работать, когда сайт переименовывает свои классы.", + "wb.doctor.css-bevel.found": "Это правило рисует скошенную кромку наложенными внутренними тенями.", + "wb.doctor.css-bevel.fix": "Используйте borderStyle \"bevel-out\" или \"bevel-in\" у части в components: скос рисуется из цветов темы.", + "wb.doctor.css-hide.found": "Это правило скрывает что-то через display: none.", + "wb.doctor.css-hide.fix": "Используйте visible у части в components (аватары, счётчики, имена) или вариант макета вроде sidebar: hidden; тогда владелец сможет вернуть это обратно.", + "wb.doctor.css-color.found": "Это правило использует конкретный цвет.", + "wb.doctor.css-color.fix": "Укажите роль (text, muted, accent, surface…) в colors или в компоненте, чтобы проверка контраста его учитывала.", + "wb.doctor.css-font.found": "Это правило задаёт семейство шрифтов.", + "wb.doctor.css-font.fix": "Используйте font.roles: он задаёт шрифты постов, заголовков, чисел и моноширинный без CSS.", + "wb.doctor.css-has.found": "Это правило использует :has(), которое заново сопоставляется при каждом изменении страницы.", + "wb.doctor.css-has.fix": "Не используйте :has() в правилах, повторяющихся по всей ленте, или привяжите правило к части.", + "wb.doctor.css-universal.found": "Это правило использует универсальный селектор (*), который сопоставляется с каждым элементом.", + "wb.doctor.css-universal.fix": "Вместо этого привяжите правило к части.", + "wb.doctor.css-blur.found": "Это правило размывает то, что находится позади (backdrop-filter), а это дорого для повторяющихся частей.", + "wb.doctor.css-blur.fix": "Используйте стеклянную заливку панелей и областей: для размытия это самое дешёвое место.", + "wb.doctor.css-outline-none.found": "Это правило убирает контур фокуса, поэтому фокус клавиатуры перестаёт быть виден.", + "wb.doctor.css-outline-none.fix": "Используйте decor.focusRing, чтобы вместо этого нарисовать видимое кольцо фокуса.", + "wb.doctor.css-motion.found": "Это правило анимирует, не проверяя настройку уменьшения движения.", + "wb.doctor.css-motion.fix": "Держите движение внутри @media (prefers-reduced-motion: no-preference) или поручите это decor.motion.", + "wb.doctor.css-size.found": "CSS длиннее 20 000 символов.", + "wb.doctor.css-size.fix": "Сайт пересчитывает стили для каждого правила; токены и настройки компонентов компилируются в меньшее число правил.", + "wb.doctor.contrast.found": "Цвет {token} скорректирован, чтобы оставаться читаемым ({ratio}:1 на фоне).", + "wb.doctor.contrast.fix": "Выберите более светлый или более тёмный цвет {token}; до тех пор тема показывается со скорректированным.", + "wb.doctor.glass-post.found": "Стекло задано для постов, но не рисуется: размытие на каждом посте ленты слишком затратно.", + "wb.doctor.glass-post.fix": "Используйте для постов сплошную или тонированную заливку, а стекло оставьте для панелей и областей.", + "wb.doctor.small-post-text.found": "Текст поста имеет размер {size}px, и многим его трудно читать.", + "wb.doctor.small-post-text.fix": "Используйте для размера текста поста 14px или больше либо увеличьте размер текста всей темы.", + "wb.doctor.nav-moved.found": "Навигация перемещена в положение {position}, из-за чего люди будут искать её в другом месте.", + "wb.doctor.nav-moved.fix": "Это действует только на широких панелях, и владелец может отключить изменения макета. Оставьте положение по умолчанию, если макет не требует иного.", "wb.setup.title": "Поделиться моими настройками", "wb.setup.hint": "Ваша тема, значки, режим и включённые функции — одной ссылкой или одним небольшим файлом. Любой может начать с того, что есть у вас.", "wb.setup.shareLabel": "Ваши настройки", diff --git a/packages/waybetter/locales/th.json b/packages/waybetter/locales/th.json index ada72e2..06ffaa6 100644 --- a/packages/waybetter/locales/th.json +++ b/packages/waybetter/locales/th.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "ลบ {name}", "wb.appearance.icons.removed": "ลบแพ็กไอคอน “{name}” แล้ว", "wb.appearance.icons.imported": "แพ็กไอคอนที่นำเข้า", + "wb.doctor.title": "หมอธีม", + "wb.doctor.hint": "คำแนะนำเกี่ยวกับธีมนี้: วิธีที่เบากว่าในการทำสิ่งเดียวกัน ต้นทุน และคอนทราสต์ ทำหน้าที่แนะนำเท่านั้น ไม่มีอะไรถูกบล็อกหรือเปลี่ยนแปลง", + "wb.doctor.empty": "ไม่มีอะไรต้องรายงาน: ธีมใช้โทเค็นและการตั้งค่าคอมโพเนนต์ และไม่มีอะไรที่สิ้นเปลืองทรัพยากร", + "wb.doctor.count": "{count, plural, other {# ข้อสังเกต}}", + "wb.doctor.kind.lighter": "วิธีที่เบากว่า", + "wb.doctor.kind.performance": "ประสิทธิภาพ", + "wb.doctor.kind.accessibility": "การเข้าถึง", + "wb.doctor.kind.contrast": "คอนทราสต์", + "wb.doctor.where": "ตำแหน่ง", + "wb.doctor.fix": "วิธีแก้", + "wb.doctor.css-radius.found": "กฎนี้กำหนดรัศมีมุมด้วย CSS", + "wb.doctor.css-radius.fix": "กำหนดด้วย radius ของส่วนหนึ่งใต้ components หรือ shape.radius สำหรับทุกส่วน: ไม่ต้องใช้ CSS และยังใช้ได้แม้เว็บไซต์เปลี่ยนชื่อคลาส", + "wb.doctor.css-bevel.found": "กฎนี้วาดขอบเอียงด้วยเงาด้านในซ้อนกัน", + "wb.doctor.css-bevel.fix": "ใช้ borderStyle \"bevel-out\" หรือ \"bevel-in\" กับส่วนหนึ่งใต้ components: ระบบจะวาดขอบเอียงจากสีของธีม", + "wb.doctor.css-hide.found": "กฎนี้ซ่อนบางอย่างด้วย display: none", + "wb.doctor.css-hide.fix": "ใช้ visible กับส่วนหนึ่งใต้ components (อวาตาร์ ตัวนับ ชื่อ) หรือตัวเลือกเลย์เอาต์ เช่น sidebar: hidden เจ้าของจะได้เปิดกลับมาได้", + "wb.doctor.css-color.found": "กฎนี้ใช้สีแบบระบุตรง ๆ", + "wb.doctor.css-color.fix": "ระบุบทบาท (text, muted, accent, surface…) ใน colors หรือในคอมโพเนนต์ เพื่อให้การตรวจคอนทราสต์ครอบคลุม", + "wb.doctor.css-font.found": "กฎนี้กำหนดตระกูลฟอนต์", + "wb.doctor.css-font.fix": "ใช้ font.roles: กำหนดฟอนต์ของโพสต์ หัวข้อ ตัวเลข และ mono ได้โดยไม่ต้องใช้ CSS", + "wb.doctor.css-has.found": "กฎนี้ใช้ :has() ซึ่งจะถูกจับคู่ใหม่ทุกครั้งที่หน้าเปลี่ยน", + "wb.doctor.css-has.fix": "อย่าใช้ :has() กับกฎที่ซ้ำตลอดไทม์ไลน์ หรือผูกกฎกับส่วนหนึ่ง", + "wb.doctor.css-universal.found": "กฎนี้ใช้ตัวเลือกสากล (*) ซึ่งถูกจับคู่กับทุกองค์ประกอบ", + "wb.doctor.css-universal.fix": "ผูกกฎกับส่วนหนึ่งแทน", + "wb.doctor.css-blur.found": "กฎนี้เบลอสิ่งที่อยู่ด้านหลัง (backdrop-filter) ซึ่งสิ้นเปลืองในส่วนที่ซ้ำกันหลายครั้ง", + "wb.doctor.css-blur.fix": "ใช้การเติมแบบกระจกของแถบและแผง: เป็นที่ที่เบลอได้ถูกกว่า", + "wb.doctor.css-outline-none.found": "กฎนี้ลบเส้นขอบโฟกัสออก ทำให้มองไม่เห็นโฟกัสของคีย์บอร์ดอีกต่อไป", + "wb.doctor.css-outline-none.fix": "ใช้ decor.focusRing เพื่อวาดวงแหวนโฟกัสที่มองเห็นได้แทน", + "wb.doctor.css-motion.found": "กฎนี้ทำแอนิเมชันโดยไม่ตรวจสอบการลดการเคลื่อนไหว", + "wb.doctor.css-motion.fix": "เก็บการเคลื่อนไหวไว้ใน @media (prefers-reduced-motion: no-preference) หรือให้ decor.motion จัดการให้", + "wb.doctor.css-size.found": "CSS ยาวเกิน 20,000 ตัวอักษร", + "wb.doctor.css-size.fix": "เว็บไซต์คำนวณสไตล์ใหม่ทุกกฎ โทเค็นและการตั้งค่าคอมโพเนนต์คอมไพล์เป็นกฎที่น้อยกว่า", + "wb.doctor.contrast.found": "สี {token} ถูกปรับเพื่อให้ยังอ่านได้ ({ratio}:1 บนพื้นหลัง)", + "wb.doctor.contrast.fix": "เลือกสี {token} ที่สว่างขึ้นหรือเข้มขึ้น ระหว่างนี้ธีมจะแสดงด้วยสีที่ปรับแล้ว", + "wb.doctor.glass-post.found": "ตั้งค่ากระจกไว้กับโพสต์ แต่ไม่ถูกวาด: การเบลอทุกโพสต์ในไทม์ไลน์สิ้นเปลืองเกินไป", + "wb.doctor.glass-post.fix": "ใช้การเติมสีทึบหรือสีอ่อนกับโพสต์ และเก็บกระจกไว้ใช้กับแถบและแผง", + "wb.doctor.small-post-text.found": "ข้อความโพสต์มีขนาด {size}px ซึ่งอ่านยากสำหรับหลายคน", + "wb.doctor.small-post-text.fix": "ใช้ 14px ขึ้นไปสำหรับขนาดข้อความโพสต์ หรือเพิ่มขนาดข้อความของทั้งธีม", + "wb.doctor.nav-moved.found": "การนำทางถูกย้ายไปที่ {position} ซึ่งเปลี่ยนที่ที่ผู้คนมองหามัน", + "wb.doctor.nav-moved.fix": "ใช้เฉพาะแผงที่กว้าง และเจ้าของปิดการเปลี่ยนเลย์เอาต์ได้ คงตำแหน่งเริ่มต้นไว้ เว้นแต่เลย์เอาต์จำเป็นต้องใช้", "wb.setup.title": "แชร์การตั้งค่าของฉัน", "wb.setup.hint": "ธีม ไอคอน โหมด และฟีเจอร์ที่เปิดอยู่ของคุณ เป็นลิงก์เดียวหรือไฟล์เล็กๆ ไฟล์เดียว ใครก็ใช้เริ่มจากสิ่งที่คุณมีได้", "wb.setup.shareLabel": "การตั้งค่าของคุณ", diff --git a/packages/waybetter/locales/tr.json b/packages/waybetter/locales/tr.json index e0c6dc7..7c368dd 100644 --- a/packages/waybetter/locales/tr.json +++ b/packages/waybetter/locales/tr.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "{name} kaldır", "wb.appearance.icons.removed": "“{name}” simge paketi kaldırıldı.", "wb.appearance.icons.imported": "İçe aktarılan simge paketleri", + "wb.doctor.title": "Tema doktoru", + "wb.doctor.hint": "Bu tema hakkında öneriler: aynı işi yapmanın daha hafif yolları, maliyetler ve kontrast. Yalnızca önerir; hiçbir şey engellenmez ya da değiştirilmez.", + "wb.doctor.empty": "Bildirilecek bir şey yok: tema belirteçleri ve bileşen ayarlarını kullanıyor, içinde maliyetli bir şey yok.", + "wb.doctor.count": "{count, plural, one {# bulgu} other {# bulgu}}", + "wb.doctor.kind.lighter": "Daha hafif bir yol", + "wb.doctor.kind.performance": "Performans", + "wb.doctor.kind.accessibility": "Erişilebilirlik", + "wb.doctor.kind.contrast": "Kontrast", + "wb.doctor.where": "Nerede", + "wb.doctor.fix": "Çözüm", + "wb.doctor.css-radius.found": "Bu kural köşe yarıçaplarını CSS ile ayarlıyor.", + "wb.doctor.css-radius.fix": "Bunları components altındaki bir parçanın radius değeriyle ya da hepsi için shape.radius ile ayarla: CSS gerekmez, site sınıf adlarını değiştirse de çalışmaya devam eder.", + "wb.doctor.css-bevel.found": "Bu kural, üst üste eklenmiş iç gölgelerle eğimli bir kenar çiziyor.", + "wb.doctor.css-bevel.fix": "components altındaki bir parçada borderStyle \"bevel-out\" ya da \"bevel-in\" kullan: eğimi temanın renklerinden çizer.", + "wb.doctor.css-hide.found": "Bu kural bir şeyi display: none ile gizliyor.", + "wb.doctor.css-hide.fix": "components altındaki bir parçada (avatarlar, sayaçlar, adlar) visible kullan ya da sidebar: hidden gibi bir yerleşim varyantı seç; böylece sahibi tekrar açabilir.", + "wb.doctor.css-color.found": "Bu kural sabit bir renk kullanıyor.", + "wb.doctor.css-color.fix": "colors içinde ya da bir bileşende bir rol (text, muted, accent, surface…) belirt; böylece kontrast denetimi onu kapsar.", + "wb.doctor.css-font.found": "Bu kural bir yazı tipi ailesi ayarlıyor.", + "wb.doctor.css-font.fix": "font.roles kullan: gönderi, başlık, sayı ve eş aralıklı yazı tiplerini CSS olmadan ayarlar.", + "wb.doctor.css-has.found": "Bu kural, sayfadaki her değişiklikte yeniden eşleştirilen :has() kullanıyor.", + "wb.doctor.css-has.fix": ":has() değerini zaman akışında tekrar eden kurallarda kullanma ya da kuralı bir parçaya bağla.", + "wb.doctor.css-universal.found": "Bu kural her öğeyle eşleştirilen bir evrensel seçici (*) kullanıyor.", + "wb.doctor.css-universal.fix": "Bunun yerine kuralı bir parçaya bağla.", + "wb.doctor.css-blur.found": "Bu kural arkasındakini bulanıklaştırıyor (backdrop-filter); tekrar eden parçalarda bu maliyetlidir.", + "wb.doctor.css-blur.fix": "Çubukların ve panellerin cam dolgusunu kullan: bulanıklık için en ucuz yer burasıdır.", + "wb.doctor.css-outline-none.found": "Bu kural odak çerçevesini kaldırıyor, böylece klavye odağı görünmez oluyor.", + "wb.doctor.css-outline-none.fix": "Bunun yerine görünür bir odak halkası çizmek için decor.focusRing kullan.", + "wb.doctor.css-motion.found": "Bu kural, hareketi azalt tercihini denetlemeden animasyon yapıyor.", + "wb.doctor.css-motion.fix": "Hareketi @media (prefers-reduced-motion: no-preference) içinde tut ya da bunu decor.motion yapsın.", + "wb.doctor.css-size.found": "CSS 20.000 karakterden uzun.", + "wb.doctor.css-size.fix": "Site her kuralda stilleri yeniden hesaplar; belirteçler ve bileşen ayarları daha az kurala derlenir.", + "wb.doctor.contrast.found": "{token} rengi okunabilir kalması için ayarlandı (arka planda {ratio}:1).", + "wb.doctor.contrast.fix": "Daha açık ya da daha koyu bir {token} rengi seç; o zamana kadar tema ayarlanmış renkle gösterilir.", + "wb.doctor.glass-post.found": "Gönderilerde cam ayarlanmış ama çizilmiyor: bir zaman akışındaki her gönderide bulanıklık çok maliyetli.", + "wb.doctor.glass-post.fix": "Gönderiler için düz ya da renk tonlu bir dolgu kullan, camı çubuklara ve panellere bırak.", + "wb.doctor.small-post-text.found": "Gönderi metni {size}px; bu birçok kişi için okunması zor bir boyut.", + "wb.doctor.small-post-text.fix": "Gönderi metin boyutu için 14px veya daha büyük kullan ya da tüm temanın metin boyutunu artır.", + "wb.doctor.nav-moved.found": "Gezinme {position} konumuna taşınmış; bu, insanların onu nerede aradığını değiştirir.", + "wb.doctor.nav-moved.fix": "Yalnızca geniş bölmelerde geçerlidir ve sahibi yerleşim değişikliklerini kapatabilir. Yerleşim gerektirmedikçe varsayılan konumu koru.", "wb.setup.title": "Kurulumumu paylaş", "wb.setup.hint": "Temanı, simgelerini, modunu ve hangi özelliklerin açık olduğunu tek bir bağlantı ya da küçük bir dosya olarak. Herkes senin kurulumundan başlamak için kullanabilir.", "wb.setup.shareLabel": "Kurulumun", diff --git a/packages/waybetter/locales/vi.json b/packages/waybetter/locales/vi.json index 548ee32..8c07083 100644 --- a/packages/waybetter/locales/vi.json +++ b/packages/waybetter/locales/vi.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "Xóa {name}", "wb.appearance.icons.removed": "Đã xóa gói biểu tượng “{name}”.", "wb.appearance.icons.imported": "Gói biểu tượng đã nhập", + "wb.doctor.title": "Bác sĩ chủ đề", + "wb.doctor.hint": "Lời khuyên về chủ đề này: cách nhẹ hơn để làm cùng một việc, chi phí và độ tương phản. Chỉ đưa ra lời khuyên; không có gì bị chặn hay thay đổi.", + "wb.doctor.empty": "Không có gì để báo cáo: chủ đề dùng token và cài đặt thành phần, và không có gì trong đó tốn kém.", + "wb.doctor.count": "{count, plural, other {# phát hiện}}", + "wb.doctor.kind.lighter": "Một cách nhẹ hơn", + "wb.doctor.kind.performance": "Hiệu năng", + "wb.doctor.kind.accessibility": "Khả năng truy cập", + "wb.doctor.kind.contrast": "Độ tương phản", + "wb.doctor.where": "Ở đâu", + "wb.doctor.fix": "Cách sửa", + "wb.doctor.css-radius.found": "Quy tắc này đặt bán kính góc bằng CSS.", + "wb.doctor.css-radius.fix": "Hãy đặt bằng radius của một phần trong components, hoặc shape.radius cho tất cả: không cần CSS, và vẫn hoạt động khi trang đổi tên class.", + "wb.doctor.css-bevel.found": "Quy tắc này vẽ viền vát bằng các bóng đổ bên trong xếp chồng.", + "wb.doctor.css-bevel.fix": "Dùng borderStyle \"bevel-out\" hoặc \"bevel-in\" cho một phần trong components: viền vát được vẽ từ màu của chủ đề.", + "wb.doctor.css-hide.found": "Quy tắc này ẩn một thứ bằng display: none.", + "wb.doctor.css-hide.fix": "Dùng visible cho một phần trong components (ảnh đại diện, số đếm, tên) hoặc một biến thể bố cục như sidebar: hidden; chủ sở hữu có thể bật lại.", + "wb.doctor.css-color.found": "Quy tắc này dùng một màu cố định.", + "wb.doctor.css-color.fix": "Hãy nêu một vai trò (text, muted, accent, surface…) trong colors hoặc trong một thành phần, để bước kiểm tra độ tương phản bao quát được nó.", + "wb.doctor.css-font.found": "Quy tắc này đặt một họ phông chữ.", + "wb.doctor.css-font.fix": "Dùng font.roles: nó đặt phông chữ cho bài đăng, tiêu đề, số và mono mà không cần CSS.", + "wb.doctor.css-has.found": "Quy tắc này dùng :has(), vốn bị so khớp lại mỗi khi trang thay đổi.", + "wb.doctor.css-has.fix": "Đừng dùng :has() trong các quy tắc lặp lại dọc theo dòng thời gian, hoặc gắn quy tắc vào một phần.", + "wb.doctor.css-universal.found": "Quy tắc này dùng bộ chọn toàn cục (*), bị so khớp với mọi phần tử.", + "wb.doctor.css-universal.fix": "Hãy gắn quy tắc vào một phần thay vào đó.", + "wb.doctor.css-blur.found": "Quy tắc này làm mờ những gì phía sau (backdrop-filter), rất tốn kém với các phần lặp lại.", + "wb.doctor.css-blur.fix": "Dùng lớp nền kính của thanh và bảng: đó là nơi làm mờ rẻ hơn.", + "wb.doctor.css-outline-none.found": "Quy tắc này xóa viền tiêu điểm, nên tiêu điểm bàn phím không còn nhìn thấy được.", + "wb.doctor.css-outline-none.fix": "Hãy dùng decor.focusRing để vẽ vòng tiêu điểm nhìn thấy được.", + "wb.doctor.css-motion.found": "Quy tắc này tạo hoạt ảnh mà không kiểm tra tùy chọn giảm chuyển động.", + "wb.doctor.css-motion.fix": "Giữ chuyển động bên trong @media (prefers-reduced-motion: no-preference), hoặc để decor.motion làm việc đó cho bạn.", + "wb.doctor.css-size.found": "CSS dài hơn 20.000 ký tự.", + "wb.doctor.css-size.fix": "Trang tính lại kiểu cho từng quy tắc; token và cài đặt thành phần được biên dịch thành ít quy tắc hơn.", + "wb.doctor.contrast.found": "Màu {token} đã được điều chỉnh để vẫn dễ đọc ({ratio}:1 trên nền).", + "wb.doctor.contrast.fix": "Hãy chọn màu {token} sáng hơn hoặc tối hơn; cho đến lúc đó chủ đề được hiển thị với màu đã điều chỉnh.", + "wb.doctor.glass-post.found": "Kính được đặt cho bài đăng nhưng không được vẽ: làm mờ trên mọi bài đăng của dòng thời gian quá tốn kém.", + "wb.doctor.glass-post.fix": "Dùng nền đặc hoặc có pha màu cho bài đăng và để dành kính cho thanh và bảng.", + "wb.doctor.small-post-text.found": "Chữ của bài đăng cỡ {size}px, nhiều người khó đọc.", + "wb.doctor.small-post-text.fix": "Dùng 14px trở lên cho cỡ chữ bài đăng, hoặc tăng cỡ chữ của cả chủ đề.", + "wb.doctor.nav-moved.found": "Thanh điều hướng được chuyển sang {position}, làm thay đổi nơi mọi người tìm nó.", + "wb.doctor.nav-moved.fix": "Điều này chỉ áp dụng trên ngăn rộng, và chủ sở hữu có thể tắt các thay đổi bố cục. Hãy giữ vị trí mặc định trừ khi bố cục cần khác.", "wb.setup.title": "Chia sẻ thiết lập của tôi", "wb.setup.hint": "Chủ đề, biểu tượng, chế độ và những tính năng đang bật của bạn, trong một liên kết hoặc một tệp nhỏ. Ai cũng có thể dùng để bắt đầu từ những gì bạn có.", "wb.setup.shareLabel": "Thiết lập của bạn", diff --git a/packages/waybetter/locales/zh-Hant.json b/packages/waybetter/locales/zh-Hant.json index 28a53f0..110dc78 100644 --- a/packages/waybetter/locales/zh-Hant.json +++ b/packages/waybetter/locales/zh-Hant.json @@ -1243,6 +1243,46 @@ "wb.appearance.icons.remove": "移除 {name}", "wb.appearance.icons.removed": "已移除圖示包「{name}」。", "wb.appearance.icons.imported": "已匯入的圖示包", + "wb.doctor.title": "主題醫生", + "wb.doctor.hint": "關於此主題的建議:用更輕量的方式達到相同效果、成本與對比度。它只提供建議,不會封鎖或更改任何內容。", + "wb.doctor.empty": "沒有需要回報的項目:此主題使用了 token 與元件設定,也沒有任何高成本的內容。", + "wb.doctor.count": "{count, plural, other {# 項發現}}", + "wb.doctor.kind.lighter": "更輕量的做法", + "wb.doctor.kind.performance": "效能", + "wb.doctor.kind.accessibility": "無障礙", + "wb.doctor.kind.contrast": "對比度", + "wb.doctor.where": "位置", + "wb.doctor.fix": "修正", + "wb.doctor.css-radius.found": "此規則以 CSS 設定圓角半徑。", + "wb.doctor.css-radius.fix": "請用 components 下某個部件的 radius 來設定,或用 shape.radius 一次套用到全部:不需要 CSS,網站更改類別名稱後也能繼續運作。", + "wb.doctor.css-bevel.found": "此規則以多層內陰影繪製斜角邊緣。", + "wb.doctor.css-bevel.fix": "請在 components 下的部件使用 borderStyle \"bevel-out\" 或 \"bevel-in\":它會依主題的顏色繪製斜角。", + "wb.doctor.css-hide.found": "此規則用 display: none 隱藏了某些內容。", + "wb.doctor.css-hide.fix": "請在 components 下的部件(頭像、數量、名稱)使用 visible,或使用 sidebar: hidden 這類版面變體;擁有者之後可以再把它開啟。", + "wb.doctor.css-color.found": "此規則使用了寫死的顏色。", + "wb.doctor.css-color.fix": "請在 colors 或元件中指定一個角色(text、muted、accent、surface…),讓對比度檢查涵蓋到它。", + "wb.doctor.css-font.found": "此規則設定了字型家族。", + "wb.doctor.css-font.fix": "請使用 font.roles:它不需要 CSS 就能設定貼文、標題、數字與等寬字型。", + "wb.doctor.css-has.found": "此規則使用了 :has(),頁面每次變動都會重新比對。", + "wb.doctor.css-has.fix": "請避免在時間軸中重複出現的規則裡使用 :has(),或將規則錨定在某個部件上。", + "wb.doctor.css-universal.found": "此規則使用了萬用選擇器 (*),會與每個元素進行比對。", + "wb.doctor.css-universal.fix": "請改為將規則錨定在某個部件上。", + "wb.doctor.css-blur.found": "此規則會模糊後方內容 (backdrop-filter),在重複出現的部件上成本很高。", + "wb.doctor.css-blur.fix": "請使用列與面板的玻璃填色:那裡是成本較低的模糊位置。", + "wb.doctor.css-outline-none.found": "此規則移除了焦點外框,使鍵盤焦點不再可見。", + "wb.doctor.css-outline-none.fix": "請改用 decor.focusRing 繪製清楚可見的焦點環。", + "wb.doctor.css-motion.found": "此規則在未檢查「減少動態效果」設定的情況下執行動畫。", + "wb.doctor.css-motion.fix": "請將動態效果放在 @media (prefers-reduced-motion: no-preference) 內,或交給 decor.motion 處理。", + "wb.doctor.css-size.found": "CSS 超過 20,000 個字元。", + "wb.doctor.css-size.fix": "網站會針對每條規則重新計算樣式;token 與元件設定編譯後的規則較少。", + "wb.doctor.contrast.found": "{token} 顏色已經過調整以維持可讀性(與背景的對比為 {ratio}:1)。", + "wb.doctor.contrast.fix": "請選擇較亮或較暗的 {token} 顏色;在此之前,主題會以調整後的顏色顯示。", + "wb.doctor.glass-post.found": "貼文已設定玻璃效果,但不會繪製:對時間軸上每則貼文都做模糊,成本太高。", + "wb.doctor.glass-post.fix": "貼文請使用純色或帶色調的填色,並把玻璃效果留給列與面板。", + "wb.doctor.small-post-text.found": "貼文文字為 {size}px,對許多人來說難以閱讀。", + "wb.doctor.small-post-text.fix": "貼文文字大小請使用 14px 以上,或調大整個主題的文字大小。", + "wb.doctor.nav-moved.found": "導覽列已移到{position},這會改變人們尋找它的位置。", + "wb.doctor.nav-moved.fix": "這只會套用在寬窗格,且擁有者可以關閉版面變更。除非版面需要,否則請保留預設位置。", "wb.setup.title": "分享我的設定", "wb.setup.hint": "你的主題、圖示、模式以及開啟了哪些功能,做成一個連結或一個小檔案。任何人都能用它從你的設定開始。", "wb.setup.shareLabel": "你的設定", diff --git a/packages/waybetter/tests/strings-cli.test.mjs b/packages/waybetter/tests/strings-cli.test.mjs index 762e633..83b2534 100644 --- a/packages/waybetter/tests/strings-cli.test.mjs +++ b/packages/waybetter/tests/strings-cli.test.mjs @@ -78,3 +78,21 @@ test('command: the config, --inventory, usage and the binary', async () => { assert.equal(run.status, 1); assert.match(execFileSync(process.execPath, [BIN, '--help'], { encoding: 'utf8' }), /waybetter strings check/); }); + +test('check: a rewording pack with a language condition is described, and a rich value with its element slots passes', async () => { + const dir = app({}, { when: { languages: ['en'] }, rewrite: { words: { Post: 'Tweet', posts: 'tweets' } } }); + const result = await checkPack(join(dir, 'pack.json'), [join(dir, 'demo.web.inventory.json')]); + assert.equal(result.errors, 0); + const text = result.lines.join('\n'); + assert.match(text, /Applies only while the site shows: en/); + assert.match(text, /Rewords 2 words inside the site's own text: Post, posts/); + const rich = app({ c0000001: 'Legu {e1} antaŭ {e0}.' }); + json(join(rich, 'demo.web.inventory.json'), { format: 1, site: 'demo', catalog: 'web', base: 'en', entries: { c0000001: { kind: 'rich', slots: 2, hash: '00000000004' } } }); + const done = await checkPack(join(rich, 'pack.json'), [join(rich, 'demo.web.inventory.json')]); + assert.equal(done.errors, 0); + assert.match(done.lines.join('\n'), /1 strings: 1 valid, 0 refused/); + const bad = app({ c0000001: 'Legu {e7}.' }); + json(join(bad, 'demo.web.inventory.json'), { format: 1, site: 'demo', catalog: 'web', base: 'en', entries: { c0000001: { kind: 'rich', slots: 2, hash: '00000000004' } } }); + const refused = await checkPack(join(bad, 'pack.json'), [join(bad, 'demo.web.inventory.json')]); + assert.equal(refused.errors, 1); +}); From d40bf273bd6ad76084f58f6fbf85106940ddfc4e Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:22:00 +0700 Subject: [PATCH 07/32] host: the palette commands of site tabs are the host's (tab_commands, tab_run_command) tab_commands keeps the list each site tab reported (validated by plugins::commands, accepted only from a tab on the site's origin), clears it when a new document starts, tells the shell, and checks the shell-only tab_run_command: only a command that tab reported, only while it is on the site. tab_run_command joins commands::SHELL (guard checked by assert_host_guards); the app's tab_report hands its `commands` to tab_commands::reported. Co-Authored-By: Claude Opus 5.5 --- crates/waybetter-host/src/app.rs | 10 ++++ crates/waybetter-host/src/commands.rs | 1 + crates/waybetter-host/src/lib.rs | 2 + crates/waybetter-host/src/tab_commands.rs | 71 +++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 crates/waybetter-host/src/tab_commands.rs diff --git a/crates/waybetter-host/src/app.rs b/crates/waybetter-host/src/app.rs index cb08c9d..7fe3b07 100644 --- a/crates/waybetter-host/src/app.rs +++ b/crates/waybetter-host/src/app.rs @@ -940,6 +940,14 @@ async fn features_set(webview: Webview, app: AppHandle, features: serde_json::Ma set_features(&app, features) } +/// Runs a plugin's palette command in tab `id`: only a command that tab reported, only while it is +/// on the site. The command's code runs in the page; the tab gets keyboard focus for what it opens. +#[tauri::command] +async fn tab_run_command(webview: Webview, app: AppHandle, id: String, command: String) -> Result<(), String> { + shell_only(&webview)?; + crate::tab_commands::run(&app, &id, &command) +} + /// The onboarding mode: what was chosen, whether the first-run screen was answered, and whether /// this app was set up before modes existed. #[tauri::command] @@ -1126,6 +1134,7 @@ fn tab_builder(app: &AppHandle, hooks: &Arc, tab: &NewTab, url: U } let finished = matches!(payload.event(), PageLoadEvent::Finished); if !finished { + crate::tab_commands::cleared(app, tab.label()); load_hooks.page_started(app, &tab); // An engine that resets page zoom on navigation still shows this tab's. host::restore_tab_zoom(app, &tab); @@ -1239,6 +1248,7 @@ fn host_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 's mode_set, settings_get, settings_set, + tab_run_command, tab_shortcut, tab_link_drag, open_panel diff --git a/crates/waybetter-host/src/commands.rs b/crates/waybetter-host/src/commands.rs index de6826d..3b4b620 100644 --- a/crates/waybetter-host/src/commands.rs +++ b/crates/waybetter-host/src/commands.rs @@ -38,6 +38,7 @@ pub const SHELL: &[&str] = &[ "mode_set", "settings_get", "settings_set", + "tab_run_command", ]; /// Tab-only: any tab webview, speaking only about itself. diff --git a/crates/waybetter-host/src/lib.rs b/crates/waybetter-host/src/lib.rs index 17404b5..bbeaad1 100644 --- a/crates/waybetter-host/src/lib.rs +++ b/crates/waybetter-host/src/lib.rs @@ -93,6 +93,8 @@ mod dev_commands; #[cfg(feature = "app")] pub mod theme_commands; #[cfg(feature = "app")] +pub mod tab_commands; +#[cfg(feature = "app")] pub mod alerts_commands; #[cfg(feature = "app")] mod backup_commands; diff --git a/crates/waybetter-host/src/tab_commands.rs b/crates/waybetter-host/src/tab_commands.rs new file mode 100644 index 0000000..34cddb4 --- /dev/null +++ b/crates/waybetter-host/src/tab_commands.rs @@ -0,0 +1,71 @@ +//! The plugin commands in the shell's command palette, native side, for every app: the list each +//! site tab last reported ([`reported`]; validated by [`crate::plugins::commands`]), kept per tab, +//! forwarded to the shell, and the check behind the shell-only `tab_run_command` ([`run`]: only a +//! command that tab reported, only while it is on the site; the command's code runs in the page). + +use crate::app::config; +use crate::host::{emit_shell, tab_webview}; +use crate::plugins::commands::{self as palette, PaletteCommand}; +use serde::Serialize; +use std::collections::HashMap; +use std::sync::{Mutex, MutexGuard, OnceLock}; +use tauri::{AppHandle, Webview}; + +fn lists() -> MutexGuard<'static, HashMap>> { + static LISTS: OnceLock>>> = OnceLock::new(); + LISTS.get_or_init(Default::default).lock().unwrap_or_else(|poisoned| poisoned.into_inner()) +} + +/// Stores what tab `label` has (empty = none) and tells the shell when it changed. +fn store(app: &AppHandle, label: &str, list: Vec) { + let Some(id) = crate::policy::tab_id(label) else { return }; + let changed = { + let mut lists = lists(); + let changed = lists.get(label).map(Vec::as_slice).unwrap_or(&[]) != list.as_slice(); + if list.is_empty() { + lists.remove(label); + } else { + lists.insert(label.to_owned(), list.clone()); + } + changed + }; + if changed { + #[derive(Clone, Serialize)] + struct Commands { + id: String, + commands: Vec, + } + emit_shell(app, palette::EVENT, Commands { id: id.to_owned(), commands: list }); + } +} + +/// A new document started in tab `label`: its plugins register their commands again. +pub(crate) fn cleared(app: &AppHandle, label: &str) { + store(app, label, Vec::new()); +} + +/// A tab reported its commands. Accepted only from a tab that is on the site right now; the list +/// is validated as a whole (any bad entry rejects the report). +pub fn reported(app: &AppHandle, webview: &Webview, list: Vec) -> Result<(), String> { + if !webview.url().is_ok_and(|url| config(app).site.is_origin(&url)) { + return Ok(()); + } + store(app, webview.label(), palette::validate(list)?); + Ok(()) +} + +/// Runs command `command` in tab `id` (the caller checked it is the shell). +pub(crate) fn run(app: &AppHandle, id: &str, command: &str) -> Result<(), String> { + let label = crate::policy::tab_label(id); + if !lists().get(&label).is_some_and(|list| list.iter().any(|item| item.id == command)) { + return Err("VALIDATION: that tab has no such command".into()); + } + let site = config(app).site; + let tab = tab_webview(app, id).ok_or("VALIDATION: no such tab")?; + if !tab.url().is_ok_and(|url| site.is_origin(&url)) { + return Err("VALIDATION: the tab is not on the site".into()); + } + let script = palette::run_script(site, command)?; + let _ = tab.set_focus(); + tab.eval(&script).map_err(|error| format!("TABS: {error}")) +} From 5d19396d89df171fdd535352980646dc222cdae7 Mon Sep 17 00:00:00 2001 From: CRT Date: Thu, 1 Oct 2026 14:23:23 +0700 Subject: [PATCH 08/32] Store: Open With (files the OS hands over) and the icons and builtin catalog kinds Open With: store_commands keeps each existing file the OS hands over (launch argument, a second launch forwarded by single-instance with its working directory, a macOS file:// open-URL) under a random id (Store::receive_file: name says what it is, regular file, size cap, 8 kept, 15 minutes) and queues LinkEvent.opened {id, name, kind}. The shell-only install_stage_opened {id} reads that one file once and stages it exactly like a dropped file; it takes an id only (testkit asserts that), so the shell cannot name a path. The shell shows the same install screen; nothing installs without it. The NSIS template lists the app under "Open with" for the declared extensions (OpenWithProgids) and never makes it the default program, unlike Tauri's own macro. Catalog kinds: icons (an icon pack, *.icons.json, at most 120 KB; validate_icons, staged and committed as text for the shell, the install screen draws every icon, .icons.json is no longer read as a theme) and builtin (a feature the app already has, such as an area plugin: no url, sha256, size or file; never staged; the Store view lists it as Built in with the app's own switch via the areas prop). Rust: Kind, CatalogItem.check, verify_item, install links refuse builtin. JS: storeModel, installController (requestOpened, icons adapter), InstallDialog, StoreView, StoreSection (remove an icon pack, area switches), words. CLI and JSON Schema: kinds, optional url/sha256/size on builtin, icons size cap; the test schema validator learns not and if/then/else. docs/STORE.md. Co-Authored-By: Claude Opus 5.5 --- crates/waybetter-host/src/app.rs | 5 +- crates/waybetter-host/src/commands.rs | 1 + crates/waybetter-host/src/store/catalog.rs | 216 ++++++++++++++- crates/waybetter-host/src/store/install.rs | 254 ++++++++++++++++-- crates/waybetter-host/src/store_commands.rs | 95 ++++++- crates/waybetter-host/src/testkit.rs | 5 + docs/STORE.md | 16 +- .../create-waybetter/tests/jsonSchema.mjs | 7 +- packages/shell/src/InstallDialog.tsx | 34 ++- packages/shell/src/StoreView.tsx | 32 ++- packages/shell/src/installController.ts | 46 +++- packages/shell/src/panel/StoreSection.tsx | 33 +++ packages/shell/src/store.css | 16 ++ packages/shell/src/storeMessages.ts | 24 ++ packages/shell/src/storeModel.ts | 35 ++- packages/shell/tests/openWith.test.ts | 144 ++++++++++ packages/waybetter/cli/store.mjs | 37 ++- packages/waybetter/locales/en.json | 24 ++ packages/waybetter/store-catalog.schema.json | 17 +- packages/waybetter/tests/store-cli.test.mjs | 40 +++ packages/waybetter/windows/installer.nsi | 24 +- 21 files changed, 1015 insertions(+), 90 deletions(-) create mode 100644 packages/shell/tests/openWith.test.ts diff --git a/crates/waybetter-host/src/app.rs b/crates/waybetter-host/src/app.rs index 7fe3b07..cbb5d22 100644 --- a/crates/waybetter-host/src/app.rs +++ b/crates/waybetter-host/src/app.rs @@ -1360,12 +1360,15 @@ impl App { let builder = tauri::Builder::::default() // Must be first: a second launch focuses the running window instead of fighting over // the app's data and WebView profile (and hands over its link). - .plugin(tauri_plugin_single_instance::init(|app, _, _| { + .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { if let Some(window) = app.get_window(policy::MAIN_LABEL) { let _ = window.unminimize(); let _ = window.show(); let _ = window.set_focus(); } + // A double-click or "Open with" on a file while the app runs: its path arrives here. + #[cfg(feature = "net")] + crate::store_commands::opened_args(app, &_args, &_cwd); })); // Install links (after single-instance, which forwards a second launch's link). let builder = if config.deep_link { builder.plugin(tauri_plugin_deep_link::init()) } else { builder }; diff --git a/crates/waybetter-host/src/commands.rs b/crates/waybetter-host/src/commands.rs index 3b4b620..82e6346 100644 --- a/crates/waybetter-host/src/commands.rs +++ b/crates/waybetter-host/src/commands.rs @@ -55,6 +55,7 @@ pub const STORE: &[&str] = &[ "install_pending", "install_stage_link", "install_stage_file", + "install_stage_opened", "install_cancel", "install_commit", "plugin_remove", diff --git a/crates/waybetter-host/src/store/catalog.rs b/crates/waybetter-host/src/store/catalog.rs index 2b9afd6..9c1ab8f 100644 --- a/crates/waybetter-host/src/store/catalog.rs +++ b/crates/waybetter-host/src/store/catalog.rs @@ -20,6 +20,8 @@ pub const DEFAULT_HOSTS: &[AllowedHost] = &[ /// The catalog format this code reads. Format 2: every item names the apps it is for (`apps`). pub const CATALOG_FORMAT: u32 = 2; pub const MAX_THEME_BYTES: usize = 2 * 1024 * 1024; +/// An icon pack file (the runtime's `ICON_LIMITS.packBytes`). +pub const MAX_ICONS_BYTES: usize = 120_000; pub const MAX_CATALOG_BYTES: usize = 1024 * 1024; pub const MAX_SIGNATURE_BYTES: usize = 512; pub const MAX_LINK_CHARS: usize = 2048; @@ -61,6 +63,11 @@ pub enum Kind { Plugin, /// A string pack: data that replaces the site's own UI strings (`store::strings`). Strings, + /// An icon pack (`*.icons.json`): path data and small drawings, never code. + Icons, + /// Catalog only: a feature that ships inside the app (an area plugin). The Store lists it as + /// built in with its switch; there is nothing to download, stage or install. + Builtin, } impl Kind { @@ -69,7 +76,9 @@ impl Kind { "theme" => Ok(Kind::Theme), "plugin" => Ok(Kind::Plugin), "strings" => Ok(Kind::Strings), - _ => Err("VALIDATION: kind must be \"theme\", \"plugin\" or \"strings\"".into()), + "icons" => Ok(Kind::Icons), + "builtin" => Ok(Kind::Builtin), + _ => Err("VALIDATION: kind must be \"theme\", \"plugin\", \"strings\", \"icons\" or \"builtin\"".into()), } } @@ -78,6 +87,8 @@ impl Kind { Kind::Theme => "theme", Kind::Plugin => "plugin", Kind::Strings => "strings", + Kind::Icons => "icons", + Kind::Builtin => "builtin", } } @@ -86,6 +97,8 @@ impl Kind { Kind::Theme => MAX_THEME_BYTES, Kind::Plugin => MAX_PLUGIN_BYTES as usize, Kind::Strings => super::strings::MAX_STRINGS_BYTES, + Kind::Icons => MAX_ICONS_BYTES, + Kind::Builtin => 0, } } } @@ -163,7 +176,10 @@ pub fn parse_install_link(config: &StoreConfig, link: &str) -> Result Result { }) } +/// What the confirmation screen shows about an icon pack (the shell parses the rest and draws it). +#[derive(Clone, Debug, PartialEq, Eq, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct IconsInfo { + pub id: String, + pub name: String, + pub author: String, + pub license: String, + pub glyphs: usize, +} + +/// An icon pack file: at most [`MAX_ICONS_BYTES`], UTF-8 JSON, an object with an `id` +/// (`[a-z0-9-]{1,40}`), a non-empty `name` and a `glyphs` object. It is data: the shell's own +/// sanitizer (`parseIconPackJson`) keeps only valid path data and small drawings. +pub fn validate_icons(bytes: &[u8]) -> Result { + if bytes.is_empty() { + return Err("VALIDATION: the icon pack file is empty".into()); + } + if bytes.len() > MAX_ICONS_BYTES { + return Err("VALIDATION: icon packs are limited to 120 KB".into()); + } + let text = std::str::from_utf8(bytes).map_err(|_| "VALIDATION: an icon pack must be UTF-8 JSON")?; + let value: serde_json::Value = serde_json::from_str(text.trim_start_matches('\u{feff}')).map_err(|_| "VALIDATION: this file is not valid JSON")?; + let object = value.as_object().ok_or("VALIDATION: an icon pack is a JSON object")?; + let id = object.get("id").and_then(serde_json::Value::as_str).unwrap_or_default(); + if !valid_id(id) { + return Err("VALIDATION: an icon pack needs an \"id\" of lowercase letters, digits and dashes".into()); + } + let name = short(object.get("name"), 60); + if name.trim().is_empty() { + return Err("VALIDATION: an icon pack needs a \"name\"".into()); + } + let glyphs = object.get("glyphs").and_then(serde_json::Value::as_object).map(|glyphs| glyphs.len()).unwrap_or(0); + if glyphs == 0 { + return Err("VALIDATION: an icon pack needs a \"glyphs\" object with at least one icon".into()); + } + Ok(IconsInfo { id: id.to_owned(), name, author: short(object.get("author"), 60), license: short(object.get("license"), 60), glyphs }) +} + +/// What a file name says it is: `.plugin.js` a plugin, `.strings.json` a string pack, +/// `.icons.json` an icon pack, any other `.json` a theme; anything else nothing. +pub fn kind_for_file_name(name: &str) -> Option { + let lower = name.to_ascii_lowercase(); + if lower.ends_with(plugins::PLUGIN_SUFFIX) { + Some(Kind::Plugin) + } else if lower.ends_with(".strings.json") { + Some(Kind::Strings) + } else if lower.ends_with(".icons.json") { + Some(Kind::Icons) + } else if lower.ends_with(".json") { + Some(Kind::Theme) + } else { + None + } +} + /// Validates a plugin for installation (see `plugins::validate_plugin`). pub fn validate_plugin(file: &str, bytes: &[u8]) -> Result { plugins::validate_plugin(file, bytes) @@ -279,11 +351,15 @@ pub struct CatalogItem { pub category: String, #[serde(default)] pub tags: Vec, + /// Where the file is (every kind but `builtin`, which has nothing to download). + #[serde(default, skip_serializing_if = "String::is_empty")] pub url: String, /// Plugins: the file name it is installed under. #[serde(default, skip_serializing_if = "Option::is_none")] pub file: Option, + #[serde(default, skip_serializing_if = "String::is_empty")] pub sha256: String, + #[serde(default, skip_serializing_if = "is_zero")] pub size: u64, #[serde(default, skip_serializing_if = "Option::is_none")] pub preview: Option, @@ -321,6 +397,10 @@ impl Catalog { } } +fn is_zero(value: &u64) -> bool { + *value == 0 +} + fn valid_id(id: &str) -> bool { !id.is_empty() && id.len() <= 40 && id.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-') } @@ -358,9 +438,22 @@ impl CatalogItem { if self.tags.len() > 12 || self.tags.iter().any(|tag| !valid_text(tag, 32)) { return bad("tags"); } - let url = Url::parse(&self.url).map_err(|_| format!("STORE: item {}: invalid url", self.id))?; - if url.scheme() != "https" || url.as_str().len() > MAX_LINK_CHARS || hosts.is_some_and(|hosts| !allowed_download_url(hosts, &url)) { - return bad("url (host not allowed)"); + if self.kind == Kind::Builtin { + // Part of the app: nothing to download, so nothing to hash or point at. + if !self.url.is_empty() || !self.sha256.is_empty() || self.size != 0 || self.file.is_some() || self.permissions.is_some() || self.colors.is_some() || self.language.is_some() { + return bad("built-in item fields"); + } + } else { + let url = Url::parse(&self.url).map_err(|_| format!("STORE: item {}: invalid url", self.id))?; + if url.scheme() != "https" || url.as_str().len() > MAX_LINK_CHARS || hosts.is_some_and(|hosts| !allowed_download_url(hosts, &url)) { + return bad("url (host not allowed)"); + } + if self.sha256.len() != 64 || !self.sha256.bytes().all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase()) { + return bad("sha256"); + } + if self.size == 0 || self.size > self.kind.max_bytes() as u64 { + return bad("size"); + } } if let Some(preview) = &self.preview { let ok = Url::parse(preview).is_ok_and(|url| url.scheme() == "https" && hosts.is_none_or(|hosts| allowed_download_url(hosts, &url))); @@ -368,12 +461,6 @@ impl CatalogItem { return bad("preview"); } } - if self.sha256.len() != 64 || !self.sha256.bytes().all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase()) { - return bad("sha256"); - } - if self.size == 0 || self.size > self.kind.max_bytes() as u64 { - return bad("size"); - } // Any item may name its licence and credit its authors; only a string pack has a language. if !self.license.as_deref().is_none_or(|v| !v.trim().is_empty() && valid_text(v, 60)) || !self.credits.as_deref().is_none_or(|v| valid_text(v, 600)) { return bad("license or credits"); @@ -393,6 +480,12 @@ impl CatalogItem { } } } + Kind::Icons => { + if self.file.is_some() || self.permissions.is_some() || self.colors.is_some() { + return bad("icon pack fields"); + } + } + Kind::Builtin => {} Kind::Strings => { if self.file.is_some() || self.permissions.is_some() || self.colors.is_some() { return bad("string pack fields"); @@ -473,6 +566,9 @@ pub fn verify_catalog(config: &StoreConfig, body: &[u8], signature: &str) -> Res /// A downloaded item must be exactly what the signed catalog describes. pub fn verify_item(item: &CatalogItem, bytes: &[u8]) -> Result<(), String> { + if item.kind == Kind::Builtin { + return Err("STORE: built-in items are part of the app; there is nothing to download".into()); + } if bytes.len() as u64 != item.size { return Err("STORE: the download's size does not match the signed catalog".into()); } @@ -795,6 +891,104 @@ pub(crate) mod tests { assert!(verify_catalog(c, &body, &sign(&key, &body)).unwrap_err().contains("update the app")); } + const ICONS: &[u8] = br#"{"id":"line-2","name":"Line 2","author":"me","license":"CC0-1.0","glyphs":{"home":{"d":"M3 3h18v18H3z"}}}"#; + + fn icons_item(body: &[u8]) -> serde_json::Value { + serde_json::json!({ + "apps": ["x"], "kind": "icons", "id": "line-2", "name": "Line 2", "version": "1.0.0", "category": "icons", + "url": "https://waybetter.fyi/store/icons/line-2.icons.json", "sha256": sha256_hex(body), "size": body.len(), "license": "CC0-1.0" + }) + } + + fn builtin_item() -> serde_json::Value { + serde_json::json!({ "apps": ["x"], "kind": "builtin", "id": "compose", "name": "Compose+", "version": "1.0.0", "description": "Writing tools.", "category": "writing" }) + } + + #[test] + fn icon_packs_and_built_in_items_are_catalog_kinds() { + let (key, public) = test_key(7); + let c = config("x", &[public]); + let body = catalog_json(serde_json::json!([icons_item(ICONS), builtin_item()])); + let catalog = verify_catalog(c, &body, &sign(&key, &body)).unwrap(); + assert_eq!(catalog.items.iter().map(|item| item.kind).collect::>(), [Kind::Icons, Kind::Builtin]); + verify_item(&catalog.items[0], ICONS).unwrap(); + assert!(verify_item(&catalog.items[0], b"{}").is_err()); + assert!(verify_item(&catalog.items[1], b"").unwrap_err().contains("built-in"), "nothing to download for a built-in item"); + // A built-in item serializes without file fields (the signed bytes stay what the builder wrote). + let json = serde_json::to_value(&catalog.items[1]).unwrap(); + for field in ["url", "sha256", "size", "file"] { + assert!(json.get(field).is_none(), "{field}"); + } + // Built-in items carry no file, hash, size, url, permissions, colors or language; icon packs no plugin or theme fields. + let mut cases: Vec<(&str, serde_json::Value)> = Vec::new(); + for (what, patch) in [ + ("url", serde_json::json!({ "url": "https://waybetter.fyi/a" })), + ("sha256", serde_json::json!({ "sha256": sha256_hex(b"x") })), + ("size", serde_json::json!({ "size": 5 })), + ("file", serde_json::json!({ "file": "a.plugin.js" })), + ("permissions", serde_json::json!({ "permissions": ["ui"] })), + ("language", serde_json::json!({ "language": "eo" })), + ("colors", serde_json::json!({ "colors": { "bg": "#000000", "text": "#ffffff", "accent": "#ff0000" } })), + ] { + let mut item = builtin_item(); + for (k, v) in patch.as_object().unwrap() { + item[k] = v.clone(); + } + cases.push((what, item)); + } + for (what, patch) in [("file", serde_json::json!({ "file": "a.plugin.js" })), ("permissions", serde_json::json!({ "permissions": ["ui"] })), ("language", serde_json::json!({ "language": "eo" }))] { + let mut item = icons_item(ICONS); + for (k, v) in patch.as_object().unwrap() { + item[k] = v.clone(); + } + cases.push((what, item)); + } + let mut no_url = icons_item(ICONS); + no_url.as_object_mut().unwrap().remove("url"); + cases.push(("icon pack without url", no_url)); + let mut big = icons_item(ICONS); + big["size"] = serde_json::json!(MAX_ICONS_BYTES + 1); + cases.push(("icon pack over the cap", big)); + for (what, item) in cases { + let body = catalog_json(serde_json::json!([item])); + assert!(verify_catalog(c, &body, &sign(&key, &body)).is_err(), "accepted bad {what}"); + } + // Another app's built-in items are not this app's. + let mut other = builtin_item(); + other["apps"] = serde_json::json!(["kick"]); + let body = catalog_json(serde_json::json!([other])); + assert!(verify_catalog(c, &body, &sign(&key, &body)).unwrap().items.is_empty()); + // Links and the shell's kind names: icons yes, built-in never. + assert_eq!(parse_install_link(c, "waybetter://install?kind=icons&url=https://waybetter.fyi/store/icons/line-2.icons.json").unwrap().kind, Kind::Icons); + assert!(parse_install_link(c, "waybetter://install?kind=builtin&url=https://waybetter.fyi/a.json").unwrap_err().contains("built-in")); + } + + #[test] + fn icon_packs_are_small_json_objects_with_an_id_a_name_and_glyphs() { + let info = validate_icons(ICONS).unwrap(); + assert_eq!((info.id.as_str(), info.name.as_str(), info.license.as_str(), info.glyphs), ("line-2", "Line 2", "CC0-1.0", 1)); + for bad in [ + &b""[..], b"[]", b"{not json", br#"{"name":"A","glyphs":{"home":{}}}"#, br#"{"id":"Bad Id","name":"A","glyphs":{"home":{}}}"#, + br#"{"id":"a","glyphs":{"home":{}}}"#, br#"{"id":"a","name":"A"}"#, br#"{"id":"a","name":"A","glyphs":{}}"#, + ] { + assert!(validate_icons(bad).is_err(), "accepted {}", String::from_utf8_lossy(bad)); + } + let big = format!(r#"{{"id":"a","name":"A","glyphs":{{"home":{{"d":"{}"}}}}}}"#, "M".repeat(MAX_ICONS_BYTES)); + assert!(validate_icons(big.as_bytes()).unwrap_err().contains("120 KB")); + } + + #[test] + fn file_names_say_what_a_file_is() { + assert_eq!(kind_for_file_name("tool.plugin.js"), Some(Kind::Plugin)); + assert_eq!(kind_for_file_name("TOOL.PLUGIN.JS"), Some(Kind::Plugin)); + assert_eq!(kind_for_file_name("eo.strings.json"), Some(Kind::Strings)); + assert_eq!(kind_for_file_name("line.icons.json"), Some(Kind::Icons), "not a theme"); + assert_eq!(kind_for_file_name("nord.json"), Some(Kind::Theme)); + for other in ["script.js", "photo.png", "notes.txt", "json", ""] { + assert_eq!(kind_for_file_name(other), None, "{other}"); + } + } + #[test] fn versions_compare_numerically() { assert!(newer_version("1.10.0", "1.9.3")); diff --git a/crates/waybetter-host/src/store/install.rs b/crates/waybetter-host/src/store/install.rs index ba988ff..e6f22b0 100644 --- a/crates/waybetter-host/src/store/install.rs +++ b/crates/waybetter-host/src/store/install.rs @@ -4,12 +4,13 @@ //! and passes a function that runs a plugin start/stop script in its site tabs. use super::catalog::{ - self as dist, Catalog, CatalogItem, InstallLink, InstallRecord, InstallRecords, Kind, SourceKind, StoreConfig, ThemeInfo, + self as dist, Catalog, CatalogItem, IconsInfo, InstallLink, InstallRecord, InstallRecords, Kind, SourceKind, StoreConfig, ThemeInfo, }; use super::strings::{self as packs, StringsInfo, StringsList, StringsStore}; -use crate::plugins::{self, PluginHost, PluginStore, ScriptPlugin, PLUGIN_SUFFIX}; +use crate::plugins::{self, PluginHost, PluginStore, ScriptPlugin}; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, VecDeque}; +use std::io::Read; use std::path::{Path, PathBuf}; use std::sync::{Mutex, MutexGuard}; use std::time::{Duration, Instant}; @@ -20,7 +21,8 @@ pub const RECORDS_FILE: &str = "store-installed.json"; /// The last verified catalog and its signature (verified again when read back). pub const CATALOG_CACHE: &str = "store-catalog.json"; pub const CATALOG_SIG_CACHE: &str = "store-catalog.json.sig"; -/// Shell event: a validated install link (`{ link: { kind, url } }`), a "Share my setup" link +/// Shell event: a validated install link (`{ link: { kind, url } }`), a file the OS handed over +/// ("Open with", double-click: `{ opened: { id, name, kind } }`), a "Share my setup" link /// (`{ setup }`: its text, for the shell's preview) or `{ error }`. pub const EVENT_LINK: &str = "install-link"; /// "Share my setup" links: `waybetter://setup?app=…&d=…`. Native code only checks the shape and @@ -31,6 +33,8 @@ const MAX_SETUP_LINK: usize = 24 * 1024; /// Links received before the shell asked for them (startup, or while the shell reloads). const MAX_PENDING: usize = 8; const MAX_STAGED: usize = 8; +/// Files the OS handed over that the shell has not asked for yet. +const MAX_OPENED: usize = 8; const STAGED_TTL: Duration = Duration::from_secs(15 * 60); /// The confirmation screen enables Install after a moment; a commit faster than this was not read. pub const MIN_REVIEW: Duration = Duration::from_millis(600); @@ -47,6 +51,19 @@ pub struct LinkEvent { /// A "Share my setup" link, as text (see [`SETUP_LINK`]). #[serde(skip_serializing_if = "Option::is_none")] pub setup: Option, + /// A file the OS handed to the app; the shell asks for it by `id` (`install_stage_opened`). + #[serde(skip_serializing_if = "Option::is_none")] + pub opened: Option, +} + +/// A file the OS handed to the app. Only its random id, its name and what it would be reach the +/// shell; the path stays in native code and the shell cannot name a path of its own. +#[derive(Clone, Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct OpenedFile { + pub id: String, + pub name: String, + pub kind: Kind, } /// `Some` when `raw` is a setup link: its text when it has the plain shape (the path, a query of @@ -97,6 +114,8 @@ pub struct InstallPreview { pub theme: Option, /// String packs: what the pack says about itself (the shell adds coverage from the inventory). pub strings: Option, + /// Icon packs: what the pack says about itself (the shell parses and draws the rest). + pub icons: Option, pub findings: Vec<&'static str>, pub existing: Option, pub store: Option, @@ -112,6 +131,8 @@ pub struct InstallOutcome { pub theme_text: Option, /// String packs: the installed packs after installing. pub strings: Option, + /// Icon packs: the exact JSON the owner confirmed; the shell adds it (sanitized) to its packs. + pub icons_text: Option, } #[derive(Clone, Debug, Serialize)] @@ -161,8 +182,16 @@ struct CatalogCache { fetched_at: String, } +struct Opened { + path: PathBuf, + name: String, + kind: Kind, + created: Instant, +} + struct Inner { pending: VecDeque, + opened: HashMap, staged: HashMap, catalog: Option, records: InstallRecords, @@ -202,7 +231,7 @@ impl Store { config, plugins, data_dir, - inner: Mutex::new(Inner { pending: VecDeque::new(), staged: HashMap::new(), catalog: None, records }), + inner: Mutex::new(Inner { pending: VecDeque::new(), opened: HashMap::new(), staged: HashMap::new(), catalog: None, records }), } } @@ -242,14 +271,19 @@ impl Store { /// A link reached the app (OS deep link, second launch): validate it and queue it for the /// shell. Returns the event to emit ([`EVENT_LINK`]). Nothing is downloaded or installed here. pub fn receive_link(&self, raw: &str) -> LinkEvent { - let event = match setup_link(raw) { - Some(Ok(text)) => LinkEvent { link: None, error: None, setup: Some(text) }, - Some(Err(error)) => LinkEvent { link: None, error: Some(error), setup: None }, + let mut event = LinkEvent { link: None, error: None, setup: None, opened: None }; + match setup_link(raw) { + Some(Ok(text)) => event.setup = Some(text), + Some(Err(error)) => event.error = Some(error), None => match dist::parse_install_link(self.config, raw) { - Ok(link) => LinkEvent { link: Some(link), error: None, setup: None }, - Err(error) => LinkEvent { link: None, error: Some(error), setup: None }, + Ok(link) => event.link = Some(link), + Err(error) => event.error = Some(error), }, - }; + } + self.queue(event) + } + + fn queue(&self, event: LinkEvent) -> LinkEvent { let mut inner = self.lock(); if inner.pending.len() >= MAX_PENDING { inner.pending.pop_front(); @@ -258,6 +292,62 @@ impl Store { event } + /// A file the OS handed over (a double-click or "Open with", at launch or to the running app): + /// check its name and size, keep its path under a random id and queue the event for the shell. + /// The file is read only when the shell asks ([`Self::stage_opened`]), and what it shows is the + /// install screen: nothing is written without the owner's Install there. + pub fn receive_file(&self, path: &Path) -> LinkEvent { + let mut event = LinkEvent { link: None, error: None, setup: None, opened: None }; + match self.keep_opened(path) { + Ok(opened) => event.opened = Some(opened), + Err(error) => event.error = Some(error), + } + self.queue(event) + } + + fn keep_opened(&self, path: &Path) -> Result { + let name = path.file_name().and_then(|name| name.to_str()).ok_or("FILE: this file's name cannot be read")?.to_owned(); + let kind = dist::kind_for_file_name(&name) + .ok_or("FILE: only a theme (.json), a plugin (.plugin.js), a string pack (.strings.json) or an icon pack (.icons.json) can be opened here")?; + let meta = std::fs::metadata(path).map_err(|_| "FILE: this file cannot be read")?; + if !meta.is_file() { + return Err("FILE: this is not a file".into()); + } + if meta.len() > kind.max_bytes() as u64 { + return Err("FILE: the file is larger than allowed".into()); + } + let id = new_token(); + let mut inner = self.lock(); + inner.opened.retain(|_, opened| opened.created.elapsed() < STAGED_TTL); + while inner.opened.len() >= MAX_OPENED { + let oldest = inner.opened.iter().min_by_key(|(_, opened)| opened.created).map(|(id, _)| id.clone()); + match oldest { + Some(id) => inner.opened.remove(&id), + None => break, + }; + } + inner.opened.insert(id.clone(), Opened { path: path.to_path_buf(), name: name.clone(), kind, created: Instant::now() }); + Ok(OpenedFile { id, name, kind }) + } + + /// Reads the file kept under `id` (single use) and stages it like a dropped file. + pub fn stage_opened(&self, id: &str) -> Result { + let opened = self.lock().opened.remove(id).filter(|opened| opened.created.elapsed() < STAGED_TTL); + let Some(opened) = opened else { + return Err("INSTALL: this file is no longer waiting; open it again".into()); + }; + let max = opened.kind.max_bytes(); + let mut bytes = Vec::new(); + std::fs::File::open(&opened.path) + .and_then(|file| file.take(max as u64 + 1).read_to_end(&mut bytes)) + .map_err(|_| "FILE: this file cannot be read")?; + if bytes.len() > max { + return Err("VALIDATION: the file is larger than allowed".into()); + } + let file = (opened.kind == Kind::Plugin).then(|| opened.name.clone()); + self.stage(opened.kind, file, bytes, SourceKind::File, None, None) + } + /// Links that arrived before the shell listened (drained). pub fn take_pending(&self) -> Vec { self.lock().pending.drain(..).collect() @@ -270,7 +360,7 @@ impl Store { let link = dist::parse_install_link(self.config, &dist::install_link(self.config, kind, url))?; let file = match kind { Kind::Plugin => Some(dist::plugin_file_from_url(&Url::parse(&link.url).map_err(|_| "VALIDATION: invalid URL")?)?), - Kind::Theme | Kind::Strings => None, + Kind::Theme | Kind::Strings | Kind::Icons | Kind::Builtin => None, }; Ok((link, file)) } @@ -291,6 +381,7 @@ impl Store { } let text = String::from_utf8(bytes.clone()).map_err(|_| "VALIDATION: not UTF-8 text")?; let mut strings = None; + let mut icons = None; let (plugin, theme, findings, version, existing) = match kind { Kind::Plugin => { let file = file.as_deref().ok_or("VALIDATION: missing plugin file name")?; @@ -325,6 +416,18 @@ impl Store { let version = store.as_ref().map(|item| item.version.clone()).unwrap_or_default(); (None, Some(info), Vec::new(), version, None) } + Kind::Icons => { + let info = dist::validate_icons(&bytes)?; + let version = store.as_ref().map(|item| item.version.clone()).unwrap_or_default(); + let existing = inner.records.items.get(&InstallRecords::key(Kind::Icons, &info.id)).map(|record| Existing { + version: record.version.clone(), + enabled: false, + same: record.sha256 == dist::sha256_hex(&bytes), + }); + icons = Some(info); + (None, None, Vec::new(), version, existing) + } + Kind::Builtin => return Err("VALIDATION: built-in items are part of the app; there is nothing to install".into()), }; let label = match source { SourceKind::Store => "wayBetter Store (signed catalog, sha256 verified)".to_owned(), @@ -345,6 +448,7 @@ impl Store { plugin, theme, strings, + icons, findings, existing, store: store.clone(), @@ -367,16 +471,9 @@ impl Store { /// A file dropped on the window (the shell read it with the File API; validated here). pub fn stage_file(&self, name: &str, text: String) -> Result { - let lower = name.to_ascii_lowercase(); - let (kind, file) = if lower.ends_with(PLUGIN_SUFFIX) { - (Kind::Plugin, Some(name.to_owned())) - } else if lower.ends_with(".strings.json") { - (Kind::Strings, None) - } else if lower.ends_with(".json") { - (Kind::Theme, None) - } else { - return Err("VALIDATION: drop a theme (.json), a plugin (.plugin.js) or a string pack (.strings.json)".into()); - }; + let kind = dist::kind_for_file_name(name) + .ok_or("VALIDATION: drop a theme (.json), a plugin (.plugin.js), a string pack (.strings.json) or an icon pack (.icons.json)")?; + let file = (kind == Kind::Plugin).then(|| name.to_owned()); if text.len() > kind.max_bytes() { return Err("VALIDATION: the file is larger than allowed".into()); } @@ -449,7 +546,7 @@ impl Store { store.set_enabled(&file, true)?; run(&script); } - Ok(InstallOutcome { kind: Kind::Plugin, plugins: Some(store.list()?), theme_text: None, strings: None }) + Ok(InstallOutcome { kind: Kind::Plugin, plugins: Some(store.list()?), theme_text: None, strings: None, icons_text: None }) } Kind::Strings => { let info = packs::validate_strings(&staged.bytes)?; @@ -460,7 +557,7 @@ impl Store { let records = inner.records.clone(); drop(inner); self.save_records(&records); - Ok(InstallOutcome { kind: Kind::Strings, plugins: None, theme_text: None, strings: Some(local.list()) }) + Ok(InstallOutcome { kind: Kind::Strings, plugins: None, theme_text: None, strings: Some(local.list()), icons_text: None }) } Kind::Theme => { let id = theme_id.filter(|id| valid_theme_id(id)).ok_or("VALIDATION: invalid theme id")?; @@ -469,8 +566,18 @@ impl Store { drop(inner); self.save_records(&records); let text = String::from_utf8(staged.bytes).map_err(|_| "VALIDATION: not UTF-8")?; - Ok(InstallOutcome { kind: Kind::Theme, plugins: None, theme_text: Some(text), strings: None }) + Ok(InstallOutcome { kind: Kind::Theme, plugins: None, theme_text: Some(text), strings: None, icons_text: None }) } + Kind::Icons => { + let info = dist::validate_icons(&staged.bytes)?; + inner.records.insert(InstallRecords::key(Kind::Icons, &info.id), record(staged.version.clone())); + let records = inner.records.clone(); + drop(inner); + self.save_records(&records); + let text = String::from_utf8(staged.bytes).map_err(|_| "VALIDATION: not UTF-8")?; + Ok(InstallOutcome { kind: Kind::Icons, plugins: None, theme_text: None, strings: None, icons_text: Some(text) }) + } + Kind::Builtin => Err("INSTALL: built-in items are part of the app".into()), } } @@ -741,6 +848,105 @@ mod tests { assert!(store.commit(&other.token, true, Some("other".into()), |_| {}).is_err()); } + const ICONS: &str = r#"{"id":"line-2","name":"Line 2","author":"me","license":"CC0-1.0","glyphs":{"home":{"d":"M3 3h18v18H3z"}}}"#; + + #[test] + fn icon_packs_install_as_text_for_the_shell_and_are_never_themes() { + let (_dir, store, _, _) = store_with_catalog(); + assert!(store.stage_file("bad.icons.json", r#"{"name":"A"}"#.into()).unwrap_err().contains("id"), "an icon pack is not read as a theme"); + let dropped = store.stage_file("line-2.icons.json", ICONS.into()).unwrap(); + assert_eq!(dropped.kind, Kind::Icons); + assert_eq!(dropped.icons.as_ref().map(|info| (info.id.as_str(), info.glyphs)), Some(("line-2", 1))); + assert!(dropped.plugin.is_none() && dropped.theme.is_none() && !dropped.source.signed); + reviewed(); + let outcome = store.commit(&dropped.token, false, None, |_| panic!("icon packs run nothing")).unwrap(); + assert_eq!((outcome.kind, outcome.icons_text.as_deref()), (Kind::Icons, Some(ICONS))); + assert!(outcome.theme_text.is_none() && outcome.plugins.is_none()); + assert_eq!(store.records().items["icons:line-2"].source, SourceKind::File); + // Staging the same pack again says it is installed; forgetting it clears the record. + let again = store.stage_file("line-2.icons.json", ICONS.into()).unwrap(); + assert!(again.existing.as_ref().is_some_and(|existing| existing.same)); + store.forget("icons", "line-2").unwrap(); + assert!(store.records().items.is_empty()); + assert!(store.stage_file("big.icons.json", format!(r#"{{"id":"a","name":"A","glyphs":{{"home":{{"d":"{}"}}}}}}"#, "M".repeat(dist::MAX_ICONS_BYTES))).unwrap_err().contains("larger")); + } + + #[test] + fn built_in_items_have_nothing_to_stage() { + let (_dir, store, _, _) = store_with_catalog(); + let entry: CatalogItem = serde_json::from_value(serde_json::json!({ "apps": ["x"], "kind": "builtin", "id": "compose", "name": "Compose+", "version": "1.0.0" })).unwrap(); + assert!(store.stage_store_download(entry, Vec::new()).unwrap_err().contains("built-in")); + assert!(store.stage(Kind::Builtin, None, b"{}".to_vec(), SourceKind::File, None, None).unwrap_err().contains("built-in")); + } + + #[test] + fn files_the_os_hands_over_are_kept_under_an_id_and_staged_like_a_drop() { + let (dir, store, _, _) = store_with_catalog(); + let theme = dir.path().join("nord.json"); + std::fs::write(&theme, THEME).unwrap(); + let event = store.receive_file(&theme); + let opened = event.opened.clone().expect("a theme file is offered"); + assert_eq!((opened.name.as_str(), opened.kind), ("nord.json", Kind::Theme)); + assert!(event.link.is_none() && event.error.is_none() && event.setup.is_none()); + // The shell sees an id and a name, never the path. + let wire = serde_json::to_string(&event).unwrap(); + assert!(!wire.contains("path") && !wire.contains(dir.path().file_name().unwrap().to_str().unwrap()), "{wire}"); + assert_eq!(store.take_pending().len(), 1, "queued for a shell that was not listening yet"); + let preview = store.stage_opened(&opened.id).unwrap(); + assert_eq!((preview.kind, preview.source.kind.clone()), (Kind::Theme, SourceKind::File)); + assert_eq!(preview.theme.as_ref().unwrap().name, "Nord"); + reviewed(); + let outcome = store.commit(&preview.token, true, Some("nord-3".into()), |_| {}).unwrap(); + assert_eq!(outcome.theme_text.as_deref().map(str::as_bytes), Some(THEME)); + // Single use, and an id the OS did not hand over is refused (the shell cannot name a path). + assert!(store.stage_opened(&opened.id).unwrap_err().contains("no longer waiting")); + assert!(store.stage_opened("../nord.json").unwrap_err().contains("no longer waiting")); + assert!(store.stage_opened(&theme.to_string_lossy()).is_err()); + + // A plugin keeps its file name; an icon pack and a string pack are told apart from a theme. + let plugin = dir.path().join("tool.plugin.js"); + std::fs::write(&plugin, PLUGIN).unwrap(); + let opened = store.receive_file(&plugin).opened.unwrap(); + let preview = store.stage_opened(&opened.id).unwrap(); + assert_eq!((preview.kind, preview.file.as_deref()), (Kind::Plugin, Some("tool.plugin.js"))); + let pack = dir.path().join("line-2.icons.json"); + std::fs::write(&pack, ICONS).unwrap(); + assert_eq!(store.receive_file(&pack).opened.unwrap().kind, Kind::Icons); + let strings = dir.path().join("eo.strings.json"); + std::fs::write(&strings, "{}").unwrap(); + assert_eq!(store.receive_file(&strings).opened.unwrap().kind, Kind::Strings); + + // Refused up front, with an error for the shell: other files, folders, missing and oversize files. + let other = dir.path().join("photo.png"); + std::fs::write(&other, "x").unwrap(); + let big = dir.path().join("big.json"); + std::fs::write(&big, vec![b'a'; dist::MAX_THEME_BYTES + 1]).unwrap(); + for bad in [other, big, dir.path().to_path_buf(), dir.path().join("missing.json")] { + let event = store.receive_file(&bad); + assert!(event.opened.is_none() && event.error.as_deref().is_some_and(|error| error.starts_with("FILE:")), "{}: {:?}", bad.display(), event.error); + } + // A file that grew after it was offered is refused when read; one that vanished says so. + let late = dir.path().join("late.json"); + std::fs::write(&late, THEME).unwrap(); + let opened = store.receive_file(&late).opened.unwrap(); + std::fs::write(&late, vec![b'a'; dist::MAX_THEME_BYTES + 1]).unwrap(); + assert!(store.stage_opened(&opened.id).unwrap_err().contains("larger")); + let gone = dir.path().join("gone.json"); + std::fs::write(&gone, THEME).unwrap(); + let opened = store.receive_file(&gone).opened.unwrap(); + std::fs::remove_file(&gone).unwrap(); + assert!(store.stage_opened(&opened.id).unwrap_err().starts_with("FILE:")); + // Bounded: only the newest ones are kept. + let ids: Vec = (0..MAX_OPENED + 3) + .map(|_| { + std::thread::sleep(Duration::from_millis(2)); + store.receive_file(&theme).opened.unwrap().id + }) + .collect(); + assert_eq!(store.lock().opened.len(), MAX_OPENED); + assert!(store.stage_opened(&ids[0]).is_err() && store.stage_opened(ids.last().unwrap()).is_ok()); + } + #[test] fn staging_is_bounded() { let (_dir, store, _, _) = store_with_catalog(); diff --git a/crates/waybetter-host/src/store_commands.rs b/crates/waybetter-host/src/store_commands.rs index 8eae406..136146b 100644 --- a/crates/waybetter-host/src/store_commands.rs +++ b/crates/waybetter-host/src/store_commands.rs @@ -13,6 +13,7 @@ use crate::host::{emit_shell, eval_in_site_tabs, shell_only}; use crate::plugins::ScriptPlugin; use crate::policy; use crate::store::{delivery_script, InstallOutcome, InstallPreview, InstallRecords, LinkEvent, Store, StoreItemRef, StoreView, StringsList, EVENT_LINK}; +use std::path::{Path, PathBuf}; use tauri::{AppHandle, Manager, State, Webview}; use tauri_plugin_deep_link::DeepLinkExt; @@ -40,18 +41,63 @@ pub(crate) fn init(app: &AppHandle, config: &AppConfig) { received(app, url.as_str()); } } + // Launched by a double-click or "Open with" on a file (Windows/Linux pass its path as an argument). + let args: Vec = std::env::args().collect(); + opened_args(app, &args, ""); +} + +/// Most files taken from one launch's arguments. +const MAX_OPENED_ARGS: usize = 8; + +/// The files named in a launch's arguments (the first launch's own, or a second launch forwarded +/// by single-instance, with its working directory): flags and links are not files and are skipped; +/// each file that exists is kept under a random id and offered to the shell +/// ([`Store::receive_file`]), and the window comes forward. Nothing is read or installed here. +pub(crate) fn opened_args(app: &AppHandle, args: &[String], cwd: &str) { + let paths = file_args(args, cwd); + if paths.is_empty() { + return; + } + let Some(store) = app.try_state::() else { return }; + for path in paths { + emit_shell(app, EVENT_LINK, store.receive_file(&path)); + } + bring_forward(app); +} + +/// The existing files among a launch's arguments (the first argument is the program itself). +fn file_args(args: &[String], cwd: &str) -> Vec { + args.iter() + .skip(1) + .filter(|arg| !arg.starts_with('-') && !arg.contains("://")) + .map(|arg| if Path::new(arg).is_absolute() || cwd.is_empty() { PathBuf::from(arg) } else { Path::new(cwd).join(arg) }) + .filter(|path| path.is_file()) + .take(MAX_OPENED_ARGS) + .collect() +} + +fn bring_forward(app: &AppHandle) { + if let Some(window) = app.get_window(policy::MAIN_LABEL) { + let _ = window.unminimize(); + let _ = window.show(); + let _ = window.set_focus(); + } } /// A `waybetter://` link reached the app: validate it, queue it for the shell and bring the window /// forward. Nothing is downloaded or installed until the shell's screen asks for it. fn received(app: &AppHandle, raw: &str) { let Some(store) = app.try_state::() else { return }; - emit_shell(app, EVENT_LINK, store.receive_link(raw)); - if let Some(window) = app.get_window(policy::MAIN_LABEL) { - let _ = window.unminimize(); - let _ = window.show(); - let _ = window.set_focus(); - } + // macOS hands a double-clicked file over as an open-URL event with a `file://` URL. + let event = match url::Url::parse(raw).ok().filter(|url| url.scheme() == "file") { + Some(url) => match url.to_file_path() { + Ok(path) => store.receive_file(&path), + Err(()) => store.receive_file(Path::new("")), + }, + None => store.receive_link(raw), + }; + emit_shell(app, EVENT_LINK, event); + bring_forward(app); } fn store(app: &AppHandle) -> Result, String> { @@ -83,6 +129,15 @@ pub(crate) async fn install_stage_file(webview: Webview, app: AppHandle, name: S store(&app)?.stage_file(&name, text) } +/// A file the OS handed to the app (a double-click or "Open with"), asked for by the random id the +/// `install-link` event carried: native code reads it and stages it exactly like a dropped file, +/// for the same install screen. The shell never supplies a path; an unknown id is refused. +#[tauri::command] +pub(crate) async fn install_stage_opened(webview: Webview, app: AppHandle, id: String) -> Result { + shell_only(&webview)?; + store(&app)?.stage_opened(&id) +} + #[tauri::command] pub(crate) async fn install_cancel(webview: Webview, app: AppHandle, token: String) -> Result<(), String> { shell_only(&webview)?; @@ -189,6 +244,7 @@ pub(crate) fn handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Sen install_pending, install_stage_link, install_stage_file, + install_stage_opened, install_cancel, install_commit, plugin_remove, @@ -203,3 +259,30 @@ pub(crate) fn handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Sen strings_apply ] } + +#[cfg(test)] +mod tests { + use super::*; + + fn args(list: &[&str]) -> Vec { + list.iter().map(|arg| (*arg).to_owned()).collect() + } + + #[test] + fn launch_arguments_name_files_never_flags_or_links() { + let dir = std::env::temp_dir().join(format!("wb-opened-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let theme = dir.join("nord.json"); + std::fs::write(&theme, "{}").unwrap(); + let absolute = theme.to_string_lossy().into_owned(); + let found = file_args(&args(&["wayBetter.exe", "--diag", "waybetter://install?kind=theme&url=https://waybetter.fyi/a.json", "file:///x.json", "missing.json", &absolute]), ""); + assert_eq!(found, [theme.clone()], "the program, flags, links and missing files are skipped"); + // A second launch's relative name is resolved against its own working directory. + let found = file_args(&args(&["wayBetter.exe", "nord.json"]), &dir.to_string_lossy()); + assert_eq!(found, [dir.join("nord.json")]); + assert!(file_args(&args(&["wayBetter.exe", &dir.to_string_lossy()]), "").is_empty(), "a folder is not a file"); + let many: Vec = std::iter::once("wayBetter.exe".to_owned()).chain((0..20).map(|_| absolute.clone())).collect(); + assert_eq!(file_args(&many, "").len(), MAX_OPENED_ARGS); + std::fs::remove_dir_all(&dir).unwrap(); + } +} diff --git a/crates/waybetter-host/src/testkit.rs b/crates/waybetter-host/src/testkit.rs index e2c1fa7..169feb4 100644 --- a/crates/waybetter-host/src/testkit.rs +++ b/crates/waybetter-host/src/testkit.rs @@ -217,6 +217,11 @@ pub fn assert_store_guards() { for command in commands::STORE { assert_guarded(source, command, "shell_only(&webview)?"); } + // A file the OS handed over is asked for by its random id: the command takes no path, so the + // shell cannot make native code read a file of its own choosing. + let at = source.find("fn install_stage_opened(").expect("install_stage_opened exists"); + let signature = &source[at..at + source[at..].find(')').expect("signature")]; + assert!(signature.contains("id: String") && !signature.contains("path") && !signature.contains("PathBuf"), "install_stage_opened takes an id only: {signature}"); } /// The media commands' wrappers check their caller first. Runs against the host's source. diff --git a/docs/STORE.md b/docs/STORE.md index 58273ac..d0e7d59 100644 --- a/docs/STORE.md +++ b/docs/STORE.md @@ -34,16 +34,20 @@ JSON Schema: `waybetter/store-catalog.schema.json` (npm package). The rules apps | --- | --- | | `format` | `2`. An app that reads another format says "update the app". Format 1 (before `apps`) is gone. | | `apps` | 1–16 distinct app ids (`[a-z0-9-]{1,32}`), e.g. `"x"`; an item for several apps lists each. | -| `kind`, `id` | `theme`, `plugin` or `strings` (a string pack, docs/STRING-PACKS.md); `[a-z0-9-]{1,40}`, unique per app and kind. | +| `kind`, `id` | `theme`, `plugin`, `strings` (a string pack, docs/STRING-PACKS.md), `icons` (an icon pack, `*.icons.json`: data, at most 120 KB, its own `id` is what it is installed under) or `builtin` (a feature that ships inside the app, below); `[a-z0-9-]{1,40}`, unique per app and kind. | | `name`, `author`, `version`, `description`, `category`, `tags` | plain text (no control characters), ≤ 60 / 60 / 32 / 600 / 32 characters, ≤ 12 tags of ≤ 32. Known categories show in the reader's language (`wb.store.category.*`). | | `url`, `preview` | https; for the reading app's own items, on its download hosts (below). | | `file` | plugins only: `name.plugin.js` (letters, digits, `-_. `), unique per app ignoring case. | -| `sha256`, `size` | of the exact file; size 1 byte … 2 MiB. | +| `url`, `sha256`, `size` | of the exact file; size 1 byte … 2 MiB (icon packs 120 KB). Absent on a `builtin` item, which has nothing to download and must not carry them. | | `permissions` | plugins only: the header's `@permissions` (`null` = no line, legacy). | | `colors` | themes only: `#rrggbb` swatches for the card. | | `language` | string packs only, required: the pack's language tag. | | `license`, `credits` | any kind, optional: its licence (≤ 60 characters, e.g. an SPDX id) and who made, translated or reviewed it (≤ 600). The install screen shows them. | +**Built-in items.** `builtin` lists something the app already has, such as one of its area plugins, so the Store can show it with the app's own switch (`StoreView`'s `areas` prop: whether the app has that id, whether it is on, turning it on or off). It has no `url`, `sha256`, `size`, `file`, `permissions`, `colors` or `language`; `Store::stage_*` refuses it, `verify_item` has nothing to verify, and an install link cannot name it. It is data for display only. An app that does not know the id just shows "Built in". + +**Old apps.** An app from before a kind existed refuses the whole signed catalog that lists it (unknown kind: "catalog schema", the Store shows as unreachable). Publish a catalog with a new kind only once the apps that read it ship the kind. + Also refused: unknown fields anywhere, more than 500 items, a catalog over 1 MiB, a signature file over 512 bytes. A malformed item for another app refuses the whole catalog (one file, one set of rules); another app's download hosts are not held to this app's list. @@ -95,6 +99,12 @@ end in `name.plugin.js`, the name it is saved under. A link only proposes an ins for the shell (`install-link` event, `install_pending` for links that arrived before the shell listened) and nothing is downloaded until the shell asks. +## Open with, double-click + +The OS can hand the app a file ("Open with", a double-click, a second launch while the app runs: single-instance forwards its arguments and working directory; macOS an open-URL event with a `file://` URL). `store_commands` keeps each existing file's path under a random id (`Store::receive_file`: a name that says what it is, `kind_for_file_name`, a regular file, within the kind's size cap; at most 8 kept, 15 minutes) and queues a `LinkEvent { opened: { id, name, kind } }` for the shell like a link. The shell asks for it with `install_stage_opened {id}`: native code reads that one file (once; size checked again while reading), validates it exactly as `stage_file` does and stages it, and the shell shows the same install screen as for a dropped file. The command takes an id only: the shell cannot name a path, and an id the OS did not hand over is refused. Nothing installs without the screen. File names: `.plugin.js` plugin, `.strings.json` string pack, `.icons.json` icon pack, any other `.json` a theme. + +The app declares the types in `tauri.conf.json` (`bundle.fileAssociations`: `js` and `json`, role Viewer, rank Alternate). A plugin is `name.plugin.js` and Windows only knows the last part, so the framework's installer template (`windows/installer.nsi`) lists the app under "Open with" (`OpenWithProgids`) and never makes it the default program for `.js` or `.json` files, unlike Tauri's own association macro. + ## Trust model - Only the app's local shell webview may call the install commands; site tabs and web pages never @@ -128,7 +138,7 @@ pub static STORE: StoreConfig = StoreConfig { Commands, each starting with `shell_only(&webview)?` and listed only in the shell's capability: `install_pending` → `take_pending`, `install_stage_link {kind,url}` → `stage_link`, -`install_stage_file {name,text}` → `stage_file`, `install_cancel {token}` → `cancel`, +`install_stage_file {name,text}` → `stage_file`, `install_stage_opened {id}` → `stage_opened` (a file the OS handed over, by its random id), `install_cancel {token}` → `cancel`, `install_commit {token,enable,themeId}` → `commit(…, run)` where `run` evaluates a plugin start/stop script in the site's tabs, `plugin_remove {file}` → `remove_plugin`, `install_records` → `records`, `install_forget {kind,name}` → `forget`, `store_catalog {refresh}` → `catalog`, diff --git a/packages/create-waybetter/tests/jsonSchema.mjs b/packages/create-waybetter/tests/jsonSchema.mjs index fc1e667..fec27b5 100644 --- a/packages/create-waybetter/tests/jsonSchema.mjs +++ b/packages/create-waybetter/tests/jsonSchema.mjs @@ -1,6 +1,6 @@ // A small JSON Schema (draft 2020-12) validator for the keywords theme.schema.json uses: type, // required, properties, additionalProperties, enum, const, pattern, min/maxLength, minimum, -// maximum, items, minItems, maxItems, uniqueItems, allOf, oneOf, anyOf and local $ref (theme and +// maximum, items, minItems, maxItems, uniqueItems, allOf, oneOf, anyOf, not, if/then/else and local $ref (theme and // store catalog schemas). Returns a list of error paths. const typeOf = value => (value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value); @@ -50,5 +50,10 @@ export function validate(schema, value, root = schema, path = '$') { if (passing !== 1) errors.push(`${path}: matches ${passing} of oneOf (needs exactly 1)`); } if (schema.anyOf && !schema.anyOf.some(option => validate(option, value, root, path).length === 0)) errors.push(`${path}: matches none of anyOf`); + if (schema.not && validate(schema.not, value, root, path).length === 0) errors.push(`${path}: matches a schema it must not match`); + if (schema.if) { + const branch = validate(schema.if, value, root, path).length === 0 ? schema.then : schema.else; + if (branch) errors.push(...validate(branch, value, root, path)); + } return errors; } diff --git a/packages/shell/src/InstallDialog.tsx b/packages/shell/src/InstallDialog.tsx index 8799364..bd8e5b5 100644 --- a/packages/shell/src/InstallDialog.tsx +++ b/packages/shell/src/InstallDialog.tsx @@ -7,6 +7,7 @@ import { useEffect, useRef, useState, useSyncExternalStore, type KeyboardEvent, type ReactNode } from 'react'; import { createPortal } from 'react-dom'; +import { GlyphPaths } from './frame/iconPack.tsx'; import type { InstallController, InstallRequest } from './installController.ts'; import type { StoreText } from './storeMessages.ts'; import { formatBytes, permissionBadges, previewLines, type InstallKind, type InstallPreview } from './storeModel.ts'; @@ -57,6 +58,7 @@ const G = { warn: 'M12 4l9 16H3zM12 10v4M12 17h.01', copy: 'M9 9h10v10H9zM5 15V5h10', close: 'M6 6l12 12M18 6L6 18', + icons: 'M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM17 14v6M14 17h6', strings: 'M4 5h9M8.5 3v2M11 5c-.8 3.8-3.4 6.6-7 8M6.5 8.5c1.1 1.6 2.7 3 4.5 3.8M13 21l4-9 4 9M14.4 18h5.2', }; @@ -101,25 +103,27 @@ function Ready({ request, props }: { request: Extract { const timer = setTimeout(() => setArmed(true), REVIEW_MS); return () => clearTimeout(timer); }, [preview.token]); const strings = preview.kind === 'strings' ? preview.strings ?? null : null; const summary = strings ? props.stringsSummary?.(preview.text) ?? null : null; - const name = plugin?.name ?? facts?.name ?? preview.theme?.name ?? strings?.name ?? t('wb.install.untitled'); - const author = plugin?.author || facts?.author || preview.theme?.author || strings?.authors.join(', ') || ''; + const pack = preview.kind === 'icons' ? request.pack ?? null : null; + const icons = preview.kind === 'icons' ? preview.icons ?? null : null; + const name = plugin?.name ?? facts?.name ?? preview.theme?.name ?? strings?.name ?? pack?.name ?? icons?.name ?? t('wb.install.untitled'); + const author = plugin?.author || facts?.author || preview.theme?.author || strings?.authors.join(', ') || pack?.author || icons?.author || ''; const version = preview.version || preview.store?.version || ''; const updating = preview.existing && !preview.existing.same; const verb = preview.existing?.same ? t('wb.install.reinstall') : updating || ready?.replaces ? t('wb.install.update') : t('wb.store.install'); const step = preview.existing?.same ? 'reinstall' : updating || ready?.replaces ? 'update' : 'install'; - const eyebrow = preview.kind === 'strings' ? t(`wb.install.eyebrow.strings.${step}`) : t(`wb.install.eyebrow.${step}`, { kind: preview.kind }); + const eyebrow = preview.kind === 'strings' ? t(`wb.install.eyebrow.strings.${step}`) : preview.kind === 'icons' ? t(`wb.install.eyebrow.icons.${step}`) : t(`wb.install.eyebrow.${step}`, { kind: preview.kind }); const badges = preview.kind === 'plugin' ? permissionBadges(plugin?.permissions, t, site) : []; const installing = request.status === 'installing'; - const description = plugin?.description || facts?.description || strings?.description; + const description = plugin?.description || facts?.description || strings?.description || pack?.description; return <>
- +
{eyebrow} @@ -184,13 +188,27 @@ function Ready({ request, props }: { request: Extract 0 &&
{t('wb.install.strings.sample')}{summary.sample.map(text => {text})}
}
} + {pack &&
+

{t('wb.install.icons.dataOnly')}

+
+ {pack.license} + {t('wb.install.icons.countValue', { count: Object.keys(pack.glyphs).length })} + {pack.source && {pack.source}} + {pack.credits && {pack.credits}} +
+ + {(ready?.warnings.length ?? 0) > 0 &&
    {ready!.warnings.map(warning =>
  • {warning}
  • )}
} +
} + {theme !== null &&
{props.renderThemePreview?.(theme)} {(ready?.warnings.length ?? 0) > 0 &&
    {ready!.warnings.map(warning =>
  • {warning}
  • )}
}
} {facts?.css ? : null} - +