Skip to content

Commit

Permalink
feat: set_theme
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Jan 23, 2024
1 parent ed46563 commit f3794f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion bindings/pyl7vp/pyl7vp/l7vp.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def __init__(self, height=600, datasets: list = [], config: dict = {}):
_validate_config(config)
self.config = _merge_config(DEFAULT_ANALYSIS_SPEC, config)

self.set_theme()

# page settting
self.page_title = "PyL7VP"

Expand Down Expand Up @@ -154,6 +156,13 @@ def _dump_js_datasets(
datasets = list(map(lambda d: _dataset_auto_create_layers(d, self.config.get("layers")), self.datasets))
return json_dump_to_js(datasets)

'''
set the l7vp theme "dark" or "light", default "dark"
'''

def set_theme(self, theme: str = "dark"):
self.theme = theme

'''
get render to html string
'''
Expand Down Expand Up @@ -184,7 +193,6 @@ def _get_html_str(
}

self.read_only = read_only
self.theme = "dark"

# get html string
return Engine(env=env).render(
Expand Down
8 changes: 7 additions & 1 deletion bindings/pyl7vp/pyl7vp/templates/l7vp.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
<script>
const LI_Theme = "{{ l7vp.theme }}"
const _theme = window.antd.theme;
const _lightTheme = {
token: {
colorPrimary: "#8274FF",
colorInfo: "#8274FF",
},
}
const _darkTheme = {
algorithm: _theme.darkAlgorithm,
token: {
Expand All @@ -81,7 +87,7 @@
borderRadius: 6,
},
}
const Antd_Theme = LI_Theme === "light" ? {} : _darkTheme
const Antd_Theme = LI_Theme === "light" ? _lightTheme : _darkTheme
</script>

{% if l7vp.app_mode %}
Expand Down

0 comments on commit f3794f5

Please sign in to comment.