-
Notifications
You must be signed in to change notification settings - Fork 8
/
drawer.stories.ts
132 lines (123 loc) · 4.21 KB
/
drawer.stories.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { html, ViewTemplate } from '@microsoft/fast-element';
import type { Meta } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { createRenderer } from '../../utilities/tests/storybook';
import '../../button/index';
import '../index';
import { DrawerLocation, DrawerState } from '../types';
enum ExampleContentType {
SimpleTextContent = 'SimpleTextContent',
HeaderContentFooter = 'HeaderContentFooter'
}
interface DrawerArgs {
location: DrawerLocation;
state: DrawerState;
modal: string;
preventDismiss: boolean;
content: ExampleContentType;
}
const simpleContent = html`
<section>
This is a drawer which can slide in from either side of the screen and
display custom content.
</section>
`;
// prettier-ignore
const headerFooterContent = html`
<header>Header</header>
<section>
<p>This is a drawer with <code>header</code>, <code>section</code>, and <code>footer</code> elements.</p>
<p>When placed in a <code>nimble-drawer</code> they will be automatically styled for you!</p>
<p style="height: 1000px;">
This is a tall piece of content so you can see how scrolling behaves. Scroll down to see more 👇.
</p>
<p>
You made it to the end! 🎉
</p>
</section>
<footer>
<nimble-button appearance="ghost">Cancel</nimble-button>
<nimble-button appearance="outline">OK</nimble-button>
</footer>`;
const content: { [key in ExampleContentType]: ViewTemplate } = {
[ExampleContentType.SimpleTextContent]: simpleContent,
[ExampleContentType.HeaderContentFooter]: headerFooterContent
};
const metadata: Meta<DrawerArgs> = {
title: 'Drawer',
decorators: [withXD],
parameters: {
docs: {
description: {
component:
'Specialized dialog designed to slide in from either side of the page. Typically contains navigation or configuration panes.'
}
},
design: {
artboardUrl:
'https://xd.adobe.com/view/8ce280ab-1559-4961-945c-182955c7780b-d9b1/screen/730cdeb8-a4b5-4dcc-9fe4-718a75da7aff/specs/'
}
},
// prettier-ignore
render: createRenderer(html`
<nimble-drawer id="myNimbleDrawer"
modal="${x => x.modal}"
?prevent-dismiss="${x => x.preventDismiss}"
location="${x => x.location}"
state="${x => x.state}"
>
${x => content[x.content]}
</nimble-drawer>
<nimble-button
style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"
onclick="myNimbleDrawer.state = myNimbleDrawer.hidden ? '${DrawerState.Opening}' : '${DrawerState.Closing}'"
>
Show/Hide Drawer (animated)
</nimble-button>
`),
argTypes: {
location: {
options: [DrawerLocation.Left, DrawerLocation.Right],
control: { type: 'radio' }
},
state: {
options: [
DrawerState.Opening,
DrawerState.Opened,
DrawerState.Closing,
DrawerState.Closed
],
control: { type: 'select' }
},
modal: {
options: ['true', 'false'],
control: { type: 'select' },
description:
'Note: The value is the string "true" or "false" unlike normal boolean attributes.'
},
content: {
options: [
ExampleContentType.SimpleTextContent,
ExampleContentType.HeaderContentFooter
],
control: {
type: 'radio',
labels: {
[ExampleContentType.SimpleTextContent]:
'Simple Text Content',
[ExampleContentType.HeaderContentFooter]:
'Header/Content/Footer Example'
}
}
}
},
args: {
location: DrawerLocation.Left,
state: DrawerState.Opening,
modal: 'true',
preventDismiss: false,
content: ExampleContentType.SimpleTextContent
}
};
export default metadata;
export const drawer = {};