theme_builder / canva_theme.py
jsscclr's picture
Update canva_theme.py
7210472 verified
from __future__ import annotations
from gradio.themes.base import Base
from gradio.themes.utils import colors, fonts, sizes
# Import our custom colors
from colors import (
purple as custom_purple,
blue as custom_blue,
grey as custom_grey,
green as custom_green,
red as custom_red,
white,
black,
purple_alpha
)
from sizes import spacing_md, radius_sm, text_md
class CanvaTheme(Base):
def __init__(
self,
*,
primary_hue: colors.Color | str = colors.purple, # Using Gradio's purple
secondary_hue: colors.Color | str = colors.blue, # Using Gradio's blue
neutral_hue: colors.Color | str = colors.gray, # Using Gradio's gray
text_size: sizes.Size | str = sizes.text_md,
spacing_size: sizes.Size | str = sizes.spacing_md,
radius_size: sizes.Size | str = sizes.radius_sm,
font: fonts.Font | str | Iterable[fonts.Font | str] = (
# fonts.LocalFont("CanvaSans", weights=[400, 500, 700]),
fonts.GoogleFont("Open Sans", weights=[400, 500, 700]),
"ui-sans-serif",
"system-ui",
"sans-serif",
),
font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
fonts.GoogleFont("JetBrains Mono", weights=[400, 700]),
"ui-monospace",
"Consolas",
"monospace",
),
):
super().__init__(
primary_hue=primary_hue,
secondary_hue=secondary_hue,
neutral_hue=neutral_hue,
spacing_size=spacing_size,
radius_size=radius_size,
text_size=text_size,
font=font,
font_mono=font_mono,
)
super().set(
# Body colors
body_background_fill=white.c50,
body_background_fill_dark=black.c50,
# Text colors
body_text_color=black.c50,
body_text_color_dark=white.c50,
# Block colors
block_background_fill=white.c50,
block_background_fill_dark=custom_grey.c800,
block_border_color=custom_grey.c200,
block_border_color_dark=custom_grey.c700,
block_title_text_color=custom_grey.c500,
block_title_text_color_dark=custom_grey.c400,
# Input colors
input_background_fill=custom_grey.c50,
input_background_fill_dark=custom_grey.c800,
input_border_color=custom_grey.c200,
input_border_color_dark=custom_grey.c700,
input_border_width="1px",
# Button colors
button_primary_background_fill=custom_purple.c500,
button_primary_background_fill_dark=custom_purple.c600,
button_primary_text_color=white.c50,
button_primary_text_color_dark=white.c50,
button_secondary_background_fill=custom_grey.c50,
button_secondary_background_fill_dark=custom_grey.c800,
button_secondary_text_color=black.c50,
button_secondary_text_color_dark=white.c50,
# Shadows
shadow_drop="0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
shadow_inset="0 2px 4px 0 rgb(0 0 0 / 0.05) inset",
# Link colors
link_text_color=custom_purple.c500,
link_text_color_dark=custom_purple.c400,
)