This commit is contained in:
maltegrosse 2023-01-23 11:37:59 +01:00
commit c8fb0128dd
35 changed files with 11513 additions and 0 deletions

8
.eslintignore Normal file
View File

@ -0,0 +1,8 @@
node_modules
dist
coverage
**/*.d.ts
tests
**/__tests__
ui-tests

39
.eslintrc.js Normal file
View File

@ -0,0 +1,39 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true
}
}
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'prefer-arrow-callback': 'error'
}
};

150
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,150 @@
name: Build
on:
push:
branches: main
pull_request:
branches: '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install dependencies
run: python -m pip install -U jupyterlab~=3.5.2
- name: Lint the extension
run: |
set -eux
jlpm
jlpm run lint:check
- name: Test the extension
run: |
set -eux
jlpm run test
- name: Build the extension
run: |
set -eux
python -m pip install .[test]
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab_sandbox_theme.*OK"
python -m jupyterlab.browser_check
- name: Package the extension
run: |
set -eux
pip install build
python -m build
pip uninstall -y "jupyterlab_sandbox_theme" jupyterlab
- name: Upload extension packages
uses: actions/upload-artifact@v3
with:
name: extension-artifacts
path: dist/jupyterlab_sandbox_theme*
if-no-files-found: error
test_isolated:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/download-artifact@v3
with:
name: extension-artifacts
- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab~=3.1" jupyterlab_sandbox_theme*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab_sandbox_theme.*OK"
python -m jupyterlab.browser_check --no-chrome-test
integration-tests:
name: Integration tests
needs: build
runs-on: ubuntu-latest
env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Download extension package
uses: actions/download-artifact@v3
with:
name: extension-artifacts
- name: Install the extension
run: |
set -eux
python -m pip install "jupyterlab~=3.1" jupyterlab_sandbox_theme*.whl
- name: Install dependencies
working-directory: ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install
- name: Set up browser cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}
- name: Install browser
run: jlpm playwright install chromium
working-directory: ui-tests
- name: Execute integration tests
working-directory: ui-tests
run: |
jlpm playwright test
- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v3
with:
name: jupyterlab_sandbox_theme-playwright-tests
path: |
ui-tests/test-results
ui-tests/playwright-report
check_links:
name: Check Links
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1

29
.github/workflows/check-release.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Check Release
on:
push:
branches: ["main"]
pull_request:
branches: ["*"]
jobs:
check_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install Dependencies
run: |
pip install -e .
- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Distributions
uses: actions/upload-artifact@v3
with:
name: jupyterlab_sandbox_theme-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist

View File

@ -0,0 +1,50 @@
name: Update Playwright Snapshots
on:
issue_comment:
types: [created, edited]
permissions:
contents: write
pull-requests: write
jobs:
update-snapshots:
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'please update playwright snapshots') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git to use https
run: git config --global hub.protocol https
- name: Checkout the branch from the PR that triggered the job
run: hub pr checkout ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install dependencies
run: python -m pip install -U jupyterlab~=3.1
- name: Install extension
run: |
set -eux
jlpm
python -m pip install .
- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Playwright knows how to start JupyterLab server
start_server_script: 'null'
test_folder: ui-tests

122
.gitignore vendored Normal file
View File

@ -0,0 +1,122 @@
*.bundle.*
lib/
node_modules/
*.log
.eslintcache
.stylelintcache
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
jupyterlab_sandbox_theme/labextension
# Version file is handled by hatchling
jupyterlab_sandbox_theme/_version.py
# Integration tests
ui-tests/test-results/
ui-tests/playwright-report/
# 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

6
.prettierignore Normal file
View File

@ -0,0 +1,6 @@
node_modules
**/node_modules
**/lib
**/package.json
!/package.json
jupyterlab_sandbox_theme

6
.prettierrc Normal file
View File

@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "auto"
}

14
.stylelintrc Normal file
View File

@ -0,0 +1,14 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-standard",
"stylelint-prettier/recommended"
],
"rules": {
"property-no-vendor-prefix": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null,
"alpha-value-notation": null,
"color-function-notation": null
}
}

8
.woodpecker.yml Normal file
View File

@ -0,0 +1,8 @@
pipeline:
build-package:
image: python:3.9.16-alpine3.17
commands:
- python -m pip install -U jupyterlab~=3.5.2
- pip install build
- python -m build -s
- sleep 600

5
CHANGELOG.md Normal file
View File

@ -0,0 +1,5 @@
# Changelog
<!-- <START NEW CHANGELOG ENTRY> -->
<!-- <END NEW CHANGELOG ENTRY> -->

29
LICENSE Normal file
View File

@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2023, Malte Grosse
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.

96
README.md Normal file
View File

@ -0,0 +1,96 @@
# jupyterlab_sandbox_theme
[![Github Actions Status](https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab_sandbox_theme/workflows/Build/badge.svg)](https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab_sandbox_theme/actions/workflows/build.yml)
Sandbox Theme
## Requirements
- JupyterLab >= 3.0
## Install
To install the extension, execute:
```bash
pip install jupyterlab_sandbox_theme
```
## Uninstall
To remove the extension, execute:
```bash
pip uninstall jupyterlab_sandbox_theme
```
## 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 jupyterlab_sandbox_theme 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 jupyterlab_sandbox_theme
```
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 `jupyterlab_sandbox_theme` within that folder.
### Testing the extension
#### Frontend tests
This extension is using [Jest](https://jestjs.io/) for JavaScript code testing.
To execute them, execute:
```sh
jlpm
jlpm test
```
#### Integration tests
This extension uses [Playwright](https://playwright.dev/docs/intro/) for the integration tests (aka user level tests).
More precisely, the JupyterLab helper [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) is used to handle testing the extension in JupyterLab.
More information are provided within the [ui-tests](./ui-tests/README.md) README.
### Packaging the extension
See [RELEASE](RELEASE.md)

68
RELEASE.md Normal file
View File

@ -0,0 +1,68 @@
# Making a new release of jupyterlab_sandbox_theme
The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).
## Manual release
### Python package
This extension can be distributed as Python
packages. All of the Python
packaging instructions in the `pyproject.toml` file to wrap your extension in a
Python package. Before generating a package, we first need to install `build`.
```bash
pip install build twine hatch
```
Bump the version using `hatch`. By default this will create a tag.
See the docs on [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-version#semver) for details.
```bash
hatch version <new-version>
```
To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do:
```bash
python -m build
```
> `python setup.py sdist bdist_wheel` is deprecated and will not work for this package.
Then to upload the package to PyPI, do:
```bash
twine upload dist/*
```
### NPM package
To publish the frontend part of the extension as a NPM package, do:
```bash
npm login
npm publish --access public
```
## Automated releases with the Jupyter Releaser
The extension repository should already be compatible with the Jupyter Releaser.
Check out the [workflow documentation](https://github.com/jupyter-server/jupyter_releaser#typical-workflow) for more information.
Here is a summary of the steps to cut a new release:
- Fork the [`jupyter-releaser` repo](https://github.com/jupyter-server/jupyter_releaser)
- Add `ADMIN_GITHUB_TOKEN`, `PYPI_TOKEN` and `NPM_TOKEN` to the Github Secrets in the fork
- Go to the Actions panel
- Run the "Draft Changelog" workflow
- Merge the Changelog PR
- Run the "Draft Release" workflow
- Run the "Publish Release" workflow
## Publishing to `conda-forge`
If the package is not on conda forge yet, check the documentation to learn how to add it: https://conda-forge.org/docs/maintainer/adding_pkgs.html
Otherwise a bot should pick up the new version publish to PyPI, and open a new PR on the feedstock repository automatically.

1
babel.config.js Normal file
View File

@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');

5
install.json Normal file
View File

@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "jupyterlab_sandbox_theme",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab_sandbox_theme"
}

46
jest.config.js Normal file
View File

@ -0,0 +1,46 @@
const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config');
const esModules = [
'@jupyterlab/',
'lib0',
'y\\-protocols',
'y\\-websocket',
'yjs'
].join('|');
const jlabConfig = jestJupyterLab(__dirname);
const {
moduleFileExtensions,
moduleNameMapper,
preset,
setupFilesAfterEnv,
setupFiles,
testPathIgnorePatterns,
transform
} = jlabConfig;
module.exports = {
moduleFileExtensions,
moduleNameMapper,
preset,
setupFilesAfterEnv,
setupFiles,
testPathIgnorePatterns,
transform,
automock: false,
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/.ipynb_checkpoints/*'
],
coverageDirectory: 'coverage',
coverageReporters: ['lcov', 'text'],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json'
}
},
testRegex: 'src/.*/.*.spec.ts[x]?$',
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`]
};

View File

@ -0,0 +1,9 @@
from ._version import __version__
def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": "jupyterlab_sandbox_theme"
}]

97
package.json Normal file
View File

@ -0,0 +1,97 @@
{
"name": "jupyterlab_sandbox_theme",
"version": "0.1.0",
"description": "Sandbox Theme",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab-extension"
],
"homepage": "https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab_sandbox_theme",
"bugs": {
"url": "https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab_sandbox_theme/issues"
},
"license": "BSD-3-Clause",
"author": {
"name": "Malte Grosse",
"email": "grosse@hdm-stuttgart.de"
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
"style/images/**/*.{jpg,svg,png}"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://git.sandbox.iuk.hdm-stuttgart.de/grosse/jupyterlab_sandbox_theme.git"
},
"scripts": {
"build": "jlpm build:lib && jlpm build:labextension:dev",
"build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"build:lib": "tsc --sourceMap",
"build:lib:prod": "tsc",
"clean": "jlpm clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
"clean:labextension": "rimraf jupyterlab_sandbox_theme/labextension jupyterlab_sandbox_theme/_version.py",
"clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache",
"eslint": "jlpm eslint:check --fix",
"eslint:check": "eslint . --cache --ext .ts,.tsx",
"install:extension": "jlpm build",
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
"prettier": "jlpm prettier:base --write --list-different",
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "jlpm prettier:base --check",
"stylelint": "jlpm stylelint:check --fix",
"stylelint:check": "stylelint --cache \"style/**/*.css\"",
"test": "jest --coverage",
"watch": "run-p watch:src watch:labextension",
"watch:src": "tsc -w",
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyterlab/application": "^3.5.2",
"@jupyterlab/apputils": "^3.5.2",
"@jupyterlab/ui-components": "^3.5.2"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@jupyterlab/builder": "^3.1.0",
"@jupyterlab/testutils": "^3.0.0",
"@types/jest": "^26.0.0",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"rimraf": "^3.0.2",
"stylelint": "^14.3.0",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-recommended": "^6.0.0",
"stylelint-config-standard": "~24.0.0",
"stylelint-prettier": "^2.0.0",
"ts-jest": "^26.0.0",
"typescript": "~4.1.3"
},
"sideEffects": [
"style/*.css"
],
"publishConfig": {
"access": "public"
},
"jupyterlab": {
"extension": true,
"outputDir": "jupyterlab_sandbox_theme/labextension",
"themePath": "style/index.css"
}
}

72
pyproject.toml Normal file
View File

@ -0,0 +1,72 @@
[build-system]
requires = ["hatchling>=1.4.0", "jupyterlab>=3.4.7,<4.0.0", "hatch-nodejs-version"]
build-backend = "hatchling.build"
[project]
name = "jupyterlab_sandbox_theme"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.7"
classifiers = [
"Framework :: Jupyter",
"Framework :: Jupyter :: JupyterLab",
"Framework :: Jupyter :: JupyterLab :: 3",
"Framework :: Jupyter :: JupyterLab :: Extensions",
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
]
dynamic = ["version", "description", "authors", "urls", "keywords"]
[tool.hatch.version]
source = "nodejs"
[tool.hatch.metadata.hooks.nodejs]
fields = ["description", "authors", "urls"]
[tool.hatch.build.targets.sdist]
artifacts = ["jupyterlab_sandbox_theme/labextension"]
exclude = [".github", "binder"]
[tool.hatch.build.targets.wheel.shared-data]
"jupyterlab_sandbox_theme/labextension" = "share/jupyter/labextensions/jupyterlab_sandbox_theme"
"install.json" = "share/jupyter/labextensions/jupyterlab_sandbox_theme/install.json"
[tool.hatch.build.hooks.version]
path = "jupyterlab_sandbox_theme/_version.py"
[tool.hatch.build.hooks.jupyter-builder]
dependencies = ["hatch-jupyter-builder>=0.5"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"jupyterlab_sandbox_theme/labextension/package.json",
]
skip-if-exists = ["jupyterlab_sandbox_theme/labextension/static/style.js"]
[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
build_cmd = "build:prod"
npm = ["jlpm"]
[tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs]
build_cmd = "install:extension"
npm = ["jlpm"]
source_dir = "src"
build_dir = "jupyterlab_sandbox_theme/labextension"
[tool.jupyter-releaser.options]
version_cmd = "hatch version"
[tool.jupyter-releaser.hooks]
before-build-npm = ["python -m pip install jupyterlab~=3.1", "jlpm", "jlpm build:prod"]
before-build-python = ["jlpm clean:all"]
[tool.check-wheel-contents]
ignore = ["W002"]

1
setup.py Normal file
View File

@ -0,0 +1 @@
__import__('setuptools').setup()

View File

@ -0,0 +1,9 @@
/**
* Example of [Jest](https://jestjs.io/docs/getting-started) unit tests
*/
describe('jupyterlab_sandbox_theme', () => {
it('should be tested', () => {
expect(1 + 1).toEqual(2);
});
});

8
src/images.ts Normal file

File diff suppressed because one or more lines are too long

90
src/index.ts Normal file
View File

@ -0,0 +1,90 @@
import { ILabShell, JupyterFrontEnd, JupyterFrontEndPlugin} from '@jupyterlab/application';
import { IThemeManager, ISplashScreen} from '@jupyterlab/apputils';
import { LabIcon, jupyterFaviconIcon, jupyterIcon, jupyterlabWordmarkIcon } from '@jupyterlab/ui-components';
import { Widget } from '@lumino/widgets';
import { Logo,FavIconIdle,FavIconBusy} from './images';
/**
* Initialization data for the jupyterlab_sandbox_theme extension.
*/
const plugin: JupyterFrontEndPlugin<void> = {
id: 'jupyterlab_sandbox_theme:plugin',
requires: [IThemeManager, ILabShell,ISplashScreen],
activate: (app: JupyterFrontEnd, manager: IThemeManager, shell: ILabShell) => {
const style = 'jupyterlab_sandbox_theme/index.css';
const logo_svg = Logo
const logo_icon = new LabIcon({ name: 'ui-components:sandbox', svgstr: logo_svg });
const logo = new Widget();
logo_icon.element({
container: logo.node,
elementPosition: 'center',
margin: '2px 2px 2px 8px',
height: 'auto',
width: '16px'
});
logo.id = 'jp-sandboxLogo';
shell.add(logo, 'top', { rank: 0 });
// Set the icons elsewhere
jupyterFaviconIcon.svgstr = logo_svg;
jupyterIcon.svgstr = logo_svg;
jupyterlabWordmarkIcon.svgstr = logo_svg;
// Register the plugin
manager.register({
name: 'Sandbox',
isLight: true,
themeScrollbars: true,
load: () => manager.loadCSS(style),
unload: () => Promise.resolve(undefined)
});
// hack to change favicons
let idle = FavIconIdle
let busy = FavIconBusy
waitForElement('.idle', document.head).then((elm: any) => {
elm.setAttribute("href",idle)
});
waitForElement('.busy',document.head).then((elm: any) => {
elm.setAttribute("href",busy)
});
waitForElement('#jupyterlab-splash',document.body).then((elm: any) => {
console.log(elm)
let child = elm.firstChild
child.innerHTML = ' <div class="cube"> <div class="cube1"></div> <div class="cube2"></div></div>';
child.classList.add("spinner")
});
},
autoStart: true
};
function waitForElement(selector: any, documentArea: any) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(documentArea, {
childList: true,
subtree: true
});
});
}
export default plugin;

4
src/typings.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare module '*.svg' {
const script: string;
export default script;
}

36
style/images/logo.svg Normal file
View File

@ -0,0 +1,36 @@
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="512.000000pt" height="512.000000pt" viewBox="0 0 512.000000 512.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M2365 5114 c-652 -67 -1178 -310 -1614 -745 -405 -405 -649 -902
-733 -1494 -17 -118 -17 -512 0 -630 84 -592 328 -1089 733 -1494 405 -405
902 -649 1494 -733 118 -17 512 -17 630 0 592 84 1089 328 1494 733 405 405
649 902 733 1494 17 118 17 512 0 630 -84 592 -328 1089 -733 1494 -395 395
-883 639 -1449 726 -101 15 -468 28 -555 19z m1255 -641 c91 -25 212 -58 269
-74 57 -15 106 -30 108 -33 10 -10 -112 -341 -142 -386 -16 -24 -52 -58 -79
-75 -45 -27 -57 -30 -138 -30 l-88 0 -55 -150 c-30 -82 -77 -211 -103 -285
l-49 -135 62 -20 c147 -48 225 -148 225 -288 0 -46 -27 -132 -133 -429 -34
-95 -34 -98 -15 -114 22 -21 53 -70 62 -101 7 -21 0 -19 -89 22 -410 190 -868
282 -1274 255 -78 -6 -154 -12 -169 -15 l-27 -6 30 17 c102 59 264 107 420
125 55 6 101 13 103 14 3 3 82 207 82 212 0 7 -197 2 -300 -7 -406 -37 -846
-182 -1256 -414 l-82 -46 -146 63 c-80 34 -146 65 -146 68 0 3 89 40 198 82
108 42 285 110 392 152 204 79 485 189 605 235 39 15 147 57 240 93 94 36 222
86 286 111 l116 45 79 -30 c166 -64 149 -60 175 -33 74 78 248 106 370 59 13
-5 26 20 67 137 28 79 74 208 102 286 28 79 50 145 48 146 -2 1 -22 10 -45 20
-81 35 -135 118 -135 206 0 39 26 121 126 396 3 8 24 6 73 -8 37 -10 142 -39
233 -65z m428 -1705 c177 -67 322 -124 322 -127 0 -3 -66 -35 -146 -70 l-146
-64 -57 32 c-31 17 -123 66 -206 107 -82 42 -152 78 -154 80 -5 4 52 164 59
164 3 0 150 -54 328 -122z m-2723 -528 c385 -171 798 -355 917 -408 l218 -97
0 -468 0 -469 -33 20 c-17 11 -84 49 -147 84 -63 36 -335 190 -605 343 -269
153 -578 327 -685 388 -107 61 -251 143 -320 182 l-125 71 -3 352 -2 351 42
-18 c24 -10 358 -159 743 -331z m3195 -3 l0 -353 -62 -36 c-35 -20 -151 -85
-258 -146 -537 -303 -1368 -772 -1470 -830 -63 -35 -118 -67 -122 -69 -5 -2
-8 206 -8 464 l0 468 278 123 c152 67 583 259 957 426 374 168 681 305 683
305 1 1 2 -158 2 -352z"/>
<path d="M3425 4308 c-2 -7 -13 -38 -25 -68 -23 -63 -25 -93 -7 -108 6 -6 70
-27 140 -47 113 -32 130 -35 149 -23 19 13 83 156 73 166 -5 5 -305 92 -318
92 -4 0 -10 -6 -12 -12z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

70
style/index.css Normal file
View File

@ -0,0 +1,70 @@
@import './variables.css';
/* Set the default typography for monospace elements */
tt,
code,
kbd,
samp,
pre {
font-family: var(--jp-code-font-family);
font-size: var(--jp-code-font-size);
line-height: var(--jp-code-line-height);
}
#jp-MainLogo {
display: none;
}
.spinner {
margin: 100px auto;
width: 40px;
height: 40px;
position: relative;
}
.cube {
position: absolute;
top: 30%;
left: 50%;
border-radius: 50%;
}
.cube1, .cube2 {
background-color: #333;
width: 15px;
height: 15px;
position: absolute;
top: 0;
left: 0;
-webkit-animation: sk-cubemove 1.8s infinite ease-in-out;
animation: sk-cubemove 1.8s infinite ease-in-out;
}
.cube2 {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}
@-webkit-keyframes sk-cubemove {
25% { -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5) }
50% { -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg) }
75% { -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5) }
100% { -webkit-transform: rotate(-360deg) }
}
@keyframes sk-cubemove {
25% {
transform: translateX(42px) rotate(-90deg) scale(0.5);
-webkit-transform: translateX(42px) rotate(-90deg) scale(0.5);
} 50% {
transform: translateX(42px) translateY(42px) rotate(-179deg);
-webkit-transform: translateX(42px) translateY(42px) rotate(-179deg);
} 50.1% {
transform: translateX(42px) translateY(42px) rotate(-180deg);
-webkit-transform: translateX(42px) translateY(42px) rotate(-180deg);
} 75% {
transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
-webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
} 100% {
transform: rotate(-360deg);
-webkit-transform: rotate(-360deg);
}
}

388
style/variables.css Normal file
View File

@ -0,0 +1,388 @@
/* ----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|--------------------------------------------------------------------------- */
/*
The following CSS variables define the main, public API for styling JupyterLab.
These variables should be used by all plugins wherever possible. In other
words, plugins should not define custom colors, sizes, etc unless absolutely
necessary. This enables users to change the visual theme of JupyterLab
by changing these variables.
Many variables appear in an ordered sequence (0,1,2,3). These sequences
are designed to work well together, so for example, `--jp-border-color1` should
be used with `--jp-layout-color1`. The numbers have the following meanings:
* 0: super-primary, reserved for special emphasis
* 1: primary, most important under normal situations
* 2: secondary, next most important under normal situations
* 3: tertiary, next most important under normal situations
Throughout JupyterLab, we are mostly following principles from Google's
Material Design when selecting colors. We are not, however, following
all of MD as it is not optimized for dense, information rich UIs.
*/
:root {
/* Elevation
*
* We style box-shadows using Material Design's idea of elevation. These particular numbers are taken from here:
*
* https://github.com/material-components/material-components-web
* https://material-components-web.appspot.com/elevation.html
*/
--jp-shadow-base-lightness: 0;
--jp-shadow-umbra-color: rgba(
var(--jp-shadow-base-lightness),
var(--jp-shadow-base-lightness),
var(--jp-shadow-base-lightness),
0.2
);
--jp-shadow-penumbra-color: rgba(
var(--jp-shadow-base-lightness),
var(--jp-shadow-base-lightness),
var(--jp-shadow-base-lightness),
0.14
);
--jp-shadow-ambient-color: rgba(
var(--jp-shadow-base-lightness),
var(--jp-shadow-base-lightness),
var(--jp-shadow-base-lightness),
0.12
);
--jp-elevation-z0: none;
--jp-elevation-z1: 0 2px 1px -1px var(--jp-shadow-umbra-color),
0 1px 1px 0 var(--jp-shadow-penumbra-color),
0 1px 3px 0 var(--jp-shadow-ambient-color);
--jp-elevation-z2: 0 3px 1px -2px var(--jp-shadow-umbra-color),
0 2px 2px 0 var(--jp-shadow-penumbra-color),
0 1px 5px 0 var(--jp-shadow-ambient-color);
--jp-elevation-z4: 0 2px 4px -1px var(--jp-shadow-umbra-color),
0 4px 5px 0 var(--jp-shadow-penumbra-color),
0 1px 10px 0 var(--jp-shadow-ambient-color);
--jp-elevation-z6: 0 3px 5px -1px var(--jp-shadow-umbra-color),
0 6px 10px 0 var(--jp-shadow-penumbra-color),
0 1px 18px 0 var(--jp-shadow-ambient-color);
--jp-elevation-z8: 0 5px 5px -3px var(--jp-shadow-umbra-color),
0 8px 10px 1px var(--jp-shadow-penumbra-color),
0 3px 14px 2px var(--jp-shadow-ambient-color);
--jp-elevation-z12: 0 7px 8px -4px var(--jp-shadow-umbra-color),
0 12px 17px 2px var(--jp-shadow-penumbra-color),
0 5px 22px 4px var(--jp-shadow-ambient-color);
--jp-elevation-z16: 0 8px 10px -5px var(--jp-shadow-umbra-color),
0 16px 24px 2px var(--jp-shadow-penumbra-color),
0 6px 30px 5px var(--jp-shadow-ambient-color);
--jp-elevation-z20: 0 10px 13px -6px var(--jp-shadow-umbra-color),
0 20px 31px 3px var(--jp-shadow-penumbra-color),
0 8px 38px 7px var(--jp-shadow-ambient-color);
--jp-elevation-z24: 0 11px 15px -7px var(--jp-shadow-umbra-color),
0 24px 38px 3px var(--jp-shadow-penumbra-color),
0 9px 46px 8px var(--jp-shadow-ambient-color);
/* Borders
*
* The following variables, specify the visual styling of borders in JupyterLab.
*/
--jp-border-width: 1px;
--jp-border-color0: var(--md-grey-400);
--jp-border-color1: var(--md-grey-400);
--jp-border-color2: var(--md-grey-300);
--jp-border-color3: var(--md-grey-200);
--jp-border-radius: 2px;
/* UI Fonts
*
* The UI font CSS variables are used for the typography all of the JupyterLab
* user interface elements that are not directly user generated content.
*
* The font sizing here is done assuming that the body font size of --jp-ui-font-size1
* is applied to a parent element. When children elements, such as headings, are sized
* in em all things will be computed relative to that body size.
*/
--jp-ui-font-scale-factor: 1.2;
--jp-ui-font-size0: 0.8333em;
--jp-ui-font-size1: 13px; /* Base font size */
--jp-ui-font-size2: 1.2em;
--jp-ui-font-size3: 1.44em;
--jp-ui-font-family: -apple-system, blinkmacsystemfont, 'Segoe UI', helvetica,
arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
/*
* Use these font colors against the corresponding main layout colors.
* In a light theme, these go from dark to light.
*/
/* Defaults use Material Design specification */
--jp-ui-font-color0: rgba(0, 0, 0, 1);
--jp-ui-font-color1: rgba(0, 0, 0, 0.87);
--jp-ui-font-color2: rgba(0, 0, 0, 0.54);
--jp-ui-font-color3: rgba(0, 0, 0, 0.38);
/*
* Use these against the brand/accent/warn/error colors.
* These will typically go from light to darker, in both a dark and light theme.
*/
--jp-ui-inverse-font-color0: rgba(255, 255, 255, 1);
--jp-ui-inverse-font-color1: rgba(255, 255, 255, 1);
--jp-ui-inverse-font-color2: rgba(255, 255, 255, 0.7);
--jp-ui-inverse-font-color3: rgba(255, 255, 255, 0.5);
/* Content Fonts
*
* Content font variables are used for typography of user generated content.
*
* The font sizing here is done assuming that the body font size of --jp-content-font-size1
* is applied to a parent element. When children elements, such as headings, are sized
* in em all things will be computed relative to that body size.
*/
--jp-content-line-height: 1.6;
--jp-content-font-scale-factor: 1.2;
--jp-content-font-size0: 0.8333em;
--jp-content-font-size1: 14px; /* Base font size */
--jp-content-font-size2: 1.2em;
--jp-content-font-size3: 1.44em;
--jp-content-font-size4: 1.728em;
--jp-content-font-size5: 2.0736em;
/* This gives a magnification of about 125% in presentation mode over normal. */
--jp-content-presentation-font-size1: 17px;
--jp-content-heading-line-height: 1;
--jp-content-heading-margin-top: 1.2em;
--jp-content-heading-margin-bottom: 0.8em;
--jp-content-heading-font-weight: 500;
/* Defaults use Material Design specification */
--jp-content-font-color0: rgba(0, 0, 0, 1);
--jp-content-font-color1: rgba(0, 0, 0, 0.87);
--jp-content-font-color2: rgba(0, 0, 0, 0.54);
--jp-content-font-color3: rgba(0, 0, 0, 0.38);
--jp-content-link-color: var(--md-blue-700);
--jp-content-font-family: -apple-system, blinkmacsystemfont, 'Segoe UI',
helvetica, arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol';
/*
* Code Fonts
*
* Code font variables are used for typography of code and other monospaces content.
*/
--jp-code-font-size: 13px;
--jp-code-line-height: 1.3077; /* 17px for 13px base */
--jp-code-padding: 0.385em; /* 5px for 13px base */
--jp-code-font-family-default: menlo, consolas, 'DejaVu Sans Mono', monospace;
--jp-code-font-family: var(--jp-code-font-family-default);
/* This gives a magnification of about 125% in presentation mode over normal. */
--jp-code-presentation-font-size: 16px;
/* may need to tweak cursor width if you change font size */
--jp-code-cursor-width0: 1.4px;
--jp-code-cursor-width1: 2px;
--jp-code-cursor-width2: 4px;
/* Layout
*
* The following are the main layout colors use in JupyterLab. In a light
* theme these would go from light to dark.
*/
--jp-layout-color0: white;
--jp-layout-color1: white;
--jp-layout-color2: var(--md-grey-200);
--jp-layout-color3: var(--md-grey-400);
--jp-layout-color4: var(--md-grey-600);
/* Inverse Layout
*
* The following are the inverse layout colors use in JupyterLab. In a light
* theme these would go from dark to light.
*/
--jp-inverse-layout-color0: #111;
--jp-inverse-layout-color1: var(--md-grey-900);
--jp-inverse-layout-color2: var(--md-grey-800);
--jp-inverse-layout-color3: var(--md-grey-700);
--jp-inverse-layout-color4: var(--md-grey-600);
/* Brand/accent */
--jp-brand-color0: #ec0c4b;
--jp-brand-color1: #ed225d;
--jp-brand-color2: #ee376b;
--jp-brand-color3: #ee3b6e;
--jp-accent-color0: var(--md-green-700);
--jp-accent-color1: var(--md-green-500);
--jp-accent-color2: var(--md-green-300);
--jp-accent-color3: var(--md-green-100);
/* State colors (warn, error, success, info) */
--jp-warn-color0: var(--md-orange-700);
--jp-warn-color1: var(--md-orange-500);
--jp-warn-color2: var(--md-orange-300);
--jp-warn-color3: var(--md-orange-100);
--jp-error-color0: var(--md-red-700);
--jp-error-color1: var(--md-red-500);
--jp-error-color2: var(--md-red-300);
--jp-error-color3: var(--md-red-100);
--jp-success-color0: var(--md-green-700);
--jp-success-color1: var(--md-green-500);
--jp-success-color2: var(--md-green-300);
--jp-success-color3: var(--md-green-100);
--jp-info-color0: var(--md-cyan-700);
--jp-info-color1: var(--md-cyan-500);
--jp-info-color2: var(--md-cyan-300);
--jp-info-color3: var(--md-cyan-100);
/* Cell specific styles */
--jp-cell-padding: 5px;
--jp-cell-collapser-width: 8px;
--jp-cell-collapser-min-height: 20px;
--jp-cell-collapser-not-active-hover-opacity: 0.6;
--jp-cell-editor-background: var(--md-grey-100);
--jp-cell-editor-border-color: var(--md-grey-300);
--jp-cell-editor-box-shadow: inset 0 0 2px var(--md-blue-300);
--jp-cell-editor-active-background: var(--jp-layout-color0);
--jp-cell-editor-active-border-color: var(--jp-brand-color1);
--jp-cell-prompt-width: 64px;
--jp-cell-prompt-font-family: 'Source Code Pro', monospace;
--jp-cell-prompt-letter-spacing: 0;
--jp-cell-prompt-opacity: 1;
--jp-cell-prompt-not-active-opacity: 0.5;
--jp-cell-prompt-not-active-font-color: var(--md-grey-700);
/* A custom blend of MD grey and blue 600
* See https://meyerweb.com/eric/tools/color-blend/#546E7A:1E88E5:5:hex */
--jp-cell-inprompt-font-color: #307fc1;
/* A custom blend of MD grey and orange 600
* https://meyerweb.com/eric/tools/color-blend/#546E7A:F4511E:5:hex */
--jp-cell-outprompt-font-color: #bf5b3d;
/* Notebook specific styles */
--jp-notebook-padding: 10px;
--jp-notebook-select-background: var(--jp-layout-color1);
--jp-notebook-multiselected-color: var(--md-blue-50);
/* The scroll padding is calculated to fill enough space at the bottom of the
notebook to show one single-line cell (with appropriate padding) at the top
when the notebook is scrolled all the way to the bottom. We also subtract one
pixel so that no scrollbar appears if we have just one single-line cell in the
notebook. This padding is to enable a 'scroll past end' feature in a notebook.
*/
--jp-notebook-scroll-padding: calc(
100% - var(--jp-code-font-size) * var(--jp-code-line-height) -
var(--jp-code-padding) - var(--jp-cell-padding) - 1px
);
/* Rendermime styles */
--jp-rendermime-error-background: #fdd;
--jp-rendermime-table-row-background: var(--md-grey-100);
--jp-rendermime-table-row-hover-background: var(--md-light-blue-50);
/* Dialog specific styles */
--jp-dialog-background: rgba(0, 0, 0, 0.25);
/* Console specific styles */
--jp-console-padding: 10px;
/* Toolbar specific styles */
--jp-toolbar-border-color: var(--jp-border-color1);
--jp-toolbar-micro-height: 8px;
--jp-toolbar-background: var(--jp-layout-color1);
--jp-toolbar-box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.24);
--jp-toolbar-header-margin: 4px 4px 0 4px;
--jp-toolbar-active-background: var(--md-grey-300);
/* Statusbar specific styles */
--jp-statusbar-height: 24px;
/* Input field styles */
--jp-input-box-shadow: inset 0 0 2px var(--md-blue-300);
--jp-input-active-background: var(--jp-layout-color1);
--jp-input-hover-background: var(--jp-layout-color1);
--jp-input-background: var(--md-grey-100);
--jp-input-border-color: var(--jp-border-color1);
--jp-input-active-border-color: var(--jp-brand-color1);
/* General editor styles */
--jp-editor-selected-background: #d9d9d9;
--jp-editor-selected-focused-background: #d7d4f0;
--jp-editor-cursor-color: var(--jp-ui-font-color0);
/* Code mirror specific styles */
--jp-mirror-editor-keyword-color: #008000;
--jp-mirror-editor-atom-color: #88f;
--jp-mirror-editor-number-color: #080;
--jp-mirror-editor-def-color: #00f;
--jp-mirror-editor-variable-color: var(--md-grey-900);
--jp-mirror-editor-variable-2-color: #05a;
--jp-mirror-editor-variable-3-color: #085;
--jp-mirror-editor-punctuation-color: #05a;
--jp-mirror-editor-property-color: #05a;
--jp-mirror-editor-operator-color: #a2f;
--jp-mirror-editor-comment-color: #408080;
--jp-mirror-editor-string-color: #ba2121;
--jp-mirror-editor-string-2-color: #708;
--jp-mirror-editor-meta-color: #a2f;
--jp-mirror-editor-qualifier-color: #555;
--jp-mirror-editor-builtin-color: #008000;
--jp-mirror-editor-bracket-color: #997;
--jp-mirror-editor-tag-color: #170;
--jp-mirror-editor-attribute-color: #00c;
--jp-mirror-editor-header-color: blue;
--jp-mirror-editor-quote-color: #090;
--jp-mirror-editor-link-color: #00c;
--jp-mirror-editor-error-color: #f00;
--jp-mirror-editor-hr-color: #999;
/* User colors */
--jp-collaborator-color1: #ad4a00;
--jp-collaborator-color2: #7b6a00;
--jp-collaborator-color3: #007e00;
--jp-collaborator-color4: #008772;
--jp-collaborator-color5: #0079b9;
--jp-collaborator-color6: #8b45c6;
--jp-collaborator-color7: #be208b;
/* File or activity icons and switch semantic variables */
--jp-jupyter-icon-color: var(--md-orange-900);
--jp-notebook-icon-color: var(--md-orange-700);
--jp-json-icon-color: var(--md-orange-700);
--jp-console-icon-background-color: var(--md-blue-700);
--jp-console-icon-color: white;
--jp-terminal-icon-background-color: var(--md-grey-200);
--jp-terminal-icon-color: var(--md-grey-800);
--jp-text-editor-icon-color: var(--md-grey-200);
--jp-inspector-icon-color: var(--md-grey-200);
--jp-switch-color: var(--md-grey-400);
--jp-switch-true-position-color: var(--md-orange-700);
--jp-switch-cursor-color: rgba(0, 0, 0, 0.8);
/* Vega extension styles */
--jp-vega-background: white;
/* Sidebar-related styles */
--jp-sidebar-min-width: 180px;
}

24
tsconfig.json Normal file
View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"composite": true,
"declaration": true,
"esModuleInterop": true,
"incremental": true,
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"preserveWatchOutput": true,
"resolveJsonModule": true,
"outDir": "lib",
"rootDir": "src",
"strict": true,
"strictNullChecks": true,
"target": "es2017",
"types": ["jest"]
},
"include": ["src/*"]
}

148
ui-tests/README.md Normal file
View File

@ -0,0 +1,148 @@
# Integration Testing
This folder contains the integration tests of the extension.
They are defined using [Playwright](https://playwright.dev/docs/intro) test runner
and [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) helper.
The Playwright configuration is defined in [playwright.config.js](./playwright.config.js).
The JupyterLab server configuration to use for the integration test is defined
in [jupyter_server_test_config.py](./jupyter_server_test_config.py).
The default configuration will produce video for failing tests and an HTML report.
## Run the tests
> All commands are assumed to be executed from the root directory
To run the tests, you need to:
1. Compile the extension:
```sh
jlpm install
jlpm build:prod
```
> Check the extension is installed in JupyterLab.
2. Install test dependencies (needed only once):
```sh
cd ./ui-tests
jlpm install
jlpm playwright install
cd ..
```
3. Execute the [Playwright](https://playwright.dev/docs/intro) tests:
```sh
cd ./ui-tests
jlpm playwright test
```
Test results will be shown in the terminal. In case of any test failures, the test report
will be opened in your browser at the end of the tests execution; see
[Playwright documentation](https://playwright.dev/docs/test-reporters#html-reporter)
for configuring that behavior.
## Update the tests snapshots
> All commands are assumed to be executed from the root directory
If you are comparing snapshots to validate your tests, you may need to update
the reference snapshots stored in the repository. To do that, you need to:
1. Compile the extension:
```sh
jlpm install
jlpm build:prod
```
> Check the extension is installed in JupyterLab.
2. Install test dependencies (needed only once):
```sh
cd ./ui-tests
jlpm install
jlpm playwright install
cd ..
```
3. Execute the [Playwright](https://playwright.dev/docs/intro) command:
```sh
cd ./ui-tests
jlpm playwright test -u
```
> Some discrepancy may occurs between the snapshots generated on your computer and
> the one generated on the CI. To ease updating the snapshots on a PR, you can
> type `please update playwright snapshots` to trigger the update by a bot on the CI.
> Once the bot has computed new snapshots, it will commit them to the PR branch.
## Create tests
> All commands are assumed to be executed from the root directory
To create tests, the easiest way is to use the code generator tool of playwright:
1. Compile the extension:
```sh
jlpm install
jlpm build:prod
```
> Check the extension is installed in JupyterLab.
2. Install test dependencies (needed only once):
```sh
cd ./ui-tests
jlpm install
jlpm playwright install
cd ..
```
3. Execute the [Playwright code generator](https://playwright.dev/docs/codegen):
```sh
cd ./ui-tests
jlpm playwright codegen localhost:8888
```
## Debug tests
> All commands are assumed to be executed from the root directory
To debug tests, a good way is to use the inspector tool of playwright:
1. Compile the extension:
```sh
jlpm install
jlpm build:prod
```
> Check the extension is installed in JupyterLab.
2. Install test dependencies (needed only once):
```sh
cd ./ui-tests
jlpm install
jlpm playwright install
cd ..
```
3. Execute the Playwright tests in [debug mode](https://playwright.dev/docs/debug):
```sh
cd ./ui-tests
PWDEBUG=1 jlpm playwright test
```

View File

@ -0,0 +1,20 @@
"""Server configuration for integration tests.
!! Never use this configuration in production because it
opens the server to the world and provide access to JupyterLab
JavaScript objects through the global window variable.
"""
from tempfile import mkdtemp
c.ServerApp.port = 8888
c.ServerApp.port_retries = 0
c.ServerApp.open_browser = False
c.ServerApp.root_dir = mkdtemp(prefix='galata-test-')
c.ServerApp.token = ""
c.ServerApp.password = ""
c.ServerApp.disable_check_xsrf = True
c.LabApp.expose_app_in_browser = True
# Uncomment to set server log level to debug level
# c.ServerApp.log_level = "DEBUG"

14
ui-tests/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "jupyterlab_sandbox_theme-ui-tests",
"version": "1.0.0",
"description": "JupyterLab jupyterlab_sandbox_theme Integration Tests",
"private": true,
"scripts": {
"start": "jupyter lab --config jupyter_server_test_config.py",
"test": "jlpm playwright test",
"test:update": "jlpm playwright test --update-snapshots"
},
"devDependencies": {
"@jupyterlab/galata": "^4.3.0"
}
}

View File

@ -0,0 +1,14 @@
/**
* Configuration for Playwright using default from @jupyterlab/galata
*/
const baseConfig = require('@jupyterlab/galata/lib/playwright-config');
module.exports = {
...baseConfig,
webServer: {
command: 'jlpm start',
url: 'http://localhost:8888/lab',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI
}
};

View File

@ -0,0 +1,21 @@
import { expect, test } from '@jupyterlab/galata';
/**
* Don't load JupyterLab webpage before running the tests.
* This is required to ensure we capture all log messages.
*/
test.use({ autoGoto: false });
test('should emit an activation console message', async ({ page }) => {
const logs: string[] = [];
page.on('console', message => {
logs.push(message.text());
});
await page.goto();
expect(
logs.filter(s => s === 'JupyterLab extension jupyterlab_sandbox_theme is activated!')
).toHaveLength(1);
});

9806
yarn.lock Normal file

File diff suppressed because it is too large Load Diff