-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathSpectrumComponents.tsx
More file actions
296 lines (285 loc) · 8.29 KB
/
SpectrumComponents.tsx
File metadata and controls
296 lines (285 loc) · 8.29 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/* eslint-disable react/style-prop-object */
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {
ActionButton,
Button,
Cell,
Checkbox,
Content,
ContextualHelp,
Column,
ComboBox,
Form,
Grid,
Icon,
IllustratedMessage,
Item,
minmax,
repeat,
Row,
Slider,
Switch,
TableBody,
TableHeader,
TableView,
TextField,
ToggleButton,
Well,
DialogTrigger,
Dialog,
Header,
Divider,
ButtonGroup,
Flex,
ListView,
} from '@adobe/react-spectrum';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { dhTruck, vsEmptyWindow } from '@deephaven/icons';
import { Heading, View, Text } from '@deephaven/components';
import { SPECTRUM_COMPONENT_SAMPLES_ID } from './constants';
import SampleSection from './SampleSection';
export function SpectrumComponents(): JSX.Element {
return (
<div id={SPECTRUM_COMPONENT_SAMPLES_ID}>
<h2 className="ui-title" data-no-menu>
Spectrum Components
</h2>
<Grid gap={20} columns={minmax('0px', '1fr')}>
<SampleSection name="spectrum-buttons" component={View}>
<h3>Buttons</h3>
<ButtonsSample />
</SampleSection>
<SampleSection name="spectrum-collections" component={View}>
<h3>Collections</h3>
<TableViewSample />
</SampleSection>
<SampleSection name="spectrum-content" component={View}>
<h3>Content</h3>
<IllustratedMessageSample />
</SampleSection>
<SampleSection name="spectrum-forms" component={View}>
<h3>Forms</h3>
<FormsSample />
</SampleSection>
<SampleSection name="spectrum-overlays" component={View}>
<h3>Overlays</h3>
<Flex gap="size-160">
<ContextualHelpSample />
<DialogTrigger>
<ActionButton>Dialog Trigger</ActionButton>
{close => (
<Dialog>
<Heading>Some Heading</Heading>
<Header>Some Header</Header>
<Divider />
<Content>
<Text>Are you sure?</Text>
</Content>
<ButtonGroup>
<Button variant="secondary" onPress={close}>
Cancel
</Button>
<Button variant="accent" onPress={close}>
Confirm
</Button>
</ButtonGroup>
</Dialog>
)}
</DialogTrigger>
<DialogTrigger type="popover">
<ActionButton>Popover</ActionButton>
<Dialog>
<Heading>Popover</Heading>
<Divider />
<Content>
<Text>This is a popover.</Text>
</Content>
</Dialog>
</DialogTrigger>
</Flex>
</SampleSection>
<SampleSection name="spectrum-well" component={View}>
<h3>Wells</h3>
<Well>This is a well.</Well>
</SampleSection>
</Grid>
</div>
);
}
export default SpectrumComponents;
function ButtonsSample(): JSX.Element {
return (
<>
<ActionButton marginBottom="size-200">
<Icon>
<FontAwesomeIcon icon={dhTruck} />
</Icon>
<Text>Icon Button</Text>
</ActionButton>
<Grid
autoFlow="column"
columnGap="size-250"
rowGap="size-150"
columns={repeat(4, minmax(0, 'size-2000'))}
rows={repeat(8, 'size-400')}
>
<label>Button style="outline"</label>
<Button variant="primary" style="outline">
Primary
</Button>
<Button variant="secondary" style="outline">
Secondary
</Button>
<Button variant="accent" style="outline">
Accent
</Button>
<Button variant="negative" style="outline">
Negative
</Button>
<Button variant="primary" staticColor="black" style="outline">
Static Black
</Button>
<Button variant="primary" staticColor="white" style="outline">
Static White
</Button>
<Button variant="primary" isDisabled style="outline">
Disabled
</Button>
<label>Button style="fill"</label>
<Button variant="primary" style="fill">
Primary
</Button>
<Button variant="secondary" style="fill">
Secondary
</Button>
<Button variant="accent" style="fill">
Accent
</Button>
<Button variant="negative" style="fill">
Negative
</Button>
<Button variant="primary" staticColor="black" style="fill">
Static Black
</Button>
<Button variant="primary" staticColor="white" style="fill">
Static White
</Button>
<Button variant="primary" isDisabled style="fill">
Disabled
</Button>
<label>Action Button</label>
<ActionButton>Normal</ActionButton>
<ActionButton gridRow="span 3" isQuiet>
Quiet
</ActionButton>
<ActionButton staticColor="black">Static Black</ActionButton>
<ActionButton staticColor="white">Static White</ActionButton>
<ActionButton isDisabled>Disabled</ActionButton>
<label>Toggle Button</label>
<ToggleButton>Normal</ToggleButton>
<ToggleButton isQuiet>Quiet</ToggleButton>
<ToggleButton gridRow="span 2" isEmphasized>
Emphasized
</ToggleButton>
<ToggleButton staticColor="black">Static Black</ToggleButton>
<ToggleButton staticColor="white">Static White</ToggleButton>
<ToggleButton isDisabled>Disabled</ToggleButton>
</Grid>
</>
);
}
function ContextualHelpSample(): JSX.Element {
return (
<>
<Text>Contextual Help</Text>
<ContextualHelp variant="info">
<Heading>Need help?</Heading>
<Content>
<Text>
This is a helpful description of the thing you need help with.
</Text>
</Content>
</ContextualHelp>
</>
);
}
function FormsSample(): JSX.Element {
return (
<Form>
<Grid gap={20} columns={repeat('auto-fit', '210px')} alignItems="end">
<TextField label="Text Field" />
<ComboBox label="Combobox" menuTrigger="focus" defaultSelectedKey="two">
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</ComboBox>
<Checkbox>Checkbox</Checkbox>
<Slider label="Slider" defaultValue={24} />
<Switch>Switch</Switch>
</Grid>
</Form>
);
}
function IllustratedMessageSample(): JSX.Element {
return (
<IllustratedMessage>
<Icon size="XL">
<FontAwesomeIcon icon={vsEmptyWindow} />
</Icon>
<Heading>Illustrated Message</Heading>
<Content>This is the content of the message.</Content>
</IllustratedMessage>
);
}
function TableViewSample(): JSX.Element {
return (
<>
<label id="table-view-sample">List View</label>
<ListView
aria-labelledby="table-view-sample"
selectionMode="multiple"
maxWidth="size-6000"
marginBottom="size-200"
>
<Item>One</Item>
<Item>Two</Item>
<Item>Three</Item>
<Item>Four</Item>
</ListView>
<label id="table-view-sample">Table View</label>
<TableView aria-labelledby="table-view-sample" selectionMode="multiple">
<TableHeader>
<Column title="Person">
<Column allowsResizing>Name</Column>
<Column>Age</Column>
</Column>
<Column title="Address">
<Column allowsResizing>City</Column>
<Column>State</Column>
</Column>
</TableHeader>
<TableBody>
<Row>
<Cell>John</Cell>
<Cell>42</Cell>
<Cell>San Francisco</Cell>
<Cell>CA</Cell>
</Row>
<Row>
<Cell>Jane</Cell>
<Cell>38</Cell>
<Cell>San Francisco</Cell>
<Cell>CA</Cell>
</Row>
<Row>
<Cell>Becky</Cell>
<Cell>12</Cell>
<Cell>San Francisco</Cell>
<Cell>CA</Cell>
</Row>
</TableBody>
</TableView>
</>
);
}