Theme decor: selection colors with a bare ::selection
With an ancestor in front (:root:root ::selection) every node the site inserts cost extra style recalculation: Terminal measured 4 elements per insertion on the theme matrix (6 after a bar theme, over the budget of 5); a bare ::selection measures 2 (3 after a bar theme). The rule did not predate the design pass's changes; it was in Terminal's decor from the start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8a5403947d
commit
7ab3ecd02e
1 changed files with 3 additions and 1 deletions
|
|
@ -116,7 +116,9 @@ export function compileDecor<Context extends { colors: RoleColors }>(decor: Them
|
||||||
if (decor.selection) {
|
if (decor.selection) {
|
||||||
const fill = colors[decor.selection.fill];
|
const fill = colors[decor.selection.fill];
|
||||||
const text = contrastRatio(colors[decor.selection.text], fill) >= 4.5 ? colors[decor.selection.text] : (contrastRatio('#ffffff', fill) >= contrastRatio('#000000', fill) ? '#ffffff' : '#000000');
|
const text = contrastRatio(colors[decor.selection.text], fill) >= 4.5 ? colors[decor.selection.text] : (contrastRatio('#ffffff', fill) >= contrastRatio('#000000', fill) ? '#ffffff' : '#000000');
|
||||||
out.push(`:root:root ::selection{background-color:${fill} !important;color:${text} !important}`);
|
// A bare ::selection: with an ancestor in front (`:root:root ::selection`) every node the site
|
||||||
|
// inserts costs the engine extra style recalculation (theme matrix: 4 elements per insertion, 2 without).
|
||||||
|
out.push(`::selection{background-color:${fill} !important;color:${text} !important}`);
|
||||||
}
|
}
|
||||||
if (decor.scrollbar) {
|
if (decor.scrollbar) {
|
||||||
const { width, thumb = 'border', track, style } = decor.scrollbar;
|
const { width, thumb = 'border', track, style } = decor.scrollbar;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue