AlGe commited on
Commit
61bd9ff
·
verified ·
1 Parent(s): 1aec62b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -12
app.py CHANGED
@@ -14,23 +14,40 @@ import time
14
  def hex_to_rgb(hex_color: str) -> tuple[int, int, int]:
15
  hex_color = hex_color.lstrip('#')
16
  return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
17
-
18
- def create_color_shades(hex_color: str) -> colors.Color:
19
- base_rgb = hex_to_rgb(hex_color)
20
- shades = [base_rgb] * 10 # Duplicate the base color for simplicity
21
-
22
- # You can adjust this to create actual different shades if needed
23
- return colors.Color(*shades)
24
 
25
  class MPGPoster(Base):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  def __init__(
27
  self,
28
  *,
29
- primary_hue: colors.Color | str = create_color_shades("#f47317"),
30
- background_hue: colors.Color | str = create_color_shades("#f6f6f6ff"),
31
- secondary_dark_hue: colors.Color | str = create_color_shades("#006c66"),
32
- secondary_light_hue: colors.Color | str = create_color_shades("#6ad5bc"),
33
- tertiary_highlight_hue: colors.Color | str = create_color_shades("#fbf22c"),
34
  spacing_size: sizes.Size | str = sizes.spacing_md,
35
  radius_size: sizes.Size | str = sizes.radius_md,
36
  text_size: sizes.Size | str = sizes.text_lg,
 
14
  def hex_to_rgb(hex_color: str) -> tuple[int, int, int]:
15
  hex_color = hex_color.lstrip('#')
16
  return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
17
+ from __future__ import annotations
18
+ from typing import Iterable
19
+ import gradio as gr
20
+ from gradio.themes.base import Base
21
+ from gradio.themes.utils import colors, fonts, sizes
22
+ import time
 
23
 
24
  class MPGPoster(Base):
25
+ @staticmethod
26
+ def create_color_shades(hex_color: str) -> colors.Color:
27
+ # Manually define shades for each color
28
+ # This is an example, adjust the shades according to your needs
29
+ shades = {
30
+ "c100": hex_color,
31
+ "c200": hex_color, # Slightly lighter or darker
32
+ "c300": hex_color,
33
+ "c400": hex_color,
34
+ "c500": hex_color, # Base color
35
+ "c600": hex_color,
36
+ "c700": hex_color,
37
+ "c800": hex_color,
38
+ "c900": hex_color,
39
+ "c950": hex_color, # Darkest shade
40
+ }
41
+ return colors.Color(**shades)
42
+
43
  def __init__(
44
  self,
45
  *,
46
+ primary_hue: colors.Color | str = MPGPoster.create_color_shades("#f47317"),
47
+ background_hue: colors.Color | str = MPGPoster.create_color_shades("#f6f6f6ff"),
48
+ secondary_dark_hue: colors.Color | str = MPGPoster.create_color_shades("#006c66"),
49
+ secondary_light_hue: colors.Color | str = MPGPoster.create_color_shades("#6ad5bc"),
50
+ tertiary_highlight_hue: colors.Color | str = MPGPoster.create_color_shades("#fbf22c"),
51
  spacing_size: sizes.Size | str = sizes.spacing_md,
52
  radius_size: sizes.Size | str = sizes.radius_md,
53
  text_size: sizes.Size | str = sizes.text_lg,