Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/issue-462-card-marks.change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
实例卡片标记改成细框、无底色,ADB 改成字母 A;鼠标操作不再出现焦点框;名称提示不再写编号
Card marks get thin frames, ADB is the letter A, focus rings are keyboard-only, and the name tooltip drops the index.
60 changes: 36 additions & 24 deletions internal/ui/web/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* the focus ring only for keyboard use (html.kbd, set in app.js): WebView2 focuses a dialog's first control on open and gives\n the focus back to the opener on close, which a mouse user saw as an error frame. :where keeps the specificity of the old\n global rule, so the rules below that turn it off still win. */
:where(html.kbd) :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-tint-2); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
Expand Down Expand Up @@ -332,7 +333,7 @@ button { -webkit-tap-highlight-color: transparent; }
/* the 开机失败 / 新建失败 label of a card: it opens 问题反馈 at the task */
.pill-link { cursor: pointer; }
.pill-link:hover { box-shadow: inset 0 0 0 1px var(--td); }
.pill-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
html.kbd .pill-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }


.bar { position: relative; height: 4px; border-radius: 2px; background: var(--bar-track); overflow: hidden; }
Expand Down Expand Up @@ -393,7 +394,7 @@ button { -webkit-tap-highlight-color: transparent; }
}
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--seg-on); color: var(--text); box-shadow: var(--shadow-seg); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
html.kbd .seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.checkbox { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; user-select: none; }
.checkbox input {
Expand All @@ -403,7 +404,7 @@ button { -webkit-tap-highlight-color: transparent; }
}
.checkbox input:checked { background: var(--accent-text) var(--tick) center / 14px no-repeat; border-color: var(--accent-text); }
.checkbox.danger input:checked { background-color: var(--danger); background-image: var(--tick-w); border-color: var(--danger); }
.checkbox input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
html.kbd .checkbox input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- header ----------------------------------------------------------------------------------------------- */

Expand All @@ -422,7 +423,7 @@ button { -webkit-tap-highlight-color: transparent; }
.brand-link { display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: default; }
.brand-link:not(:disabled) { cursor: pointer; border-radius: 7px; }
.brand-link:not(:disabled):hover .brand-name { text-decoration: underline; }
.brand-link:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 3px; }
html.kbd .brand-link:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 3px; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.brand-ver {
padding: 2px 8px; border-radius: 6px; background: var(--ver-bg);
Expand Down Expand Up @@ -615,33 +616,37 @@ button { -webkit-tap-highlight-color: transparent; }
.grid:not(.is-list) .card-meta .act-more { width: 18px; height: 18px; border-radius: 5px; }
/* Marks after the instance name in the card's title line: one rule for all of them, kept in cards.js next to where they are
built (the same text is there).
Every mark is a single-glyph block: 18px square, with exactly one capital letter (10px cap height, 4px above and 4px
below at 1x) or one 12px icon (3px around it) in it. No words and no second letter; what a mark means goes in its
Every mark is a single glyph in an 18px cell with a 1px --line-2 frame (inset box-shadow, radius 5px) and no background colour: exactly one capital
letter (14px, 600, 10px cap height, 4px above and below at 1x) or one icon in it, whose ink is 10px too (y 4–14). The colour is --text-2
(--tf for the adb tag and for a proxy mark in tone-warn / tone-err). The two marks that are buttons (cat head, A) darken their frame to --text-3 on hover. No words and no second letter; what a mark means goes in its
title and aria-label. Today: cat head = 按应用走代理, G = Google Play 商店,
K = KernelSU, monitor with a slash = 无头 (headless).
K = KernelSU, monitor with a slash = 无头 (headless), A = copy the ADB address.
Always-there marks come first, marks that follow the run state come last, so one appearing never pushes the others.
In the card view they are at the right end of the title line. The card view does not write 运行中 or 已关机 (the
screen and the power button say it): the status label shows only for the states in between and the failed ones, and
for the other two it is for screen readers only (.pill-quiet).
The card view is the title and one config line: a new state is another single-glyph block or a hover text, not a word
The card view is the title and one config line: a new state is another single glyph or a hover text, not a word
and not a line. The cat head is the only mark that is a button (it opens the proxy dialog) and the only one that
can have a state colour (--tb / --tf from .tone-*), and only when something is wrong (tone-warn, tone-err): while the
can have a state colour (--tf from .tone-*; the icon only, never a background), and only when something is wrong (tone-warn, tone-err): while the
proxy works it looks like the others; the others are static. */
.pmark, .smark, .kmark, .hmark {
display: inline-flex; align-items: center; justify-content: center; flex: none;
width: 18px; height: 18px; padding: 0; border: 0; border-radius: 5px;
background: var(--sunken); color: var(--text-2);
background: none; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-2);
}
.pmark { cursor: pointer; }
.pmark.tone-warn, .pmark.tone-err { background: var(--tb); color: var(--tf); }
.pmark:hover { box-shadow: inset 0 0 0 1px var(--td, var(--text-3)); }
.pmark:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pmark .ic, .hmark .ic { width: 12px; height: 12px; }
.smark, .kmark { font-size: 13px; font-weight: 600; line-height: 1; }
.pmark.tone-warn, .pmark.tone-err { color: var(--tf); }
.pmark:hover { box-shadow: inset 0 0 0 1px var(--text-3); } /* the two marks that are buttons: the frame darkens on hover */
html.kbd .pmark:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* every mark is 10px of ink (the capital height of the 14px letters), y 4–14 of the 18px box: the monitor drawing is 12.5px tall at 16px,
so it is drawn at 12.83px; the cat head is 11.04px tall at 16px, so it is drawn at 14.5px (the same centre). */
.pmark .ic { width: 14.5px; height: 14.5px; }
.hmark .ic { width: 12.83px; height: 12.83px; }
.smark, .kmark { font-size: 14px; font-weight: 600; line-height: 1; }
/* A letter is centred on its capitals, not on its line box: the font leaves more room above the capitals than below the
baseline, so a flex-centred G sat 1.5px low. font-size-adjust fixes the capital height at 10px whatever the font
baseline, so a flex-centred G sat low. font-size-adjust fixes the capital height at 10px whatever the font
(a 14px size scaled to cap-height 10/14), text-box trims the line to cap height and baseline, and the 4px padding
leaves 4px below. The two marks become blocks because text-box does not reach the anonymous box inside a flex
leaves 4px below. The two letters become blocks (the A of the ADB tag is the same, in its own rule below) because text-box does not reach the anonymous box inside a flex
container. A browser without either property keeps the flex centring above. */
@supports (text-box: trim-both cap alphabetic) and (font-size-adjust: cap-height 0.7) {
.smark, .kmark {
Expand All @@ -656,12 +661,19 @@ button { -webkit-tap-highlight-color: transparent; }

.adb-tag {
display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; padding: 0;
border: 0; border-radius: 5px;
background: var(--tb); color: var(--tf);
border: 0; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--line-2);
background: none; color: var(--tf); font-family: inherit;
cursor: pointer;
font-size: 14px; font-weight: 600; line-height: 1;
}
@supports (text-box: trim-both cap alphabetic) and (font-size-adjust: cap-height 0.7) {
.adb-tag {
display: block; text-align: center;
font-size-adjust: cap-height 0.7143;
text-box: trim-both cap alphabetic; /* a button centres its 10px of cap height itself: 4px above and below, so no padding-top here */
}
}
.adb-tag .ic { width: 12px; height: 12px; }
.adb-tag:hover { box-shadow: inset 0 0 0 1px var(--td); }
.adb-tag:hover { box-shadow: inset 0 0 0 1px var(--text-3); }
.adb { display: none; }
.adb-addr { color: var(--text-2); white-space: nowrap; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }

Expand Down Expand Up @@ -804,7 +816,7 @@ dialog > .toasts .toast.out { animation-name: toast-out-left; }
}
.menu-item > .ic { color: var(--text-3); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
html.kbd .menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.menu-item[aria-disabled="true"] { color: var(--text-3); opacity: .55; cursor: default; }
.menu-item[aria-disabled="true"]:hover { background: transparent; }
.menu-item.danger, .menu-item.danger > .ic { color: var(--err); }
Expand Down Expand Up @@ -1006,7 +1018,7 @@ fieldset.keymap-profiles { border: 0; padding: 0; margin: 0 0 16px; min-width: 0
.group::before { content: ""; margin-bottom: -1px; }
.group + .group { margin-top: 8px; }
.row { padding: 10px 12px; border-top: 1px solid var(--line); }
.group .row:focus-visible, .fold-head:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
html.kbd .group .row:focus-visible, html.kbd .fold-head:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.row-title { min-width: 0; color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
/* what a row found and what to do: all of it (an item that did not pass says what to do, and that is the point of the
row); a passed item, folded away in 其余 N 项已通过, keeps to three lines */
Expand Down
6 changes: 6 additions & 0 deletions internal/ui/web/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ if (!themeParam) {
// before the locale is read

// ---- wiring
// the focus ring is for the keyboard only (html.kbd): WebView2 focuses a dialog's first control on open and gives the focus
// back on close, which looked like an error frame to a mouse user. Tab, the arrows, Enter, Space and Escape turn it on, a pointer turns it off.
const NAV_KEYS = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown', 'Enter', ' ', 'Escape']);
addEventListener('keydown', (e) => { if (NAV_KEYS.has(e.key)) document.documentElement.classList.add('kbd'); }, true);
addEventListener('pointerdown', () => document.documentElement.classList.remove('kbd'), true);

initUI();
initGrid($('grid'));
// ---- 卡片 / 列表 (?view= for screenshots, not remembered)
Expand Down
18 changes: 10 additions & 8 deletions internal/ui/web/js/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ function makeCard(i) {
h('div', { class: 'prog' }, h('div', { class: 'prog-row' }, h('span', { class: 'spin' }), c.progMsg), c.progBar),
c.peek);
c.title = h('h2', { class: 'card-title', id: `card-t-${i}` });
// The marks after the instance name are single-glyph blocks. The rule (the styles are in app.css, with the same text):
// - A mark is an 18px square with exactly one capital letter (10px cap height, 4px above and 4px below at 1x) or one
// 12px icon in it. No words, no second letter; what it means goes in its title and aria-label.
// The marks after the instance name are single glyphs, with no box behind them. The rule (the styles are in app.css, with the same text):
// - A mark is an 18px cell with a 1px --line-2 frame (inset box-shadow, radius 5px) and no background colour, with exactly one capital
// letter (14px, weight 600, 10px cap height, 4px above and below at 1x) or one icon in it. The ink of every mark is 10px, y 4–14;
// the cat head is drawn at 14.5px and the monitor at 12.83px for that, the ADB tag is the letter A like G and K. Colour is
// --text-2 (--tf for the adb tag, which is a button too, and a proxy mark in tone-warn / tone-err; the icon only, never a background).
// The two buttons (cat head, A) darken the frame to --text-3 on hover. No words, no second letter; what it means goes in its title and aria-label.
// - Today: cat head = 按应用走代理, G = Google Play 商店, K = KernelSU,
// monitor with a slash = 无头 (headless).
// - Order: marks that are always there come first; marks that come and go with the run state come last, so one
Expand All @@ -166,13 +169,13 @@ function makeCard(i) {
// The status label shows only for the states in between and the failed ones (开机中, 关机中, 新建中,
// 开机失败, 新建失败); for the other two it stays in the DOM for screen readers only (.pill-quiet). The list view
// always shows it (it has a status column). 诊断模式 is on the name's hover text in the card view.
// - The card view is the title and one config line. A new state is another single-glyph block or a hover text, not a
// - The card view is the title and one config line. A new state is another single glyph or a hover text, not a
// word and not a line; the label showing or not never changes the card's height.
// - There is no box under the card: nothing is added below the config line, so no state makes a card taller than
// another. The reason of a failure (开机失败, 新建失败) is the status label's hover text, and clicking the label
// opens 问题反馈 at that task; software rendering and a data disk that is nearly full are lines on the name's hover
// text, the first start's setup (about 1–2 minutes) is a line on the screen's hover text.
// - The cat head (pmark) is a single-glyph block too: an icon-only button that opens the 按应用走代理 dialog. It is
// - The cat head (pmark) is a single glyph too: an icon-only button that opens the 按应用走代理 dialog. It is
// the only mark that is clickable and the only one that can carry a state colour, and only when something is wrong:
// it looks like the other marks while the proxy works (tone ok) or has nothing to report yet (tone info), and takes
// tone-warn / tone-err when the guest says part of it does not work.
Expand Down Expand Up @@ -200,7 +203,7 @@ function makeCard(i) {
c.pill = h('span', { class: 'pill', onclick: showFailure,
onkeydown: (e) => { if (c.failure && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); showFailure(); } } }, c.pillText);
const copyAdb = () => A.copy(c.inst.adb_address);
c.adbTag = btn('adb-tag tone-idle', icon('robot'), copyAdb);
c.adbTag = btn('adb-tag tone-idle', 'A', copyAdb);
c.adb = h('span', { class: 'adb-addr' });
c.copy = ibtn('copy', t('复制 adb 地址'), copyAdb);
c.adbList = h('div', { class: 'adb' }, c.adb, c.copy);
Expand Down Expand Up @@ -240,7 +243,6 @@ function updateCard(c, inst) {
const name = label(inst);
c.el.dataset.status = v.key;
setText(c.title, name);
const id = [t('编号 {index}', { index: inst.index }), inst.name].filter(Boolean).join(' · ');
// diagnostics mode: the list view writes it under the name; the card view has no such line and, while running, no
// status label either, so it is a line on the name's hover text (and in the status name screen readers read)
const diag = inst.diagnostics ? t('诊断模式') : '';
Expand All @@ -250,7 +252,7 @@ function updateCard(c, inst) {
const ds = inst.data_space;
const warnings = [inst.software_renderer && t('软件渲染:显卡驱动不可用,游戏会卡'),
ds && ds.message && (ds.advice ? ds.message + comma() + ds.advice : ds.message)];
c.title.title = [id, ownTitle(inst) && name, diag, ...warnings].filter(Boolean).join('\n');
c.title.title = [ownTitle(inst) && name, diag, ...warnings].filter(Boolean).join('\n');
const headless = inst.running && inst.window === false && v.key !== 'creating';
c.hmark.hidden = !headless;
c.sub.hidden = !diag;
Expand Down
1 change: 0 additions & 1 deletion internal/ui/web/js/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const I = {
refresh: '<path d="M19.25 12a7.25 7.25 0 1 1-2.12-5.13"/><path d="M19.25 4.75v3.5h-3.5"/>',
window: '<rect x="3.75" y="4.75" width="16.5" height="14.5" rx="2.25"/><path d="M3.75 9h16.5"/>',
monitorOff: '<rect x="2.75" y="4.25" width="18.5" height="12" rx="2.25"/><path d="M12 16.25v3.25"/><path d="M8 19.75h8"/><path d="M3.5 3.5l17 17"/>',
robot: '<path d="M7 8.5a5 5 0 0 1 10 0v7.25A2.25 2.25 0 0 1 14.75 18h-5.5A2.25 2.25 0 0 1 7 15.75z"/><path d="M12 3.5v-1.25M9 6 7.5 4.25M15 6l1.5-1.75M9.5 11h.01M14.5 11h.01M5 10.5v4M19 10.5v4"/>',
eye: '<path d="M2.75 12S6.15 5.75 12 5.75 21.25 12 21.25 12 17.85 18.25 12 18.25 2.75 12 2.75 12z"/><circle cx="12" cy="12" r="2.75"/>',
eyeOff: '<path d="M9.9 6a9.6 9.6 0 0 1 2.1-.25c5.85 0 9.25 6.25 9.25 6.25a15.6 15.6 0 0 1-2.35 3.05M6.55 7.1C4.1 8.85 2.75 12 2.75 12S6.15 18.25 12 18.25a8.6 8.6 0 0 0 4.2-1.1"/><path d="M4.25 4.25l15.5 15.5"/><path d="M10.05 10.1a2.75 2.75 0 0 0 3.85 3.85"/>',
download: '<path d="M12 4.25v10.5"/><path d="M7.75 10.75L12 15l4.25-4.25"/><path d="M5 19.25h14"/>',
Expand Down
Loading
Loading