Skip to content

Commit

Permalink
Change defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudmiribel committed Oct 31, 2024
1 parent 3108030 commit f1de297
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/streamlit_extras/metric_cards/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
from streamlit_extras import extra
from streamlit_extras.theme import st_theme

theme = st_theme()

DEFAULT_BACKGROUND_COLOR_LIGHT = "#FFF"
DEFAULT_BORDER_COLOR_LIGHT = "#CCC"

DEFAULT_BACKGROUND_COLOR_DARK = "#1B1C24"
DEFAULT_BORDER_COLOR_DARK = "#292D34"

DEFAULT_BACKGROUND_COLOR = (
DEFAULT_BACKGROUND_COLOR_DARK
if theme.get("base") == "dark"
else DEFAULT_BACKGROUND_COLOR_LIGHT
)
DEFAULT_BORDER_COLOR = (
DEFAULT_BORDER_COLOR_DARK
if theme.get("base") == "dark"
else DEFAULT_BORDER_COLOR_LIGHT
)


@extra
def style_metric_cards(
background_color: str = "#FFF",
background_color: str = DEFAULT_BACKGROUND_COLOR,
border_size_px: int = 1,
border_color: str = "#CCC",
border_color: str = DEFAULT_BORDER_COLOR,
border_radius_px: int = 5,
border_left_color: str = "#9AD8E1",
box_shadow: bool = True,
Expand All @@ -24,13 +44,6 @@ def style_metric_cards(
box_shadow (bool, optional): Whether a box shadow is applied. Defaults to True.
"""

theme = st_theme()

# When dark mode, convert background and border to be dark
if theme.get("base") == "dark":
background_color = "#1B1C24"
border_color = "#292D34"

box_shadow_str = (
"box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;"
if box_shadow
Expand Down

0 comments on commit f1de297

Please sign in to comment.