-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathswitch.ts
69 lines (66 loc) · 2.02 KB
/
switch.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
import { ComponentInfo } from '../components';
import { BaseComponent } from '../entities';
import { checkmark, indexByOptionId, stringArray } from '../utils';
const componentId = 'switch';
export interface Switch extends BaseComponent {
componentId: typeof componentId;
options: {
disabled: boolean;
indeterminate: boolean;
internalIcons: boolean;
internalText: boolean;
labelPlacement: ('above' | 'below' | 'left' | 'right')[];
loading: boolean;
sizes: string[];
};
}
export const switchComponent: ComponentInfo = {
cannonicalName: 'Switch',
componentId,
description: 'Used to toggle between two states: on and off.',
indefiniteArticle: 'a',
optionsById: indexByOptionId([
{
criteria: 'The switch has a `disabled` state, indicating that the user cannot interact with it.',
name: 'Disabled',
optionId: 'disabled',
...checkmark,
},
{
criteria: 'The switch has an ability to display an indeterminate state.',
name: 'Indeterminate',
optionId: 'indeterminate',
...checkmark,
},
{
criteria: 'The switch has a prop (or child) to include custom icons within the space of the switch (e.g. a `checkmark` and an `x` icon).',
name: 'Internal Icons',
optionId: 'internalIcons',
...checkmark,
},
{
criteria: 'The switch has a prop (or child) to include custom text within the space of the switch (e.g. the text `on` and `off`).',
name: 'Internal Text',
optionId: 'internalText',
...checkmark,
},
{
criteria: 'Where a label can be attached to the switch.',
name: 'Lable Placement',
optionId: 'labelPlacement',
...stringArray,
},
{
criteria: 'The switch has a `loading` state that indicates a pending state of a switch action.',
name: 'Loading',
optionId: 'loading',
...checkmark,
},
{
criteria: 'The lable has native, pre-configured size options.',
name: 'Sizes',
optionId: 'sizes',
...stringArray,
},
]),
};