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

Improve CDN example #73

Draft
wants to merge 1 commit 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
29 changes: 15 additions & 14 deletions examples/cdn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,31 @@
body {
background-color: var(--neutral-layer-1);
}

#theme-mode>span {
display: inline-block;
width: 24px;
height: 24px;
background-image: url('https://unpkg.com/@mdi/svg/svg/brightness-6.svg');
background-color: var(--neutral-foreground-rest);
mix-blend-mode: difference;
}
</style>
</head>

<body data-theme-mode="dark">
<body data-theme-mode="light">
<jp-button appearance="accent" onclick="alert('Accent button pressed')">Click me!</jp-button>
<jp-button onclick="alert('Neutral button pressed')">Click me!</jp-button>
<jp-button id="theme-mode">
<span></span>
</jp-button>
<jp-button id="theme-mode"></jp-button>

<script type="module">
// Apply JupyterLab theme
import { applyJupyterTheme } from 'https://unpkg.com/@jupyter/web-components/dist/toolkit.min.js';

// Inject icon in theme mode button
fetch('https://unpkg.com/@mdi/svg@7.2.96/svg/brightness-6.svg')
.then(
r => r.text()
)
.then(
brightness6 => {
document.querySelector('#theme-mode').insertAdjacentHTML('afterbegin', brightness6)
}
);

applyJupyterTheme();

function switchThemeMode(th) {
const mode = document.body.getAttribute('data-theme-mode');
document.body.setAttribute(
Expand All @@ -58,7 +60,6 @@
);
applyJupyterTheme();
}
switchThemeMode();

document.querySelector('#theme-mode').addEventListener('click', () => {
switchThemeMode();
Expand Down
2 changes: 1 addition & 1 deletion packages/components/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ A pre-bundled script that contains all APIs needed to use Jupyter UI Toolkit is

The above CDN location points to the latest release of `@jupyter/web-components`. It is advised that when you deploy your site or app, you import the specific version you have developed and tested with.

> A [example](https://raw.githubusercontent.com/jupyterlab-contrib/jupyter-ui-toolkit/main/examples/cdn) is available in the project repository.
> A [example](https://raw.githubusercontent.com/jupyterlab-contrib/jupyter-ui-toolkit/main/examples/cdn/index.html) is available in the project repository.

## NPM package

Expand Down
Loading