Apply global styles to body (#222)

This commit is contained in:
Nikhil Rao 2023-01-07 20:00:05 -08:00 committed by GitHub
parent 2d5cb4a561
commit 92fe881479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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},
}