Skip to content

Commit f7f5605

Browse files
committed
refactor: brand_yml now handles validation of color.palette names
1 parent fa78936 commit f7f5605

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

shiny/ui/_theme_brand.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,10 @@ def _prepare_color_vars(
353353
mapped[pal_name] = pal_color
354354

355355
# Create Sass and CSS variables for the brand color palette
356-
color_var = sanitize_sass_var_name(pal_name)
357-
358356
# => Sass var: `$brand-{name}: {value}`
359-
brand_sass_vars.update({f"brand-{color_var}": pal_color})
357+
brand_sass_vars.update({f"brand-{pal_name}": pal_color})
360358
# => CSS var: `--brand-{name}: {value}`
361-
brand_css_vars.append(f"--brand-{color_var}: {pal_color};")
359+
brand_css_vars.append(f"--brand-{pal_name}: {pal_color};")
362360

363361
# We keep Sass and Brand vars separate so we can ensure Brand Sass vars come
364362
# first in the compiled Sass definitions.
@@ -565,11 +563,6 @@ def _html_dependencies(self) -> list[HTMLDependency]:
565563
return [fonts_dep, *theme_deps]
566564

567565

568-
def sanitize_sass_var_name(x: str) -> str:
569-
x = re.sub(r"""['"]""", "", x)
570-
return re.sub(r"[^a-zA-Z0-9_-]+", "-", x)
571-
572-
573566
def maybe_convert_font_size_to_rem(x: str) -> CssUnit:
574567
"""
575568
Convert a font size to rem

0 commit comments

Comments
 (0)