Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Include theme colors in theme object #29

Merged
merged 24 commits into from
Mar 7, 2024
Merged

Conversation

gadenbuie
Copy link
Contributor

@gadenbuie gadenbuie commented Mar 7, 2024

Also refactors shinyswatch.theme.___ into a ShinyswatchTheme object.

  1. Read key theme colors from the bslib theme object
  2. Those are saved as the bsw5_theme_colors dict in _bsw5.py.
  3. Themes are now a callable ShinyswatchTheme class that include a .colors property.
  4. (Incidentally themes are also now tagifiable.)
  5. The colors property is actually a ThemeColors class that makes the theme's colors available as properties on the class, e.g. shinyswatch.theme.cosmo.primary.
>>> from shinyswatch.theme import cosmo
>>> cosmo.colors
<ThemeColors('cosmo'): 
 body_color : #373a3c
 body_bg    : #fff
 light      : #f8f9fa
 dark       : #373a3c
 primary    : #2780e3
 secondary  : #373a3c
 info       : #9954bb
 success    : #3fb618
 warning    : #ff7518
 danger     : #ff0039
>
>>> cosmo.colors.info
'#9954bb'
>>> cosmo.colors.success
'#3fb618'

I also updated the documentation in the index to use shinyswatch.theme.minty instead of shinyswatch.theme.minty() and I added an example where the theme's colors are used to theme a plot.

Note: I did not update the example app included in each theme's docs.

@gadenbuie gadenbuie requested a review from schloerke March 7, 2024 17:42
CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
docs/index.qmd Outdated Show resolved Hide resolved
docs/index.qmd Show resolved Hide resolved
docs/index.qmd Show resolved Hide resolved
@schloerke schloerke merged commit 1a813dc into main Mar 7, 2024
14 checks passed
@schloerke schloerke deleted the feat/theme-colors branch March 7, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants