From a788d5ada5fa82bcd497c0902e90bb0746cde999 Mon Sep 17 00:00:00 2001 From: brianchristopherbrady Date: Thu, 26 Oct 2023 18:44:15 -0700 Subject: [PATCH] drawer: updates docs --- packages/web-components/src/drawer/README.md | 22 +- .../src/drawer/drawer.stories.ts | 371 ++++++++---------- 2 files changed, 169 insertions(+), 224 deletions(-) diff --git a/packages/web-components/src/drawer/README.md b/packages/web-components/src/drawer/README.md index f015370ca24120..909bf07caf2eb9 100644 --- a/packages/web-components/src/drawer/README.md +++ b/packages/web-components/src/drawer/README.md @@ -15,28 +15,28 @@ The Fluent WC3 Drawer extends `FASTElement` ### Template ```html - -
-
+
+
-
+
@@ -48,7 +48,7 @@ The Fluent WC3 Drawer extends `FASTElement`
-
+ ; ``` ### **Variables** @@ -78,7 +78,7 @@ The Fluent WC3 Drawer extends `FASTElement` | Name | Type | Description | | -------------- | ------------- | ------------------------------------------ | | `onOpenChange` | `CustomEvent` | Fires when the drawer is opened or closed. | -| `dismiss` | `CustomEvent` | Fires when the drawer is dismissed. | +| `cancel` | `CustomEvent` | Fires when the drawer is dismissed. | ### **Methods** @@ -101,7 +101,7 @@ The Fluent WC3 Drawer extends `FASTElement` | Name | Description | | -------------------------- | ------------------------------------------------------- | | `--drawer-overflow-border` | Used to set the overflow border color | -| `--drawer-size` | Used to set the overflow border color | +| `--drawer-width` | Used to set the width of the drawer | | `--drawer-separator` | Used to set the border color between drawer and content | ## **Accessiblity** diff --git a/packages/web-components/src/drawer/drawer.stories.ts b/packages/web-components/src/drawer/drawer.stories.ts index f212d419aed661..34776163c87884 100644 --- a/packages/web-components/src/drawer/drawer.stories.ts +++ b/packages/web-components/src/drawer/drawer.stories.ts @@ -2,7 +2,7 @@ import { html } from '@microsoft/fast-element'; import type { Args, Meta } from '@storybook/html'; import { renderComponent } from '../helpers.stories.js'; import { RadioGroup } from '../radio-group/radio-group.js'; -import { colorNeutralStroke2 } from '../theme/design-tokens.js'; +import { colorNeutralStroke1, colorNeutralStroke2 } from '../theme/design-tokens.js'; import type { Drawer as FluentDrawer } from './drawer.js'; import { DrawerModalType, DrawerPosition, DrawerSize, DrawerType } from './drawer.options.js'; import './define.js'; @@ -112,22 +112,15 @@ const hideDrawer = (drawerID: string) => { setTimeout(() => { const input = document.getElementById('custom-size-input') as FluentDrawer; - const drawer = document.getElementById('drawer-size-custom') as FluentDrawer; + const drawer = document.getElementById('drawer-width-custom') as FluentDrawer; input.addEventListener('input', (e: any) => { - drawer.style.setProperty('--drawer-size', `${e.target.value}px`); + drawer.style.setProperty('--drawer-width', `${e.target.value}px`); }); }, 2000); const storyTemplate = html`
-
+
` modal-type="${x => x.modalType}" type="${x => x.type}" > -
- - ${arrowLeft20Regular} - - - ${arrowClockwise20Regular} - - - ${settings20Regular} - - - hideDrawer('drawer-default-start')} - appearance="transparent" - icon-only - size="medium" - aria-label="close" - > - ${dismissed20Regular} - -

Drawer Header

-
+
The drawer gives users a quick entry point to configuration and information. It should be used when retaining context is beneficial to users. An overlay is optional depending on whether or not interacting @@ -236,12 +201,14 @@ const storyTemplate = html`
- Primary - Secondary + Close + Do Something
-
+

Drawer

@@ -255,7 +222,7 @@ const storyTemplate = html` Position - Start + Start End @@ -271,31 +238,10 @@ const storyTemplate = html` modal-type="${x => x.modalType}" type="${x => x.type}" > -
- - ${arrowLeft20Regular} - - - ${arrowClockwise20Regular} - - - ${settings20Regular} - - - hideDrawer('drawer-default-end')} - appearance="transparent" - icon-only - size="medium" - aria-label="close" - > - ${dismissed20Regular} - -

Drawer Header

-
+
The drawer gives users a quick entry point to configuration and information. It should be used when retaining context is beneficial to users. An overlay is optional depending on whether or not interacting @@ -312,8 +258,8 @@ const storyTemplate = html`
- Primary - Secondary + Close + Do Something
@@ -335,6 +281,9 @@ export default { type: { summary: 'Sets the position of drawer', }, + defaultValue: { + summary: DrawerPosition.start, + }, }, }, modalType: { @@ -385,7 +334,7 @@ export default { export const Drawer = renderComponent(storyTemplate).bind({}); export const Modal = renderComponent(html` -
+

Modal

@@ -398,7 +347,7 @@ export const Modal = renderComponent(html` > ${dismissed20Regular} -
+

When a modal dialog is open, the rest of the page is dimmed out and cannot be interacted with. The tab @@ -412,7 +361,7 @@ export const Modal = renderComponent(html`

-
+

Modal

@@ -430,11 +379,11 @@ export const Modal = renderComponent(html` `); export const Alert = renderComponent(html` -

+

Alert

-
+

When an alert dialog is open it interrupts the user's workflow to communicate an important message or ask @@ -452,7 +401,7 @@ export const Alert = renderComponent(html`

-
+

Alert

@@ -470,7 +419,7 @@ export const Alert = renderComponent(html` `); export const NonModal = renderComponent(html` -

+

Non Modal

@@ -483,7 +432,7 @@ export const NonModal = renderComponent(html` > ${dismissed20Regular} -
+

When a non-modal dialog is open, the rest of the page is not dimmed out and users can interact with the @@ -497,7 +446,7 @@ export const NonModal = renderComponent(html`

-
+

Non Modal

@@ -517,7 +466,7 @@ export const NonModal = renderComponent(html` `); export const Overlay = renderComponent(html` -

+

Overlay

@@ -530,7 +479,7 @@ export const Overlay = renderComponent(html` > ${dismissed20Regular} -
+

A Drawer rendered with an overlay contains supplementary content and are used for complex creation, edit, @@ -545,7 +494,7 @@ export const Overlay = renderComponent(html`

-
+

Overlay

@@ -563,19 +512,19 @@ export const Overlay = renderComponent(html` `); export const Inline = renderComponent(html` -

- +
+

Drawer Inline

${dismissed20Regular} -
+

An inline Drawer is often used for navigation that is not dismissible. As it is on the same level as the @@ -588,7 +537,7 @@ export const Inline = renderComponent(html`

-
+

Inline

@@ -600,12 +549,14 @@ export const Inline = renderComponent(html` type="inline" -

- Toggle Start - Toggle End -
+ Select a Drawer Position + + Start + End + + Toggle Drawer

Drawer Inline

@@ -618,7 +569,7 @@ export const Inline = renderComponent(html` > ${dismissed20Regular} -
+

An inline Drawer is often used for navigation that is not dismissible. As it is on the same level as the @@ -635,7 +586,7 @@ export const Inline = renderComponent(html` `); export const Position = renderComponent(html` -

+
` > ${dismissed20Regular} -
+

When a Drawer is invoked, it slides in from either the left or right side of the screen. This can be @@ -667,7 +618,7 @@ export const Position = renderComponent(html`

-
+

Position

@@ -681,7 +632,7 @@ export const Position = renderComponent(html` Select a Drawer Position - Start + Start End ` > ${dismissed20Regular} -
+

The drawer component offers flexible positioning options to suit your layout needs. By using the position @@ -725,8 +676,8 @@ export const Position = renderComponent(html` `); export const Size = renderComponent(html` -

-
+
+

Size

@@ -738,7 +689,7 @@ export const Size = renderComponent(html` Select a Drawer Size Small - Medium + Medium Large Full @@ -757,7 +708,7 @@ export const Size = renderComponent(html` > ${dismissed20Regular} -
+

The size attribute controls the width of the drawer. The default is medium.

@@ -777,7 +728,7 @@ export const Size = renderComponent(html` > ${dismissed20Regular} -
+

The size attribute controls the width of the drawer. The default is medium.

@@ -797,7 +748,7 @@ export const Size = renderComponent(html` > ${dismissed20Regular} -
+

The size attribute controls the width of the drawer. The default is medium.

@@ -817,7 +768,7 @@ export const Size = renderComponent(html` > ${dismissed20Regular} -
+

The size attribute controls the width of the drawer. The default is medium.

@@ -829,9 +780,51 @@ export const Size = renderComponent(html`
`); +export const WithTitleAndAction = renderComponent(html` + +
+
+ +

With Title and Action

+ + ${dismissed20Regular} + +
+
+
+

Drawer with title and action

+ + + The Drawer component provides a title and action slot to display a title and an action. + + + slot="title" + + + slot="action" + +
+ Toggle Drawer +
+
+
+`); + export const WithNavigation = renderComponent(html` -
-
+
+

With Navigation

@@ -849,31 +842,27 @@ export const WithNavigation = renderComponent(html` >
-
- - ${arrowLeft20Regular} - - - ${arrowClockwise20Regular} - - - ${settings20Regular} - - - hideDrawer('drawer-top-navigation')} - appearance="transparent" - icon-only - size="medium" - size - aria-label="close" - > - ${dismissed20Regular} - +
+
+ ${arrowLeft20Regular} +
+
+ ${arrowClockwise20Regular} + ${settings20Regular} + hideDrawer('drawer-default-end')} + appearance="transparent" + icon-only + size="medium" + aria-label="close" + > + ${dismissed20Regular} + +

With Navigation

-
+

The drawer component features an optional top navigation slot named "navigation" providing users with the @@ -894,87 +883,45 @@ export const WithNavigation = renderComponent(html` `); export const CustomSize = renderComponent(html` -

-
+
+

Custom Size

-

The Drawer can be sized to any custom width, by overriding the size CSS variable:

+

The Drawer can be sized to any custom width, by overriding the drawer-width CSS variable:

- --drawer-size + var(--drawer-width) Set a Drawer Size - Toggle Drawer
- +

Custom Size

${dismissed20Regular} -
+
-

The Drawer can be sized to any custom width, by overriding the size CSS variable:

+

The Drawer can be sized to any custom width, by overriding the drawer-width CSS variable:

- --drawer-size + var(--drawer-width)
`); -export const WithTitleAndAction = renderComponent(html` - -
-
- -

With Title and Action

- - ${dismissed20Regular} - -
-
-
-

Drawer with title and action

- - - The Drawer component provides a title and action slot to display a title and an action. - - - slot="title" - - - slot="action" - -
- Toggle Drawer -
-
-
-`); - export const Separator = renderComponent(html`
` > ${dismissed20Regular} -
+

To apply a separator line within the drawer, you can customize its color by setting the --drawer-separator @@ -1004,11 +951,11 @@ export const Separator = renderComponent(html`

- --drawer-separator + var(--drawer-separator)
-
+

Separator

@@ -1018,7 +965,7 @@ export const Separator = renderComponent(html`

- --drawer-separator + var(--drawer-separator)
` `); export const ContentOverflowSeparator = renderComponent(html` -
- +

Content Overflow Separator

` > ${dismissed20Regular} -
+

- When the content section of the drawer exceeds its allocated space and overflows, the --overflow-border CSS custom property is applied. This property is specifically designed to add a border style to the top of the drawer's footer, giving a visual indication that there's more content above. + The --drawer-overflow-border CSS token allows you to define a border color for the top of the drawer's footer. This visual cue helps indicate the presence of overflowed content above, signaling to users that there's more content to be viewed or accessed.

Personal Info

@@ -1088,15 +1033,15 @@ export const ContentOverflowSeparator = renderComponent(html`
-
+

Content Overflow Separator

- When the content section of the drawer exceeds its allocated space and overflows, the --overflow-border CSS custom property is applied. This property is specifically designed to add a border style to the top of the drawer's footer, giving a visual indication that there's more content above. + The --drawer-overflow-border CSS token allows you to define a border color for the top of the drawer's footer. This visual cue helps indicate the presence of overflowed content above, signaling to users that there's more content to be viewed or accessed.

- --overflow-border + var(--drawer-overflow-border)