Gruvbox: light and dark themes with three contrast choices (#10292)

* claim: consolidate Gruvbox contrast variants

* Consolidate Gruvbox variants into light and dark contrast choices

* Check both original Gruvbox viewport gradient endpoints

* Reset Gruvbox scenario state before independent theme checks
This commit is contained in:
Nathan Dane
2026-10-31 21:58:30 +00:00
committed by GitHub
parent 2e3448f348
commit 4594d81f7a
14 changed files with 530 additions and 729 deletions
-4
View File
@@ -189,11 +189,7 @@ Editable drawing code, native projects and shipped exports are collected under `
| assets/shaders/viewport.wgsl | SolidCraft contributors | Original SolidCraft resource data or drawing code, collected without redesign | MIT OR Apache-2.0 |
| assets/styles/ui/palettes.rs | SolidCraft contributors | Original SolidCraft resource data or drawing code, collected without redesign | MIT OR Apache-2.0 |
| assets/styles/ui/themes/gruvbox-dark.json | SolidCraft contributors | original SolidCraft theme file mapping SolidCraft's UI colours to the Gruvbox palette's colour values (Gruvbox by Pavel Pertsev, https://github.com/morhetz/gruvbox, MIT) | MIT OR Apache-2.0 |
| assets/styles/ui/themes/gruvbox-dark-hard.json | SolidCraft contributors | original SolidCraft theme file mapping SolidCraft's UI colours to the Gruvbox palette's colour values (Gruvbox by Pavel Pertsev, https://github.com/morhetz/gruvbox, MIT) | MIT OR Apache-2.0 |
| assets/styles/ui/themes/gruvbox-dark-soft.json | SolidCraft contributors | original SolidCraft theme file mapping SolidCraft's UI colours to the Gruvbox palette's colour values (Gruvbox by Pavel Pertsev, https://github.com/morhetz/gruvbox, MIT) | MIT OR Apache-2.0 |
| assets/styles/ui/themes/gruvbox-light.json | SolidCraft contributors | original SolidCraft theme file mapping SolidCraft's UI colours to the Gruvbox palette's colour values (Gruvbox by Pavel Pertsev, https://github.com/morhetz/gruvbox, MIT) | MIT OR Apache-2.0 |
| assets/styles/ui/themes/gruvbox-light-hard.json | SolidCraft contributors | original SolidCraft theme file mapping SolidCraft's UI colours to the Gruvbox palette's colour values (Gruvbox by Pavel Pertsev, https://github.com/morhetz/gruvbox, MIT) | MIT OR Apache-2.0 |
| assets/styles/ui/themes/gruvbox-light-soft.json | SolidCraft contributors | original SolidCraft theme file mapping SolidCraft's UI colours to the Gruvbox palette's colour values (Gruvbox by Pavel Pertsev, https://github.com/morhetz/gruvbox, MIT) | MIT OR Apache-2.0 |
| assets/styles/ui/themes/solidcraft-95.json | SolidCraft contributors | original SolidCraft theme file | MIT OR Apache-2.0 |
| assets/styles/ui/themes/platinum-9.json | SolidCraft contributors | original SolidCraft theme file | MIT OR Apache-2.0 |
| assets/styles/ui/themes/cupertino.json | SolidCraft contributors | original SolidCraft theme file | MIT OR Apache-2.0 |
@@ -1,171 +0,0 @@
{
"order": 20,
"provenance": "Original SolidCraft mapping of Gruvbox (MIT palette)",
"format": "solidcraft-theme/1",
"name": "Gruvbox Dark Hard",
"base": "dark",
"colors": {
"app_bar": "#141617",
"toolbar": "#1d2021",
"panel": "#1d2021",
"panel_header": "#3c3836",
"border": "#504945",
"text": "#ebdbb2",
"text_dim": "#a89984",
"accent": "#83a598",
"accent_soft": "#414f4b",
"sketch_accent": "#a1a322",
"error": "#fb4934",
"warning": "#fabd2f",
"icon": "#d5c4a1",
"timeline": "#141617",
"hover": "#46403e",
"sel_face": "#458588",
"sel_edge": "#83a598",
"sel_edge_rim": "#aec4bc",
"sel_profile": "#076678",
"sel_profile_edge": "#458588",
"hover_profile": "#83a59830",
"hover_profile_edge": "#83a598",
"sel_vertex": "#83a598",
"origin_plane": "#fe801950",
"origin_plane_edge": "#d65d0ec8",
"origin_plane_hover": "#83a59896",
"origin_point": "#d5c4a1",
"axis_x": "#fb4934",
"axis_y": "#b8bb26",
"axis_z": "#83a598",
"construction_plane": "#fe801940",
"construction_geom": "#e97926",
"body": "#a89984",
"body_edge": "#141617",
"manipulator": "#83a598",
"preview_add": "#83a598",
"preview_new": "#fabd2f",
"preview_sketch": "#b8bb26",
"preview_cut": "#fb49346e",
"cube_face": "#ebdbb2",
"cube_border": "#665c54",
"cube_text": "#282828",
"cube_hover": "#83a598",
"viewport_top": "#2c2c2c",
"viewport_bottom": "#2c2c2c",
"grid": "#443f3c",
"grid_major": "#504945",
"body_selected": "#83a598",
"sketch": "#83a598",
"sketch_fixed": "#ebdbb2",
"sketch_halo": "#141617",
"sketch_locked": "#b8bb26",
"dimension": "#fabd2f",
"dimension_driven": "#b57614",
"sketch_point": "#ebdbb2",
"sketch_point_free": "#83a598",
"dialog_bg": "#3c3836",
"dialog_border": "#504945",
"chip": "#458588",
"section_cap": "#d65d0e",
"profile_fill": "#83a59828",
"glyph_bg": "#2c2c2c",
"glyph_edge": "#fe614c",
"glyph_text": "#fe614c",
"overlay": "#1d2021f0",
"rubber_band": "#83a598",
"app_bar_text": "#ebdbb2",
"app_bar_hover": "#ebdbb21c",
"timeline_item": "#3c3836",
"timeline_item_error": "#63221f",
"timeline_marker": "#bdae93",
"field": "#141617",
"box_window": "#83a598",
"box_crossing": "#b8bb26",
"sketch_projected": "#d3869b",
"sketch_lost": "#fb4934",
"sketch_construction": "#fe8019",
"sketch_centerline": "#d65d0e",
"bend_up": "#b8bb26",
"bend_down": "#fe8019",
"interference": "#fb4934",
"icons.agent": "#d3869b",
"surface_fill": "#fe9755",
"surface_soft": "#382c20",
"surface_ink": "#fe8019",
"surface_accent": "#e97926",
"mesh_fill": "#e1ab32",
"mesh_soft": "#383323",
"mesh_ink": "#fabd2f",
"mesh_accent": "#c39429",
"form_fill": "#ea9bb0",
"form_soft": "#332c30",
"form_tab_ink": "#d3869b",
"form_accent": "#cf8297",
"sheet_fill": "#93c681",
"sheet_soft": "#2b332c",
"sheet_ink": "#8ec07c",
"render_fill": "#fc9483",
"render_soft": "#382523",
"render_ink": "#fb5d4a",
"render_accent": "#fe614c",
"sketch_soft": "#303322",
"sketch_ink": "#b8bb26",
"form_ink": "#ebdbb2",
"form_dim": "#bdae93",
"form_primary": "#83a598",
"form_error": "#fb4934",
"form_error_fill": "#63221f",
"form_success": "#b8bb26",
"form_success_fill": "#343a28",
"dialog_body": "#1d2021",
"dialog_footer": "#3c3836",
"dialog_rule": "#504945",
"control_fill": "#141617",
"control_border": "#7c6f64",
"dialog_label": "#ebdbb2",
"selected_ink": "#ebdbb2",
"selected_bg": "#414f4b",
"on_accent": "#1d2021"
},
"icon_palette": {
"ink": "#141617",
"line": "#d5c4a1",
"passive-1": "#c5c0b8",
"passive-2": "#9a948d",
"passive-3": "#706b64",
"guide": "#a89984",
"solid": [
"#b8dbcd",
"#9bbeb1",
"#83a598"
],
"surface": [
"#fcc4a3",
"#fe9755",
"#e97926"
],
"mesh": [
"#fbca67",
"#e1ab32",
"#c39429"
],
"form": [
"#fbbfce",
"#ea9bb0",
"#cf8297"
],
"sketch": [
"#d7db50",
"#babd2a",
"#a1a322"
],
"constraint": [
"#fcc2b7",
"#fc9483",
"#fe614c"
],
"construction": [
"#fcc4a3",
"#fe9755",
"#e97926"
]
}
}
@@ -1,172 +0,0 @@
{
"order": 30,
"provenance": "Original SolidCraft mapping of Gruvbox (MIT palette)",
"format": "solidcraft-theme/1",
"name": "Gruvbox Dark Soft",
"base": "dark",
"colors": {
"app_bar": "#1d2021",
"toolbar": "#32302f",
"panel": "#32302f",
"panel_header": "#3c3836",
"border": "#504945",
"text": "#ebdbb2",
"text_dim": "#a89984",
"accent": "#83a598",
"accent_soft": "#4e5954",
"selected_ink": "#ebdbb2",
"sketch_accent": "#a1a322",
"error": "#fb4934",
"warning": "#fabd2f",
"icon": "#d5c4a1",
"timeline": "#1d2021",
"hover": "#46403e",
"sel_face": "#458588",
"sel_edge": "#83a598",
"sel_edge_rim": "#aec4bc",
"sel_profile": "#076678",
"sel_profile_edge": "#458588",
"hover_profile": "#83a59830",
"hover_profile_edge": "#83a598",
"sel_vertex": "#83a598",
"origin_plane": "#fe801950",
"origin_plane_edge": "#d65d0ec8",
"origin_plane_hover": "#83a59896",
"origin_point": "#d5c4a1",
"axis_x": "#fb4934",
"axis_y": "#b8bb26",
"axis_z": "#83a598",
"construction_plane": "#fe801940",
"construction_geom": "#e97926",
"body": "#a89984",
"body_edge": "#1d2021",
"manipulator": "#83a598",
"preview_add": "#83a598",
"preview_new": "#fabd2f",
"preview_sketch": "#b8bb26",
"preview_cut": "#fb49346e",
"cube_face": "#ebdbb2",
"cube_border": "#665c54",
"cube_text": "#282828",
"cube_hover": "#83a598",
"viewport_top": "#373432",
"viewport_bottom": "#373432",
"grid": "#443f3c",
"grid_major": "#504945",
"body_selected": "#83a598",
"sketch": "#83a598",
"sketch_fixed": "#ebdbb2",
"sketch_halo": "#1d2021",
"sketch_locked": "#b8bb26",
"dimension": "#fabd2f",
"dimension_driven": "#b57614",
"sketch_point": "#ebdbb2",
"sketch_point_free": "#83a598",
"dialog_bg": "#3c3836",
"dialog_border": "#504945",
"chip": "#458588",
"section_cap": "#d65d0e",
"profile_fill": "#83a59828",
"glyph_bg": "#373432",
"glyph_edge": "#fe614c",
"glyph_text": "#fe614c",
"overlay": "#32302ff0",
"rubber_band": "#83a598",
"app_bar_text": "#ebdbb2",
"app_bar_hover": "#ebdbb21c",
"timeline_item": "#3c3836",
"timeline_item_error": "#702b28",
"timeline_marker": "#bdae93",
"field": "#1d2021",
"box_window": "#83a598",
"box_crossing": "#b8bb26",
"sketch_projected": "#d3869b",
"sketch_lost": "#fb4934",
"sketch_construction": "#fe8019",
"sketch_centerline": "#d65d0e",
"bend_up": "#b8bb26",
"bend_down": "#fe8019",
"interference": "#fb4934",
"icons.agent": "#d3869b",
"surface_fill": "#fe9755",
"surface_soft": "#4a3a2c",
"surface_ink": "#fe8b2e",
"surface_accent": "#e97926",
"mesh_fill": "#e1ab32",
"mesh_soft": "#4a412f",
"mesh_ink": "#fabd2f",
"mesh_accent": "#c39429",
"form_fill": "#ea9bb0",
"form_soft": "#453a3c",
"form_tab_ink": "#d996a8",
"form_accent": "#cf8297",
"sheet_fill": "#93c681",
"sheet_soft": "#3d4138",
"sheet_ink": "#8ec07c",
"render_fill": "#fc9483",
"render_soft": "#4a3330",
"render_ink": "#fc7e6f",
"render_accent": "#fe614c",
"sketch_soft": "#42412e",
"sketch_ink": "#b8bb26",
"form_ink": "#ebdbb2",
"form_dim": "#bdae93",
"form_primary": "#83a598",
"form_error": "#fb4934",
"form_error_fill": "#702b28",
"form_success": "#b8bb26",
"form_success_fill": "#343a28",
"dialog_body": "#32302f",
"dialog_footer": "#3c3836",
"dialog_rule": "#504945",
"control_fill": "#1d2021",
"control_border": "#7c6f64",
"dialog_label": "#ebdbb2",
"selected_ink": "#ebdbb2",
"selected_bg": "#4e5954",
"on_accent": "#1d2021"
},
"icon_palette": {
"ink": "#1d2021",
"line": "#d5c4a1",
"passive-1": "#c5c0b8",
"passive-2": "#9a948d",
"passive-3": "#706b64",
"guide": "#a89984",
"solid": [
"#b8dbcd",
"#9bbeb1",
"#83a598"
],
"surface": [
"#fcc4a3",
"#fe9755",
"#e97926"
],
"mesh": [
"#fbca67",
"#e1ab32",
"#c39429"
],
"form": [
"#fbbfce",
"#ea9bb0",
"#cf8297"
],
"sketch": [
"#d7db50",
"#babd2a",
"#a1a322"
],
"constraint": [
"#fcc2b7",
"#fc9483",
"#fe614c"
],
"construction": [
"#fcc4a3",
"#fe9755",
"#e97926"
]
}
}
+120 -2
View File
@@ -122,7 +122,6 @@
"control_fill": "#1d2021",
"control_border": "#7c6f64",
"dialog_label": "#ebdbb2",
"selected_ink": "#ebdbb2",
"selected_bg": "#48544f",
"on_accent": "#1d2021"
},
@@ -168,5 +167,124 @@
"#fe9755",
"#e97926"
]
}
},
"options": [
{
"id": "contrast",
"type": "choice",
"default": "standard",
"label": {
"de": "Kontrast",
"en": "Contrast",
"ja": "コントラスト",
"ko": "대비",
"zh": "对比度"
},
"help": {
"de": "Wähle die weiche, normale oder harte Gruvbox-Palette.",
"en": "Choose the soft, standard or hard Gruvbox palette.",
"ja": "Gruvboxのソフト・標準・ハードのパレットを選びます。",
"ko": "Gruvbox의 부드러운, 표준 또는 강한 팔레트를 선택합니다.",
"zh": "选择柔和、标准或强对比的 Gruvbox 配色。"
},
"values": [
{
"id": "soft",
"label": {
"de": "Weich",
"en": "Soft",
"ja": "ソフト",
"ko": "부드럽게",
"zh": "柔和"
}
},
{
"id": "standard",
"label": {
"de": "Standard",
"en": "Standard",
"ja": "標準",
"ko": "표준",
"zh": "标准"
}
},
{
"id": "hard",
"label": {
"de": "Hart",
"en": "Hard",
"ja": "ハード",
"ko": "강하게",
"zh": "强对比"
}
}
]
}
],
"overlays": [
{
"when": {
"opt": "contrast",
"eq": "soft"
},
"colors": {
"toolbar": "#32302f",
"panel": "#32302f",
"accent_soft": "#4e5954",
"viewport_top": "#373432",
"viewport_bottom": "#373432",
"glyph_bg": "#373432",
"overlay": "#32302ff0",
"timeline_item_error": "#702b28",
"surface_soft": "#4a3a2c",
"surface_ink": "#fe8b2e",
"mesh_soft": "#4a412f",
"form_soft": "#453a3c",
"form_tab_ink": "#d996a8",
"sheet_soft": "#3d4138",
"render_soft": "#4a3330",
"render_ink": "#fc7e6f",
"sketch_soft": "#42412e",
"form_error_fill": "#702b28",
"dialog_body": "#32302f",
"selected_bg": "#4e5954"
}
},
{
"when": {
"opt": "contrast",
"eq": "hard"
},
"colors": {
"app_bar": "#141617",
"toolbar": "#1d2021",
"panel": "#1d2021",
"accent_soft": "#414f4b",
"timeline": "#141617",
"body_edge": "#141617",
"viewport_top": "#2c2c2c",
"viewport_bottom": "#2c2c2c",
"sketch_halo": "#141617",
"glyph_bg": "#2c2c2c",
"overlay": "#1d2021f0",
"timeline_item_error": "#63221f",
"field": "#141617",
"surface_soft": "#382c20",
"mesh_soft": "#383323",
"form_soft": "#332c30",
"form_tab_ink": "#d3869b",
"sheet_soft": "#2b332c",
"render_soft": "#382523",
"render_ink": "#fb5d4a",
"sketch_soft": "#303322",
"form_error_fill": "#63221f",
"dialog_body": "#1d2021",
"control_fill": "#141617",
"selected_bg": "#414f4b"
},
"icon_palette": {
"ink": "#141617"
}
}
]
}
@@ -1,171 +0,0 @@
{
"order": 50,
"provenance": "Original SolidCraft mapping of Gruvbox (MIT palette)",
"format": "solidcraft-theme/1",
"name": "Gruvbox Light Hard",
"base": "light",
"colors": {
"app_bar": "#3c3836",
"toolbar": "#f9f5d7",
"panel": "#f9f5d7",
"panel_header": "#ebdbb2",
"border": "#d5c4a1",
"text": "#3c3836",
"text_dim": "#7c6f64",
"accent": "#076678",
"accent_soft": "#c9d8c4",
"sketch_accent": "#625e15",
"error": "#9d0006",
"warning": "#b57614",
"icon": "#504945",
"timeline": "#ebdbb2",
"hover": "#f1e5c1",
"sel_face": "#458588",
"sel_edge": "#076678",
"sel_edge_rim": "#83a598",
"sel_profile": "#076678",
"sel_profile_edge": "#458588",
"hover_profile": "#45858830",
"hover_profile_edge": "#458588",
"sel_vertex": "#076678",
"origin_plane": "#fe80195e",
"origin_plane_edge": "#d65d0ec8",
"origin_plane_hover": "#45858896",
"origin_point": "#d5c4a1",
"axis_x": "#cc241d",
"axis_y": "#98971a",
"axis_z": "#458588",
"construction_plane": "#fe801946",
"construction_geom": "#9b3407",
"body": "#bdae93",
"body_edge": "#3c3836",
"manipulator": "#076678",
"preview_add": "#458588",
"preview_new": "#d79921",
"preview_sketch": "#98971a",
"preview_cut": "#cc241d6e",
"cube_face": "#fbf1c7",
"cube_border": "#7c6f64",
"cube_text": "#3c3836",
"cube_hover": "#83a598",
"viewport_top": "#fbf8e3",
"viewport_bottom": "#ebdbb2",
"grid": "#d5c4a1",
"grid_major": "#bdae93",
"body_selected": "#83a598",
"sketch": "#076678",
"sketch_fixed": "#282828",
"sketch_halo": "#fbf8e3",
"sketch_locked": "#79740e",
"dimension": "#1f5c40",
"dimension_driven": "#4f7d64",
"sketch_point": "#282828",
"sketch_point_free": "#076678",
"dialog_bg": "#f9f5d7",
"dialog_border": "#d5c4a1",
"chip": "#458588",
"section_cap": "#d65d0e",
"profile_fill": "#fabd2f46",
"glyph_bg": "#fcfaeb",
"glyph_edge": "#a91714",
"glyph_text": "#a91714",
"overlay": "#f9f5d7eb",
"rubber_band": "#076678",
"app_bar_text": "#fbf1c7",
"app_bar_hover": "#fbf1c71c",
"timeline_item": "#f9f5d7",
"timeline_item_error": "#f0cbb2",
"timeline_marker": "#504945",
"field": "#fcfaeb",
"box_window": "#076678",
"box_crossing": "#79740e",
"sketch_projected": "#8f3f71",
"sketch_lost": "#9d0006",
"sketch_construction": "#af3a03",
"sketch_centerline": "#d65d0e",
"bend_up": "#79740e",
"bend_down": "#af3a03",
"interference": "#cc241d",
"icons.agent": "#8f3f71",
"surface_fill": "#df663c",
"surface_soft": "#f3e6c6",
"surface_ink": "#af3a03",
"surface_accent": "#9b3407",
"mesh_fill": "#c08024",
"mesh_soft": "#f4ebc7",
"mesh_ink": "#915e10",
"mesh_accent": "#7b5112",
"form_fill": "#c46fa2",
"form_soft": "#f1e6cf",
"form_tab_ink": "#8f3f71",
"form_accent": "#893a6c",
"sheet_fill": "#659f7a",
"sheet_soft": "#eaebcd",
"sheet_ink": "#3d7252",
"render_fill": "#e85a4d",
"render_soft": "#f2e1c6",
"render_ink": "#9d0006",
"render_accent": "#a91714",
"sketch_soft": "#efebc7",
"sketch_ink": "#6e6a0d",
"form_ink": "#3c3836",
"form_dim": "#665c54",
"form_primary": "#076678",
"form_error": "#9d0006",
"form_error_fill": "#f0cbb2",
"form_success": "#427b58",
"form_success_fill": "#dae3b6",
"dialog_body": "#f9f5d7",
"dialog_footer": "#ebdbb2",
"dialog_rule": "#d5c4a1",
"control_fill": "#fcfaeb",
"control_border": "#a89984",
"dialog_label": "#3c3836",
"selected_ink": "#3c3836",
"selected_bg": "#c9d8c4",
"on_accent": "#fbf1c7"
},
"icon_palette": {
"ink": "#3c3836",
"line": "#504945",
"passive-1": "#e9e3df",
"passive-2": "#b8b3af",
"passive-3": "#8a8581",
"guide": "#7c6f64",
"solid": [
"#87d5e9",
"#4e9caf",
"#076678"
],
"surface": [
"#feb299",
"#df663c",
"#9b3407"
],
"mesh": [
"#fcb864",
"#c08024",
"#7b5112"
],
"form": [
"#fbaad9",
"#c46fa2",
"#893a6c"
],
"sketch": [
"#d0cc73",
"#989439",
"#625e15"
],
"constraint": [
"#fab3a8",
"#e85a4d",
"#a91714"
],
"construction": [
"#feb299",
"#df663c",
"#9b3407"
]
}
}
@@ -1,171 +0,0 @@
{
"order": 60,
"provenance": "Original SolidCraft mapping of Gruvbox (MIT palette)",
"format": "solidcraft-theme/1",
"name": "Gruvbox Light Soft",
"base": "light",
"colors": {
"app_bar": "#3c3836",
"toolbar": "#f2e5bc",
"panel": "#f2e5bc",
"panel_header": "#ebdbb2",
"border": "#d5c4a1",
"text": "#3c3836",
"text_dim": "#7c6f64",
"accent": "#076678",
"accent_soft": "#c3ccae",
"sketch_accent": "#625e15",
"error": "#9d0006",
"warning": "#b57614",
"icon": "#504945",
"timeline": "#ebdbb2",
"hover": "#eedfb6",
"sel_face": "#458588",
"sel_edge": "#076678",
"sel_edge_rim": "#83a598",
"sel_profile": "#076678",
"sel_profile_edge": "#458588",
"hover_profile": "#45858830",
"hover_profile_edge": "#458588",
"sel_vertex": "#076678",
"origin_plane": "#fe80195e",
"origin_plane_edge": "#d65d0ec8",
"origin_plane_hover": "#45858896",
"origin_point": "#d5c4a1",
"axis_x": "#cc241d",
"axis_y": "#98971a",
"axis_z": "#458588",
"construction_plane": "#fe801946",
"construction_geom": "#9b3407",
"body": "#bdae93",
"body_edge": "#3c3836",
"manipulator": "#076678",
"preview_add": "#458588",
"preview_new": "#d79921",
"preview_sketch": "#98971a",
"preview_cut": "#cc241d6e",
"cube_face": "#fbf1c7",
"cube_border": "#7c6f64",
"cube_text": "#3c3836",
"cube_hover": "#83a598",
"viewport_top": "#f6edd0",
"viewport_bottom": "#ebdbb2",
"grid": "#d5c4a1",
"grid_major": "#bdae93",
"body_selected": "#83a598",
"sketch": "#076678",
"sketch_fixed": "#282828",
"sketch_halo": "#f6edd0",
"sketch_locked": "#79740e",
"dimension": "#1f5c40",
"dimension_driven": "#4f7d64",
"sketch_point": "#282828",
"sketch_point_free": "#076678",
"dialog_bg": "#f2e5bc",
"dialog_border": "#d5c4a1",
"chip": "#458588",
"section_cap": "#d65d0e",
"profile_fill": "#fabd2f46",
"glyph_bg": "#f8f2de",
"glyph_edge": "#a91714",
"glyph_text": "#a91714",
"overlay": "#f2e5bceb",
"rubber_band": "#076678",
"app_bar_text": "#fbf1c7",
"app_bar_hover": "#fbf1c71c",
"timeline_item": "#f2e5bc",
"timeline_item_error": "#eabe9c",
"timeline_marker": "#504945",
"field": "#f8f2de",
"box_window": "#076678",
"box_crossing": "#79740e",
"sketch_projected": "#8f3f71",
"sketch_lost": "#9d0006",
"sketch_construction": "#af3a03",
"sketch_centerline": "#d65d0e",
"bend_up": "#79740e",
"bend_down": "#af3a03",
"interference": "#cc241d",
"icons.agent": "#8f3f71",
"surface_fill": "#df663c",
"surface_soft": "#edd7ad",
"surface_ink": "#a83803",
"surface_accent": "#9b3407",
"mesh_fill": "#c08024",
"mesh_soft": "#eddcaf",
"mesh_ink": "#84560f",
"mesh_accent": "#7b5112",
"form_fill": "#c46fa2",
"form_soft": "#ead8b6",
"form_tab_ink": "#8f3f71",
"form_accent": "#893a6c",
"sheet_fill": "#659f7a",
"sheet_soft": "#e4ddb4",
"sheet_ink": "#38694b",
"render_fill": "#e85a4d",
"render_soft": "#ebd3ad",
"render_ink": "#9d0006",
"render_accent": "#a91714",
"sketch_soft": "#e8dcae",
"sketch_ink": "#66610c",
"form_ink": "#3c3836",
"form_dim": "#665c54",
"form_primary": "#076678",
"form_error": "#9d0006",
"form_error_fill": "#eabe9c",
"form_success": "#427b58",
"form_success_fill": "#dae3b6",
"dialog_body": "#f2e5bc",
"dialog_footer": "#ebdbb2",
"dialog_rule": "#d5c4a1",
"control_fill": "#f8f2de",
"control_border": "#a89984",
"dialog_label": "#3c3836",
"selected_ink": "#3c3836",
"selected_bg": "#c3ccae",
"on_accent": "#fbf1c7"
},
"icon_palette": {
"ink": "#3c3836",
"line": "#504945",
"passive-1": "#e9e3df",
"passive-2": "#b8b3af",
"passive-3": "#8a8581",
"guide": "#7c6f64",
"solid": [
"#87d5e9",
"#4e9caf",
"#076678"
],
"surface": [
"#feb299",
"#df663c",
"#9b3407"
],
"mesh": [
"#fcb864",
"#c08024",
"#7b5112"
],
"form": [
"#fbaad9",
"#c46fa2",
"#893a6c"
],
"sketch": [
"#d0cc73",
"#989439",
"#625e15"
],
"constraint": [
"#fab3a8",
"#e85a4d",
"#a91714"
],
"construction": [
"#feb299",
"#df663c",
"#9b3407"
]
}
}
+123 -1
View File
@@ -167,5 +167,127 @@
"#df663c",
"#9b3407"
]
}
},
"options": [
{
"id": "contrast",
"type": "choice",
"default": "standard",
"label": {
"de": "Kontrast",
"en": "Contrast",
"ja": "コントラスト",
"ko": "대비",
"zh": "对比度"
},
"help": {
"de": "Wähle die weiche, normale oder harte Gruvbox-Palette.",
"en": "Choose the soft, standard or hard Gruvbox palette.",
"ja": "Gruvboxのソフト・標準・ハードのパレットを選びます。",
"ko": "Gruvbox의 부드러운, 표준 또는 강한 팔레트를 선택합니다.",
"zh": "选择柔和、标准或强对比的 Gruvbox 配色。"
},
"values": [
{
"id": "soft",
"label": {
"de": "Weich",
"en": "Soft",
"ja": "ソフト",
"ko": "부드럽게",
"zh": "柔和"
}
},
{
"id": "standard",
"label": {
"de": "Standard",
"en": "Standard",
"ja": "標準",
"ko": "표준",
"zh": "标准"
}
},
{
"id": "hard",
"label": {
"de": "Hart",
"en": "Hard",
"ja": "ハード",
"ko": "강하게",
"zh": "强对比"
}
}
]
}
],
"overlays": [
{
"when": {
"opt": "contrast",
"eq": "soft"
},
"colors": {
"toolbar": "#f2e5bc",
"panel": "#f2e5bc",
"accent_soft": "#c3ccae",
"hover": "#eedfb6",
"viewport_top": "#f6edd0",
"sketch_halo": "#f6edd0",
"dialog_bg": "#f2e5bc",
"glyph_bg": "#f8f2de",
"overlay": "#f2e5bceb",
"timeline_item": "#f2e5bc",
"timeline_item_error": "#eabe9c",
"field": "#f8f2de",
"surface_soft": "#edd7ad",
"surface_ink": "#a83803",
"mesh_soft": "#eddcaf",
"mesh_ink": "#84560f",
"form_soft": "#ead8b6",
"sheet_soft": "#e4ddb4",
"sheet_ink": "#38694b",
"render_soft": "#ebd3ad",
"sketch_soft": "#e8dcae",
"sketch_ink": "#66610c",
"form_error_fill": "#eabe9c",
"dialog_body": "#f2e5bc",
"control_fill": "#f8f2de",
"selected_bg": "#c3ccae"
}
},
{
"when": {
"opt": "contrast",
"eq": "hard"
},
"colors": {
"toolbar": "#f9f5d7",
"panel": "#f9f5d7",
"accent_soft": "#c9d8c4",
"hover": "#f1e5c1",
"viewport_top": "#fbf8e3",
"sketch_halo": "#fbf8e3",
"dialog_bg": "#f9f5d7",
"glyph_bg": "#fcfaeb",
"overlay": "#f9f5d7eb",
"timeline_item": "#f9f5d7",
"timeline_item_error": "#f0cbb2",
"field": "#fcfaeb",
"surface_soft": "#f3e6c6",
"mesh_soft": "#f4ebc7",
"mesh_ink": "#915e10",
"form_soft": "#f1e6cf",
"sheet_soft": "#eaebcd",
"sheet_ink": "#3d7252",
"render_soft": "#f2e1c6",
"sketch_soft": "#efebc7",
"sketch_ink": "#6e6a0d",
"form_error_fill": "#f0cbb2",
"dialog_body": "#f9f5d7",
"control_fill": "#fcfaeb",
"selected_bg": "#c9d8c4"
}
}
]
}
+86 -7
View File
@@ -3612,10 +3612,14 @@ fn theme_options_row(app: &mut SolveApp, ui: &mut egui::Ui) {
fn merge_theme_options(prefs: &mut Prefs, followed: Option<&crate::theme_files::ThemeFile>, update: &serde_json::Value) -> Result<(), String> {
use crate::theme_files::{OptionKind, OptionValue};
let themes = update.as_object().ok_or("`theme_options` must be a map of theme ids to option maps")?;
for (theme_id, update) in themes {
// Apply legacy keys first so a canonical entry in the same request always wins.
let aliases = themes.iter().filter(|(id, _)| crate::theme_files::legacy_gruvbox(id).is_some());
let canonical = themes.iter().filter(|(id, _)| crate::theme_files::legacy_gruvbox(id).is_none());
for (requested_id, update) in aliases.chain(canonical) {
let theme_id = crate::theme_files::legacy_gruvbox(requested_id).map_or(requested_id.as_str(), |(family, _)| family);
let key = format!("theme_options.{theme_id}");
let file = followed.filter(|f| &f.id == theme_id).or_else(|| crate::theme_files::find(theme_id, &prefs.custom_themes));
let mode = THEMES.iter().any(|(id, _)| *id == theme_id.as_str());
let file = followed.filter(|f| f.id == theme_id).or_else(|| crate::theme_files::find(theme_id, &prefs.custom_themes));
let mode = THEMES.iter().any(|(id, _)| *id == theme_id);
if file.is_none() && !mode {
return Err(format!("`{key}`: unknown theme"));
}
@@ -3648,7 +3652,7 @@ fn merge_theme_options(prefs: &mut Prefs, followed: Option<&crate::theme_files::
if !valid {
return Err(format!("`{key}`: wrong type, unknown choice or out of range"));
}
prefs.theme_options.entry(theme_id.clone()).or_default().insert(id.clone(), value.clone());
prefs.theme_options.entry(theme_id.to_owned()).or_default().insert(id.clone(), value.clone());
}
if prefs.theme_options.get(theme_id).is_some_and(BTreeMap::is_empty) {
prefs.theme_options.remove(theme_id);
@@ -3736,6 +3740,7 @@ fn theme_file(app: &SolveApp, id: &str, system_dark: bool) -> serde_json::Value
/// calibration that can't be used as it is (a hand edit) is dropped, so the device is read as it
/// reports rather than spinning the view.
pub fn migrate(mut p: Prefs) -> Prefs {
migrate_gruvbox(&mut p);
// Every saved file carries the old default limit; it reads as no limit.
if p.agent_chat_turn_limit == crate::agent_chat::gate::OLD_DEFAULT_TURN_LIMIT {
p.agent_chat_turn_limit = 0;
@@ -3773,6 +3778,25 @@ pub fn migrate(mut p: Prefs) -> Prefs {
p
}
/// Fold old contrast cards into their family without replacing unrelated saved options.
/// An active old card still names the selected appearance; explicit control updates run after
/// this migration, so their contrast choice (including a reset) takes precedence.
pub(crate) fn migrate_gruvbox(p: &mut Prefs) {
let selected = crate::theme_files::legacy_gruvbox(&p.theme);
for (old, family, _) in crate::theme_files::GRUVBOX_ALIASES {
if let Some(options) = p.theme_options.remove(old) {
let canonical = p.theme_options.entry(family.into()).or_default();
for (id, value) in options {
canonical.entry(id).or_insert(value);
}
}
}
if let Some((family, contrast)) = selected {
p.theme = family.into();
p.theme_options.entry(family.into()).or_default().insert("contrast".into(), json!(contrast));
}
}
/// Drop plugin ids this page would not show, and keep at most [`crate::plugins::MAX_DISABLED`],
/// so a hand-edited preferences file cannot carry a huge or nonsense list. `set` still refuses
/// those instead of dropping them.
@@ -3884,6 +3908,7 @@ fn prepare_preferences(
return Err("`stand_up_unknown` must be ask, note or off".into());
}
let mut new: Prefs = serde_json::from_value(cur).map_err(|e| e.to_string())?;
migrate_gruvbox(&mut new);
if let Some(update) = p.get("theme_options") {
merge_theme_options(&mut new, followed, update)?;
}
@@ -5925,7 +5950,7 @@ mod tests {
let out = h.call("ui.prefs", json!({"theme": "gruvbox-dark-hard", "viewport_theme": "light"}));
assert_eq!((out["result"]["dark"].as_bool(), out["result"]["viewport_dark"].as_bool()), (Some(true), Some(false)), "{out}");
h.frames(2);
let hard = crate::theme_files::find("gruvbox-dark-hard", &[]).map(crate::theme_files::resolve).unwrap();
let hard = resolved_theme(&h.app.preferences, active_theme_file(&h.app).unwrap());
assert_eq!((Tokens::get().panel, Tokens::get().viewport_top), (hard.panel, Tokens::light().viewport_top));
// Asked for, an unknown value is refused; read from saved preferences, it is the default.
@@ -6798,16 +6823,70 @@ mod tests {
assert_eq!(Tokens::get().panel, Tokens::dark().panel);
}
#[test]
fn gruvbox_legacy_selection_migrates_on_load_and_preserves_saved_values() {
for (old, family, contrast) in crate::theme_files::GRUVBOX_ALIASES {
let saved = json!({"theme":old,"theme_options":{
family:{"contrast":"standard","unrelated":{"keep":true}},
old:{"contrast":"standard","future":42}
}});
let migrated = lenient(&saved);
assert_eq!(migrated.theme, family);
assert_eq!(migrated.theme_options[family]["contrast"], contrast);
assert_eq!(migrated.theme_options[family]["unrelated"], json!({"keep":true}));
assert_eq!(migrated.theme_options[family]["future"], 42);
assert!(!migrated.theme_options.contains_key(old));
assert_eq!(serde_json::to_value(migrate(migrated.clone())).unwrap(), serde_json::to_value(&migrated).unwrap());
let mut h = crate::scenario::Harness::new();
h.app.load_prefs(&json!({"preferences":saved}).to_string());
assert_eq!(h.app.preferences.theme, family);
assert_eq!(h.app.preferences.theme_options[family]["contrast"], contrast);
let output: serde_json::Value = serde_json::from_str(&h.app.prefs()).unwrap();
assert_eq!(output["preferences"]["theme"], family);
assert_eq!(output["preferences"]["theme_options"][family]["contrast"], contrast);
}
// An unselected legacy map must not replace an existing canonical contrast.
let migrated = lenient(&json!({"theme":"dark","theme_options":{
"gruvbox-dark":{"contrast":"soft"},"gruvbox-dark-hard":{"contrast":"hard"}
}}));
assert_eq!(migrated.theme_options["gruvbox-dark"]["contrast"], "soft");
}
#[test]
fn gruvbox_control_legacy_ids_allow_explicit_choices_resets_and_atomic_errors() {
let mut h = crate::scenario::Harness::new();
for (old, family, contrast) in crate::theme_files::GRUVBOX_ALIASES {
let out = control(&mut h.app, &json!({"theme":old})).unwrap();
assert_eq!(out["theme"], family);
assert_eq!(out["theme_option_values"]["contrast"], contrast);
let ids = out["theme_ids"].as_array().unwrap();
assert_eq!(ids.iter().filter(|id| id.as_str().is_some_and(|id| id.starts_with("gruvbox-"))).count(), 2);
let out = control(&mut h.app, &json!({"theme":old,"theme_options":{family:{"contrast":"standard"}}})).unwrap();
assert_eq!(out["theme_option_values"]["contrast"], "standard");
let out = control(&mut h.app, &json!({"theme":old,"theme_options":{family:{"contrast":null}}})).unwrap();
assert_eq!(out["theme_option_values"]["contrast"], "standard");
let out = control(&mut h.app, &json!({"theme":old,"theme_options":{family:{}}})).unwrap();
assert_eq!(out["theme_option_values"]["contrast"], "standard");
let out = control(&mut h.app, &json!({"theme":old,"theme_options":{old:{"contrast":"hard"},family:{"contrast":"soft"}}})).unwrap();
assert_eq!(out["theme_option_values"]["contrast"], "soft", "canonical explicit values win over alias entries");
let before = h.app.prefs();
assert!(control(&mut h.app, &json!({"theme":old,"open":"Interface","theme_options":{family:{"contrast":"invalid"}}})).is_err());
assert_eq!(h.app.prefs(), before, "failed changes do not migrate or open the dialog");
assert!(!h.app.prefs_window.open);
}
}
#[test]
fn theme_files_import_apply_export_save_and_remove() {
use crate::theme::{ColorVision, Tokens};
use serde_json::json;
let mut h = crate::scenario::Harness::new();
let out = h.call("ui.prefs", json!({"theme": "gruvbox-dark-hard"}));
assert_eq!(out["result"]["theme"], "gruvbox-dark-hard", "{out}");
assert_eq!(out["result"]["theme"], "gruvbox-dark", "{out}");
assert_eq!(out["result"]["theme_option_values"]["contrast"], "hard");
assert!(out["result"]["theme_ids"].as_array().is_some_and(|ids| ids.len() == 3 + crate::theme_files::builtin().len()), "{out}");
h.frames(2);
let hard = crate::theme_files::find("gruvbox-dark-hard", &[]).map(crate::theme_files::resolve).unwrap();
let hard = resolved_theme(&h.app.preferences, active_theme_file(&h.app).unwrap());
assert!(h.app.ui.dark);
assert_eq!(Tokens::get().panel, hard.panel);
assert_eq!(
+35 -7
View File
@@ -256,24 +256,52 @@ fn apply(app: &mut SolveApp, doc: &Value) -> Vec<String> {
theme_ids.insert(wanted, id);
}
}
// Resolve imported identities before migrating retired built-in cards. Migrate the
// theme and its option maps together: applying `theme` first and then replacing the
// saved maps would otherwise discard the old card's selected contrast.
let mut preferences = doc.get("preferences").and_then(Value::as_object).cloned().unwrap_or_default();
if let Some(id) = preferences.get("theme").and_then(Value::as_str).and_then(|id| theme_ids.get(id)).cloned() {
preferences.insert("theme".into(), json!(id));
}
if let Some(options) = preferences.get("theme_options").and_then(Value::as_object) {
let remapped: Map<String, Value> = options.iter().map(|(id, values)| (theme_ids.get(id).unwrap_or(id).clone(), values.clone())).collect();
preferences.insert("theme_options".into(), Value::Object(remapped));
}
let options = preferences
.get("theme_options")
.map(|value| serde_json::from_value::<std::collections::BTreeMap<String, std::collections::BTreeMap<String, Value>>>(value.clone()))
.transpose();
// Leave malformed raw fields intact for the existing per-key skipped reporting.
// In particular, a bad option map must not become an empty map that clears saved values.
if let Ok(options) = options {
let theme = preferences.get("theme").and_then(Value::as_str).map(str::to_owned);
let legacy = theme.as_deref().and_then(theme_files::legacy_gruvbox).is_some();
let mut migrated = prefs::Prefs {
theme: theme.clone().unwrap_or_else(|| "dark".into()),
theme_options: options.unwrap_or_else(|| app.preferences.theme_options.clone()),
..Default::default()
};
prefs::migrate_gruvbox(&mut migrated);
if theme.is_some() {
preferences.insert("theme".into(), json!(migrated.theme));
}
if preferences.contains_key("theme_options") || legacy {
preferences.insert("theme_options".into(), json!(migrated.theme_options));
}
}
let mut skipped = Vec::new();
for (key, value) in doc.get("preferences").and_then(Value::as_object).into_iter().flatten() {
for (key, value) in &preferences {
if key == "theme_options" {
// Restoring saved state keeps stale entries just like loading preferences. The
// control channel's strict merge is for new edits, not profile restoration.
match serde_json::from_value::<std::collections::BTreeMap<String, std::collections::BTreeMap<String, Value>>>(value.clone()) {
Ok(options) => {
app.preferences.theme_options =
options.into_iter().map(|(id, values)| (theme_ids.get(&id).cloned().unwrap_or(id), values)).collect();
app.preferences.theme_options = options;
}
Err(_) => skipped.push(key.clone()),
}
continue;
}
let value = match value.as_str().and_then(|id| theme_ids.get(id)) {
Some(id) if key == "theme" => json!(id),
_ => value.clone(),
};
if let Err(e) = prefs::set(app, &json!({ key: value })) {
log::warn!("settings profile: `{key}` keeps its current value: {e}");
skipped.push(key.clone());
@@ -109,6 +109,54 @@ fn profiles_and_the_active_one_are_kept_between_runs() {
assert_eq!(other.settings_profiles.list, h.app.settings_profiles.list);
}
#[test]
fn gruvbox_legacy_profiles_keep_their_selected_contrast_with_empty_option_maps() {
let mut h = Harness::new();
for (old, family, contrast) in crate::theme_files::GRUVBOX_ALIASES {
let profile = json!({"format":FORMAT,"name":old,"preferences":{"theme":old,"theme_options":{}}});
run(&mut h, "settings.profile.import", json!({"profile":profile}));
let out = run(&mut h, "settings.profile.apply", json!({"name":old}));
assert_eq!(out["skipped"], json!([]));
assert_eq!(h.app.preferences.theme, family);
assert_eq!(h.app.preferences.theme_options[family]["contrast"], contrast);
}
h.app.preferences.theme_options.insert("unrelated".into(), [("future".into(), json!({"keep":true}))].into());
let profile = json!({"format":FORMAT,"name":"Legacy without options","preferences":{"theme":"gruvbox-light-soft"}});
run(&mut h, "settings.profile.import", json!({"profile":profile}));
let out = run(&mut h, "settings.profile.apply", json!({"name":"Legacy without options"}));
assert_eq!(out["skipped"], json!([]));
assert_eq!(h.app.preferences.theme_options["gruvbox-light"]["contrast"], "soft");
assert_eq!(h.app.preferences.theme_options["unrelated"]["future"], json!({"keep":true}));
// A profile's own theme with a retired name is imported under a custom id,
// rather than being mistaken for a built-in contrast selection.
let profile = json!({"format":FORMAT,"name":"Named theme","preferences":{"theme":"gruvbox-dark-hard",
"theme_options":{"gruvbox-dark-hard":{"contrast":"personal"}}},
"themes":[{"id":"gruvbox-dark-hard","format":"solidcraft-theme/1","name":"Gruvbox Dark Hard","base":"light",
"options":[{"id":"contrast","type":"choice","default":"personal","values":[{"id":"personal","label":{"en":"Personal"}},{"id":"other","label":{"en":"Other"}}]}]}]});
run(&mut h, "settings.profile.import", json!({"profile":profile}));
let out = run(&mut h, "settings.profile.apply", json!({"name":"Named theme"}));
assert_eq!(out["skipped"], json!([]));
assert_eq!(h.app.preferences.theme, "custom-gruvbox-dark-hard");
assert_eq!(h.app.preferences.theme_options["custom-gruvbox-dark-hard"]["contrast"], "personal");
}
#[test]
fn gruvbox_profile_migration_keeps_malformed_theme_fields_for_skipped_reporting() {
let mut h = Harness::new();
h.call("ui.prefs", json!({"theme":"gruvbox-light","theme_options":{"gruvbox-light":{"contrast":"soft"}}}));
for bad in [json!({"theme":42,"theme_options":"bad"}), json!({"theme":false,"theme_options":{"gruvbox-dark":"bad"}})] {
let before_theme = h.app.preferences.theme.clone();
let before_options = h.app.preferences.theme_options.clone();
let profile = json!({"format":FORMAT,"name":"Malformed","preferences":bad});
// Keep the per-key apply guard effective even for malformed in-memory documents.
h.app.settings_profiles.list = vec![profile];
let out = run(&mut h, "settings.profile.apply", json!({"name":"Malformed"}));
assert_eq!(out["skipped"], json!(["theme", "theme_options"]));
assert_eq!(h.app.preferences.theme, before_theme);
assert_eq!(h.app.preferences.theme_options, before_options);
}
}
#[test]
fn theme_options_profiles_restore_replace_and_preserve_stale_values() {
let mut h = Harness::new();
+88 -23
View File
@@ -1338,11 +1338,24 @@ pub fn find<'a>(id: &str, custom: &'a [ThemeFile]) -> Option<&'a ThemeFile> {
builtin().iter().find(|t| t.id == id).or_else(|| custom.iter().find(|t| t.id == id))
}
/// Retired built-in cards now select a contrast value on their light/dark family.
/// Keep these ids reserved so importing a theme cannot take a saved built-in identity.
pub(crate) const GRUVBOX_ALIASES: [(&str, &str, &str); 4] = [
("gruvbox-dark-hard", "gruvbox-dark", "hard"),
("gruvbox-dark-soft", "gruvbox-dark", "soft"),
("gruvbox-light-hard", "gruvbox-light", "hard"),
("gruvbox-light-soft", "gruvbox-light", "soft"),
];
pub(crate) fn legacy_gruvbox(id: &str) -> Option<(&'static str, &'static str)> {
GRUVBOX_ALIASES.iter().find(|(old, _, _)| *old == id).map(|(_, family, contrast)| (*family, *contrast))
}
/// Add an imported theme to `custom`, replacing one with the same id (importing a file again
/// updates it). Its id never takes a built-in one's or the modes' (dark, light, system).
/// Returns the id it is kept under.
pub fn add(custom: &mut Vec<ThemeFile>, mut theme: ThemeFile) -> Result<String, String> {
if ["dark", "light", "system"].contains(&theme.id.as_str()) || builtin().iter().any(|t| t.id == theme.id) {
if ["dark", "light", "system"].contains(&theme.id.as_str()) || builtin().iter().any(|t| t.id == theme.id) || legacy_gruvbox(&theme.id).is_some() {
theme.id = format!("custom-{}", theme.id);
}
let id = theme.id.clone();
@@ -1976,12 +1989,16 @@ mod tests {
fn all_shipped_themes_keep_the_original_resolver_output_and_serialization() {
assert_eq!(builtin().len(), BUILTIN.len());
for theme in builtin() {
assert!(theme.options.is_empty() && theme.overlays.is_empty() && !theme.needs_newer());
let gruvbox = matches!(theme.id.as_str(), "gruvbox-dark" | "gruvbox-light");
assert!(!theme.needs_newer());
assert_eq!(!theme.options.is_empty(), gruvbox);
assert_eq!(!theme.overlays.is_empty(), gruvbox);
assert_eq!(resolve(theme), resolve_base(theme), "{}", theme.id);
assert_eq!(resolve_with(theme, &BTreeMap::from([("opacity".into(), OptionValue::Num(40.0))])), resolve_base(theme), "{}", theme.id);
let stored = serde_json::to_value(theme).unwrap();
for key in ["options", "overlays", "requires"] {
assert!(stored.get(key).is_none(), "{}: {key}", theme.id);
assert!(stored.get("requires").is_none(), "{}", theme.id);
for key in ["options", "overlays"] {
assert_eq!(stored.get(key).is_some(), gruvbox, "{}: {key}", theme.id);
}
}
}
@@ -2091,7 +2108,7 @@ mod tests {
assert_eq!(resolve(&file).borders, crate::theme::Borders::LEGACY);
assert!(parse_borders(&BTreeMap::from([("primary".into(), json!({"width":null,"color":"#ffffff"}))])).is_err());
assert_eq!(resolve(find("blueprint", &[]).unwrap()).borders.primary.unwrap().color, Color32::WHITE);
for id in ["gruvbox-dark", "gruvbox-light", "gruvbox-dark-soft", "gruvbox-light-soft"] {
for id in ["gruvbox-dark", "gruvbox-light"] {
assert_eq!(resolve(find(id, &[]).unwrap()).borders, crate::theme::Borders::LEGACY);
}
}
@@ -2155,17 +2172,22 @@ mod tests {
use crate::theme::{TabAccent, contrast_ratio};
assert_eq!(builtin().len(), BUILTIN.len(), "all shipped themes must be valid");
for file in builtin() {
let t = resolve(file);
assert!(t.icon_palette.is_some(), "{} has no icon palette", file.id);
// A two-colour theme (1-bit, 1-bit Dark) can't give each workspace its own fill; it
// still has to keep every tab readable, below.
let two_colour = is_two_colour(&file.id);
let mut fills = std::collections::HashSet::new();
for tab in ["MODEL", "SURFACE", "MESH", "FORM", "SHEET METAL", "RENDER", "SKETCH"] {
let accent = TabAccent::for_tab(&t, tab);
assert!(fills.insert(accent.color) || two_colour, "{} repeats {tab}", file.id);
assert!(contrast_ratio(accent.ink, accent.soft) >= 4.5, "{} {tab} soft text", file.id);
assert!(contrast_ratio(accent.on_fill(&t), accent.color) >= 4.5, "{} {tab} pill text", file.id);
let gruvbox = matches!(file.id.as_str(), "gruvbox-dark" | "gruvbox-light");
let contrasts: &[&str] = if gruvbox { &["soft", "standard", "hard"] } else { &["standard"] };
for contrast in contrasts {
let options = if gruvbox { BTreeMap::from([("contrast".into(), OptionValue::Choice((*contrast).into()))]) } else { BTreeMap::new() };
let t = resolve_with(file, &options);
assert!(t.icon_palette.is_some(), "{} {contrast} has no icon palette", file.id);
// A two-colour theme (1-bit, 1-bit Dark) can't give each workspace its own fill; it
// still has to keep every tab readable, below.
let two_colour = is_two_colour(&file.id);
let mut fills = std::collections::HashSet::new();
for tab in ["MODEL", "SURFACE", "MESH", "FORM", "SHEET METAL", "RENDER", "SKETCH"] {
let accent = TabAccent::for_tab(&t, tab);
assert!(fills.insert(accent.color) || two_colour, "{} {contrast} repeats {tab}", file.id);
assert!(contrast_ratio(accent.ink, accent.soft) >= 4.5, "{} {contrast} {tab} soft text", file.id);
assert!(contrast_ratio(accent.on_fill(&t), accent.color) >= 4.5, "{} {contrast} {tab} pill text", file.id);
}
}
}
}
@@ -2250,15 +2272,56 @@ mod tests {
assert_eq!(t.file_image_tint, Color32::WHITE, "{id}");
}
#[test]
fn gruvbox_contrast_choices_keep_six_appearances() {
let families: Vec<_> = builtin().iter().filter(|f| f.id.starts_with("gruvbox-")).map(|f| f.id.as_str()).collect();
assert_eq!(families, ["gruvbox-dark", "gruvbox-light"]);
for (id, panels, tops, bottoms, inks) in [
(
"gruvbox-dark",
["#32302f", "#282828", "#1d2021"],
["#373432", "#32302f", "#2c2c2c"],
["#373432", "#32302f", "#2c2c2c"],
["#1d2021", "#1d2021", "#141617"],
),
("gruvbox-light", ["#f2e5bc", "#fbf1c7", "#f9f5d7"], ["#f6edd0", "#fcf5d8", "#fbf8e3"], ["#ebdbb2"; 3], ["#3c3836"; 3]),
] {
let file = find(id, &[]).unwrap();
assert_eq!(file.options.len(), 1);
let option = &file.options[0];
assert_eq!(option.id, "contrast");
let OptionKind::Choice { default, values } = &option.kind else { panic!("contrast must be a choice") };
assert_eq!(default, "standard");
assert_eq!(values.iter().map(|v| v.id.as_str()).collect::<Vec<_>>(), ["soft", "standard", "hard"]);
for (index, contrast) in ["soft", "standard", "hard"].into_iter().enumerate() {
let options = BTreeMap::from([("contrast".into(), OptionValue::Choice(contrast.into()))]);
let tokens = resolve_with(file, &options);
assert_eq!(tokens.panel, parse_color(panels[index]).unwrap(), "{id}: {contrast}");
assert_eq!(tokens.viewport_top, parse_color(tops[index]).unwrap(), "{id}: {contrast}");
assert_eq!(tokens.viewport_bottom, parse_color(bottoms[index]).unwrap(), "{id}: {contrast}");
assert_eq!(export_icon_palette(tokens.icon_palette)["ink"], inks[index], "{id}: {contrast}");
assert_eq!(tokens.borders, crate::theme::Borders::LEGACY);
assert_eq!(resolve_with(&from_value(&export_file(file)).unwrap(), &options), tokens);
}
assert_eq!(resolve(file), resolve_base(file), "the Standard default keeps the old family palette");
}
}
#[test]
fn gruvbox_retired_ids_stay_reserved_for_imported_names() {
let mut custom = Vec::new();
for (old, _, _) in GRUVBOX_ALIASES {
let file = from_value(&json!({"format":FORMAT,"name":old,"base":"dark"})).unwrap();
assert_eq!(add(&mut custom, file).unwrap(), format!("custom-{old}"));
assert!(find(old, &custom).is_none(), "retired ids are not duplicate theme cards");
}
}
#[test]
fn builtin_order_preserves_the_existing_picker_sequence() {
let original: &[&str] = &[
"gruvbox-dark",
"gruvbox-dark-hard",
"gruvbox-dark-soft",
"gruvbox-light",
"gruvbox-light-hard",
"gruvbox-light-soft",
"solidcraft-95",
"1-bit",
"1-bit-dark",
@@ -2591,9 +2654,11 @@ mod tests {
}
let defaults = radius_values(Tokens::dark());
assert_eq!(defaults, radius_values(Tokens::light()));
for suffix in ["", "-hard", "-soft"] {
assert_eq!(values(&format!("gruvbox-dark{suffix}")), defaults);
assert_eq!(values(&format!("gruvbox-light{suffix}")), defaults);
for id in ["gruvbox-dark", "gruvbox-light"] {
for contrast in ["soft", "standard", "hard"] {
let options = BTreeMap::from([("contrast".into(), OptionValue::Choice(contrast.into()))]);
assert_eq!(radius_values(resolve_with(find(id, &[]).unwrap(), &options)), defaults);
}
}
for file in builtin().iter().filter(|file| file.radii.is_empty()) {
assert_eq!(radius_values(resolve(file)), defaults, "{}", file.id);
@@ -11,6 +11,19 @@
{"expect": {"prefs": {"theme": "light", "dark": false}}},
{"widget": "Cancel"},
{"expect": {"prefs": {"dialog": null, "theme": "dark", "dark": true}}},
{"note":"Gruvbox has two cards, each with Soft, Standard and Hard contrast. Old variant ids select the matching choice."},
{"call":"ui.prefs","params":{"theme":"gruvbox-dark-hard","open":"Interface"}},
{"expect":{"prefs":{"theme":"gruvbox-dark","theme_option_values":{"contrast":"hard"}},"theme_colors":{"panel":"#1d2021"}}},
{"call":"ui.prefs","params":{"theme_options":{"gruvbox-dark":{"contrast":"soft"}}}},
{"expect":{"prefs":{"theme_option_values":{"contrast":"soft"}},"theme_colors":{"panel":"#32302f"}}},
{"call":"ui.prefs","params":{"theme":"gruvbox-light-hard"}},
{"expect":{"prefs":{"theme":"gruvbox-light","theme_option_values":{"contrast":"hard"}},"theme_colors":{"panel":"#f9f5d7"}}},
{"call":"ui.prefs","params":{"theme":"gruvbox-dark"}},
{"expect":{"prefs":{"theme_option_values":{"contrast":"soft"}},"theme_colors":{"panel":"#32302f"}}},
{"call":"ui.prefs","params":{"theme_options":{"gruvbox-dark":{"contrast":null}}}},
{"expect":{"prefs":{"theme_option_values":{"contrast":"standard"}},"theme_colors":{"panel":"#282828"}}},
{"call":"ui.prefs","params":{"theme_options":{"gruvbox-light":{}}}},
{"call":"ui.prefs","params":{"button":"ok"}},
{"note": "Okibi (dark) and Akari (light) are built in by id."},
{"call": "ui.prefs", "params": {"theme": "akari"}},
{"expect": {"prefs": {"theme": "akari", "dark": false}}},
+7
View File
@@ -443,6 +443,13 @@ not record whether their background was explicitly chosen, so even a setup saved
camera conservatively retains its scene backplate. With tab surfaces absent/off, Render keeps
its original flat scene background. Theme surfaces never change rendered images or exports.
Gruvbox has two cards, **Gruvbox Dark** and **Gruvbox Light**. Each offers a
**Contrast** choice: **Soft**, **Standard** (the default), or **Hard**. These are the
same six palettes as the former separate cards, including their icon colours.
Saved selections and settings profiles using the former `-soft` and `-hard` ids
select the corresponding family and contrast. Selecting a family again restores its
last contrast; Reset returns it to Standard.
Up to 32 overlays apply in file order, after the base palette and the theme's own value tables.
Later matching entries win by key. Every overlay has one `when`: `{"opt":"id","eq":value}`
for an exact, correctly typed comparison, or `gte`, `lte`, or both for inclusive range bounds.
+10
View File
@@ -511,6 +511,16 @@ One setting per line, sorted by name. A change that adds a setting adds its own
- `zoom_stop_at_model` (default false: the 3D mouse and navigation bridge stop zoom at the surface in the middle of the view; drag-zoom holds its press point; independent of `zoom_to_cursor`)
- `zoom_to_cursor`
The built-in `gruvbox-dark` and `gruvbox-light` themes each expose the `contrast`
choice (`soft`, `standard` default, `hard`). For example:
`{"theme":"gruvbox-dark","theme_options":{"gruvbox-dark":{"contrast":"soft"}}}`.
The former `gruvbox-dark-soft`, `gruvbox-dark-hard`, `gruvbox-light-soft` and
`gruvbox-light-hard` ids remain accepted for compatibility and select the matching
family and contrast; replies and `theme_ids` expose only the two canonical families.
An explicit canonical option change or reset in the same call wins over the legacy
selection. Legacy option-map keys are also accepted; canonical keys take precedence
when both occur in a call. Imported themes cannot claim the retired built-in ids.
Theme option values persist per theme, including a followed file's own id, through the same
preference store in the browser and on desktop. Switching themes restores their saved values;
Interface's Restore Defaults clears them. Preference exports and settings profiles carry values;