Skip to content

Commit 88b2348

Browse files
authored
Add new option vega_theme_light
1 parent af21c74 commit 88b2348

File tree

7 files changed

+51
-12
lines changed

7 files changed

+51
-12
lines changed

docs/options.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ You can customize the plugin by setting options in `mkdocs.yml`. For example:
88
plugins:
99
- charts:
1010
vega_width: container
11-
vega_theme: default
11+
vega_theme_light: default
1212
vega_theme_dark: dark
1313
vega_renderer: svg
1414
use_data_path: True
@@ -22,9 +22,9 @@ You can customize the plugin by setting options in `mkdocs.yml`. For example:
2222
```
2323
2424
- `vega_width` (default is `container`). When not specified explicitly in the JSON schema, the `width` to use (see [vegalite customizing size](https://vega.github.io/vega-lite/docs/size.html)). When set to `container` width will be 100%.
25-
- `vega_theme` (default is `default`). Specify one of the available [vegalite themes](https://vega.github.io/vega-themes/).
26-
- `vega_theme_dark` (default is `dark`). When using the [mkdocs-material](https://squidfunk.github.io/mkdocs-material) theme with a dark mode or the user's preferred color scheme in the browser or OS is "dark", automatically render charts using this theme. Dark mode toggle is also supported. Specify one of the available [vegalite themes](https://vega.github.io/vega-themes/).
27-
- `vega_renderer` (default is `svg`). Specify one of the available [vegalite renderers](https://vega.github.io/vega-themes/).
25+
- `vega_theme_light` (default is `default`). Specify one of the available [vegalite themes](https://vega.github.io/vega-themes/) to use when in light mode. When using the [mkdocs-material](https://squidfunk.github.io/mkdocs-material) theme with a light mode or the user's preferred color scheme in the browser or OS is "light", automatically render charts using this theme. [Color pallete toggle](https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#color-palette-toggle) is also supported.
26+
- `vega_theme_dark` (default is `dark`). Specify one of the available [vegalite themes](https://vega.github.io/vega-themes/) to use when in dark mode. When using the [mkdocs-material](https://squidfunk.github.io/mkdocs-material) theme with a dark mode or the user's preferred color scheme in the browser or OS is "dark", automatically render charts using this theme. [Color pallete toggle](https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#color-palette-toggle) is also supported.
27+
- `vega_renderer` (default is `svg`). Specify one of `canvas` or `svg`. See the [demo vegalite renderers](https://vega.github.io/vega-themes/).
2828
- `use_data_path` (default is `True`). When `True`, any relative urls used in the JSON schema are relative to the `data_path`. When `False`, relative urls should be relative to the URL of the page.
2929
- `data_path` (default is `""`). When `use_data_path` is enabled, the base path relative to the `docs/` folder.
3030
- `integrations.mkdocs_material.themes_light` (default is `[default]`). When using the [mkdocs-material](https://squidfunk.github.io/mkdocs-material) theme, specify the light [color schemes](https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#color-scheme).

mkdocs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ nav:
3333

3434
plugins:
3535
- search
36-
- charts:
37-
vega_theme: default
38-
vega_renderer: "canvas"
36+
- charts
3937
- git-revision-date-localized:
4038
type: timeago
4139
timezone: Europe/Amsterdam

mkdocs_charts_plugin/plugin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class ChartsPlugin(BasePlugin):
3535
config_scheme = (
3636
("data_path", config_options.Type(str, default="")),
3737
("use_data_path", config_options.Type(bool, default=True)),
38-
("vega_theme", config_options.Type(str, default="default")),
38+
("vega_theme", config_options.Type(str, default="deprecated")),
39+
("vega_theme_light", config_options.Type(str, default="default")),
3940
("vega_theme_dark", config_options.Type(str, default="dark")),
4041
("vega_renderer", config_options.Type(str, default="svg")),
4142
("vega_width", config_options.Type(str, default="container")),
@@ -48,6 +49,11 @@ def on_config(self, config, **kwargs):
4849
Event trigger on config.
4950
See https://www.mkdocs.org/user-guide/plugins/#on_config.
5051
"""
52+
if self.config.get("vega_theme") != "deprecated":
53+
raise PluginError(
54+
"[mkdocs_charts_plugin]: 'vega_theme' is deprecated and has been renamed to 'vega_theme_light'. Together with 'vega_theme_dark' this enables automatic theme switching. Please update your mkdocs.yml."
55+
)
56+
5157
# Add pointer to mkdocs-charts-plugin.js
5258
# which is added to the output directory during on_post_build() event
5359
config["extra_javascript"] = ["js/mkdocs-charts-plugin.js"] + config["extra_javascript"]

tests/fixtures/projects/basic/mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ theme:
66
plugins:
77
# - search
88
- charts:
9-
vega_theme: dark
109
vega_renderer: "canvas"
1110

1211
use_directory_urls: true
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
site_name: My Docs
2+
3+
theme:
4+
name: material
5+
palette:
6+
# Palette toggle for light mode
7+
- scheme: default
8+
toggle:
9+
icon: material/brightness-7
10+
name: Switch to dark mode
11+
12+
# Palette toggle for dark mode
13+
- scheme: slate
14+
toggle:
15+
icon: material/brightness-4
16+
name: Switch to light mode
17+
18+
plugins:
19+
# - search
20+
- charts
21+
22+
use_directory_urls: true
23+
24+
markdown_extensions:
25+
- pymdownx.superfences:
26+
custom_fences:
27+
- name: vegalite
28+
class: vegalite
29+
format: !!python/name:mkdocs_charts_plugin.fences.fence_vegalite
30+
- pymdownx.tabbed:
31+
alternate_style: true
32+
33+
extra_javascript:
34+
- https://cdn.jsdelivr.net/npm/vega@5
35+
- https://cdn.jsdelivr.net/npm/vega-lite@5
36+
- https://cdn.jsdelivr.net/npm/vega-embed@6

tests/fixtures/projects/basic/mkdocs_instant.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ theme:
88
plugins:
99
# - search
1010
- charts:
11-
vega_theme: dark
11+
vega_theme_light: default
12+
vega_theme_dark: dark
1213
vega_renderer: "canvas"
1314

1415
use_directory_urls: true
@@ -18,7 +19,7 @@ markdown_extensions:
1819
custom_fences:
1920
- name: vegalite
2021
class: vegalite
21-
format: !!python/name:mkdocs_charts_plugin.fences.fence__vegalite
22+
format: !!python/name:mkdocs_charts_plugin.fences.fence_vegalite
2223
- pymdownx.tabbed:
2324
alternate_style: true
2425

tests/fixtures/projects/invalid_json/mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ site_name: My Docs
77

88
plugins:
99
- charts:
10-
vega_theme: dark
1110
vega_renderer: "canvas"
1211

1312
use_directory_urls: true

0 commit comments

Comments
 (0)