Skip to content

Commit efcb11f

Browse files
committed
fix: Can't use null !default trick for Bootstrap core vars like $primary, $secondary, etc.
1 parent 2e0f444 commit efcb11f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

shiny/ui/_theme_brand.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,19 @@ def _prepare_color_vars(
262262
palette_defaults_dict: dict[str, str | float | int | bool | None] = {}
263263
palette_css_vars: list[str] = []
264264

265-
# Map values in colors to their Sass variable counterparts
266265
for thm_name, thm_color in brand.color.to_dict(include="theme").items():
267-
defaults_dict[f"brand_color_{thm_name}"] = thm_color
266+
# Create brand Sass variables and set related Bootstrap Sass vars
267+
# brand.color.primary = "#007bff"
268+
# ==> $brand_color_primary: #007bff !default;
269+
# ==> $primary: $brand_color_primary !default;
270+
271+
brand_color_var = f"brand_color_{thm_name}"
272+
defaults_dict[brand_color_var] = thm_color
273+
# Currently, brand.color fields are directly named after Bootstrap vars. If
274+
# that changes, we'd need to use a map here. These values can't be set to
275+
# `null !default` because they're used by maps in the Bootstrap mixins layer
276+
# and cause errors if a color is `null` rather than non-existent.
277+
defaults_dict[thm_name] = f"${brand_color_var}"
268278

269279
brand_color_palette = brand.color.to_dict(include="palette")
270280

shiny/www/py-shiny/brand/_brand-yml.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,10 @@ $body-color: $brand_color_foreground !default;
7272
$body-bg-dark: $brand_color_foreground !default;
7373
$body-bg: $brand_color_background !default;
7474
$body-color-dark: $brand_color_background !default;
75-
$primary: $brand_color_primary !default;
76-
$secondary: $brand_color_secondary !default;
7775
$body-secondary-color: $brand_color_secondary !default;
7876
$body-secondary: $brand_color_secondary !default;
7977
$body-tertiary-color: $brand_color_tertiary !default;
8078
$body-tertiary: $brand_color_tertiary !default;
81-
$success: $brand_color_success !default;
82-
$info: $brand_color_info !default;
83-
$warning: $brand_color_warning !default;
84-
$danger: $brand_color_danger !default;
85-
$light: $brand_color_light !default;
86-
$dark: $brand_color_dark !default;
8779

8880
//*-- brand.typography --*//
8981
// brand.typography.base

0 commit comments

Comments
 (0)