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

Web Component Dialog #28569

Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
7f9af9e
radio init
brianchristopherbrady Mar 3, 2023
70c55e0
styles radio
brianchristopherbrady Mar 3, 2023
f3cb7f4
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Mar 3, 2023
a72d10f
reverts branch
brianchristopherbrady Mar 3, 2023
2941fa7
Merge branch 'web-components-v3' of https://github.com/brianchristoph…
brianchristopherbrady Mar 3, 2023
9b350fc
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Mar 20, 2023
2cf59ce
input spec init
brianchristopherbrady Mar 20, 2023
79b6bff
cleans up spec
brianchristopherbrady Mar 20, 2023
5558b93
formatting
brianchristopherbrady Mar 20, 2023
3c045c3
updates component name to text input
brianchristopherbrady Mar 20, 2023
2370967
updates component name in spec
brianchristopherbrady Mar 20, 2023
9c4eb6b
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Mar 27, 2023
056b82e
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Apr 24, 2023
196ed30
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady May 9, 2023
2a9ae23
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady May 22, 2023
677a59c
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Jun 6, 2023
17819f9
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Jun 28, 2023
c6d99b9
dialog init
brianchristopherbrady Jul 18, 2023
8e367ef
dialog: updates stories, styles, and docs
brianchristopherbrady Jul 18, 2023
7e6a240
dialog: updates styles
brianchristopherbrady Jul 18, 2023
bd041b9
dialog: removes dead code, cleans up
brianchristopherbrady Jul 18, 2023
133f49b
dialog: updates styles
brianchristopherbrady Jul 19, 2023
7e3aeae
updates docs
brianchristopherbrady Jul 19, 2023
91dd5a0
deletes dead code
brianchristopherbrady Aug 3, 2023
d04442e
dialog: addresses PR feedback
brianchristopherbrady Aug 3, 2023
514f6b6
reverts dead file
brianchristopherbrady Aug 3, 2023
ac4a4c8
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 9, 2023
6bdf6b7
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 14, 2023
6a22421
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 14, 2023
e5a9dbf
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 15, 2023
9e40250
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 18, 2023
807ba7c
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 21, 2023
31c68ca
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 21, 2023
194d786
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 21, 2023
559953f
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 21, 2023
8359b57
dialog: updates styles per feedback
brianchristopherbrady Aug 21, 2023
abd7b44
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 23, 2023
e1a41f5
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 24, 2023
45707f0
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Aug 28, 2023
3d57319
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Sep 18, 2023
321a8f1
Merge branch 'web-components-v3' into user/brianbrady/web-component-d…
brianchristopherbrady Sep 19, 2023
b7d6c59
drawer: updates template, styles
brianchristopherbrady Sep 19, 2023
344eca2
dialog: removes attr changed callback
brianchristopherbrady Sep 19, 2023
99fd3e3
dialog: updates slot names for react parity, updates docs
brianchristopherbrady Sep 19, 2023
c024a16
Merge branch 'web-components-v3' into user/brianbrady/web-component-d…
brianchristopherbrady Oct 2, 2023
51e5374
yarn change
brianchristopherbrady Oct 2, 2023
22c1726
Merge branch 'user/brianbrady/web-component-dialog' of https://github…
brianchristopherbrady Oct 2, 2023
113a05e
dialog: addresses feedback
brianchristopherbrady Oct 3, 2023
ccfde13
dialog: updates README
brianchristopherbrady Oct 3, 2023
f5659df
dialog: fixes responsive styles
brianchristopherbrady Oct 3, 2023
01049a8
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Oct 10, 2023
a41f491
dialog: removes dead styles
brianchristopherbrady Oct 10, 2023
2526272
dialog: updates readme docs
brianchristopherbrady Oct 10, 2023
7a8246c
dialog: reworks dialog to use navtive html dialog element
brianchristopherbrady Oct 13, 2023
7c69db7
dialog: fixes jsdoc
brianchristopherbrady Oct 13, 2023
1dcfd48
dialog: updates slot names for closer parity with fv9, updates storie…
brianchristopherbrady Oct 23, 2023
bf6bf37
dialog: updates README
brianchristopherbrady Oct 23, 2023
0e78c12
dialog: updates template class names
brianchristopherbrady Oct 23, 2023
71b0a23
dialog: updates backdrop to use fluent token
brianchristopherbrady Oct 23, 2023
4ae3e62
dialog: adds two column layout story
brianchristopherbrady Oct 23, 2023
6f01f6c
dialog: adds additional stories
brianchristopherbrady Oct 23, 2023
573d511
dialog: adds exports to index and package json
brianchristopherbrady Oct 23, 2023
d06797a
Merge branch 'web-components-v3' into user/brianbrady/web-component-d…
brianchristopherbrady Oct 23, 2023
3f096ad
Merge branch 'web-components-v3' into user/brianbrady/web-component-d…
brianchristopherbrady Oct 24, 2023
e238714
Merge branch 'user/brianbrady/web-component-dialog' of https://github…
brianchristopherbrady Oct 24, 2023
93a3263
dialog: fixes style token imports
brianchristopherbrady Oct 24, 2023
6b1d7e4
dialog: cleans up open state
brianchristopherbrady Oct 24, 2023
e8823ba
dialog: updates template slot names
brianchristopherbrady Oct 24, 2023
614cfdd
dialog: updates property name
brianchristopherbrady Oct 24, 2023
7ded032
dialog: removes change-focus
brianchristopherbrady Oct 24, 2023
975da6e
dialog: syncs open attr
brianchristopherbrady Oct 24, 2023
bd5b13c
dialog: sync open attribute
brianchristopherbrady Oct 24, 2023
0a7ddc4
dialog: updates storybook docs
brianchristopherbrady Oct 24, 2023
25b97ae
dialog: updates readme docs
brianchristopherbrady Oct 24, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link
Collaborator

@fabricteam fabricteam Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵 fluentui-web-components-v3 Open the Visual Regressions report to inspect the affected screenshots

Switch 2 screenshots
Image Name Diff(in Pixels) Image Type
Switch.Checked - RTL.hover.chromium.png 104 Changed
Switch.Checked - RTL.normal.chromium.png 97 Changed

"type": "prerelease",
"comment": "feat(dialog): add dialog web component",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
5 changes: 5 additions & 0 deletions packages/web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
"types": "./dist/dts/counter-badge/define.d.ts",
"default": "./dist/esm/counter-badge/define.js"
},
"./dialog.js": {
"types": "./dist/dts/dialog/define.d.ts",
"default": "./dist/esm/dialog/define.js"
},
"./divider.js": {
"types": "./dist/dts/divider/define.d.ts",
"default": "./dist/esm/divider/define.js"
Expand Down Expand Up @@ -150,6 +154,7 @@
"./dist/esm/checkbox/define.js",
"./dist/esm/compound-button/define.js",
"./dist/esm/counter-badge/define.js",
"./dist/esm/dialog/define.js",
halerankin marked this conversation as resolved.
Show resolved Hide resolved
"./dist/esm/divider/define.js",
"./dist/esm/image/define.js",
"./dist/esm/label/define.js",
Expand Down
101 changes: 101 additions & 0 deletions packages/web-components/src/dialog/README.md
brianchristopherbrady marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Dialog

> Dialog is a window overlaid on either the primary window or another dialog window. Windows under a modal dialog are inert. That is, users cannot interact with content outside an active dialog window. Inert content outside an active dialog is typically visually obscured or dimmed so it is difficult to discern, and in some implementations, attempts to interact with the inert content cause the dialog to close.

## **Design Spec**

[Link to Dialog in Figma](https://www.figma.com/file/jtF47yOXDxkI00ZkydE999/Dialog?type=design&node-id=2605%3A15263&mode=dev)

## **Engineering Spec**

Fluent WC3 Dialog has feature parity with the Fluent UI React 9 Dialog implementation but not direct parity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement is a bit ambiguous to me, what does it mean but not direct parity? I think we should actually say how it differs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chris and I had a discussion on this blurb and this is what we landed on. Most of the components with README's have this at the beginning.

The differences between react and web component implementation is detailed in the "Preparation" section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it should say see Preparation section for a fill description of differences.


## Superclass: [FASTElement](https://www.fast.design/docs/fast-element/defining-elements)

## Class: `Dialog`

<br />

### **Component Name**

`<fluent-dialog></fluent-dialog>`

### **Basic Implemenation**

```html
<fluent-dialog open>
<!-- Header -->
<fluent-text slot="title">Dialog</fluent-text>
<fluent-button slot="title-action"><svg></svg></fluent-button>
<!-- Default Content -->
<fluent-text>Content</fluent-text>

<!-- Footer/Actions -->
<fluent-button slot="footer-action">Do Something</fluent-button>
</fluent-dialog>
```

### **Attributes**

| Name | Privacy | Type | Default | Description |
| ------------------ | ------- | ----------------- | ----------------------- | --------------------------------------------------------- |
| `modal-type` | public | `DialogModalType` | `DialogModalType.modal` | Indicates that the type of modal to render. |
| `open` | public | `boolean` | `false` | Controls the open state of the dialog |
| `no-title-action` | public | `boolean` | `false` | Used to set whether the default title action is rendered. |
| `change-focus` | public | `string` | `undefined` | Used to set id of desired focus target. |
| `aria-labelledby` | public | `string` | `undefined` | optional based on implementation\*\* |
| `aria-describedby` | public | `string` | `undefined` | optional based on implementation\*\* |
| `aria-label ` | public | `string` | `undefined` | optional based on implementation\*\* |

\*\* See the [W3C Specification](https://w3c.github.io/aria-practices/#dialog_roles_states_props) for requirements and details.

<br />

### **Methods**

| Name | Privacy | Description | Parameters | Return | Inherited From |
| ------ | ------- | ------------------------------ | ---------- | ------ | -------------- |
| `hide` | public | The method to hide the dialog. | | void | FASTDialog |
| `show` | public | The method to show the dialog. | | void | FASTDialog |

<br />

### **Slots**

| Name | Description |
| --------------- | ---------------------------------------------------------- |
| `title` | slot for title content |
| `title-action` | slot for close button |
| | default slot for content rendered between title and footer |
| `footer-action` | slot for actions content |
| `start` | slot for content at the start of the dialog |
| `end` | slot for content at the end of the dialog |

### **Events**

| Name | Description | Details |
| -------------- | --------------------------------------------------------------- | -------------------------------------------------- |
| `onOpenChange` | Event fired when the component transitions from its open state. | `{ open: this.dialog.open, dismissed: dismissed }` |

## **Preparation**

### **Fluent Web Component v3 v.s Fluent React 9**

**Component, Element, and Slot Mapping**

| Fluent UI React 9 | Fluent Web Components 3 | Description of difference |
| ------------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<Dialog>` | `<fluent-dialog>` | tag name |
| `<DialogTrigger>` | methods: `hide() show()` | In the React version of our components, a "DialogTrigger" component is utilized as part of a composite component of Dialog. The DialogTrigger component provides functionality for toggling the visibility of the Dialog component. <br /> In the Web Component version does not include a dialog trigger. Instead, it expects the user to directly access methods on the Dialog class or utilize CSS to control the visibility of the dialog component. |
| `<DialogSurface>` | `dialog::backdrop` | In the React version of our components, the DialogSurface component is used as part of the composite Dialog component to represent the dimmed background of the dialog. <br /> The Web Component version utilizes the HTML dialog ::backdrop pseudoelement. |
| `<DialogTitle>` | `slot: title` | In the React version of our components, the <DialogTitle> component is used to implement the title of the dialog. <br /> In the Web Component version, the title is provided through the title slot. |
| `<DialogTitle action="">` | `slot: title-action` | In the React version of our components, the <DialogTitle> component the DialogTitles action prop. <br /> In the Web Component version, the title action is provided through the Dialogs title-action slot |
| `<DialogActions>` | `slot: footer-action` | In the React version of our components, the <DialogActions> component is used to implement the actions within the dialog. <br /> In the Web Component version, actions are passsed through the `actions` slot |

<br />

**Attribute and prop Mapping**

| Fluent UI React 9 | Fluent Web Components 3 | Description of difference |
| ------------------------------------ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| use effect to customize focus target | `change-focus` | Changing the default focused element can be done in an effect. In FUIWC3, the id of the desired target to focus can be passed through the change-focus slot |
4 changes: 4 additions & 0 deletions packages/web-components/src/dialog/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { definition } from './dialog.definition.js';

definition.define(FluentDesignSystem.registry);
17 changes: 17 additions & 0 deletions packages/web-components/src/dialog/dialog.definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FluentDesignSystem } from '../fluent-design-system.js';
import { Dialog } from './dialog.js';
import { template } from './dialog.template.js';
import { styles } from './dialog.styles.js';

/**
* The Fluent Dialog Element
*
* @public
* @remarks
* HTML Element: \<fluent-dialog\>
*/
export const definition = Dialog.compose({
brianchristopherbrady marked this conversation as resolved.
Show resolved Hide resolved
name: `${FluentDesignSystem.prefix}-dialog`,
template,
styles,
});
13 changes: 13 additions & 0 deletions packages/web-components/src/dialog/dialog.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ValuesOf } from '@microsoft/fast-foundation/utilities.js';

/**
* Dialog modal type
* @public
*/
export const DialogModalType = {
modal: 'modal',
nonModal: 'non-modal',
alert: 'alert',
} as const;
Comment on lines +7 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was this API decided upon?


export type DialogModalType = ValuesOf<typeof DialogModalType>;
Loading