Skip to content

Commit dcf4e32

Browse files
committed
refactor: Don't version the bootstrap color list
1 parent 409a53b commit dcf4e32

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

shiny/ui/_theme_brand.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,21 @@
2727
}
2828
"""Maps brand.color fields to Bootstrap Sass variables"""
2929

30-
bootstrap_colors = {
31-
# https://github.com/twbs/bootstrap/blob/6e1f75/scss/_variables.scss#L38-L49
32-
"5": [
33-
"white",
34-
"black",
35-
"blue",
36-
"indigo",
37-
"purple",
38-
"pink",
39-
"red",
40-
"orange",
41-
"yellow",
42-
"green",
43-
"teal",
44-
"cyan",
45-
]
46-
}
30+
# https://github.com/twbs/bootstrap/blob/6e1f75/scss/_variables.scss#L38-L49
31+
bootstrap_colors: list[str] = [
32+
"white",
33+
"black",
34+
"blue",
35+
"indigo",
36+
"purple",
37+
"pink",
38+
"red",
39+
"orange",
40+
"yellow",
41+
"green",
42+
"teal",
43+
"cyan",
44+
]
4745
"""
4846
Colors known to Bootstrap
4947
@@ -172,16 +170,16 @@ def __init__(
172170
# Map values in colors to their Sass variable counterparts
173171
for field, theme_color in brand.color.to_dict(include="theme").items():
174172
if field not in color_map:
173+
# TODO: Catch and ensure mapping exists
175174
print(f"skipping color.{field} not mapped")
176175
continue
177176

178177
for sass_var in color_map[field]:
179178
sass_vars_colors[sass_var] = theme_color
180179

181180
# Map the brand color palette to Bootstrap's named colors, e.g. $red, $blue.
182-
bs_color_vars = bootstrap_colors[brand_bootstrap.version]
183181
for field, palette_color in brand.color.to_dict(include="palette").items():
184-
if field in bs_color_vars:
182+
if field in bootstrap_colors:
185183
sass_vars_colors[field] = palette_color
186184

187185
# brand.typography ------------------------------------------------------------

0 commit comments

Comments
 (0)