Skip to content

Commit e084a6f

Browse files
authored
Merge pull request #131 from Carreau/misc-css
Misc parsing warnings.
2 parents 9792e22 + bacf530 commit e084a6f

File tree

5 files changed

+73
-18
lines changed

5 files changed

+73
-18
lines changed

docs/_static/try_examples.css

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,64 @@
1+
:root {
2+
--jupyter-light-primary: #f7dc1e;
3+
--jupyter-light-primary-muted: #fff221;
4+
}
5+
16
.try_examples_button {
2-
background-color: #f7dc1e;
3-
border: none;
4-
padding: 5px 10px;
5-
border-radius: 15px;
6-
font-family: vibur;
7-
font-size: larger;
8-
box-shadow: 0 2px 5px rgba(108,108,108,0.2);
7+
background-color: var(--jupyter-light-primary);
8+
border: none;
9+
padding: 5px 10px;
10+
border-radius: 15px;
11+
font-family: vibur;
12+
font-size: larger;
13+
box-shadow: 0 2px 5px rgba(108, 108, 108, 0.2);
914
}
1015

1116
.try_examples_button:hover {
12-
background-color: #fff221;
13-
transform: scale(1.02);
14-
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
15-
cursor: pointer;
17+
background-color: var(--jupyter-light-primary-muted);
18+
transform: scale(1.02);
19+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
20+
cursor: pointer;
1621
}
1722

1823
.try_examples_button_container {
19-
display: flex;
20-
justify-content: flex-end;
24+
display: flex;
25+
justify-content: flex-end;
26+
}
27+
28+
.try_examples_outer_container,
29+
.try_examples_outer_iframe {
30+
flex-direction: column-reverse;
31+
display: flex;
32+
}
33+
34+
/* override class + hidden, otherwise any attempt of custom css to
35+
* set the display mode would lead to the iframe/container always visible.
36+
* */
37+
38+
.try_examples_outer_container.hidden,
39+
.try_examples_outer_iframe.hidden {
40+
display: none;
41+
}
42+
43+
/* customisation when the buttons containers have the blue-bottom class */
44+
45+
/* here we just show how to:
46+
* - change the color of the button
47+
* - change the color on hover.
48+
*
49+
* As we _used to have_ option to show the button above/below, and left/right
50+
* we show how to achieve the same with flex-direction
51+
*/
52+
53+
.blue-bottom .try_examples_button_container {
54+
justify-content: flex-start;
55+
}
56+
57+
.blue-bottom .try_examples_button {
58+
background-color: #00bcd4;
59+
color: white;
60+
}
61+
62+
.blue-bottom button.try_examples_button:hover {
63+
background-color: #2196f3;
2164
}

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Furthermore, this automatically installs any labextension that it founds, for ex
3333

3434
Say you want to install NumPy, Matplotlib and ipycanvas, it can be done by creating the environment.yml file with the following content:
3535

36-
```yml
36+
```yaml
3737
name: xeus-python-kernel
3838
channels:
3939
- https://repo.mamba.pm/emscripten-forge

docs/directives/try_examples.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ Here's an example with some options set
125125
.. try_examples::
126126
:button_text: Try it in your browser!
127127
:height: 400px
128+
:example_class: blue-bottom
128129
129130
The button text has changed and the height now exceeds the size of the content.
130131
@@ -133,6 +134,11 @@ Here's an example with some options set
133134
>>> x + y
134135
4
135136
137+
We've also added the ``blue-bottom`` class, the button should appear as blue,
138+
below the examples, and on the left side of the screen.
139+
140+
See ``try_examples.css`` in the Repository to see how we achieved this via
141+
custom css.
136142
```
137143

138144
and here is the result
@@ -141,6 +147,7 @@ and here is the result
141147
.. try_examples::
142148
:button_text: Try it in your browser!
143149
:height: 400px
150+
:example_class: blue-bottom
144151
145152
The button text has changed and the height now exceeds the size of the content.
146153
@@ -149,6 +156,11 @@ and here is the result
149156
>>> x + y
150157
4
151158
159+
We've also added the ``blue-bottom`` class, the button should appear as blue,
160+
below the examples, and on the left side of the screen.
161+
162+
See ``try_examples.css`` in the Repository to see how we achieved this via
163+
custom css.
152164
```
153165

154166

@@ -230,7 +242,7 @@ patterns, effectively disabling the interactive documentation. In the provided e
230242
in a Jupyterlite kernel.
231243

232244
* The pattern `"^/stable/reference/generated/example.html"` targets a particular url
233-
in the documentation for the latest stable release.
245+
in the documentation for the latest stable release.
234246

235247
Note that these patterns should match the [pathname](https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname) of the url, not the full url. This is the path portion of
236248
the url. For instance, the pathname of https://jupyterlite-sphinx.readthedocs.io/en/latest/directives/try_examples.html is `/en/latest/directives/try_examples.html`.

jupyterlite_sphinx/_try_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def examples_to_notebook(input_lines):
3636
>>> "\n",
3737
>>> ".. math::\n",
3838
>>> "\n",
39-
>>> " x = 2,\;y = 2
39+
>>> " x = 2,\\;y = 2
4040
>>> "\n",
4141
>>> " x + y = 4\n",
4242
>>> ]

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def run(self):
394394
notebooks_path = "../notebooks/"
395395

396396
content_container_node = nodes.container(
397-
classes=["try_examples_outer_container"]
397+
classes=["try_examples_outer_container", example_class]
398398
)
399399
examples_div_id = uuid4()
400400
content_container_node["ids"].append(examples_div_id)
@@ -430,7 +430,7 @@ def run(self):
430430
# Parent container (initially hidden)
431431
iframe_parent_container_div_start = (
432432
f'<div id="{iframe_parent_div_id}" '
433-
f'class="try_examples_outer_container {example_class} hidden">'
433+
f'class="try_examples_outer_iframe {example_class} hidden">'
434434
)
435435

436436
iframe_parent_container_div_end = "</div>"

0 commit comments

Comments
 (0)