Skip to content

Commit f0826f6

Browse files
authored
More components (#6)
* Use outline only for button focus * Improve styling for text field * Add Avatar, Breadcrumb and Breadcrumb Item * Add stories and test for avatar * Add progress * Add search component * Add tabs * Increase timeout for visual tests * Update gallery * Fix event for react components * Add new snapshots * Fix some stories * Correct breadcrumb and progress snapshots * Fix more snapshots * Fix some styling * Use inset shadow on select focus Similarly to text field * Update autofocus snapshots following style change * Improve test robustness * Update README * [skip ci] storybook server quiet on CI
1 parent 01c98ca commit f0826f6

File tree

127 files changed

+2196
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2196
-171
lines changed

.github/workflows/visual-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
visual-test:
1111
runs-on: ubuntu-latest
12-
timeout-minutes: 20
12+
timeout-minutes: 40
1313
steps:
1414
- name: Checkout 🛎️
1515
uses: actions/checkout@v2

README.md

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,91 @@
11
# UI Toolkit for Jupyter
22

3-
**WIP this is very early work in progress and nothing is yet working.** But don't hesitate to open issues and PRs if you want to help.
3+
**WIP this is early work in progress.** But don't hesitate to open issues and PRs if you want to
4+
help.
45

5-
![Extension status](https://img.shields.io/badge/status-draft-critical 'Not yet working')
6+
[![Extension status](https://img.shields.io/badge/status-draft-critical 'Not yet working')](https://jupyterlab-contrib.github.io/)
67
[![NPM Version](https://img.shields.io/npm/v/@jupyter-notebook/web-components?color=blue)](https://www.npmjs.com/package/@jupyter-notebook/web-components)
78
[![Toolkit CI Status](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/actions/workflows/ci.yml)
8-
![Deploy Docs Status](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/actions/workflows/docs-cd.yml/badge.svg)
9+
[![Deploy Docs Status](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/actions/workflows/docs-cd.yml/badge.svg)](https://jupyterlab-contrib.github.io/jupyter-ui-toolkit/)
910
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterlab-contrib/jupyter-ui-toolkit/main)
1011

11-
![Toolkit for Jupyter Artwork](./packages/components/docs/assets/toolkit-artwork.png)
12+
![Toolkit for Jupyter Artwork](https://raw.githubusercontent.com/jupyterlab-contrib/jupyter-ui-toolkit/main/packages/components/docs/assets/toolkit-artwork.png)
1213

1314
## Introduction
1415

15-
The UI Toolkit is a component library for building web interfaces in Jupyter ecosystem (JupyterHub, Jupyter Widgets, JupyterLab,...).
16+
The UI Toolkit is a component library for building web interfaces in Jupyter ecosystem (JupyterHub,
17+
Jupyter Widgets, JupyterLab,...).
1618

1719
Features of the library include:
1820

19-
- **Implements the Jupyter design language:** All components follow the design language of Jupyter – enabling developers to create extensions that have a consistent look and feel with the rest of the ecosystem.
20-
- **Automatic support for color themes:** All components are designed with theming in mind and will automatically display the current application theme.
21-
- **Use any tech stack:** The library ships as a set of web components, meaning developers can use the toolkit no matter what tech stack (React, Vue, Svelte, etc.) their extension is built with.
22-
- **Accessible out of the box:** All components ship with web standard compliant ARIA labels and keyboard navigation.
23-
24-
Note this project started as a fork of the [WebView toolkit for Visual Studio Code](https://github.com/microsoft/vscode-webview-ui-toolkit) (licensed under MIT) on which Jupyter design specification. The fundamental technology used is [Fast Design](https://www.fast.design/).
21+
- **Implements the Jupyter design language:** All components follow the design language of Jupyter
22+
– enabling developers to create extensions that have a consistent look and feel with the rest of
23+
the ecosystem.
24+
- **Automatic support for color themes:** All components are designed with theming in mind and will
25+
automatically display the current application theme.
26+
- **Use any tech stack:** The library ships as a set of web components, meaning developers can use
27+
the toolkit no matter what tech stack (React, Vue, Svelte, etc.) their extension is built with.
28+
- **Accessible out of the box:** All components ship with web standard compliant ARIA labels and
29+
keyboard navigation.
30+
31+
This repository contains three packages:
32+
33+
- [`@jupyter-notebook/web-components`](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/tree/main/packages/components/):
34+
The main package defining the web components.
35+
- [`@jupyter-notebook/react-components`](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/tree/main/packages/react-components):
36+
Wrapped the web components to use them with [React](https://reactjs.org).
37+
- [`jupyter-ui-demo`](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/tree/main/packages/lab-example):
38+
Unpublished JupyterLab extension to demonstrate the integration of the toolkit.
39+
40+
Those features are brought through the [Fast Design](https://www.fast.design/). And it is inspired
41+
by the [WebView toolkit for Visual Studio Code](https://github.com/microsoft/vscode-webview-ui-toolkit)
42+
as example for creating a customized toolkit.
2543

2644
## Release
2745

28-
The UI Toolkit is currently in a proof of concept. Track progress towards 1.0 [here](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/issues?q=is%3Aopen+is%3Aissue+milestone%3Av1.0). Styles and API
29-
are not guarantee between minor versions prior to v1.0.0.
46+
The UI Toolkit is currently in a proof of concept. Track progress towards 1.0 [here](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/issues?q=is%3Aopen+is%3Aissue+milestone%3Av1.0).
47+
Styles and API are not guarantee between minor versions prior to v1.0.0.
3048

3149
## Getting started
3250

33-
<!--
34-
Follow the [Getting Started Guide](./docs/getting-started.md).
51+
You will need to install `yarn` (for example with `npm install --global yarn`).
52+
53+
To build the components packages, execute:
54+
55+
```sh
56+
yarn install
57+
yarn build
58+
```
3559

36-
If you already have a webview-based extension, you can install the toolkit with the following command:
60+
Then to interactively test or develop web components:
3761

62+
```sh
63+
cd packages/components
64+
yarn start
3865
```
39-
npm install --save @vscode/webview-ui-toolkit
66+
67+
### JupyterLab demo extension
68+
69+
To test locally the JupyterLab demo extension, using `conda` package manager:
70+
71+
```sh
72+
conda create -n jupyter-toolkit -c conda-forge -y nodejs yarn jupyterlab=3
73+
conda activate jupyter-toolkit
74+
yarn install
75+
yarn build
76+
pip install -e .
77+
jupyter labextension develop --overwrite .
4078
```
41-
-->
4279

4380
## Documentation
4481

4582
Further documentation can be found in the following places:
4683

47-
- [Component Docs](./packages/components/docs/components.md)
84+
- [Component Docs](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/tree/main/packages/components/docs/components.md)
4885
- [Storybook (Interactive Component Sandbox)](https://jupyterlab-contrib.github.io/jupyter-ui-toolkit/)
49-
- [Toolkit Extension Samples](./packages/lab-example)
86+
- [Toolkit Extension Samples](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/tree/main/packages/lab-example):
87+
[Try online](https://mybinder.org/v2/gh/jupyterlab-contrib/jupyter-ui-toolkit/main)
5088

5189
## Contributing
5290

53-
See the [contributing](./CONTRIBUTING.md) documentation.
91+
See the [contributing](https://github.com/jupyterlab-contrib/jupyter-ui-toolkit/tree/main/CONTRIBUTING.md) documentation.

packages/components/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"sideEffects": false,
1818
"scripts": {
1919
"start": "start-storybook -p 6006",
20-
"start:ci": "start-storybook -p 6006 --ci",
20+
"start:ci": "start-storybook -p 6006 --ci --quiet",
2121
"build": "rollup -c && tsc -p ./tsconfig.json",
2222
"build:docs": "build-storybook",
2323
"deploy:docs": "yarn run build:docs && gh-pages -d storybook-static",
2424
"doc": "api-extractor run --local",
25-
"prettier:check": "prettier --config ./.prettierrc --check \"**/*.{ts,js,md}\"",
26-
"prettier": "prettier --config ./.prettierrc --write \"**/*.{ts,js,md}\"",
25+
"prettier:check": "prettier --config ../../.prettierrc --check \"src/**/*.ts\"",
26+
"prettier": "prettier --config ../../.prettierrc --write \"src/**/*.ts\"",
2727
"eslint:check": "eslint . --ext .ts",
2828
"eslint": "eslint . --ext .ts --fix",
2929
"prepublishOnly": "yarn run build",

packages/components/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const config: PlaywrightTestConfig = {
1616
trace: 'on-first-retry',
1717
launchOptions: {
1818
// Force slow motion to let storybook the time to update styles
19-
slowMo: 30
19+
slowMo: 40
2020
}
2121
},
2222
projects: [
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import { setTheme } from '../utilities/storybook';
5+
6+
export default {
7+
title: 'Avatar',
8+
argTypes: {
9+
shape: { control: 'select', options: ['circle', 'square', 'default'] },
10+
fill: {
11+
control: 'select',
12+
options: ['accent-primary', 'accent-secondary']
13+
},
14+
color: { control: 'select', options: ['foo', 'bar'] },
15+
image: { control: 'boolean' }
16+
},
17+
parameters: {
18+
actions: {
19+
disabled: true
20+
}
21+
},
22+
decorators: [
23+
story => `<style>
24+
jp-avatar {
25+
--avatar-fill-accent-primary: #cf4073;
26+
--avatar-fill-accent-secondary: #0078d4;
27+
--avatar-color-foo: hsl(0, 0%, 100%);
28+
--avatar-color-bar: grey;
29+
--avatar-text-ratio: 3;
30+
}
31+
</style>
32+
${story()}`
33+
]
34+
};
35+
36+
const Template = (
37+
args,
38+
{ globals: { backgrounds, accent }, parameters }
39+
): string => {
40+
setTheme(accent, parameters.backgrounds, backgrounds);
41+
42+
return `<jp-avatar
43+
alt="John's avatar"
44+
link="#"
45+
shape="${args.shape}"
46+
fill="${args.fill}"
47+
color="${args.color}"
48+
>
49+
${
50+
args.image
51+
? '<img class="image" slot="media" src="https://via.placeholder.com/32" />'
52+
: 'JS'
53+
}
54+
</jp-avatar>`;
55+
};
56+
57+
export const Default = Template.bind({});
58+
Default.args = {
59+
shape: 'circle',
60+
fill: 'accent-primary',
61+
color: 'foo',
62+
image: false
63+
};
64+
65+
export const Square = Template.bind({});
66+
Square.args = {
67+
...Default.args,
68+
shape: 'square'
69+
};
70+
71+
export const WithImage = Template.bind({});
72+
WithImage.args = {
73+
...Default.args,
74+
image: true
75+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import { test, expect } from '@playwright/test';
5+
6+
test.describe('Avatar', () => {
7+
test('Default', async ({ page }) => {
8+
await page.goto('/iframe.html?id=avatar--default');
9+
10+
expect(await page.locator('jp-avatar').screenshot()).toMatchSnapshot(
11+
'avatar-default.png'
12+
);
13+
});
14+
15+
test('Square', async ({ page }) => {
16+
await page.goto('/iframe.html?id=avatar--square');
17+
18+
expect(await page.locator('jp-avatar').screenshot()).toMatchSnapshot(
19+
'avatar-square.png'
20+
);
21+
});
22+
23+
test('With Image', async ({ page }) => {
24+
await page.goto('/iframe.html?id=avatar--with-image');
25+
26+
expect(await page.locator('jp-avatar').screenshot()).toMatchSnapshot(
27+
'avatar-with-image.png'
28+
);
29+
});
30+
});
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Copyright (c) Microsoft Corporation.
3+
// Distributed under the terms of the Modified BSD License.
4+
5+
import {
6+
accentFillRest,
7+
Avatar,
8+
avatarStyles as styles,
9+
foregroundOnAccentRest,
10+
imgTemplate
11+
} from '@microsoft/fast-components';
12+
import { css, ElementStyles } from '@microsoft/fast-element';
13+
import {
14+
Avatar as FoundationAvatar,
15+
AvatarOptions,
16+
avatarTemplate as template,
17+
FoundationElementTemplate
18+
} from '@microsoft/fast-foundation';
19+
20+
export { Avatar } from '@microsoft/fast-components';
21+
22+
export const avatarStyles: FoundationElementTemplate<
23+
ElementStyles,
24+
AvatarOptions
25+
> = (context, definition: AvatarOptions) => css`
26+
${styles(context, definition)}
27+
28+
.backplate {
29+
min-width: var(--avatar-size, var(--avatar-size-default));
30+
background-color: ${accentFillRest};
31+
}
32+
33+
.link {
34+
color: ${foregroundOnAccentRest};
35+
}
36+
`;
37+
38+
/**
39+
* A function that returns a {@link @microsoft/fast-foundation#Avatar} registration for configuring the component with a DesignSystem.
40+
* {@link @microsoft/fast-foundation#avatarTemplate}
41+
*
42+
*
43+
* @public
44+
* @remarks
45+
* Generates HTML Element: `<jp-avatar>`
46+
*/
47+
export const jpAvatar = Avatar.compose<AvatarOptions>({
48+
baseName: 'avatar',
49+
baseClass: FoundationAvatar,
50+
template,
51+
styles: avatarStyles,
52+
media: imgTemplate,
53+
shadowOptions: {
54+
delegatesFocus: true
55+
}
56+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
import { getFaIcon, setTheme } from '../utilities/storybook';
5+
6+
export default {
7+
title: 'Breadcrumb Item',
8+
argTypes: {
9+
href: { control: 'boolean' },
10+
startIcon: { control: 'boolean' },
11+
endIcon: { control: 'boolean' }
12+
}
13+
};
14+
15+
const Template = (
16+
args,
17+
{ globals: { backgrounds, accent }, parameters }
18+
): string => {
19+
setTheme(accent, parameters.backgrounds, backgrounds);
20+
21+
return `<jp-breadcrumb-item
22+
${args.href ? 'href="#"' : ''}
23+
>
24+
${args.startIcon ? getFaIcon('folder', 'start') : ''}
25+
Breadcrumb item
26+
${args.endIcon ? getFaIcon('robot', 'end') : ''}
27+
</jp-breadcrumb-item>`;
28+
};
29+
30+
export const Default = Template.bind({});
31+
Default.args = {
32+
href: true,
33+
startIcon: false,
34+
endIcon: false
35+
};
36+
37+
export const WithoutHref = Template.bind({});
38+
WithoutHref.args = {
39+
...Default.args,
40+
href: false
41+
};
42+
43+
export const WithStartIcon = Template.bind({});
44+
WithStartIcon.args = {
45+
...Default.args,
46+
startIcon: true
47+
};
48+
49+
export const WithEndIcon = Template.bind({});
50+
WithEndIcon.args = {
51+
...Default.args,
52+
endIcon: true
53+
};

0 commit comments

Comments
 (0)