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

Introduce color module #2614

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nicegui/color.py linguist-generated
nicegui/elements/tailwind.py linguist-generated
nicegui/elements/tailwind_types/** linguist-generated
nicegui/elements/lib/** linguist-vendored
Expand Down
28 changes: 28 additions & 0 deletions fetch_colors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
from pathlib import Path
from typing import cast

import webcolors

from nicegui.elements.mixins.color_elements import QUASAR_COLORS, TAILWIND_COLORS

CSS_COLORS = sorted(set([
*list(webcolors.CSS2_NAMES_TO_HEX),
*list(webcolors.CSS21_NAMES_TO_HEX),
*list(webcolors.CSS3_NAMES_TO_HEX),
*list(webcolors.HTML4_NAMES_TO_HEX),
]))

with open(Path(__file__).parent / 'nicegui' / 'color.py', 'w') as f:
for color in CSS_COLORS:
f.write(f"{color.upper()} = '{color}'\n")

f.write('\n')
f.write('class quasar:\n')
for color in QUASAR_COLORS:
f.write(f" {color.upper().replace('-', '_')} = '{color}'\n")

f.write('\n')
f.write('class tailwind:\n')
for color in cast(list[str], TAILWIND_COLORS):
f.write(f" {color.upper().replace('-', '_')} = '{color}'\n")
3 changes: 2 additions & 1 deletion nicegui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import context, elements, run, ui
from . import color, context, elements, run, ui
from .api_router import APIRouter
from .app.app import App
from .client import Client
Expand All @@ -10,6 +10,7 @@
'APIRouter',
'app',
'App',
'color',
'Client',
'context',
'elements',
Expand Down