File tree 8 files changed +121
-0
lines changed
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:
21
21
| ` combobox ` | [ Combobox element] ( https://www.w3.org/WAI/ARIA/apg/patterns/combobox/ ) | [ Stories] ( ?path=/story/components-combobox--documentation ) |
22
22
| ` data-grid ` | [ Grid pattern] ( https://www.w3.org/WAI/ARIA/apg/patterns/grid/ ) | [ Stories] ( ?path=/story/components-data-grid--documentation ) |
23
23
| ` 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 ) |
24
25
| ` divider ` | [ Horizontal or vertical rule] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr ) | [ Stories] ( ?path=/story/components-divider--documentation ) |
25
26
| ` listbox ` | [ Listbox] ( https://www.w3.org/WAI/ARIA/apg/patterns/listbox/ ) | [ Stories] ( ?path=/story/components-listbox--documentation ) |
26
27
| ` 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';
16
16
import { jpCombobox } from './combobox/index' ;
17
17
import { jpDataGrid , jpDataGridCell , jpDataGridRow } from './data-grid/index' ;
18
18
import { jpDateField } from './date-field/index' ;
19
+ import { jpDialog } from './dialog/index' ;
19
20
import { jpDivider } from './divider/index' ;
20
21
import { jpListbox } from './listbox/index' ;
21
22
import { jpMenu } from './menu/index' ;
@@ -58,6 +59,7 @@ import type { Checkbox } from './checkbox/index';
58
59
import type { Combobox } from './combobox/index' ;
59
60
import type { DataGrid , DataGridCell , DataGridRow } from './data-grid/index' ;
60
61
import type { DateField } from './date-field/index' ;
62
+ import type { Dialog } from './dialog/index' ;
61
63
import type { Divider } from './divider/index' ;
62
64
import type { ListboxElement } from './listbox/index' ;
63
65
import type { Menu } from './menu/index' ;
@@ -101,6 +103,7 @@ export {
101
103
jpDataGridCell ,
102
104
jpDataGridRow ,
103
105
jpDateField ,
106
+ jpDialog ,
104
107
jpDivider ,
105
108
jpListbox ,
106
109
jpMenu ,
@@ -151,6 +154,7 @@ export const allComponents = {
151
154
jpDataGridCell,
152
155
jpDataGridRow,
153
156
jpDateField,
157
+ jpDialog,
154
158
jpDivider,
155
159
jpListbox,
156
160
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';
23
23
export * from './combobox/index' ;
24
24
export * from './date-field/index' ;
25
25
export * from './data-grid/index' ;
26
+ export * from './dialog/index' ;
26
27
export * from './divider/index' ;
27
28
export * from './listbox/index' ;
28
29
export * 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';
15
15
export * from './combobox' ;
16
16
export * from './data-grid' ;
17
17
export * from './date-field' ;
18
+ export * from './dialog' ;
18
19
export * from './divider' ;
19
20
export * from './listbox' ;
20
21
export * from './menu' ;
You can’t perform that action at this time.
0 commit comments