Skip to content

Commit 916576f

Browse files
committed
📚 DOCS: Add note on CSS
1 parent 911fb82 commit 916576f

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

‎docs/index.md‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,31 @@ Now your website will have tooltips on many of your links!
7272

7373
This is another paragraph
7474

75+
:::{important}
76+
Dependent on the theme you ar using with sphinx,
77+
you may need to add some CSS to your `conf.py` to make the tooltips show correctly.
78+
79+
For example, for the [Pydata Sphinx Theme](https://pydata-sphinx-theme.readthedocs.io):
80+
81+
`conf.py`:
82+
83+
```python
84+
html_static_path = ['_static']
85+
html_css_files = ["tippy.css"]
86+
```
87+
88+
`_static/tippy.css`:
89+
90+
```css
91+
.tippy-box {
92+
background-color:var(--pst-color-surface);
93+
color:var(--pst-color-text-base);
94+
border: 1px solid var(--pst-color-border);
95+
}
96+
```
97+
98+
:::
99+
75100
## How does it work?
76101

77102
The extension uses the [tippy.js](https://atomiks.github.io/tippyjs) library to create tooltips.
@@ -97,7 +122,7 @@ Overrides for the [tippy.js props](https://atomiks.github.io/tippyjs/v6/all-prop
97122
tippy_props = {"placement": "auto-start", "maxWidth": 500, "interactive": False, "arrow": True}
98123
```
99124

100-
Note, only the `placement`, `maxWidth` and `interactive` props are allowed to be overridden currently.
125+
Note, only the `placement`, `maxWidth`, `theme`, and `interactive` props are allowed to be overridden currently.
101126
:::
102127

103128
:::{confval} tippy_add_class

‎src/sphinx_tippy.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def compile_config(app: Sphinx):
125125
props = dict(
126126
{"placement": "auto-start", "maxWidth": 500, "interactive": False}, **updates
127127
)
128-
if set(props.keys()) - {"placement", "maxWidth", "interactive"}:
128+
if set(props.keys()) - {"placement", "maxWidth", "interactive", "theme"}:
129129
raise ExtensionError(
130130
"tippy_props can only contain keys 'placement', 'maxWidth', 'interactive'"
131131
)
@@ -159,6 +159,10 @@ def compile_config(app: Sphinx):
159159
if not isinstance(props["interactive"], bool):
160160
raise ExtensionError("tippy_props['interactive'] must be a boolean")
161161
props["interactive"] = "true" if props["interactive"] else "false"
162+
if "theme" in props:
163+
if not (props["theme"] is None or isinstance(props["theme"], str)):
164+
raise ExtensionError("tippy_props['theme'] must be None or a string")
165+
props["theme"] = f"'{props['theme']}'" if props["theme"] else "null"
162166
app.env.tippy_config = TippyConfig( # type: ignore[attr-defined]
163167
props=props,
164168
custom_tips=app.config.tippy_custom_tips,

0 commit comments

Comments
 (0)