From 92fe8814796e2b35f5cd95c616e2d3d76be2cca7 Mon Sep 17 00:00:00 2001 From: Nikhil Rao Date: Sat, 7 Jan 2023 20:00:05 -0800 Subject: [PATCH] Apply global styles to body (#222) --- pynecone/compiler/utils.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pynecone/compiler/utils.py b/pynecone/compiler/utils.py index 7623bcc0c..0364a7ac2 100644 --- a/pynecone/compiler/utils.py +++ b/pynecone/compiler/utils.py @@ -223,10 +223,20 @@ def create_theme(style: Style) -> Dict: Returns: The base style for the app. """ + # Get the global style from the style dict. + global_style = Style({k: v for k, v in style.items() if not isinstance(k, type)}) + + # Root styles. + root_style = Style({k: v for k, v in global_style.items() if k.startswith("::")}) + + # Body styles. + root_style["body"] = Style( + {k: v for k, v in global_style.items() if k not in root_style} + ) + + # Return the theme. return { - "styles": { - "global": Style({k: v for k, v in style.items() if not isinstance(k, type)}) - }, + "styles": {"global": root_style}, }