Skip to content

Commit b5db029

Browse files
committed
Feature: optional prompt button for lazy loading the JupyterLite UI
1 parent b5f83fa commit b5db029

File tree

13 files changed

+240
-82
lines changed

13 files changed

+240
-82
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
channels: conda-forge
3838

3939
- name: Test PEP8
40-
run: black --check src
40+
run: black --check jupyterlite_sphinx

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
src/jupyterlite_sphinx.egg-info
1+
jupyterlite_sphinx/jupyterlite_sphinx.egg-info
22
**/.ipynb_checkpoints
33
**/__pycache__
44
docs/build

MANIFEST.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
include LICENSE
2+
include README.md
3+
include setup.py
4+
5+
graft jupyterlite_sphinx
6+
graft docs
7+
8+
# Patterns to exclude from any directory
9+
global-exclude *~
10+
global-exclude *.pyc
11+
global-exclude *.pyo
12+
global-exclude .git
13+
global-exclude .ipynb_checkpoints

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
jupyter_lite_config = "jupyter_lite_config.json"
1111
jupyter_lite_contents = "./custom_contents"
12+
jupyterlite_bind_ipynb_suffix = False
1213

1314
master_doc = 'index'
1415

docs/directives/jupyterlite.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ JupyterLite directive
88
.. jupyterlite::
99
:width: 100%
1010
:height: 600px
11+
:prompt: Try JupyterLite!
12+
:prompt_color: #00aa42
1113
1214
.. jupyterlite::
1315
:width: 100%
1416
:height: 600px
17+
:prompt: Try JupyterLite!
18+
:prompt_color: #00aa42
1519

1620
You can also pass a Notebook file to open automatically:
1721

@@ -20,7 +24,11 @@ You can also pass a Notebook file to open automatically:
2024
.. jupyterlite:: my_notebook.ipynb
2125
:width: 100%
2226
:height: 600px
27+
:prompt: Try JupyterLite!
28+
:prompt_color: #00aa42
2329
2430
.. jupyterlite:: my_notebook.ipynb
2531
:width: 100%
2632
:height: 600px
33+
:prompt: Try JupyterLite!
34+
:prompt_color: #00aa42

docs/directives/replite.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ Replite directive
22
=================
33

44
``jupyterlite-sphinx`` provides a ``replite`` directive that allows you to embed a replite console in your docs.
5-
This directive takes the same options as the ``replite`` package, see https://github.com/jtpio/replite for reference.
5+
This directive takes extra options which are the same options as the ``replite`` package, see https://github.com/jtpio/replite for reference.
66

77
.. code-block:: rst
88
99
.. replite::
1010
:kernel: python
1111
:height: 600px
12+
:prompt: Try Replite!
13+
:prompt_color: #dc3545
1214
1315
import matplotlib.pyplot as plt
1416
import numpy as np
@@ -23,6 +25,8 @@ This directive takes the same options as the ``replite`` package, see https://gi
2325
.. replite::
2426
:kernel: python
2527
:height: 600px
28+
:prompt: Try Replite!
29+
:prompt_color: #dc3545
2630

2731
import matplotlib.pyplot as plt
2832
import numpy as np

docs/directives/retrolite.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ RetroLite directive
88
.. retrolite::
99
:width: 100%
1010
:height: 600px
11+
:prompt: Try Retrolite!
1112
1213
.. retrolite::
1314
:width: 100%
1415
:height: 600px
16+
:prompt: Try Retrolite!
1517

1618
You can also pass a Notebook file to open:
1719

@@ -20,7 +22,9 @@ You can also pass a Notebook file to open:
2022
.. retrolite:: my_notebook.ipynb
2123
:width: 100%
2224
:height: 600px
25+
:prompt: Try Retrolite!
2326
2427
.. retrolite:: my_notebook.ipynb
2528
:width: 100%
2629
:height: 600px
30+
:prompt: Try Retrolite!

docs/index.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,24 @@ A Sphinx extension that provides utilities for embedding JupyterLite in your doc
1515
print("Hello from a JupyterLite console!")
1616

1717
.. toctree::
18-
:caption: Installation
1918
:maxdepth: 2
2019

2120
installation
2221
configuration
2322

23+
Usage
24+
-----
25+
26+
``jupyterlite-sphinx`` provides a collection of directives that allows you to embed the different JupyterLite UIs directly in your documentation page.
27+
Each of those directives can be configured with the following options:
28+
29+
- ``width`` (default ``"100%"``) the width of the UI
30+
- ``height`` (default ``"600px"``) the height of the UI
31+
- ``theme`` (default ``None``) the JupyterLab theme to use
32+
- ``prompt`` (default ``False``) whether or not to lazy-load the UI. If the value is a string, it will use this value for the prompt button.
33+
- ``prompt_color`` (default ``#f7dc1e``) The color of the prompt button, if there is one.
34+
2435
.. toctree::
25-
:caption: Usage
2636
:maxdepth: 2
2737

2838
directives/jupyterlite

jupyterlite_sphinx/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .jupyterlite_sphinx import setup ## noqa
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.jupyterlite_sphinx_raw_iframe {
2+
border-width: 1px;
3+
border-style: solid;
4+
border-color: #d8d8d8;
5+
box-shadow: 0 0.2rem 0.5rem #d8d8d8;
6+
}
7+
8+
.jupyterlite_sphinx_iframe_container {
9+
border-width: 1px;
10+
border-style: solid;
11+
border-color: #d8d8d8;
12+
position: relative;
13+
cursor: pointer;
14+
box-shadow: 0 0.2rem 0.5rem #d8d8d8;
15+
}
16+
17+
.jupyterlite_sphinx_iframe {
18+
z-index: 1;
19+
position: relative;
20+
border-style: none;
21+
}
22+
23+
.jupyterlite_sphinx_try_it_button {
24+
z-index: 0;
25+
position: absolute;
26+
left: 50%;
27+
top: 50%;
28+
transform: translateY(-50%) translateX(-50%);
29+
height: 100px;
30+
width: 100px;
31+
line-height: 100px;
32+
text-align: center;
33+
white-space: nowrap;
34+
background-color: #f7dc1e;
35+
border-radius: 50%;
36+
font-family: vibur;
37+
font-size: larger;
38+
box-shadow: 0 0.2rem 0.5rem #d8d8d8;
39+
}
40+
41+
.jupyterlite_sphinx_iframe_container:hover .jupyterlite_sphinx_try_it_button_unclicked {
42+
-webkit-animation:grow 0.2s ease-in-out;
43+
animation:grow 0.2s ease-in-out;
44+
transform: translateY(-50%) translateX(-50%) scale(1.2);
45+
}
46+
47+
.jupyterlite_sphinx_try_it_button_clicked {
48+
-webkit-animation:grow 1s infinite alternate;
49+
animation:grow 1s infinite alternate;
50+
transform: translateY(-50%) translateX(-50%) scale(1.2);
51+
}
52+
53+
@keyframes grow {
54+
from {
55+
transform: translateY(-50%) translateX(-50%) scale(1);
56+
}
57+
to {
58+
transform: translateY(-50%) translateX(-50%) scale(1.2);
59+
}
60+
}
61+
62+
@-webkit-keyframes grow {
63+
from {
64+
transform: translateY(-50%) translateX(-50%) scale(1);
65+
}
66+
to {
67+
transform: translateY(-50%) translateX(-50%) scale(1.2);
68+
}
69+
}

0 commit comments

Comments
 (0)