forked from vega/altair
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds 4 missing
carbon
themes, provide autocomplete (vega#3516)
* style: Sort `VEGA_THEMES` alphabetically * feat: Add missing `carbon...` themes Examples https://vega.github.io/vega-themes/?theme=carbonwhite Related vega/vega-themes#587 * feat(typing): Support autocomplete for `themes.enable(name)` And provide link to `vega-themes` playground * chore: Fix `PluginRegistery` comment typo * Add comments --------- Co-authored-by: Stefan Binder <binder_stefan@outlook.com>
- Loading branch information
1 parent
c12ca27
commit 15f1151
Showing
2 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,49 @@ | ||
"""Utilities for registering and working with themes.""" | ||
|
||
from typing import Callable | ||
from __future__ import annotations | ||
|
||
import sys | ||
from typing import TYPE_CHECKING, Callable | ||
|
||
from .plugin_registry import PluginRegistry | ||
|
||
if sys.version_info >= (3, 11): | ||
from typing import LiteralString | ||
else: | ||
from typing_extensions import LiteralString | ||
|
||
if TYPE_CHECKING: | ||
from altair.utils.plugin_registry import PluginEnabler | ||
from altair.vegalite.v5.theme import _ThemeName | ||
|
||
ThemeType = Callable[..., dict] | ||
|
||
|
||
class ThemeRegistry(PluginRegistry[ThemeType, dict]): | ||
pass | ||
def enable( | ||
self, name: LiteralString | _ThemeName | None = None, **options | ||
) -> PluginEnabler: | ||
""" | ||
Enable a theme by name. | ||
This can be either called directly, or used as a context manager. | ||
Parameters | ||
---------- | ||
name : string (optional) | ||
The name of the theme to enable. If not specified, then use the | ||
current active name. | ||
**options : | ||
Any additional parameters will be passed to the theme as keyword | ||
arguments | ||
Returns | ||
------- | ||
PluginEnabler: | ||
An object that allows enable() to be used as a context manager | ||
Notes | ||
----- | ||
Default `vega` themes can be previewed at https://vega.github.io/vega-themes/ | ||
""" | ||
return super().enable(name, **options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters