diff --git a/blocksuite/crates/editor/src/theme.rs b/blocksuite/crates/editor/src/theme.rs index 8bceec28de..e2c9b1c4f4 100644 --- a/blocksuite/crates/editor/src/theme.rs +++ b/blocksuite/crates/editor/src/theme.rs @@ -5,8 +5,7 @@ use std::{ borrow::Cow, - collections::HashMap, - sync::{Arc, OnceLock, RwLock}, + sync::{Arc, OnceLock}, }; use ui::{ @@ -252,71 +251,28 @@ impl PlaygroundTheme { } /// Box shadow layers of a `--affine-*-shadow` token in this theme, outermost first. - /// Inset layers and layers that do not parse are left out. + /// Inset layers are omitted at token generation time. pub fn shadows(self, name: &str) -> Vec { - static CACHE: OnceLock>>> = OnceLock::new(); - let Some(raw) = self.tokens().shadow(name) else { + let Some(layers) = self.tokens().shadow(name) else { return Vec::new(); }; - let cache = CACHE.get_or_init(|| RwLock::new(HashMap::new())); - if let Some(hit) = cache.read().ok().and_then(|map| map.get(raw).cloned()) { - return hit; - } - let parsed = parse_box_shadows(raw); - if let Ok(mut map) = cache.write() { - map.insert(raw, parsed.clone()); - } - parsed - } -} - -/// Parse a CSS `box-shadow` list of ` [] ` layers. -fn parse_box_shadows(value: &str) -> Vec { - // Layers are separated by the commas outside of `rgba(...)`. - let mut layers = Vec::new(); - let (mut depth, mut start) = (0_i32, 0_usize); - for (index, ch) in value.char_indices() { - match ch { - '(' => depth += 1, - ')' => depth -= 1, - ',' if depth == 0 => { - layers.push(&value[start..index]); - start = index + 1; - } - _ => {} - } - } - layers.push(&value[start..]); - - layers - .into_iter() - .filter_map(|layer| { - let layer = layer.trim(); - if layer.split_whitespace().any(|word| word == "inset") { - return None; - } - let (lengths, color) = match layer.find("rgb") { - Some(at) => (&layer[..at], parse_rgb_function(&layer[at..])?), - None => { - let at = layer.find('#')?; - (&layer[..at], parse_hex_color(layer[at..].trim())?) + layers + .iter() + .map(|layer| BoxShadow { + color: ui::Rgba { + r: layer.r, + g: layer.g, + b: layer.b, + a: layer.a, } - }; - let lengths: Vec = lengths - .split_whitespace() - .map(|length| length.trim_end_matches("px").parse::()) - .collect::>() - .ok()?; - let length = |index: usize| lengths.get(index).copied().unwrap_or(0.0); - (lengths.len() >= 2).then(|| BoxShadow { - color, - offset: point(px(length(0)), px(length(1))), - blur_radius: px(length(2)), - spread_radius: px(length(3)), + .into(), + offset: point(px(layer.offset_x), px(layer.offset_y)), + blur_radius: px(layer.blur_radius), + spread_radius: px(layer.spread_radius), inset: false, }) - }) - .collect() + .collect() + } } /// Parse `rgb(r, g, b)` or `rgba(r, g, b, a)` with 0-255 channels and a 0-1 alpha. @@ -651,33 +607,60 @@ mod tests { } #[test] - fn shadow_tokens_parse_into_outer_layers() { - for theme in [PlaygroundTheme::Light, PlaygroundTheme::Dark] { - let panel = theme.shadows("--affine-overlay-panel-shadow"); - assert_eq!(panel.len(), 2, "{theme:?}"); - assert_eq!(panel[0].offset, point(px(0.0), px(1.0))); - assert_eq!(panel[0].blur_radius, px(6.0)); - assert_eq!(panel[1].offset, point(px(0.0), px(8.0))); - assert_eq!(panel[1].blur_radius, px(14.0)); - assert!( - panel - .iter() - .all(|layer| layer.color.a > 0.0 && !layer.inset) - ); + fn shadow_tokens_expose_compile_time_layers_with_exact_semantics() { + let light = PlaygroundTheme::Light; + let dark = PlaygroundTheme::Dark; - // A hex color with alpha, and a list whose inset layer is dropped. - let toolbar = theme.shadows("--affine-toolbar-shadow"); - assert_eq!(toolbar.len(), 1, "{theme:?}"); - assert_eq!(toolbar[0].offset, point(px(0.0), px(6.0))); - assert!(toolbar[0].color.a > 0.0 && toolbar[0].color.a < 1.0); - assert_eq!(theme.shadows("--affine-popover-shadow").len(), 2); - } - assert!( - PlaygroundTheme::Light - .shadows("--affine-not-a-shadow") - .is_empty() + assert_eq!(light.tokens().shadows.len(), 26); + assert_eq!(dark.tokens().shadows.len(), 26); + + // 3-layer paper shadow in both themes. + let light_paper = light.shadows("--affine-note-shadow-paper"); + let dark_paper = dark.shadows("--affine-note-shadow-paper"); + assert_eq!(light_paper.len(), 3); + assert_eq!(dark_paper.len(), 3); + assert_ne!(light_paper, dark_paper); + + // Inset layer is omitted at generation time, leaving 2 outer layers. + assert_eq!(light.shadows("--affine-popover-shadow").len(), 2); + assert_eq!(dark.shadows("--affine-popover-shadow").len(), 2); + + // Hex alpha (#00000024 / #00000052) retains exact f32 channel precision. + let light_toolbar = light.shadows("--affine-toolbar-shadow"); + let dark_toolbar = dark.shadows("--affine-toolbar-shadow"); + assert_eq!(light_toolbar.len(), 1); + assert_eq!(dark_toolbar.len(), 1); + assert_eq!( + light_toolbar[0].color, + ui::Rgba { + r: 0.0, + g: 0.0, + b: 0.0, + a: 0x24 as f32 / 255.0, + } + .into() ); - assert!(parse_box_shadows("unset").is_empty()); + assert_eq!( + dark_toolbar[0].color, + ui::Rgba { + r: 0.0, + g: 0.0, + b: 0.0, + a: 0x52 as f32 / 255.0, + } + .into() + ); + + // Negative spread_radius is preserved. + let float_btn = light.shadows("--affine-float-button-shadow-1"); + assert_eq!(float_btn.len(), 2); + assert_eq!(float_btn[0].spread_radius, px(-3.0)); + assert_eq!(float_btn[1].spread_radius, px(-2.0)); + + // `unset` and unknown shadow names resolve to empty slices. + assert!(light.shadows("--affine-button-inner-shadow").is_empty()); + assert!(dark.shadows("--affine-button-inner-shadow").is_empty()); + assert!(light.shadows("--affine-not-a-shadow").is_empty()); } #[test] diff --git a/blocksuite/crates/preview/BENCHMARK.md b/blocksuite/crates/preview/BENCHMARK.md index 955460aa29..75f6ee3168 100644 --- a/blocksuite/crates/preview/BENCHMARK.md +++ b/blocksuite/crates/preview/BENCHMARK.md @@ -58,14 +58,14 @@ The nine-family mean is 1,602 KiB (1.56 MiB) and the peak is 4,078 KiB (3.98 MiB Each preview capability builds independently under the unified `packages/frontend/Cargo.toml` workspace for `wasm32-unknown-unknown` with `--no-default-features --features ,wasm-worker` so the main Web application pays zero upfront preview bundle cost. -Production web packaging builds all four workers as standalone `cdylib` modules with `cargo rustc --profile wasm-worker-size --lib --crate-type cdylib` (`opt-level = "z"`, `lto = "fat"`, `codegen-units = 1`, `strip = "debuginfo"`), remaps workspace and Cargo paths via `CARGO_ENCODED_RUSTFLAGS`, and post-processes every `.wasm` with Binaryen `wasm-opt -Oz --strip-debug --strip-producers`. `mermaid` and `typst` workers omit `svg-text` (the Web host renders their SVG directly), and `merman` keeps all 35 diagram families on Dagre and Cytoscape with ELK disabled: +Production web packaging builds all four workers as standalone `cdylib` modules with `cargo rustc --profile wasm-worker-size --lib --crate-type cdylib` (`opt-level = "z"`, `lto = "fat"`, `codegen-units = 1`, `strip = "debuginfo"`), remaps workspace and Cargo paths via `CARGO_ENCODED_RUSTFLAGS`, and post-processes every `.wasm` with Binaryen `wasm-opt -Oz --strip-debug --strip-producers`. `mermaid` and `typst` workers omit `svg-text` (the Web host renders their SVG directly), and `merman` keeps all 35 diagram families with Dagre, ELK (`layout-elk`), and Cytoscape (`layout-cytoscape`) layout engines enabled: | Worker Feature | Profile | Stripped + `wasm-opt -Oz` Raw Size | `gzip -9` Size | | --- | --- | ---: | ---: | -| `math,wasm-worker` (RaTeX + `svg-raster` outlines) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 3,162,430 B (3.02 MiB) | 1,214,867 B (1.16 MiB) | -| `pdf,wasm-worker` (`hayro 0.9.0`, zero `resvg`) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 4,205,280 B (4.01 MiB) | 1,735,130 B (1.65 MiB) | -| `mermaid,wasm-worker` (`merman 0.11.0`, zero `svg-text`, no ELK) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 9,790,598 B (9.34 MiB) | 3,811,139 B (3.63 MiB) | -| `typst,wasm-worker` (`typst 0.15.1`, zero `svg-text`) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 19,526,781 B (18.62 MiB) | 8,187,644 B (7.81 MiB) | +| `math,wasm-worker` (RaTeX + `svg-raster` outlines) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 3,159,126 B (3.01 MiB) | 1,214,695 B (1.16 MiB) | +| `pdf,wasm-worker` (`hayro 0.9.0`, zero `resvg`) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 4,201,826 B (4.01 MiB) | 1,735,013 B (1.65 MiB) | +| `mermaid,wasm-worker` (`merman 0.11.0`, zero `svg-text`, with ELK) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 10,860,584 B (10.36 MiB) | 4,202,097 B (4.01 MiB) | +| `typst,wasm-worker` (`typst 0.15.1`, zero `svg-text`) | `wasm-worker-size` (`opt-level = "z"`, fat LTO) | 19,515,404 B (18.61 MiB) | 8,187,963 B (7.81 MiB) | Measured on Linux x86-64 with Rust `1.98.1` and Binaryen `version_123` (`wasm-opt -Oz --strip-debug --strip-producers --enable-bulk-memory --enable-nontrapping-float-to-int --enable-sign-ext --enable-mutable-globals`). diff --git a/blocksuite/crates/preview/Cargo.toml b/blocksuite/crates/preview/Cargo.toml index 2d788bb48c..fb72496977 100644 --- a/blocksuite/crates/preview/Cargo.toml +++ b/blocksuite/crates/preview/Cargo.toml @@ -37,8 +37,8 @@ sha2 = "0.10" thiserror.workspace = true ttf-parser.workspace = true -# Mermaid (all 35 diagram families on Dagre and Cytoscape; ELK disabled) -merman = { version = "0.11.0", default-features = false, features = ["all-diagrams", "svg", "layout-cytoscape"], optional = true } +# Mermaid (all 35 diagram families with Dagre, ELK, and Cytoscape layouts) +merman = { version = "0.11.0", default-features = false, features = ["all-diagrams", "svg", "layout-elk", "layout-cytoscape"], optional = true } # LaTeX Math (pure in-memory RaTeX parser/layout + embedded KaTeX TTF bytes, zero ratex-unicode-font) ratex-parser = { version = "0.1.16", optional = true } diff --git a/blocksuite/crates/preview/src/mermaid.rs b/blocksuite/crates/preview/src/mermaid.rs index a3b2f51ef0..34449be2d9 100644 --- a/blocksuite/crates/preview/src/mermaid.rs +++ b/blocksuite/crates/preview/src/mermaid.rs @@ -1159,4 +1159,222 @@ mod tests { Err(PreviewError::EmptyInput) )); } + + #[test] + fn elk_layout_produces_distinct_orthogonal_routing_from_dagre() { + let pool = build_test_font_pool(); + let renderer = MermaidRenderer::new(); + let opts = MermaidOptions { + today: PreviewDate::new(2026, 1, 3), + timezone_offset_minutes: 0, + diagram_id: Some("elk-check".to_string()), + viewbox_padding: 8.0, + theme: Some(MermaidTheme::Light), + }; + let body = concat!( + "flowchart LR\n", + " subgraph Ingress\n", + " A[Gateway] --> B[Auth]\n", + " A --> C[Router]\n", + " end\n", + " subgraph Workers\n", + " B --> D[Planner]\n", + " C --> D\n", + " C --> E[Renderer]\n", + " D --> F[Cache]\n", + " E --> F\n", + " end\n", + " F --> G[Client]\n", + " B --> G\n", + ); + let dagre_src = format!("---\nconfig:\n layout: dagre\n---\n{body}"); + let elk_src = format!("---\nconfig:\n layout: elk\n---\n{body}"); + + let dagre_svg = renderer + .render_svg_with_fonts(&dagre_src, &opts, &pool) + .expect("dagre flowchart must render"); + let elk_svg = renderer + .render_svg_with_fonts(&elk_src, &opts, &pool) + .expect("elk flowchart must render"); + let elk_svg_repeat = renderer + .render_svg_with_fonts(&elk_src, &opts, &pool) + .expect("elk flowchart second render must succeed"); + + assert!(elk_svg.contains("" + ); + assert_eq!( + elk_svg, elk_svg_repeat, + "elk layout must be deterministic across repeated renders" + ); + assert_ne!( + elk_svg, dagre_svg, + "layout: elk must route differently from layout: dagre" + ); + + // Extract `d="..."` from directed edge `` elements + // and verify orthogonal geometry: ELK emits axis-aligned M/L segments with + // optional 90-degree Q corner fillets (both tangents axis-aligned, zero C + // cubic Beziers), whereas Dagre emits cubic Bezier curves or diagonal edges. + fn extract_edge_path_ds(svg: &str) -> Vec<&str> { + let mut ds = Vec::new(); + let mut rest = svg; + while let Some(pos) = rest.find("') else { break }; + let tag = &rest[..=end]; + rest = &rest[end + 1..]; + if !tag.contains("marker-end=") { + continue; + } + if let Some(d_pos) = tag.find(" d=\"") { + let after = &tag[d_pos + 4..]; + if let Some(q_end) = after.find('"') { + ds.push(&after[..q_end]); + } + } + } + ds + } + + fn is_axis_aligned(a: (f64, f64), b: (f64, f64)) -> bool { + (b.0 - a.0).abs() <= 1e-2 || (b.1 - a.1).abs() <= 1e-2 + } + + fn is_orthogonal_elk_edge(d: &str) -> bool { + let mut has_segment = false; + let mut prev: Option<(f64, f64)> = None; + let mut chars = d.chars().peekable(); + let mut cmd = '\0'; + + let skip_ws_comma = |it: &mut std::iter::Peekable>| { + while let Some(&c) = it.peek() { + if c.is_ascii_whitespace() || c == ',' { + it.next(); + } else { + break; + } + } + }; + let read_num = |it: &mut std::iter::Peekable>| -> Option { + skip_ws_comma(it); + let mut buf = String::new(); + while let Some(&c) = it.peek() { + if c.is_ascii_digit() + || c == '.' + || c == '-' + || c == '+' + || c == 'e' + || c == 'E' + { + if (c == '-' || c == '+') && !buf.is_empty() && !buf.ends_with(['e', 'E']) { + break; + } + buf.push(c); + it.next(); + } else { + break; + } + } + buf.parse::().ok() + }; + + loop { + skip_ws_comma(&mut chars); + let Some(&peek) = chars.peek() else { break }; + if peek.is_ascii_alphabetic() { + cmd = chars.next().unwrap(); + } + match cmd { + 'M' | 'L' => { + let (Some(x), Some(y)) = (read_num(&mut chars), read_num(&mut chars)) + else { + return false; + }; + if cmd == 'L' { + if let Some(p) = prev { + has_segment = true; + if !is_axis_aligned(p, (x, y)) { + return false; + } + } + } + prev = Some((x, y)); + if cmd == 'M' { + cmd = 'L'; + } + } + 'Q' => { + let (Some(cx), Some(cy), Some(x), Some(y)) = ( + read_num(&mut chars), + read_num(&mut chars), + read_num(&mut chars), + read_num(&mut chars), + ) else { + return false; + }; + let Some(p) = prev else { return false }; + let dx1 = (cx - p.0).abs(); + let dy1 = (cy - p.1).abs(); + let dx2 = (x - cx).abs(); + let dy2 = (y - cy).abs(); + let t1_horiz = dx1 > 1e-2 && dy1 <= 1e-2; + let t1_vert = dy1 > 1e-2 && dx1 <= 1e-2; + let t2_horiz = dx2 > 1e-2 && dy2 <= 1e-2; + let t2_vert = dy2 > 1e-2 && dx2 <= 1e-2; + if !((t1_horiz && t2_vert) || (t1_vert && t2_horiz)) { + return false; + } + has_segment = true; + prev = Some((x, y)); + } + 'H' => { + let Some(x) = read_num(&mut chars) else { + return false; + }; + if let Some((_, py)) = prev { + has_segment = true; + prev = Some((x, py)); + } + } + 'V' => { + let Some(y) = read_num(&mut chars) else { + return false; + }; + if let Some((px, _)) = prev { + has_segment = true; + prev = Some((px, y)); + } + } + _ => return false, + } + } + has_segment + } + + let elk_edges = extract_edge_path_ds(&elk_svg); + let dagre_edges = extract_edge_path_ds(&dagre_svg); + assert_eq!( + elk_edges.len(), + 9, + "expected exactly 9 directed edge paths in ELK SVG" + ); + assert_eq!( + dagre_edges.len(), + 9, + "expected exactly 9 directed edge paths in Dagre SVG" + ); + for d in &elk_edges { + assert!( + is_orthogonal_elk_edge(d), + "ELK edge path must be orthogonal (axis-aligned M/L with 90-deg Q fillets), got d={d:?}" + ); + } + assert!( + dagre_edges.iter().any(|d| !is_orthogonal_elk_edge(d)), + "Dagre baseline must contain curved or non-orthogonal edge paths" + ); + } } diff --git a/packages/frontend/Cargo.lock b/packages/frontend/Cargo.lock index f259c26181..98f576bd7d 100644 --- a/packages/frontend/Cargo.lock +++ b/packages/frontend/Cargo.lock @@ -3484,6 +3484,25 @@ dependencies = [ "serde", ] +[[package]] +name = "merman-elk-layered" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897499a47993ef5999ce9d9498210a95e0ab6fe7b0814cb4513a7418ba66d132" +dependencies = [ + "thiserror 2.0.21", +] + +[[package]] +name = "merman-layout-elk" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668cd869cdfd7b774b6e7d4ff7d1d477b29dd47f61cd96ee9d24e69a2441584b" +dependencies = [ + "merman-elk-layered", + "thiserror 2.0.21", +] + [[package]] name = "merman-markup" version = "0.11.0" @@ -3531,6 +3550,7 @@ dependencies = [ "libm", "manatee", "memchr", + "merman-layout-elk", "merman-markup", "merman-model", "merman-theme-contract", diff --git a/packages/frontend/Cargo.toml b/packages/frontend/Cargo.toml index 04922b6e43..66885c2a74 100644 --- a/packages/frontend/Cargo.toml +++ b/packages/frontend/Cargo.toml @@ -63,7 +63,6 @@ foreign-types = "0.5" frame-audit = { path = "../../tools/frame-audit" } futures = "0.3.34" getrandom = { version = "0.3.4", features = ["wasm_js"] } -heapless = "0.9.2" icu_segmenter = { version = "2.3.0", default-features = false, features = ["compiled_data"] } image = { version = "0.25.1", default-features = false, features = ["bmp", "gif", "ico", "jpeg", "png", "webp"] } indexmap = { version = "2.7.0", features = ["serde"] } @@ -172,7 +171,6 @@ pin-project = "1.1.10" pollster = "0.4.0" rand = { version = "0.9", default-features = false, features = ["std", "std_rng", "os_rng", "small_rng", "thread_rng"] } raw-window-handle = "0.6" -regex = { version = "1.5", default-features = false, features = ["std", "perf"] } resvg = { version = "0.46.0", default-features = false, features = ["raster-images"] } rustc-hash = "2.1.0" seahash = "4.1" @@ -240,6 +238,10 @@ opt-level = "s" opt-level = "s" [profile.dev.package.merman-editor-core] opt-level = "s" +[profile.dev.package.merman-elk-layered] +opt-level = 0 +[profile.dev.package.merman-layout-elk] +opt-level = 0 [profile.dev.package.merman-markup] opt-level = "s" [profile.dev.package.merman-model] @@ -312,6 +314,10 @@ opt-level = 0 opt-level = 0 [profile.test.package.merman-editor-core] opt-level = 0 +[profile.test.package.merman-elk-layered] +opt-level = 0 +[profile.test.package.merman-layout-elk] +opt-level = 0 [profile.test.package.merman-markup] opt-level = 0 [profile.test.package.merman-model] @@ -356,6 +362,10 @@ opt-level = "z" opt-level = "z" [profile.release.package.merman-editor-core] opt-level = "z" +[profile.release.package.merman-elk-layered] +opt-level = "z" +[profile.release.package.merman-layout-elk] +opt-level = "z" [profile.release.package.merman-markup] opt-level = "z" [profile.release.package.merman-model] diff --git a/packages/frontend/hosts/web/tests/extract-tokens-shadow.test.mjs b/packages/frontend/hosts/web/tests/extract-tokens-shadow.test.mjs new file mode 100644 index 0000000000..1ed38b5f68 --- /dev/null +++ b/packages/frontend/hosts/web/tests/extract-tokens-shadow.test.mjs @@ -0,0 +1,145 @@ +// @ts-check + +import assert from 'node:assert/strict'; +import { spawnSync } from 'node:child_process'; +import { mkdtempSync, rmSync, symlinkSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join, resolve } from 'node:path'; +import test from 'node:test'; +import { fileURLToPath } from 'node:url'; + +import { + formatF32, + formatShadowLayer, + parseShadowLayers, +} from '../../../../ui/tokens/extract-tokens.mjs'; + +void test('formatF32 emits valid Rust f32 literals for scientific notation and rejects non-finite or out-of-range f32 values', () => { + assert.equal(formatF32(0.0000001, '--test-shadow'), '1e-7_f32'); + assert.equal(formatF32(-0, '--test-shadow'), '0.0_f32'); + assert.equal(formatF32(12, '--test-shadow'), '12.0_f32'); + assert.equal(formatF32(0.14, '--test-shadow'), '0.14_f32'); + assert.throws(() => formatF32(Number.NaN, '--test-shadow'), /--test-shadow/); + assert.throws( + () => formatF32(Number.POSITIVE_INFINITY, '--test-shadow'), + /--test-shadow/ + ); + assert.throws( + () => formatF32(1e39, '--affine-overflow-shadow'), + /--affine-overflow-shadow/ + ); + const overflowLayers = parseShadowLayers( + '0px 1e39px 0px #000', + '--affine-overflow-shadow' + ); + assert.throws( + () => formatShadowLayer(overflowLayers[0], '--affine-overflow-shadow'), + /--affine-overflow-shadow/ + ); +}); + +void test('extract-tokens.mjs runs CLI main() even when invoked through a symlink', () => { + const tmp = mkdtempSync(join(tmpdir(), 'affine-extract-tokens-symlink-')); + try { + const targetScript = resolve( + fileURLToPath( + new URL('../../../../ui/tokens/extract-tokens.mjs', import.meta.url) + ) + ); + const linkScript = join(tmp, 'extract-tokens-link.mjs'); + symlinkSync(targetScript, linkScript); + + const res = spawnSync(process.execPath, [linkScript, '--unknown-flag'], { + encoding: 'utf8', + }); + assert.notEqual( + res.status, + 0, + 'symlink invocation must execute CLI main() and fail non-zero on --unknown-flag' + ); + assert.match(res.stderr || '', /--unknown-flag/); + } finally { + rmSync(tmp, { recursive: true, force: true }); + } +}); + +void test('parseShadowLayers rejects malformed numeric tokens without silent parseFloat truncation', () => { + assert.throws( + () => + parseShadowLayers( + '0px 4px 8px rgba(1..2, 0, 0, .14)', + '--affine-broken-shadow' + ), + err => { + const msg = String(err?.message || err); + assert.match(msg, /--affine-broken-shadow/); + return true; + } + ); + assert.throws( + () => + parseShadowLayers( + '0px 4px 8px rgba(10, 20, 30, 0.1.2)', + '--affine-broken-alpha' + ), + /--affine-broken-alpha/ + ); +}); + +void test('parseShadowLayers preserves fractional RGB channel precision without rounding', () => { + const layers = parseShadowLayers( + '0px 2px 4px rgba(12.5, 18, 255, .0000001)', + '--affine-fractional-shadow' + ); + assert.equal(layers.length, 1); + const rendered = formatShadowLayer(layers[0], '--affine-fractional-shadow'); + assert.match(rendered, /r: 12\.5_f32 \/ 255\.0_f32/); + assert.match(rendered, /g: 18\.0_f32 \/ 255\.0_f32/); + assert.match(rendered, /b: 255\.0_f32 \/ 255\.0_f32/); + assert.match(rendered, /a: 1e-7_f32/); +}); + +void test('parseShadowLayers rejects negative blur radius while preserving negative spread radius', () => { + assert.throws( + () => parseShadowLayers('0px 0px -2px #000', '--affine-neg-blur-shadow'), + err => { + const msg = String(err?.message || err); + assert.match(msg, /--affine-neg-blur-shadow/); + assert.match(msg, /blur/i); + return true; + } + ); + + const layers = parseShadowLayers( + '0px 4px 6px -3px rgba(66, 65, 73, .1), 0px 10px 12px -2px rgba(66, 65, 73, .1)', + '--affine-float-button-shadow-1' + ); + assert.equal(layers.length, 2); + assert.equal(layers[0].blur_radius, 6); + assert.equal(layers[0].spread_radius, -3); + assert.equal(layers[1].blur_radius, 12); + assert.equal(layers[1].spread_radius, -2); +}); + +void test('parseShadowLayers handles unset, inset omission, 3-layer paper shadow, and hex alpha', () => { + assert.deepEqual( + parseShadowLayers('unset', '--affine-button-inner-shadow'), + [] + ); + + const popover = parseShadowLayers( + '0px 0px 30px rgba(75, 75, 75, .2), 0px 0px 4px rgba(75, 75, 75, .3), inset 0px 0px 0px rgba(227, 226, 228, 1)', + '--affine-popover-shadow' + ); + assert.equal(popover.length, 2); + + const toolbar = parseShadowLayers( + '0px 6px 16px #00000024', + '--affine-toolbar-shadow' + ); + assert.equal(toolbar.length, 1); + assert.equal( + formatShadowLayer(toolbar[0], '--affine-toolbar-shadow'), + 'ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 16.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 36.0_f32 / 255.0_f32 }' + ); +}); diff --git a/packages/ui/tokens/extract-tokens.mjs b/packages/ui/tokens/extract-tokens.mjs index 4cf2713dd7..dd3b8a38d5 100644 --- a/packages/ui/tokens/extract-tokens.mjs +++ b/packages/ui/tokens/extract-tokens.mjs @@ -299,9 +299,31 @@ function requirePx(map, name) { return parsePxStrict(requireVar(map, name), name); } -function formatF32(n) { - const s = Number(n).toString(); - return s.includes('.') ? `${s}_f32` : `${s}.0_f32`; +const STRICT_NUMBER_RE = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/; + +function parseStrictNumber(raw, context) { + const trimmed = String(raw).trim(); + if (!STRICT_NUMBER_RE.test(trimmed)) { + throw new Error(`Invalid numeric value "${raw}" in ${context}`); + } + const n = Number(trimmed); + if (!Number.isFinite(n)) { + throw new Error(`Non-finite numeric value "${raw}" in ${context}`); + } + return n; +} + +export function formatF32(n, context = 'value') { + if ( + typeof n !== 'number' || + !Number.isFinite(n) || + !Number.isFinite(Math.fround(n)) + ) { + throw new Error(`Out-of-range or non-finite f32 value "${n}" in ${context}`); + } + const normalized = Object.is(n, -0) ? 0 : n; + const s = String(normalized); + return /[eE]/.test(s) || s.includes('.') ? `${s}_f32` : `${s}.0_f32`; } function rustStr(s) { @@ -323,43 +345,253 @@ function resolveColorVar(map, name, depth = 0) { return parseColor(raw); } +function clampRange(n, min, max) { + return Math.max(min, Math.min(max, n)); +} + +export function parseShadowColor(raw, tokenName = 'shadow') { + const val = raw.trim(); + if (val.startsWith('#')) { + const hex = val.slice(1); + if (hex.length === 3 && /^[0-9a-fA-F]{3}$/.test(hex)) { + const r = parseInt(hex[0] + hex[0], 16); + const g = parseInt(hex[1] + hex[1], 16); + const b = parseInt(hex[2] + hex[2], 16); + return { + rExpr: `${r}.0_f32 / 255.0_f32`, + gExpr: `${g}.0_f32 / 255.0_f32`, + bExpr: `${b}.0_f32 / 255.0_f32`, + alphaExpr: '1.0_f32', + }; + } + if (hex.length === 4 && /^[0-9a-fA-F]{4}$/.test(hex)) { + const r = parseInt(hex[0] + hex[0], 16); + const g = parseInt(hex[1] + hex[1], 16); + const b = parseInt(hex[2] + hex[2], 16); + const a = parseInt(hex[3] + hex[3], 16); + return { + rExpr: `${r}.0_f32 / 255.0_f32`, + gExpr: `${g}.0_f32 / 255.0_f32`, + bExpr: `${b}.0_f32 / 255.0_f32`, + alphaExpr: `${a}.0_f32 / 255.0_f32`, + }; + } + if (hex.length === 6 && /^[0-9a-fA-F]{6}$/.test(hex)) { + const r = parseInt(hex.slice(0, 2), 16); + const g = parseInt(hex.slice(2, 4), 16); + const b = parseInt(hex.slice(4, 6), 16); + return { + rExpr: `${r}.0_f32 / 255.0_f32`, + gExpr: `${g}.0_f32 / 255.0_f32`, + bExpr: `${b}.0_f32 / 255.0_f32`, + alphaExpr: '1.0_f32', + }; + } + if (hex.length === 8 && /^[0-9a-fA-F]{8}$/.test(hex)) { + const r = parseInt(hex.slice(0, 2), 16); + const g = parseInt(hex.slice(2, 4), 16); + const b = parseInt(hex.slice(4, 6), 16); + const a = parseInt(hex.slice(6, 8), 16); + return { + rExpr: `${r}.0_f32 / 255.0_f32`, + gExpr: `${g}.0_f32 / 255.0_f32`, + bExpr: `${b}.0_f32 / 255.0_f32`, + alphaExpr: `${a}.0_f32 / 255.0_f32`, + }; + } + return null; + } + + const fnMatch = val.match(/^rgba?\(\s*([^)]+?)\s*\)$/i); + if (fnMatch) { + const inner = fnMatch[1]; + let rgbParts; + let alphaPart; + if (inner.includes(',')) { + const parts = inner.split(',').map(p => p.trim()); + if (parts.length !== 3 && parts.length !== 4) { + throw new Error( + `Expected 3 or 4 channels in shadow color "${raw}" of ${tokenName}` + ); + } + rgbParts = parts.slice(0, 3); + alphaPart = parts[3]; + } else { + const slashParts = inner.split('/').map(p => p.trim()); + if (slashParts.length > 2) { + throw new Error( + `Invalid slash syntax in shadow color "${raw}" of ${tokenName}` + ); + } + rgbParts = slashParts[0].split(/\s+/).filter(Boolean); + if (rgbParts.length !== 3) { + throw new Error( + `Expected 3 RGB channels in shadow color "${raw}" of ${tokenName}` + ); + } + alphaPart = slashParts[1]; + } + + const parseChannelExpr = chRaw => { + if (chRaw.endsWith('%')) { + const pct = clampRange( + parseStrictNumber(chRaw.slice(0, -1), tokenName), + 0, + 100 + ); + return `${formatF32(pct / 100, tokenName)}`; + } + const ch = clampRange(parseStrictNumber(chRaw, tokenName), 0, 255); + return `${formatF32(ch, tokenName)} / 255.0_f32`; + }; + + const rExpr = parseChannelExpr(rgbParts[0]); + const gExpr = parseChannelExpr(rgbParts[1]); + const bExpr = parseChannelExpr(rgbParts[2]); + let alphaExpr = '1.0_f32'; + if (alphaPart !== undefined) { + if (alphaPart.endsWith('%')) { + const pct = clampRange( + parseStrictNumber(alphaPart.slice(0, -1), tokenName), + 0, + 100 + ); + alphaExpr = formatF32(pct / 100, tokenName); + } else { + const alpha = clampRange( + parseStrictNumber(alphaPart, tokenName), + 0, + 1 + ); + alphaExpr = formatF32(alpha, tokenName); + } + } + return { rExpr, gExpr, bExpr, alphaExpr }; + } + + return null; +} + +function parseShadowLengthPx(token, tokenName) { + const m = token.trim().match(/^(.+?)(?:px)?$/i); + if (!m) { + throw new Error( + `Unparseable shadow length "${token}" in ${tokenName}` + ); + } + return parseStrictNumber(m[1], tokenName); +} + +export function parseShadowLayers(raw, tokenName = 'shadow') { + const trimmed = raw.trim(); + if (trimmed === 'unset' || trimmed === 'none') { + return []; + } + + // Split by commas outside parentheses so `rgba(r, g, b, a)` stays intact. + const parts = []; + let depth = 0; + let start = 0; + for (let i = 0; i < trimmed.length; i += 1) { + const ch = trimmed[i]; + if (ch === '(') depth += 1; + else if (ch === ')') depth -= 1; + else if (ch === ',' && depth === 0) { + parts.push(trimmed.slice(start, i)); + start = i + 1; + } + } + if (depth !== 0) { + throw new Error(`Unbalanced parentheses in shadow ${tokenName}: ${raw}`); + } + parts.push(trimmed.slice(start)); + + const layers = []; + for (const rawLayer of parts) { + const layer = rawLayer.trim(); + if (!layer) { + throw new Error(`Empty shadow layer in ${tokenName}: ${raw}`); + } + if (layer.split(/\s+/).includes('inset')) { + continue; + } + + const rgbIdx = layer.search(/\brgba?\(/i); + const hexIdx = layer.indexOf('#'); + let colorIdx = -1; + if (rgbIdx !== -1 && (hexIdx === -1 || rgbIdx < hexIdx)) { + colorIdx = rgbIdx; + } else if (hexIdx !== -1) { + colorIdx = hexIdx; + } + if (colorIdx === -1) { + throw new Error( + `Missing color in outer shadow layer of ${tokenName}: ${layer}` + ); + } + + const lengthsText = layer.slice(0, colorIdx).trim(); + const colorText = layer.slice(colorIdx).trim(); + const color = parseShadowColor(colorText, tokenName); + if (!color) { + throw new Error( + `Unparseable shadow color "${colorText}" in ${tokenName}: ${layer}` + ); + } + + const lengthTokens = lengthsText ? lengthsText.split(/\s+/) : []; + if (lengthTokens.length < 2 || lengthTokens.length > 4) { + throw new Error( + `Expected 2-4 lengths in shadow layer of ${tokenName}, got ${lengthTokens.length}: ${layer}` + ); + } + const lengths = lengthTokens.map(tok => + parseShadowLengthPx(tok, tokenName) + ); + const blurRadius = lengths[2] ?? 0; + if (blurRadius < 0) { + throw new Error( + `Negative blur radius ${blurRadius} in shadow ${tokenName}: ${layer}` + ); + } + layers.push({ + offset_x: lengths[0], + offset_y: lengths[1], + blur_radius: blurRadius, + spread_radius: lengths[3] ?? 0, + rExpr: color.rExpr, + gExpr: color.gExpr, + bExpr: color.bExpr, + alphaExpr: color.alphaExpr, + }); + } + + return layers; +} + +export function formatShadowLayer(l, tokenName = 'shadow') { + return `ShadowLayer { offset_x: ${formatF32(l.offset_x, tokenName)}, offset_y: ${formatF32(l.offset_y, tokenName)}, blur_radius: ${formatF32(l.blur_radius, tokenName)}, spread_radius: ${formatF32(l.spread_radius, tokenName)}, r: ${l.rExpr}, g: ${l.gExpr}, b: ${l.bExpr}, a: ${l.alphaExpr} }`; +} + function buildThemeSection(mergedMap) { const colors = []; const shadows = []; - const notePalette = []; - const shapePalette = []; - const connectorPalette = []; const sortedNames = [...mergedMap.keys()].sort(cmpCodeUnit); for (const name of sortedNames) { const raw = mergedMap.get(name); if (/shadow/i.test(name) && !parseColor(raw)) { - shadows.push([name, raw]); + shadows.push([name, parseShadowLayers(raw, name)]); continue; } const color = resolveColorVar(mergedMap, name); if (color) { colors.push([name, color]); - if ( - name.startsWith('--affine-note-background-') || - name.startsWith('--affine-v2-edgeless-note-') - ) { - notePalette.push([name, color]); - } - if ( - name.startsWith('--affine-palette-shape-') || - name.startsWith('--affine-v2-edgeless-palette-') - ) { - shapePalette.push([name, color]); - } - if (name.startsWith('--affine-palette-line-')) { - connectorPalette.push([name, color]); - } } } - return { colors, shadows, notePalette, shapePalette, connectorPalette }; + return { colors, shadows }; } function generateTokensRs(nodeModulesDir) { @@ -398,7 +630,17 @@ function generateTokensRs(nodeModulesDir) { entries.map(([k, c]) => ` (${rustStr(k)}, ${formatRgba(c)}),`).join('\n'); const renderShadowSlice = entries => - entries.map(([k, v]) => ` (${rustStr(k)}, ${rustStr(v)}),`).join('\n'); + entries + .map(([k, layers]) => { + if (layers.length === 0) { + return ` (${rustStr(k)}, &[]),`; + } + const items = layers + .map(layer => ` ${formatShadowLayer(layer, k)},`) + .join('\n'); + return ` (${rustStr(k)}, &[\n${items}\n ]),`; + }) + .join('\n'); const renderThemeConst = (constName, map, data) => `pub const ${constName}: ThemeTokens = ThemeTokens { brand: ${formatRgba(pickColor(map, '--affine-brand-color'))}, @@ -429,15 +671,6 @@ ${renderColorSlice(data.colors)} shadows: &[ ${renderShadowSlice(data.shadows)} ], - note_palette: &[ -${renderColorSlice(data.notePalette)} - ], - shape_palette: &[ -${renderColorSlice(data.shapePalette)} - ], - connector_palette: &[ -${renderColorSlice(data.connectorPalette)} - ], };`; const lineHeightRaw = requireVar(root, '--affine-line-height'); @@ -485,6 +718,18 @@ impl Rgba { } } +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct ShadowLayer { + pub offset_x: f32, + pub offset_y: f32, + pub blur_radius: f32, + pub spread_radius: f32, + pub r: f32, + pub g: f32, + pub b: f32, + pub a: f32, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ThemeMode { Light, @@ -494,10 +739,8 @@ pub enum ThemeMode { #[derive(Debug, Clone, Copy)] pub struct TypographyTokens { pub font_family: &'static str, - pub font_serif_family: &'static str, pub font_mono_family: &'static str, pub font_sans_family: &'static str, - pub font_number_family: &'static str, pub font_code_family: &'static str, pub font_base_px: f32, pub font_sm_px: f32, @@ -508,7 +751,6 @@ pub struct TypographyTokens { pub font_h4_px: f32, pub font_h5_px: f32, pub font_h6_px: f32, - pub line_height_css: &'static str, pub line_height_base_px: f32, pub editor_width_px: f32, pub paragraph_space_px: f32, @@ -518,10 +760,8 @@ pub struct TypographyTokens { pub const TYPOGRAPHY: TypographyTokens = TypographyTokens { font_family: ${rustStr(requireVar(root, '--affine-font-family'))}, - font_serif_family: ${rustStr(requireVar(root, '--affine-font-serif-family'))}, font_mono_family: ${rustStr(requireVar(root, '--affine-font-mono-family'))}, font_sans_family: ${rustStr(requireVar(root, '--affine-font-sans-family'))}, - font_number_family: ${rustStr(requireVar(root, '--affine-font-number-family'))}, font_code_family: ${rustStr(requireVar(root, '--affine-font-code-family'))}, font_base_px: ${formatF32(basePx)}, font_sm_px: ${formatF32(requirePx(root, '--affine-font-sm'))}, @@ -532,7 +772,6 @@ pub const TYPOGRAPHY: TypographyTokens = TypographyTokens { font_h4_px: ${formatF32(requirePx(root, '--affine-font-h-4'))}, font_h5_px: ${formatF32(requirePx(root, '--affine-font-h-5'))}, font_h6_px: ${formatF32(requirePx(root, '--affine-font-h-6'))}, - line_height_css: ${rustStr(lineHeightRaw)}, line_height_base_px: ${formatF32(resolvedLineHeightPx)}, editor_width_px: ${formatF32(requirePx(root, '--affine-editor-width'))}, paragraph_space_px: ${formatF32(requirePx(root, '--affine-paragraph-space'))}, @@ -567,10 +806,7 @@ pub struct ThemeTokens { pub hover: Rgba, pub edgeless_grid: Rgba, pub colors: &'static [(&'static str, Rgba)], - pub shadows: &'static [(&'static str, &'static str)], - pub note_palette: &'static [(&'static str, Rgba)], - pub shape_palette: &'static [(&'static str, Rgba)], - pub connector_palette: &'static [(&'static str, Rgba)], + pub shadows: &'static [(&'static str, &'static [ShadowLayer])], } impl ThemeTokens { @@ -581,7 +817,7 @@ impl ThemeTokens { .map(|idx| self.colors[idx].1) } - pub fn shadow(&self, css_var: &str) -> Option<&'static str> { + pub fn shadow(&self, css_var: &str) -> Option<&'static [ShadowLayer]> { self.shadows .binary_search_by_key(&css_var, |(name, _)| *name) .ok() @@ -1033,9 +1269,22 @@ function main() { } } -try { - main(); -} catch (error) { - console.error(error instanceof Error ? error.message : String(error)); - process.exitCode = 1; +let isDirectRun = false; +if (process.argv[1]) { + try { + isDirectRun = + fs.realpathSync(process.argv[1]) === + fs.realpathSync(fileURLToPath(import.meta.url)); + } catch { + isDirectRun = false; + } +} + +if (isDirectRun) { + try { + main(); + } catch (error) { + console.error(error instanceof Error ? error.message : String(error)); + process.exitCode = 1; + } } diff --git a/packages/ui/tokens/src/lib.rs b/packages/ui/tokens/src/lib.rs index 9d7c407d36..0487c3467c 100644 --- a/packages/ui/tokens/src/lib.rs +++ b/packages/ui/tokens/src/lib.rs @@ -16,7 +16,7 @@ pub mod icons { } pub use icons::{IconDef, icon_by_name}; -pub use tokens::{DARK_THEME, LIGHT_THEME, Rgba, TYPOGRAPHY, ThemeMode, ThemeTokens}; +pub use tokens::{DARK_THEME, LIGHT_THEME, Rgba, ShadowLayer, TYPOGRAPHY, ThemeMode, ThemeTokens}; /// Base UI and document font family. pub const FONT_SANS: &str = "Inter"; diff --git a/packages/ui/tokens/tokens.rs b/packages/ui/tokens/tokens.rs index fb308da93e..8a1664716b 100644 --- a/packages/ui/tokens/tokens.rs +++ b/packages/ui/tokens/tokens.rs @@ -34,6 +34,18 @@ impl Rgba { } } +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct ShadowLayer { + pub offset_x: f32, + pub offset_y: f32, + pub blur_radius: f32, + pub spread_radius: f32, + pub r: f32, + pub g: f32, + pub b: f32, + pub a: f32, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ThemeMode { Light, @@ -43,10 +55,8 @@ pub enum ThemeMode { #[derive(Debug, Clone, Copy)] pub struct TypographyTokens { pub font_family: &'static str, - pub font_serif_family: &'static str, pub font_mono_family: &'static str, pub font_sans_family: &'static str, - pub font_number_family: &'static str, pub font_code_family: &'static str, pub font_base_px: f32, pub font_sm_px: f32, @@ -57,7 +67,6 @@ pub struct TypographyTokens { pub font_h4_px: f32, pub font_h5_px: f32, pub font_h6_px: f32, - pub line_height_css: &'static str, pub line_height_base_px: f32, pub editor_width_px: f32, pub paragraph_space_px: f32, @@ -67,10 +76,8 @@ pub struct TypographyTokens { pub const TYPOGRAPHY: TypographyTokens = TypographyTokens { font_family: "\"Inter\", \"Source Sans 3\", Poppins, apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Tahoma, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\",\"Segoe UI Symbol\", \"Noto Color Emoji\"", - font_serif_family: "\"Source Serif 4\", \"Noto Serif\" , serif, \"Cambria\", apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Tahoma, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\",\"Segoe UI Symbol\", \"Noto Color Emoji\"", font_mono_family: "\"Source Code Pro\", \"IBM Plex Mono\", \"Roboto Mono\",\"Noto Sans Mono\", \"Noto Sans CJK\", apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Tahoma, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\",\"Segoe UI Symbol\", \"Noto Color Emoji\"", font_sans_family: "\"Inter\", \"Source Sans 3\", Poppins, apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Tahoma, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\",\"Segoe UI Symbol\", \"Noto Color Emoji\"", - font_number_family: "\"Roboto Mono\", \"Noto Sans Mono\", apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Tahoma, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\",\"Segoe UI Symbol\", \"Noto Color Emoji\"", font_code_family: "\"IBM Plex Mono\", \"Space Mono\", Consolas, Menlo, Monaco, Courier, monospace, apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Tahoma, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\",\"Segoe UI Symbol\", \"Noto Color Emoji\"", font_base_px: 15.0_f32, font_sm_px: 14.0_f32, @@ -81,7 +88,6 @@ pub const TYPOGRAPHY: TypographyTokens = TypographyTokens { font_h4_px: 22.0_f32, font_h5_px: 20.0_f32, font_h6_px: 18.0_f32, - line_height_css: "calc(1em + 8px)", line_height_base_px: 23.0_f32, editor_width_px: 944.0_f32, paragraph_space_px: 8.0_f32, @@ -116,10 +122,7 @@ pub struct ThemeTokens { pub hover: Rgba, pub edgeless_grid: Rgba, pub colors: &'static [(&'static str, Rgba)], - pub shadows: &'static [(&'static str, &'static str)], - pub note_palette: &'static [(&'static str, Rgba)], - pub shape_palette: &'static [(&'static str, Rgba)], - pub connector_palette: &'static [(&'static str, Rgba)], + pub shadows: &'static [(&'static str, &'static [ShadowLayer])], } impl ThemeTokens { @@ -130,7 +133,7 @@ impl ThemeTokens { .map(|idx| self.colors[idx].1) } - pub fn shadow(&self, css_var: &str) -> Option<&'static str> { + pub fn shadow(&self, css_var: &str) -> Option<&'static [ShadowLayer]> { self.shadows .binary_search_by_key(&css_var, |(name, _)| *name) .ok() @@ -745,111 +748,97 @@ pub const LIGHT_THEME: ThemeTokens = ThemeTokens { ("--affine-windows-close-button", Rgba::new(196, 43, 28, 255)), ], shadows: &[ - ("--affine-active-shadow", "0px 0px 0px 2px rgba(30, 150, 235, .3)"), - ("--affine-ai-empty-shadow", "0px 4px 4px rgba(66, 65, 73, .1), 0px 6px 8px rgba(66, 65, 73, .05)"), - ("--affine-button-inner-shadow", "unset"), - ("--affine-button-shadow", "0px 0px 1px 0px rgba(0, 0, 0, .12), 0px 1px 5px 0px rgba(0, 0, 0, .12)"), - ("--affine-cmd-shadow", "0px 10px 80px 0px rgba(0, 0, 0, .2)"), - ("--affine-embed-shadow", "0px 0px 0px 2px rgba(0, 0, 0, .08)"), - ("--affine-float-button-shadow", "0px 0px 10px rgba(0, 0, 0, .05), 0px 0px 0px .5px rgba(0, 0, 0, .1)"), - ("--affine-float-button-shadow-1", "0px 4px 6px -3px rgba(66, 65, 73, .1), 0px 10px 12px -2px rgba(66, 65, 73, .1)"), - ("--affine-float-button-shadow-2", "0px 4px 4px -2px rgba(66, 65, 73, .1), 0px 6px 8px 1px rgba(66, 65, 73, .05)"), - ("--affine-kanban-shadow", "0px 2px 3px 0px rgba(0, 0, 0, .05)"), - ("--affine-menu-shadow", "0px 10px 18px rgba(0,0,0,.14), 0px -1px 12px rgba(0,0,0,.08)"), - ("--affine-multi-cursors-shadow", "0px 2px 4px 0px rgba(0, 0, 0, .28)"), - ("--affine-multi-players-shadow", "0px 1px 6px 0px rgba(0, 0, 0, .16)"), - ("--affine-note-shadow-box", "0px 0px 4px 0px rgba(0, 0, 0, .14), 0px 2px 12px 0px rgba(0, 0, 0, .14)"), - ("--affine-note-shadow-film", "10px 10px 0px 6px #000, 0px 0px 0px 6px #000"), - ("--affine-note-shadow-float", "0px 0px 32px 0px rgba(0, 0, 0, .09), 0px 0px 3px 0px rgba(0, 0, 0, .1)"), - ("--affine-note-shadow-paper", "0px 2px 4px 0px rgba(0, 0, 0, .05), 0px 0px 0px 10px #FFF, 0px 3px 6px 12px rgba(0, 0, 0, .14)"), - ("--affine-note-shadow-sticker", "0px 6px 16px 0px rgba(0, 0, 0, .08), 0px 26px 18px -20px rgba(0, 0, 0, .1)"), - ("--affine-overlay-panel-shadow", "0px 1px 6px rgba(0,0,0,.16), 0px 8px 14px rgba(0,0,0,.08)"), - ("--affine-overlay-shadow", "0px 1px 6px 0px rgba(0, 0, 0, .16), 0px 8px 14px 0px rgba(0, 0, 0, .08)"), - ("--affine-popover-shadow", "0px 0px 30px rgba(75, 75, 75, .2), 0px 0px 4px rgba(75, 75, 75, .3), inset 0px 0px 0px rgba(227, 226, 228, 1)"), - ("--affine-shadow-1", "0px 0px 4px 0px rgba(66, 65, 73, .14)"), - ("--affine-shadow-2", "0px 0px 12px 0px rgba(66, 65, 73, .18)"), - ("--affine-shadow-3", "0px 0px 20px 0px rgba(66, 65, 73, .22)"), - ("--affine-toggle-circle-shadow", "0px 1px 2px 0px rgba(0, 0, 0, .25), inset -2px -3px 2px 0px rgba(0, 0, 0, .05)"), - ("--affine-toolbar-shadow", "0px 6px 16px #00000024"), - ], - note_palette: &[ - ("--affine-note-background-black", Rgba::new(0, 0, 0, 255)), - ("--affine-note-background-blue", Rgba::new(205, 235, 255, 255)), - ("--affine-note-background-green", Rgba::new(201, 248, 193, 255)), - ("--affine-note-background-grey", Rgba::new(230, 230, 230, 255)), - ("--affine-note-background-magenta", Rgba::new(255, 218, 237, 255)), - ("--affine-note-background-orange", Rgba::new(255, 196, 143, 255)), - ("--affine-note-background-purple", Rgba::new(221, 214, 254, 255)), - ("--affine-note-background-red", Rgba::new(250, 182, 182, 255)), - ("--affine-note-background-teal", Rgba::new(199, 248, 242, 255)), - ("--affine-note-background-white", Rgba::new(255, 255, 255, 255)), - ("--affine-note-background-yellow", Rgba::new(253, 230, 138, 255)), - ("--affine-v2-edgeless-note-black", Rgba::new(179, 179, 179, 255)), - ("--affine-v2-edgeless-note-blue", Rgba::new(206, 236, 255, 255)), - ("--affine-v2-edgeless-note-green", Rgba::new(201, 248, 193, 255)), - ("--affine-v2-edgeless-note-grey", Rgba::new(230, 230, 230, 255)), - ("--affine-v2-edgeless-note-magenta", Rgba::new(255, 218, 237, 255)), - ("--affine-v2-edgeless-note-orange", Rgba::new(255, 197, 143, 255)), - ("--affine-v2-edgeless-note-purple", Rgba::new(221, 214, 254, 255)), - ("--affine-v2-edgeless-note-red", Rgba::new(251, 183, 183, 255)), - ("--affine-v2-edgeless-note-teal", Rgba::new(199, 248, 242, 255)), - ("--affine-v2-edgeless-note-white", Rgba::new(255, 255, 255, 255)), - ("--affine-v2-edgeless-note-yellow", Rgba::new(253, 230, 138, 255)), - ], - shape_palette: &[ - ("--affine-palette-shape-black", Rgba::new(35, 35, 35, 255)), - ("--affine-palette-shape-blue", Rgba::new(184, 227, 255, 255)), - ("--affine-palette-shape-green", Rgba::new(157, 209, 148, 255)), - ("--affine-palette-shape-grey", Rgba::new(216, 217, 216, 255)), - ("--affine-palette-shape-magenta", Rgba::new(237, 140, 189, 255)), - ("--affine-palette-shape-navy", Rgba::new(122, 149, 246, 255)), - ("--affine-palette-shape-orange", Rgba::new(255, 196, 107, 255)), - ("--affine-palette-shape-purple", Rgba::new(147, 126, 231, 255)), - ("--affine-palette-shape-red", Rgba::new(241, 111, 111, 255)), - ("--affine-palette-shape-tangerine", Rgba::new(251, 161, 121, 255)), - ("--affine-palette-shape-teal", Rgba::new(184, 242, 231, 255)), - ("--affine-palette-shape-white", Rgba::new(255, 255, 255, 255)), - ("--affine-palette-shape-yellow", Rgba::new(255, 223, 107, 255)), - ("--affine-v2-edgeless-palette-black", Rgba::new(0, 0, 0, 255)), - ("--affine-v2-edgeless-palette-heavy-blue", Rgba::new(28, 112, 165, 255)), - ("--affine-v2-edgeless-palette-heavy-green", Rgba::new(68, 119, 86, 255)), - ("--affine-v2-edgeless-palette-heavy-magenta", Rgba::new(148, 21, 85, 255)), - ("--affine-v2-edgeless-palette-heavy-orange", Rgba::new(181, 83, 9, 255)), - ("--affine-v2-edgeless-palette-heavy-purple", Rgba::new(90, 33, 182, 255)), - ("--affine-v2-edgeless-palette-heavy-red", Rgba::new(118, 23, 23, 255)), - ("--affine-v2-edgeless-palette-heavy-yellow", Rgba::new(172, 116, 0, 255)), - ("--affine-v2-edgeless-palette-light-blueLight", Rgba::new(230, 245, 255, 255)), - ("--affine-v2-edgeless-palette-light-greenLight", Rgba::new(241, 253, 244, 255)), - ("--affine-v2-edgeless-palette-light-greyLight", Rgba::new(230, 230, 230, 255)), - ("--affine-v2-edgeless-palette-light-magentaLight", Rgba::new(255, 236, 246, 255)), - ("--affine-v2-edgeless-palette-light-orangeLight", Rgba::new(255, 235, 213, 255)), - ("--affine-v2-edgeless-palette-light-purpleLight", Rgba::new(237, 233, 255, 255)), - ("--affine-v2-edgeless-palette-light-redLight", Rgba::new(252, 229, 230, 255)), - ("--affine-v2-edgeless-palette-light-yellowLight", Rgba::new(255, 251, 213, 255)), - ("--affine-v2-edgeless-palette-medium-blueMedium", Rgba::new(132, 207, 255, 255)), - ("--affine-v2-edgeless-palette-medium-greenMedium", Rgba::new(60, 188, 54, 255)), - ("--affine-v2-edgeless-palette-medium-greyMedium", Rgba::new(146, 146, 146, 255)), - ("--affine-v2-edgeless-palette-medium-magentaMedium", Rgba::new(233, 108, 171, 255)), - ("--affine-v2-edgeless-palette-medium-orangeMedium", Rgba::new(255, 140, 56, 255)), - ("--affine-v2-edgeless-palette-medium-purpleMedium", Rgba::new(110, 82, 223, 255)), - ("--affine-v2-edgeless-palette-medium-redMedium", Rgba::new(251, 112, 129, 255)), - ("--affine-v2-edgeless-palette-medium-yellowMedium", Rgba::new(252, 211, 77, 255)), - ("--affine-v2-edgeless-palette-white", Rgba::new(255, 255, 255, 255)), - ], - connector_palette: &[ - ("--affine-palette-line-black", Rgba::new(35, 35, 35, 255)), - ("--affine-palette-line-blue", Rgba::new(79, 144, 255, 255)), - ("--affine-palette-line-green", Rgba::new(124, 194, 112, 255)), - ("--affine-palette-line-grey", Rgba::new(191, 192, 191, 255)), - ("--affine-palette-line-magenta", Rgba::new(230, 96, 164, 255)), - ("--affine-palette-line-navy", Rgba::new(59, 37, 204, 255)), - ("--affine-palette-line-orange", Rgba::new(255, 175, 56, 255)), - ("--affine-palette-line-purple", Rgba::new(110, 82, 223, 255)), - ("--affine-palette-line-red", Rgba::new(237, 63, 63, 255)), - ("--affine-palette-line-tangerine", Rgba::new(250, 124, 69, 255)), - ("--affine-palette-line-teal", Rgba::new(122, 226, 213, 255)), - ("--affine-palette-line-white", Rgba::new(255, 255, 255, 255)), - ("--affine-palette-line-yellow", Rgba::new(255, 211, 56, 255)), + ("--affine-active-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 2.0_f32, r: 30.0_f32 / 255.0_f32, g: 150.0_f32 / 255.0_f32, b: 235.0_f32 / 255.0_f32, a: 0.3_f32 }, + ]), + ("--affine-ai-empty-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 4.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.1_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 8.0_f32, spread_radius: 0.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.05_f32 }, + ]), + ("--affine-button-inner-shadow", &[]), + ("--affine-button-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 1.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.12_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 5.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.12_f32 }, + ]), + ("--affine-cmd-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 10.0_f32, blur_radius: 80.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.2_f32 }, + ]), + ("--affine-embed-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 2.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.08_f32 }, + ]), + ("--affine-float-button-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 10.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.05_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 0.5_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.1_f32 }, + ]), + ("--affine-float-button-shadow-1", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 4.0_f32, blur_radius: 6.0_f32, spread_radius: -3.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.1_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 10.0_f32, blur_radius: 12.0_f32, spread_radius: -2.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.1_f32 }, + ]), + ("--affine-float-button-shadow-2", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 4.0_f32, blur_radius: 4.0_f32, spread_radius: -2.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.1_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 8.0_f32, spread_radius: 1.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.05_f32 }, + ]), + ("--affine-kanban-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 3.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.05_f32 }, + ]), + ("--affine-menu-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 10.0_f32, blur_radius: 18.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.14_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: -1.0_f32, blur_radius: 12.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.08_f32 }, + ]), + ("--affine-multi-cursors-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.28_f32 }, + ]), + ("--affine-multi-players-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 6.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.16_f32 }, + ]), + ("--affine-note-shadow-box", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.14_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 12.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.14_f32 }, + ]), + ("--affine-note-shadow-film", &[ + ShadowLayer { offset_x: 10.0_f32, offset_y: 10.0_f32, blur_radius: 0.0_f32, spread_radius: 6.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 1.0_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 6.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 1.0_f32 }, + ]), + ("--affine-note-shadow-float", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 32.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.09_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 3.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.1_f32 }, + ]), + ("--affine-note-shadow-paper", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.05_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 10.0_f32, r: 255.0_f32 / 255.0_f32, g: 255.0_f32 / 255.0_f32, b: 255.0_f32 / 255.0_f32, a: 1.0_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 3.0_f32, blur_radius: 6.0_f32, spread_radius: 12.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.14_f32 }, + ]), + ("--affine-note-shadow-sticker", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 16.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.08_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 26.0_f32, blur_radius: 18.0_f32, spread_radius: -20.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.1_f32 }, + ]), + ("--affine-overlay-panel-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 6.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.16_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 8.0_f32, blur_radius: 14.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.08_f32 }, + ]), + ("--affine-overlay-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 6.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.16_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 8.0_f32, blur_radius: 14.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.08_f32 }, + ]), + ("--affine-popover-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 30.0_f32, spread_radius: 0.0_f32, r: 75.0_f32 / 255.0_f32, g: 75.0_f32 / 255.0_f32, b: 75.0_f32 / 255.0_f32, a: 0.2_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 75.0_f32 / 255.0_f32, g: 75.0_f32 / 255.0_f32, b: 75.0_f32 / 255.0_f32, a: 0.3_f32 }, + ]), + ("--affine-shadow-1", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.14_f32 }, + ]), + ("--affine-shadow-2", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 12.0_f32, spread_radius: 0.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.18_f32 }, + ]), + ("--affine-shadow-3", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 20.0_f32, spread_radius: 0.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.22_f32 }, + ]), + ("--affine-toggle-circle-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 2.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.25_f32 }, + ]), + ("--affine-toolbar-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 16.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 36.0_f32 / 255.0_f32 }, + ]), ], }; @@ -1460,111 +1449,97 @@ pub const DARK_THEME: ThemeTokens = ThemeTokens { ("--affine-windows-close-button", Rgba::new(196, 43, 28, 255)), ], shadows: &[ - ("--affine-active-shadow", "0px 0px 0px 2px rgba(28, 158, 228, .3)"), - ("--affine-ai-empty-shadow", "0px 4px 4px rgba(66, 65, 73, .1), 0px 6px 8px rgba(66, 65, 73, .05)"), - ("--affine-button-inner-shadow", "unset"), - ("--affine-button-shadow", "0px 0px 1px 0px rgba(0, 0, 0, .2), 0px 1px 5px 0px rgba(0, 0, 0, .2)"), - ("--affine-cmd-shadow", "0px 16px 80px 0px rgba(0, 0, 0, .8)"), - ("--affine-embed-shadow", "0px 0px 0px 2px rgba(255, 255, 255, .14)"), - ("--affine-float-button-shadow", "0px 0px 10px rgba(0, 0, 0, .05), 0px 0px 0px .5px rgba(0, 0, 0, .1)"), - ("--affine-float-button-shadow-1", "0px 4px 6px -3px rgba(0, 0, 0, .1), 0px 10px 12px -2px rgba(0, 0, 0, .1)"), - ("--affine-float-button-shadow-2", "0px 4px 4px -2px rgba(15, 15, 15, .1), 0px 6px 8px 1px rgba(15, 15, 15, .05)"), - ("--affine-kanban-shadow", "0px 2px 3px 0px rgba(0, 0, 0, .6)"), - ("--affine-menu-shadow", "0px 10px 18px rgba(0,0,0,.14), 0px -1px 12px rgba(0,0,0,.08)"), - ("--affine-multi-cursors-shadow", "0px 2px 4px 0px rgba(0, 0, 0, .28)"), - ("--affine-multi-players-shadow", "0px 1px 6px 0px rgba(0, 0, 0, .16)"), - ("--affine-note-shadow-box", "0px 0px 2px 0px rgba(255, 255, 255, .44), 0px 2px 12px 0px rgba(0, 0, 0, .3)"), - ("--affine-note-shadow-film", "10px 10px 0px 6px #7A7A7A, 0px 0px 0px 6px #7A7A7A"), - ("--affine-note-shadow-float", "0px 0px 32px 0px rgba(0, 0, 0, .3), 0px 0px 2px 0px rgba(255, 255, 255, .44)"), - ("--affine-note-shadow-paper", "0px 2px 4px 0px rgba(0, 0, 0, .3), 0px 0px 10px #7A7A7A, 0px 6px 12px rgba(0, 0, 0, .4)"), - ("--affine-note-shadow-sticker", "0px 24px 26px -10px rgba(0, 0, 0, .22), 0px 26px 18px -18px rgba(0, 0, 0, .52)"), - ("--affine-overlay-panel-shadow", "0px 1px 6px rgba(0,0,0,.2), 0px 8px 14px rgba(0,0,0,.3)"), - ("--affine-overlay-shadow", "0px 1px 6px 0px rgba(0, 0, 0, .72), 0px 8px 14px 0px rgba(0, 0, 0, .32)"), - ("--affine-popover-shadow", "0px 0px 30px 0px rgba(0, 0, 0, .1), 0px 0px 8px 0px rgba(0, 0, 0, .18), 0px 0px 0px .5px rgba(48, 48, 48, 1) inset"), - ("--affine-shadow-1", "0px 0px 4px 0px rgba(0, 0, 0, .24)"), - ("--affine-shadow-2", "0px 0px 12px 0px rgba(0, 0, 0, .28)"), - ("--affine-shadow-3", "0px 0px 20px 0px rgba(0, 0, 0, .32)"), - ("--affine-toggle-circle-shadow", "0px 1px 2px 0px rgba(0, 0, 0, .25), inset -2px -3px 2px 0px rgba(0, 0, 0, .05)"), - ("--affine-toolbar-shadow", "0px 6px 18px #00000052"), - ], - note_palette: &[ - ("--affine-note-background-black", Rgba::new(255, 255, 255, 255)), - ("--affine-note-background-blue", Rgba::new(3, 95, 159, 255)), - ("--affine-note-background-green", Rgba::new(59, 83, 21, 255)), - ("--affine-note-background-grey", Rgba::new(86, 86, 86, 255)), - ("--affine-note-background-magenta", Rgba::new(148, 21, 85, 255)), - ("--affine-note-background-orange", Rgba::new(132, 59, 6, 255)), - ("--affine-note-background-purple", Rgba::new(49, 46, 129, 255)), - ("--affine-note-background-red", Rgba::new(118, 23, 23, 255)), - ("--affine-note-background-teal", Rgba::new(28, 107, 99, 255)), - ("--affine-note-background-white", Rgba::new(0, 0, 0, 255)), - ("--affine-note-background-yellow", Rgba::new(111, 65, 0, 255)), - ("--affine-v2-edgeless-note-black", Rgba::new(37, 37, 37, 255)), - ("--affine-v2-edgeless-note-blue", Rgba::new(0, 75, 123, 255)), - ("--affine-v2-edgeless-note-green", Rgba::new(59, 83, 21, 255)), - ("--affine-v2-edgeless-note-grey", Rgba::new(86, 86, 86, 255)), - ("--affine-v2-edgeless-note-magenta", Rgba::new(95, 10, 53, 255)), - ("--affine-v2-edgeless-note-orange", Rgba::new(132, 59, 6, 255)), - ("--affine-v2-edgeless-note-purple", Rgba::new(49, 46, 129, 255)), - ("--affine-v2-edgeless-note-red", Rgba::new(70, 6, 6, 255)), - ("--affine-v2-edgeless-note-teal", Rgba::new(14, 72, 65, 255)), - ("--affine-v2-edgeless-note-white", Rgba::new(37, 37, 37, 255)), - ("--affine-v2-edgeless-note-yellow", Rgba::new(112, 66, 0, 255)), - ], - shape_palette: &[ - ("--affine-palette-shape-black", Rgba::new(35, 35, 35, 255)), - ("--affine-palette-shape-blue", Rgba::new(184, 227, 255, 255)), - ("--affine-palette-shape-green", Rgba::new(157, 209, 148, 255)), - ("--affine-palette-shape-grey", Rgba::new(216, 217, 216, 255)), - ("--affine-palette-shape-magenta", Rgba::new(237, 140, 189, 255)), - ("--affine-palette-shape-navy", Rgba::new(122, 149, 246, 255)), - ("--affine-palette-shape-orange", Rgba::new(255, 196, 107, 255)), - ("--affine-palette-shape-purple", Rgba::new(147, 126, 231, 255)), - ("--affine-palette-shape-red", Rgba::new(241, 111, 111, 255)), - ("--affine-palette-shape-tangerine", Rgba::new(251, 161, 121, 255)), - ("--affine-palette-shape-teal", Rgba::new(184, 242, 231, 255)), - ("--affine-palette-shape-white", Rgba::new(255, 255, 255, 255)), - ("--affine-palette-shape-yellow", Rgba::new(255, 223, 107, 255)), - ("--affine-v2-edgeless-palette-black", Rgba::new(255, 255, 255, 255)), - ("--affine-v2-edgeless-palette-heavy-blue", Rgba::new(28, 112, 165, 255)), - ("--affine-v2-edgeless-palette-heavy-green", Rgba::new(68, 119, 86, 255)), - ("--affine-v2-edgeless-palette-heavy-magenta", Rgba::new(148, 21, 85, 255)), - ("--affine-v2-edgeless-palette-heavy-orange", Rgba::new(181, 83, 9, 255)), - ("--affine-v2-edgeless-palette-heavy-purple", Rgba::new(90, 33, 182, 255)), - ("--affine-v2-edgeless-palette-heavy-red", Rgba::new(118, 23, 23, 255)), - ("--affine-v2-edgeless-palette-heavy-yellow", Rgba::new(172, 116, 0, 255)), - ("--affine-v2-edgeless-palette-light-blueLight", Rgba::new(230, 245, 255, 255)), - ("--affine-v2-edgeless-palette-light-greenLight", Rgba::new(241, 253, 244, 255)), - ("--affine-v2-edgeless-palette-light-greyLight", Rgba::new(230, 230, 230, 255)), - ("--affine-v2-edgeless-palette-light-magentaLight", Rgba::new(255, 236, 246, 255)), - ("--affine-v2-edgeless-palette-light-orangeLight", Rgba::new(255, 235, 213, 255)), - ("--affine-v2-edgeless-palette-light-purpleLight", Rgba::new(215, 205, 255, 255)), - ("--affine-v2-edgeless-palette-light-redLight", Rgba::new(252, 229, 230, 255)), - ("--affine-v2-edgeless-palette-light-yellowLight", Rgba::new(255, 251, 213, 255)), - ("--affine-v2-edgeless-palette-medium-blueMedium", Rgba::new(132, 207, 255, 255)), - ("--affine-v2-edgeless-palette-medium-greenMedium", Rgba::new(60, 188, 54, 255)), - ("--affine-v2-edgeless-palette-medium-greyMedium", Rgba::new(146, 146, 146, 255)), - ("--affine-v2-edgeless-palette-medium-magentaMedium", Rgba::new(233, 108, 171, 255)), - ("--affine-v2-edgeless-palette-medium-orangeMedium", Rgba::new(255, 140, 56, 255)), - ("--affine-v2-edgeless-palette-medium-purpleMedium", Rgba::new(110, 82, 223, 255)), - ("--affine-v2-edgeless-palette-medium-redMedium", Rgba::new(251, 112, 129, 255)), - ("--affine-v2-edgeless-palette-medium-yellowMedium", Rgba::new(252, 211, 77, 255)), - ("--affine-v2-edgeless-palette-white", Rgba::new(0, 0, 0, 255)), - ], - connector_palette: &[ - ("--affine-palette-line-black", Rgba::new(35, 35, 35, 255)), - ("--affine-palette-line-blue", Rgba::new(79, 144, 255, 255)), - ("--affine-palette-line-green", Rgba::new(124, 194, 112, 255)), - ("--affine-palette-line-grey", Rgba::new(191, 192, 191, 255)), - ("--affine-palette-line-magenta", Rgba::new(230, 96, 164, 255)), - ("--affine-palette-line-navy", Rgba::new(59, 37, 204, 255)), - ("--affine-palette-line-orange", Rgba::new(255, 175, 56, 255)), - ("--affine-palette-line-purple", Rgba::new(110, 82, 223, 255)), - ("--affine-palette-line-red", Rgba::new(237, 63, 63, 255)), - ("--affine-palette-line-tangerine", Rgba::new(250, 124, 69, 255)), - ("--affine-palette-line-teal", Rgba::new(122, 226, 213, 255)), - ("--affine-palette-line-white", Rgba::new(255, 255, 255, 255)), - ("--affine-palette-line-yellow", Rgba::new(255, 211, 56, 255)), + ("--affine-active-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 2.0_f32, r: 28.0_f32 / 255.0_f32, g: 158.0_f32 / 255.0_f32, b: 228.0_f32 / 255.0_f32, a: 0.3_f32 }, + ]), + ("--affine-ai-empty-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 4.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.1_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 8.0_f32, spread_radius: 0.0_f32, r: 66.0_f32 / 255.0_f32, g: 65.0_f32 / 255.0_f32, b: 73.0_f32 / 255.0_f32, a: 0.05_f32 }, + ]), + ("--affine-button-inner-shadow", &[]), + ("--affine-button-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 1.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.2_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 5.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.2_f32 }, + ]), + ("--affine-cmd-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 16.0_f32, blur_radius: 80.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.8_f32 }, + ]), + ("--affine-embed-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 2.0_f32, r: 255.0_f32 / 255.0_f32, g: 255.0_f32 / 255.0_f32, b: 255.0_f32 / 255.0_f32, a: 0.14_f32 }, + ]), + ("--affine-float-button-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 10.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.05_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 0.5_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.1_f32 }, + ]), + ("--affine-float-button-shadow-1", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 4.0_f32, blur_radius: 6.0_f32, spread_radius: -3.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.1_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 10.0_f32, blur_radius: 12.0_f32, spread_radius: -2.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.1_f32 }, + ]), + ("--affine-float-button-shadow-2", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 4.0_f32, blur_radius: 4.0_f32, spread_radius: -2.0_f32, r: 15.0_f32 / 255.0_f32, g: 15.0_f32 / 255.0_f32, b: 15.0_f32 / 255.0_f32, a: 0.1_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 8.0_f32, spread_radius: 1.0_f32, r: 15.0_f32 / 255.0_f32, g: 15.0_f32 / 255.0_f32, b: 15.0_f32 / 255.0_f32, a: 0.05_f32 }, + ]), + ("--affine-kanban-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 3.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.6_f32 }, + ]), + ("--affine-menu-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 10.0_f32, blur_radius: 18.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.14_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: -1.0_f32, blur_radius: 12.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.08_f32 }, + ]), + ("--affine-multi-cursors-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.28_f32 }, + ]), + ("--affine-multi-players-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 6.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.16_f32 }, + ]), + ("--affine-note-shadow-box", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 2.0_f32, spread_radius: 0.0_f32, r: 255.0_f32 / 255.0_f32, g: 255.0_f32 / 255.0_f32, b: 255.0_f32 / 255.0_f32, a: 0.44_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 12.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.3_f32 }, + ]), + ("--affine-note-shadow-film", &[ + ShadowLayer { offset_x: 10.0_f32, offset_y: 10.0_f32, blur_radius: 0.0_f32, spread_radius: 6.0_f32, r: 122.0_f32 / 255.0_f32, g: 122.0_f32 / 255.0_f32, b: 122.0_f32 / 255.0_f32, a: 1.0_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 0.0_f32, spread_radius: 6.0_f32, r: 122.0_f32 / 255.0_f32, g: 122.0_f32 / 255.0_f32, b: 122.0_f32 / 255.0_f32, a: 1.0_f32 }, + ]), + ("--affine-note-shadow-float", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 32.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.3_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 2.0_f32, spread_radius: 0.0_f32, r: 255.0_f32 / 255.0_f32, g: 255.0_f32 / 255.0_f32, b: 255.0_f32 / 255.0_f32, a: 0.44_f32 }, + ]), + ("--affine-note-shadow-paper", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 2.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.3_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 10.0_f32, spread_radius: 0.0_f32, r: 122.0_f32 / 255.0_f32, g: 122.0_f32 / 255.0_f32, b: 122.0_f32 / 255.0_f32, a: 1.0_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 12.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.4_f32 }, + ]), + ("--affine-note-shadow-sticker", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 24.0_f32, blur_radius: 26.0_f32, spread_radius: -10.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.22_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 26.0_f32, blur_radius: 18.0_f32, spread_radius: -18.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.52_f32 }, + ]), + ("--affine-overlay-panel-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 6.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.2_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 8.0_f32, blur_radius: 14.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.3_f32 }, + ]), + ("--affine-overlay-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 6.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.72_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 8.0_f32, blur_radius: 14.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.32_f32 }, + ]), + ("--affine-popover-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 30.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.1_f32 }, + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 8.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.18_f32 }, + ]), + ("--affine-shadow-1", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 4.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.24_f32 }, + ]), + ("--affine-shadow-2", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 12.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.28_f32 }, + ]), + ("--affine-shadow-3", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 0.0_f32, blur_radius: 20.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.32_f32 }, + ]), + ("--affine-toggle-circle-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 1.0_f32, blur_radius: 2.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 0.25_f32 }, + ]), + ("--affine-toolbar-shadow", &[ + ShadowLayer { offset_x: 0.0_f32, offset_y: 6.0_f32, blur_radius: 18.0_f32, spread_radius: 0.0_f32, r: 0.0_f32 / 255.0_f32, g: 0.0_f32 / 255.0_f32, b: 0.0_f32 / 255.0_f32, a: 82.0_f32 / 255.0_f32 }, + ]), ], };