Spaces:
Sleeping
Sleeping
Create canva_theme.py
Browse files- canva_theme.py +114 -0
canva_theme.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from gradio.themes.base import Base
|
| 4 |
+
from gradio.themes.utils import fonts
|
| 5 |
+
|
| 6 |
+
from colors import purple, neutral, blue, green, red, white, black, purpleA # Import our custom colors
|
| 7 |
+
from sizes import spacing_md, radius_sm, text_md # Import our custom sizes
|
| 8 |
+
|
| 9 |
+
class CanvaTheme(Base):
|
| 10 |
+
def __init__(
|
| 11 |
+
self,
|
| 12 |
+
*,
|
| 13 |
+
font: fonts.Font | str = fonts.LocalFont(
|
| 14 |
+
"CanvaSans",
|
| 15 |
+
weights=[400, 500, 700], # Regular, Medium, Bold weights
|
| 16 |
+
),
|
| 17 |
+
font_mono: fonts.Font | str = fonts.GoogleFont(
|
| 18 |
+
"JetBrains Mono",
|
| 19 |
+
weights=[400, 700] # Regular and Bold weights
|
| 20 |
+
),
|
| 21 |
+
):
|
| 22 |
+
super().__init__(
|
| 23 |
+
primary_hue=purple,
|
| 24 |
+
secondary_hue=blue,
|
| 25 |
+
neutral_hue=neutral,
|
| 26 |
+
spacing_size=spacing_md,
|
| 27 |
+
radius_size=radius_sm,
|
| 28 |
+
text_size=text_md,
|
| 29 |
+
font=font,
|
| 30 |
+
font_mono=font_mono,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
super().set(
|
| 34 |
+
# Colors from our colors.py
|
| 35 |
+
body_background_fill=white["white"],
|
| 36 |
+
body_background_fill_dark=neutral.c950,
|
| 37 |
+
background_fill_primary=white["white"],
|
| 38 |
+
background_fill_primary_dark=neutral.c900,
|
| 39 |
+
background_fill_secondary=neutral.c50,
|
| 40 |
+
background_fill_secondary_dark=neutral.c800,
|
| 41 |
+
|
| 42 |
+
# Border colors
|
| 43 |
+
border_color_primary=neutral.c200,
|
| 44 |
+
border_color_primary_dark=neutral.c700,
|
| 45 |
+
|
| 46 |
+
# Text colors
|
| 47 |
+
body_text_color=neutral.c900,
|
| 48 |
+
body_text_color_dark=neutral.c50,
|
| 49 |
+
body_text_color_subdued=neutral.c500,
|
| 50 |
+
body_text_color_subdued_dark=neutral.c400,
|
| 51 |
+
|
| 52 |
+
# Button styling
|
| 53 |
+
button_primary_background_fill=purple.c500,
|
| 54 |
+
button_primary_background_fill_dark=purple.c600,
|
| 55 |
+
button_primary_background_fill_hover=purple.c600,
|
| 56 |
+
button_primary_background_fill_hover_dark=purple.c700,
|
| 57 |
+
button_primary_text_color=white["white"],
|
| 58 |
+
button_primary_text_color_dark=white["white"],
|
| 59 |
+
|
| 60 |
+
button_secondary_background_fill=neutral.c50,
|
| 61 |
+
button_secondary_background_fill_dark=neutral.c800,
|
| 62 |
+
button_secondary_background_fill_hover=neutral.c100,
|
| 63 |
+
button_secondary_background_fill_hover_dark=neutral.c700,
|
| 64 |
+
button_secondary_text_color=neutral.c900,
|
| 65 |
+
button_secondary_text_color_dark=neutral.c50,
|
| 66 |
+
|
| 67 |
+
# Input styling
|
| 68 |
+
input_background_fill=neutral.c50,
|
| 69 |
+
input_background_fill_dark=neutral.c800,
|
| 70 |
+
input_border_color=neutral.c200,
|
| 71 |
+
input_border_color_dark=neutral.c700,
|
| 72 |
+
input_border_width="1px",
|
| 73 |
+
|
| 74 |
+
# Block styling
|
| 75 |
+
block_label_background_fill=white["white"],
|
| 76 |
+
block_label_background_fill_dark=neutral.c900,
|
| 77 |
+
block_title_text_color=neutral.c500,
|
| 78 |
+
block_title_text_color_dark=neutral.c400,
|
| 79 |
+
|
| 80 |
+
# Shadow effects
|
| 81 |
+
shadow_drop="0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
|
| 82 |
+
shadow_drop_lg="0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
|
| 83 |
+
|
| 84 |
+
# Border radius from our sizes.py
|
| 85 |
+
radius_sm=radius_sm.md,
|
| 86 |
+
radius_md=radius_sm.lg,
|
| 87 |
+
radius_lg=radius_sm.xl,
|
| 88 |
+
|
| 89 |
+
# Link colors using our purple
|
| 90 |
+
link_text_color=purple.c500,
|
| 91 |
+
link_text_color_dark=purple.c400,
|
| 92 |
+
link_text_color_hover=purple.c600,
|
| 93 |
+
link_text_color_hover_dark=purple.c500,
|
| 94 |
+
|
| 95 |
+
# Error states
|
| 96 |
+
error_background_fill=red.c50,
|
| 97 |
+
error_background_fill_dark=neutral.c900,
|
| 98 |
+
error_text_color=red.c600,
|
| 99 |
+
error_text_color_dark=red.c200,
|
| 100 |
+
error_border_color=red.c500,
|
| 101 |
+
error_border_color_dark=red.c600,
|
| 102 |
+
|
| 103 |
+
# Success states
|
| 104 |
+
button_secondary_background_fill_selected=green.c50,
|
| 105 |
+
button_secondary_text_color_selected=green.c700,
|
| 106 |
+
|
| 107 |
+
# Alpha transparencies
|
| 108 |
+
overlay_background_fill=black["blackA50"],
|
| 109 |
+
|
| 110 |
+
# Additional button states using alpha colors
|
| 111 |
+
button_primary_border_color=purpleA["purpleA0"],
|
| 112 |
+
button_secondary_border_color=neutral.c200,
|
| 113 |
+
button_secondary_border_color_dark=neutral.c700,
|
| 114 |
+
)
|