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

Cusom Themes support in ThemePicker #71

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

ndendic
Copy link
Contributor

@ndendic ndendic commented Feb 15, 2025

No description provided.

Copy link

gitnotebooks bot commented Feb 15, 2025

Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/AnswerDotAI/MonsterUI/pull/71

@ndendic
Copy link
Contributor Author

ndendic commented Feb 15, 2025

Hello @Isaac-Flath, added a small change to support custom themes in ThemePicker. Please review and let me know if something should be adjusted.

@Isaac-Flath
Copy link
Collaborator

Would you mind providing an example or a guide I can add to the documentation page for how to do custom themes? Other people are very interested in custom themes too!

(This PR would resolve #38 )

@ndendic
Copy link
Contributor Author

ndendic commented Feb 15, 2025

Hey @Isaac-Flath sure. I thought adding new nb under docs/guides but decided not to mess around that.
Here is my customization flow.

  1. Go to https://ui.jln.dev/ to generate a new theme
  2. Then "Copy current theme as code" (second button on the bottom menu)
  3. I would then adjust the theme CSS to look something like this
/* custom_theme.css */

.uk-theme-grass {
  --background: 78 47% 99%;
  --foreground: 78 51% 0%;
  --muted: 78 12% 85%;
  --muted-foreground: 78 8% 38%;
  --popover: 78 47% 99%;
  --popover-foreground: 78 51% 0%;
  --card: 78 47% 99%;
  --card-foreground: 78 51% 0%;
  --border: 78 2% 93%;
  --input: 78 2% 93%;
  --primary: 78 28% 60%;
  --primary-foreground: 0 0% 0%;
  --secondary: 78 8% 81%;
  --secondary-foreground: 78 8% 21%;
  --accent: 78 8% 81%;
  --accent-foreground: 78 8% 21%;
  --destructive: 17 86% 32%;
  --destructive-foreground: 17 86% 92%;
  --ring: 78 28% 60%;
  --chart-1: 78 28% 60%;
  --chart-2: 78 8% 81%;
  --chart-3: 78 8% 81%;
  --chart-4: 78 8% 84%;
  --chart-5: 78 31% 60%;
  --radius: 0.5rem;
}

.dark.uk-theme-grass {
  --background: 78 48% 2%;
  --foreground: 78 24% 99%;
  --muted: 78 12% 15%;
  --muted-foreground: 78 8% 62%;
  --popover: 78 48% 2%;
  --popover-foreground: 78 24% 99%;
  --card: 78 48% 2%;
  --card-foreground: 78 24% 99%;
  --border: 78 2% 14%;
  --input: 78 2% 14%;
  --primary: 78 28% 60%;
  --primary-foreground: 0 0% 0%;
  --secondary: 78 8% 14%;
  --secondary-foreground: 78 8% 74%;
  --accent: 78 8% 14%;
  --accent-foreground: 78 8% 74%;
  --destructive: 17 86% 60%;
  --destructive-foreground: 17 86% 0%;
  --ring: 78 28% 60%;
  --chart-1: 78 28% 60%;
  --chart-2: 78 8% 14%;
  --chart-3: 78 8% 14%;
  --chart-4: 78 8% 17%;
  --chart-5: 78 31% 60%;
}
  1. Place that CSS in new static .css file and load it to your FastHTML headers like:
custom_theme_css = Link(rel="stylesheet", href="/css/custom_theme.css", type="text/css")
monsterui_headers = Theme.rose.headers()

app, rt = fast_app(
    static_path="assets",
    live=True,
    pico=False,
    hdrs=(
        monsterui_headers,
        custom_theme_css,
    ),
    htmlkw=dict(cls="bg-surface-light dark:bg-surface-dark"),
)
  1. Add custom theme in ThemePicker like this:
ThemePicker(custom_themes=[("Grass", "#10b981")] 

This will add new "Grass" theme button with circle colored with provided RGB color to theme picker

@Isaac-Flath Isaac-Flath added the enhancement New feature or request label Feb 15, 2025
@Isaac-Flath Isaac-Flath merged commit 6b4201d into AnswerDotAI:main Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants