Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds dark theme and theme switching functionality (REPL + website) #25

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Mark some repl-theme-bridge files as linguist-generated so that
# they doesn't show up in diffs automatically
repl-theme-bridge/yarn.lock linguist-generated=true
repl-theme-bridge/package.json linguist-generated=true

# Text files newline normalisation
* text=auto
14 changes: 12 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ jobs:
- name: Build the JupyterLite site
run: |
jupyter lite build
- name: Add custom index.html (live.sympy.org landing page) and static/ files
- name: Build dark theme support bridge
working-directory: repl-theme-bridge
run: jlpm run build
# Check for Pyodide kernel and theme bridge extension
# For some reason "jupyter labextension list" writes to
# both stdout and stderr, causing grep to fail. Maybe
# bug upstream?
- name: Sanity check extensions
run: |
./generateindex.py
jupyter labextension list 2>&1 | grep -E 'sympy-live-repl-theme-bridge'
jupyter labextension list 2>&1 | grep -E 'pyodide-kernel-extension'
- name: Add custom index.html (live.sympy.org landing page) and static/ files
run: python generateindex.py
- name: Add CNAME file containing live.sympy.org
run: |
echo "live.sympy.org" > ./_output/CNAME
Expand Down
18 changes: 18 additions & 0 deletions repl-theme-bridge/.copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file was generated automatically by Copier and the template at
# https://github.com/jupyterlab/extension-template

# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v4.3.7
_src_path: https://github.com/jupyterlab/extension-template
author_email: agriyakhetarpal@outlook.com
author_name: SymPy Live REPL Theme Bridge
has_binder: false
has_settings: false
kind: frontend
labextension_name: sympy-live-repl-theme-bridge
project_short_description:
A basic JupyterLab/JupyterLite extension to create a theme
bridge for the SymPy Live Shell hosted at https://live.sympy.org
python_name: sympy_live_repl_theme_bridge
repository: https://github.com/sympy/live
test: false
124 changes: 124 additions & 0 deletions repl-theme-bridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# This file was generated automatically by Copier and the template at
# https://github.com/jupyterlab/extension-template

*.bundle.*
lib/
node_modules/
*.log
.eslintcache
.stylelintcache
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
sympy_live_repl_theme_bridge/labextension
# Version file is handled by hatchling
sympy_live_repl_theme_bridge/_version.py

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage/
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# End of https://www.gitignore.io/api/python

# OSX files
.DS_Store

# Yarn cache
.yarn/
9 changes: 9 additions & 0 deletions repl-theme-bridge/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated automatically by Copier and the template at
# https://github.com/jupyterlab/extension-template

node_modules
**/node_modules
**/lib
**/package.json
!/package.json
sympy_live_repl_theme_bridge
4 changes: 4 additions & 0 deletions repl-theme-bridge/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file was generated automatically by Copier and the template at
# https://github.com/jupyterlab/extension-template

nodeLinker: node-modules
29 changes: 29 additions & 0 deletions repl-theme-bridge/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2025, Agriya Khetarpal
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82 changes: 82 additions & 0 deletions repl-theme-bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# sympy-live-repl-theme-bridge

A basic JupyterLab/JupyterLite extension to create a theme bridge for the SymPy Live Shell
hosted at https://live.sympy.org. It provides the machinery to change the theme for the
JupyterLite REPL in sync with the contents of the page, without having to restart the
kernel again.

This extension is based on the [JupyterLab Theme Bridge](https://jupyterlite.readthedocs.io/en/stable/howto/configure/advanced/iframe.html#extension-development) and modifies the theme of the SymPy Live Shell
to match the theme of the JupyterLab/JupyterLite environment.

The bridging logic is present in the `src/index.ts` file, and is complemented by the
theme toggle in the [`main.js`](../static/main.js) file.

## Requirements

- JupyterLab >= 4.0.0

## Install

The extension has not been published to the Python Package Index (PyPI) yet.

To install it, execute:

```bash
pip install .
```

## Uninstall

To remove the extension, execute:

```bash
pip uninstall sympy-live-repl-theme-bridge
```

## Contributing

### Development install

Note: You will need NodeJS to build the extension package.

The `jlpm` command is JupyterLab's pinned version of
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
`yarn` or `npm` in lieu of `jlpm` below.

```bash
# Clone the repo to your local environment
# Change directory to the sympy_live_repl_theme_bridge directory
# Install package in development mode
pip install -e "."
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm build
```

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
# Run JupyterLab in another terminal
jupyter lab
```

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

```bash
jupyter lab build --minimize=False
```

### Development uninstall

```bash
pip uninstall sympy-live-repl-theme-bridge
```

In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
folder is located. Then you can remove the symlink named `sympy-live-repl-theme-bridge` within that folder.
5 changes: 5 additions & 0 deletions repl-theme-bridge/install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "sympy-live-repl-theme-bridge",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package sympy_live_repl_theme_bridge"
}
Loading
Loading