Light-mode accent hex and slider track use the server's light chroma
Browse files at this commit2d9fd121462585de463027f3565e39d550ffb7a2Parent: d9edf01- fix
- light-mode accent hex and slider track use the server's light chroma
3 changed files +13 -5
- crates/forge-web/assets/nav.js +8 -4
- crates/forge-web/src/pages/settings_appearance.rs +3 -1
- style/main.scss +2 -0
crates/forge-web/assets/nav.jsmodified+8 -4
| @@ -920,8 +920,11 @@ | |||
| 920 | } | 920 | } |
| 921 | 921 | ||
| 922 | // The chroma a row's vividness stands for: the background's is small, as the stylesheet draws it. | 922 | // The chroma a row's vividness stands for: the background's is small, as the stylesheet draws it. |
| 923 | - function rowChroma(kind, vivid) { | 923 | + // The light panel's accent chroma is the server's 12/11 of the dark one (its base chroma is 0.12, not 0.11). |
| 924 | - return kind === 'base' ? 0.0004 * vivid : 0.03 + 0.16 * vivid / 100; | 924 | + function rowChroma(row, vivid) { |
| 925 | + if (row.getAttribute('data-kind') === 'base') { return 0.0004 * vivid; } | ||
| 926 | + var c = 0.03 + 0.16 * vivid / 100; | ||
| 927 | + return row.closest('[data-colour-panel="light"]') ? c * 12 / 11 : c; | ||
| 925 | } | 928 | } |
| 926 | 929 | ||
| 927 | function rowHue(row) { return parseInt(row.querySelector('input[data-hue-stripe]').value, 10) || 0; } | 930 | function rowHue(row) { return parseInt(row.querySelector('input[data-hue-stripe]').value, 10) || 0; } |
| @@ -942,7 +945,7 @@ | |||
| 942 | row.style.setProperty('--v', String(vivid / 100)); | 945 | row.style.setProperty('--v', String(vivid / 100)); |
| 943 | if (custom) { custom.value = 'hue-' + hue + '-v' + vivid; } | 946 | if (custom) { custom.value = 'hue-' + hue + '-v' + vivid; } |
| 944 | if (fillHex && hex) { | 947 | if (fillHex && hex) { |
| 945 | - hex.value = hexOfOklch(parseFloat(row.getAttribute('data-lightness')), rowChroma(row.getAttribute('data-kind'), vivid), hue); | 948 | + hex.value = hexOfOklch(parseFloat(row.getAttribute('data-lightness')), rowChroma(row, vivid), hue); |
| 946 | hex.removeAttribute('aria-invalid'); | 949 | hex.removeAttribute('aria-invalid'); |
| 947 | } | 950 | } |
| 948 | } | 951 | } |
| @@ -981,7 +984,8 @@ | |||
| 981 | var lch = oklchOfHex(match[1]); | 984 | var lch = oklchOfHex(match[1]); |
| 982 | var kind = row.getAttribute('data-kind'); | 985 | var kind = row.getAttribute('data-kind'); |
| 983 | var hue = Math.round(lch.h) % 360; | 986 | var hue = Math.round(lch.h) % 360; |
| 984 | - var vivid = kind === 'base' ? Math.round(lch.c / 0.0004) : Math.round((lch.c - 0.03) / 0.16 * 100); | 987 | + var accentC = kind !== 'base' && row.closest('[data-colour-panel="light"]') ? lch.c * 11 / 12 : lch.c; |
| 988 | + var vivid = kind === 'base' ? Math.round(lch.c / 0.0004) : Math.round((accentC - 0.03) / 0.16 * 100); | ||
| 985 | vivid = clamp(vivid, 0, 100); | 989 | vivid = clamp(vivid, 0, 100); |
| 986 | var note = row.querySelector('[data-hex-note]'); | 990 | var note = row.querySelector('[data-hex-note]'); |
| 987 | if (note) { | 991 | if (note) { |
crates/forge-web/src/pages/settings_appearance.rsmodified+3 -1
| @@ -107,8 +107,10 @@ fn picker_hex(hue: u16, vivid: u8, base: bool, dark: bool) -> String { | |||
| 107 | let v = f64::from(vivid); | 107 | let v = f64::from(vivid); |
| 108 | let chroma = if base { | 108 | let chroma = if base { |
| 109 | 0.0004 * v | 109 | 0.0004 * v |
| 110 | - } else { | 110 | + } else if dark { |
| 111 | 0.03 + 0.16 * v / 100.0 | 111 | 0.03 + 0.16 * v / 100.0 |
| 112 | + } else { | ||
| 113 | + 12.0 / 11.0 * (0.03 + 0.16 * v / 100.0) | ||
| 112 | }; | 114 | }; |
| 113 | custom_colour::colour(row_lightness(base, dark), chroma, f64::from(hue)) | 115 | custom_colour::colour(row_lightness(base, dark), chroma, f64::from(hue)) |
| 114 | } | 116 | } |
style/main.scssmodified+2 -0
| @@ -2526,6 +2526,8 @@ code { | |||
| 2526 | 2526 | ||
| 2527 | [data-colour-panel="light"] [data-colour-row][data-kind="accent"] { | 2527 | [data-colour-panel="light"] [data-colour-row][data-kind="accent"] { |
| 2528 | --track-l: 0.52; | 2528 | --track-l: 0.52; |
| 2529 | + --c-min: calc(0.03 * 12 / 11); | ||
| 2530 | + --c-span: calc(0.16 * 12 / 11); | ||
| 2529 | } | 2531 | } |
| 2530 | 2532 | ||
| 2531 | .hue-row { | 2533 | .hue-row { |