File tree Expand file tree Collapse file tree 8 files changed +121
-0
lines changed Expand file tree Collapse file tree 8 files changed +121
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ Here is the list of components part of the Jupyter UI toolkit:
2121| ` combobox ` | [ Combobox element] ( https://www.w3.org/WAI/ARIA/apg/patterns/combobox/ ) | [ Stories] ( ?path=/story/components-combobox--documentation ) |
2222| ` data-grid ` | [ Grid pattern] ( https://www.w3.org/WAI/ARIA/apg/patterns/grid/ ) | [ Stories] ( ?path=/story/components-data-grid--documentation ) |
2323| ` date-field ` | [ Date input element] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date ) | [ Stories] ( ?path=/story/components-date-field--documentation ) |
24+ | ` dialog ` | [ Dialog (Modal) pattern] ( https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/ ) | [ Stories] ( ?path=/story/components-dialog--documentation ) |
2425| ` divider ` | [ Horizontal or vertical rule] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr ) | [ Stories] ( ?path=/story/components-divider--documentation ) |
2526| ` listbox ` | [ Listbox] ( https://www.w3.org/WAI/ARIA/apg/patterns/listbox/ ) | [ Stories] ( ?path=/story/components-listbox--documentation ) |
2627| ` menu ` | [ Menu] ( https://www.w3.org/WAI/ARIA/apg/patterns/menubar/ ) | [ Stories] ( ?path=/story/components-menu--documentation ) |
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { jpCheckbox } from './checkbox/index';
1616import { jpCombobox } from './combobox/index' ;
1717import { jpDataGrid , jpDataGridCell , jpDataGridRow } from './data-grid/index' ;
1818import { jpDateField } from './date-field/index' ;
19+ import { jpDialog } from './dialog/index' ;
1920import { jpDivider } from './divider/index' ;
2021import { jpListbox } from './listbox/index' ;
2122import { jpMenu } from './menu/index' ;
@@ -58,6 +59,7 @@ import type { Checkbox } from './checkbox/index';
5859import type { Combobox } from './combobox/index' ;
5960import type { DataGrid , DataGridCell , DataGridRow } from './data-grid/index' ;
6061import type { DateField } from './date-field/index' ;
62+ import type { Dialog } from './dialog/index' ;
6163import type { Divider } from './divider/index' ;
6264import type { ListboxElement } from './listbox/index' ;
6365import type { Menu } from './menu/index' ;
@@ -101,6 +103,7 @@ export {
101103 jpDataGridCell ,
102104 jpDataGridRow ,
103105 jpDateField ,
106+ jpDialog ,
104107 jpDivider ,
105108 jpListbox ,
106109 jpMenu ,
@@ -151,6 +154,7 @@ export const allComponents = {
151154 jpDataGridCell,
152155 jpDataGridRow,
153156 jpDateField,
157+ jpDialog,
154158 jpDivider,
155159 jpListbox,
156160 jpMenu,
Original file line number Diff line number Diff line change 1+ // Copyright (c) Jupyter Development Team.
2+ // Distributed under the terms of the Modified BSD License.
3+
4+ import type { StoryFn , Meta , StoryObj } from '@storybook/html' ;
5+ import { setTheme } from '../utilities/storybook' ;
6+
7+ export default {
8+ title : 'Components/Dialog' ,
9+ argTypes : {
10+ trapFocus : { control : 'boolean' }
11+ } ,
12+ parameters : {
13+ actions : {
14+ disabled : true
15+ }
16+ } ,
17+ decorators : [
18+ story => `
19+ <style>
20+ #container {
21+ width: 300px;
22+ height: 300px;
23+ }
24+
25+ jp-dialog > div {
26+ padding: 10px;
27+ color: var(--neutral-foreground-rest);
28+ }
29+ </style>
30+ <div id="container">
31+ ${ story ( ) }
32+ </div>`
33+ ]
34+ } as Meta ;
35+
36+ const Template : StoryFn = ( args , context ) : string => {
37+ const {
38+ globals : { backgrounds, accent } ,
39+ parameters
40+ } = context ;
41+ setTheme ( accent , parameters . backgrounds , backgrounds ) ;
42+
43+ return `<jp-dialog trap-focus="${ args . trapFocus } ">
44+ <div>
45+ <h2>Dialog heading</h2>
46+ <jp-button>Cancel</jp-button><jp-button appearance="accent">Ok</jp-button>
47+ </div>
48+ </jp-dialog>` ;
49+ } ;
50+
51+ export const Default : StoryObj = { render : Template . bind ( { } ) } ;
52+ Default . args = {
53+ trapFocus : true
54+ } ;
Original file line number Diff line number Diff line change 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 . skip ( 'Default' , async ( { page } ) => {
7+ await page . goto ( '/iframe.html?id=components-dialog--default' ) ;
8+
9+ expect ( await page . locator ( 'jp-dialog' ) . screenshot ( ) ) . toMatchSnapshot (
10+ 'dialog-default.png'
11+ ) ;
12+ } ) ;
Original file line number Diff line number Diff line change 1+ // Copyright (c) Jupyter Development Team.
2+ // Distributed under the terms of the Modified BSD License.
3+
4+ import { Dialog , dialogTemplate as template } from '@microsoft/fast-foundation' ;
5+ import { dialogStyles as styles } from '@microsoft/fast-components' ;
6+
7+ /**
8+ * A function that returns a {@link @microsoft/fast-foundation#Dialog } registration for configuring the component with a DesignSystem.
9+ * Implements {@link @microsoft/fast-foundation#dialogTemplate }
10+ *
11+ *
12+ * @public
13+ * @remarks
14+ * HTML Element: `<jp-dialog>`
15+ *
16+ */
17+ export const jpDialog = Dialog . compose ( {
18+ baseName : 'dialog' ,
19+ template,
20+ styles
21+ } ) ;
22+
23+ /**
24+ * Base class for Dialog
25+ * @public
26+ */
27+ export { Dialog } ;
28+
29+ export { styles as dialogStyles } ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export * from './checkbox/index';
2323export * from './combobox/index' ;
2424export * from './date-field/index' ;
2525export * from './data-grid/index' ;
26+ export * from './dialog/index' ;
2627export * from './divider/index' ;
2728export * from './listbox/index' ;
2829export * from './menu/index' ;
Original file line number Diff line number Diff line change 1+ // Copyright (c) Jupyter Development Team.
2+ // Distributed under the terms of the Modified BSD License.
3+
4+ import { provideJupyterDesignSystem , jpDialog } from '@jupyter/web-components' ;
5+ import { provideReactWrapper } from '@microsoft/fast-react-wrapper' ;
6+ import React from 'react' ;
7+
8+ const { wrap } = provideReactWrapper ( React , provideJupyterDesignSystem ( ) ) ;
9+
10+ export const Dialog : React . DetailedHTMLFactory <
11+ React . HTMLAttributes < HTMLElement > & {
12+ hidden ?: boolean ;
13+ modal ?: boolean ;
14+ 'trap-focus' ?: boolean ;
15+ } ,
16+ HTMLElement
17+ > = wrap ( jpDialog ( ) ) as any ;
18+ // @ts -expect-error unknown property
19+ Dialog . displayName = 'Jupyter.Dialog' ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export * from './checkbox';
1515export * from './combobox' ;
1616export * from './data-grid' ;
1717export * from './date-field' ;
18+ export * from './dialog' ;
1819export * from './divider' ;
1920export * from './listbox' ;
2021export * from './menu' ;
You can’t perform that action at this time.
0 commit comments