@ornikar/kitt-universal 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/CHANGELOG.md +0 -8
- package/src/.eslintrc.json +0 -19
- package/src/Avatar/Avatar.stories.tsx +0 -45
- package/src/Avatar/Avatar.tsx +0 -60
- package/src/Avatar/__snapshots__/Avatar.stories.tsx.snap +0 -1229
- package/src/Button/Button.stories.tsx +0 -301
- package/src/Button/Button.tsx +0 -60
- package/src/Button/ButtonContainer.tsx +0 -32
- package/src/Button/ButtonContent.tsx +0 -133
- package/src/Button/__snapshots__/Button.stories.tsx.snap +0 -7483
- package/src/Button/useButton.ts +0 -14
- package/src/Card/Card.stories.tsx +0 -31
- package/src/Card/Card.tsx +0 -25
- package/src/Card/__snapshots__/Card.stories.tsx.snap +0 -306
- package/src/FullScreenModal/Body.tsx +0 -25
- package/src/FullScreenModal/FullScreenModal.stories.tsx +0 -63
- package/src/FullScreenModal/FullScreenModal.tsx +0 -21
- package/src/FullScreenModal/Header.tsx +0 -129
- package/src/FullScreenModal/__snapshots__/FullScreenModal.stories.tsx.snap +0 -771
- package/src/Icon/Icon.stories.tsx +0 -59
- package/src/Icon/Icon.tsx +0 -37
- package/src/Icon/SpinningIcon.tsx +0 -38
- package/src/Icon/SpinningIcon.web.module.css +0 -13
- package/src/Icon/SpinningIcon.web.module.css.d.ts +0 -6
- package/src/Icon/SpinningIcon.web.tsx +0 -11
- package/src/Icon/__snapshots__/Icon.stories.tsx.snap +0 -5648
- package/src/KittBreakpoints.ts +0 -44
- package/src/ListItem/ListItem.stories.tsx +0 -122
- package/src/ListItem/ListItem.tsx +0 -61
- package/src/ListItem/ListItemContent.tsx +0 -17
- package/src/ListItem/ListItemSideContent.tsx +0 -41
- package/src/ListItem/__snapshots__/ListItem.stories.tsx.snap +0 -1514
- package/src/Loader/LargeLoader.tsx +0 -12
- package/src/Loader/LargeLoader.web.module.css +0 -103
- package/src/Loader/LargeLoader.web.module.css.d.ts +0 -11
- package/src/Loader/LargeLoader.web.test.tsx +0 -10
- package/src/Loader/LargeLoader.web.tsx +0 -18
- package/src/Loader/Loader.stories.tsx +0 -47
- package/src/Loader/Loader.tsx +0 -21
- package/src/Loader/Loader.web.test.tsx +0 -20
- package/src/Loader/Loader.web.tsx +0 -14
- package/src/Loader/__snapshots__/LargeLoader.web.test.tsx.snap +0 -33
- package/src/Loader/__snapshots__/Loader.stories.tsx.snap +0 -607
- package/src/Loader/__snapshots__/Loader.web.test.tsx.snap +0 -103
- package/src/Message/Message.stories.tsx +0 -102
- package/src/Message/Message.tsx +0 -114
- package/src/Message/__snapshots__/Message.stories.tsx.snap +0 -2776
- package/src/Modal/Body.tsx +0 -20
- package/src/Modal/Footer.tsx +0 -18
- package/src/Modal/Header.tsx +0 -66
- package/src/Modal/Modal.stories.tsx +0 -181
- package/src/Modal/Modal.tsx +0 -66
- package/src/Modal/OnCloseContext.ts +0 -3
- package/src/Modal/__snapshots__/Modal.stories.tsx.snap +0 -2960
- package/src/Notification/Notification.stories.tsx +0 -102
- package/src/Notification/Notification.tsx +0 -21
- package/src/Notification/__snapshots__/Notification.stories.tsx.snap +0 -2861
- package/src/Overlay/Overlay.tsx +0 -22
- package/src/Tag/Tag.stories.tsx +0 -18
- package/src/Tag/Tag.tsx +0 -31
- package/src/Tag/__snapshots__/Tag.stories.tsx.snap +0 -303
- package/src/Tooltip/Tooltip.tsx +0 -17
- package/src/__mocks__/react-native-safe-area-context.tsx +0 -26
- package/src/forms/InputFeedback/InputFeedback.stories.tsx +0 -17
- package/src/forms/InputFeedback/InputFeedback.tsx +0 -28
- package/src/forms/InputFeedback/__snapshots__/InputFeedback.stories.tsx.snap +0 -252
- package/src/forms/InputField/InputField.stories.tsx +0 -19
- package/src/forms/InputField/InputField.tsx +0 -45
- package/src/forms/InputField/__snapshots__/InputField.stories.tsx.snap +0 -240
- package/src/forms/InputFormState.ts +0 -1
- package/src/forms/InputText/InputText.stories.tsx +0 -85
- package/src/forms/InputText/InputText.tsx +0 -172
- package/src/forms/InputText/__snapshots__/InputText.stories.tsx.snap +0 -4274
- package/src/forms/InputText/useInputText.ts +0 -19
- package/src/forms/Label/Label.stories.tsx +0 -14
- package/src/forms/Label/Label.tsx +0 -17
- package/src/forms/Label/__snapshots__/Label.stories.tsx.snap +0 -174
- package/src/forms/Radio/Radio.stories.tsx +0 -48
- package/src/forms/Radio/Radio.tsx +0 -81
- package/src/forms/Radio/__snapshots__/Radio.stories.tsx.snap +0 -967
- package/src/forms/TextArea/TextArea.stories.tsx +0 -72
- package/src/forms/TextArea/TextArea.tsx +0 -12
- package/src/forms/TextArea/__snapshots__/TextArea.stories.tsx.snap +0 -2091
- package/src/index.ts +0 -61
- package/src/stories/Block.tsx +0 -24
- package/src/stories/Flex.tsx +0 -16
- package/src/stories/color-tokens.stories.tsx +0 -143
- package/src/stories-list.ts +0 -22
- package/src/story-components/Section.tsx +0 -56
- package/src/story-components/Story.tsx +0 -24
- package/src/story-components/StoryDecorator.tsx +0 -8
- package/src/story-components/StoryGrid.tsx +0 -80
- package/src/story-components/StoryTitle.stories.tsx +0 -12
- package/src/story-components/StoryTitle.tsx +0 -69
- package/src/story-components/__snapshots__/StoryTitle.stories.tsx.snap +0 -155
- package/src/story-components/index.ts +0 -5
- package/src/themes/default.ts +0 -34
- package/src/themes/late-ocean/avatarLateOceanTheme.ts +0 -12
- package/src/themes/late-ocean/buttonLateOceanTheme.ts +0 -37
- package/src/themes/late-ocean/cardLateOceanTheme.ts +0 -19
- package/src/themes/late-ocean/colorsLateOceanTheme.ts +0 -19
- package/src/themes/late-ocean/feedbackMessageLateOceanTheme.ts +0 -10
- package/src/themes/late-ocean/formLateOceanTheme.ts +0 -9
- package/src/themes/late-ocean/fullScreenModalLateOceanTheme.ts +0 -9
- package/src/themes/late-ocean/inputFieldLateOceanTheme.ts +0 -4
- package/src/themes/late-ocean/inputLateOceanTheme.ts +0 -55
- package/src/themes/late-ocean/listItemLateOceanTheme.ts +0 -8
- package/src/themes/late-ocean/radioLateOceanTheme.ts +0 -19
- package/src/themes/late-ocean/shadowsLateOceanTheme.ts +0 -3
- package/src/themes/late-ocean/tagLateOceanTheme.ts +0 -17
- package/src/themes/late-ocean/typographyLateOceanTheme.ts +0 -94
- package/src/themes/palettes/lateOceanColorPalette.ts +0 -24
- package/src/typings/babel-config.d.ts +0 -6
- package/src/typings/metro.d.ts +0 -6
- package/src/typography/Typography.stories.tsx +0 -113
- package/src/typography/Typography.tsx +0 -165
- package/src/typography/TypographyIcon.stories.tsx +0 -31
- package/src/typography/TypographyIcon.tsx +0 -35
- package/src/typography/TypographyLink.stories.tsx +0 -88
- package/src/typography/TypographyLink.tsx +0 -48
- package/src/typography/__snapshots__/Typography.stories.tsx.snap +0 -6118
- package/src/typography/__snapshots__/TypographyIcon.stories.tsx.snap +0 -334
- package/src/typography/__snapshots__/TypographyLink.stories.tsx.snap +0 -10945
- package/src/useKittTheme.tsx +0 -12
- package/src/utils/storybook/decorators/KittThemeDecorator.tsx +0 -27
- package/src/utils/storybook/decorators/SafeAreaProviderDecorator.tsx +0 -11
- package/src/utils/storybook/setup-global-decorators.ts +0 -6
- package/src/utils/tests/renderWithProvidersUtils.tsx +0 -17
- package/src/utils/typeUtils.ts +0 -6
- package/src/utils/windowSize/MatchWindowSize.tsx +0 -14
- package/src/utils/windowSize/__snapshots__/windowSize.stories.tsx.snap +0 -1485
- package/src/utils/windowSize/createWindowSizeHelper.test.ts +0 -11
- package/src/utils/windowSize/createWindowSizeHelper.ts +0 -65
- package/src/utils/windowSize/useMatchWindowSize.ts +0 -14
- package/src/utils/windowSize/useWindowSize.ts +0 -1
- package/src/utils/windowSize/windowSize.stories.tsx +0 -115
- package/tsconfig.build.json +0 -33
- package/tsconfig.json +0 -13
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { action } from '@storybook/addon-actions';
|
|
2
|
-
import { storiesOf } from '@storybook/react-native';
|
|
3
|
-
import { ArrowLeftIcon, ArrowRightIcon, LoaderIcon } from '@ornikar/kitt-icons';
|
|
4
|
-
import { Section, Story } from '@ornikar/kitt-universal';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { View } from 'react-native';
|
|
7
|
-
import { Button } from './Button';
|
|
8
|
-
|
|
9
|
-
storiesOf('kitt-universal/Action', module).add(
|
|
10
|
-
'Button',
|
|
11
|
-
() => (
|
|
12
|
-
<Story title="Button">
|
|
13
|
-
<Section.DemoSection>
|
|
14
|
-
<View>
|
|
15
|
-
<Button icon={<LoaderIcon />} onPress={action('press')}>
|
|
16
|
-
Label
|
|
17
|
-
</Button>
|
|
18
|
-
</View>
|
|
19
|
-
</Section.DemoSection>
|
|
20
|
-
|
|
21
|
-
<Section title="Primary">
|
|
22
|
-
<Section.SubSection title="Default">
|
|
23
|
-
<Button type="primary" onPress={action('press')}>
|
|
24
|
-
Label
|
|
25
|
-
</Button>
|
|
26
|
-
</Section.SubSection>
|
|
27
|
-
<Section.SubSection title="Stretch">
|
|
28
|
-
<Button stretch type="primary" onPress={action('press')}>
|
|
29
|
-
Label
|
|
30
|
-
</Button>
|
|
31
|
-
</Section.SubSection>
|
|
32
|
-
<Section.SubSection title="Disabled">
|
|
33
|
-
<Button disabled type="primary" onPress={action('press')}>
|
|
34
|
-
Label
|
|
35
|
-
</Button>
|
|
36
|
-
</Section.SubSection>
|
|
37
|
-
<Section.SubSection title="Loading">
|
|
38
|
-
<Button iconSpin type="primary" icon={<LoaderIcon />} onPress={action('press')}>
|
|
39
|
-
Label
|
|
40
|
-
</Button>
|
|
41
|
-
</Section.SubSection>
|
|
42
|
-
<Section.SubSection title="With icon left">
|
|
43
|
-
<Button type="primary" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
44
|
-
Label
|
|
45
|
-
</Button>
|
|
46
|
-
</Section.SubSection>
|
|
47
|
-
<Section.SubSection title="With icon right">
|
|
48
|
-
<Button type="primary" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
49
|
-
Label
|
|
50
|
-
</Button>
|
|
51
|
-
</Section.SubSection>
|
|
52
|
-
<Section.SubSection title="Disabled with icon left">
|
|
53
|
-
<Button disabled type="primary" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
54
|
-
Label
|
|
55
|
-
</Button>
|
|
56
|
-
</Section.SubSection>
|
|
57
|
-
<Section.SubSection title="Disabled with icon right">
|
|
58
|
-
<Button disabled type="primary" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
59
|
-
Label
|
|
60
|
-
</Button>
|
|
61
|
-
</Section.SubSection>
|
|
62
|
-
<Section.SubSection title="Icon only">
|
|
63
|
-
<Button type="primary" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
64
|
-
</Section.SubSection>
|
|
65
|
-
<Section.SubSection title="Disabled Icon only">
|
|
66
|
-
<Button disabled type="primary" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
67
|
-
</Section.SubSection>
|
|
68
|
-
<Section.SubSection title="Icon only loading">
|
|
69
|
-
<Button iconSpin type="primary" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')} />
|
|
70
|
-
</Section.SubSection>
|
|
71
|
-
<Section.SubSection title="Long text">
|
|
72
|
-
<Button type="primary" onPress={action('press')}>
|
|
73
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
74
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
75
|
-
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
76
|
-
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
|
|
77
|
-
anim id est laborum.
|
|
78
|
-
</Button>
|
|
79
|
-
</Section.SubSection>
|
|
80
|
-
<Section.SubSection title="Long text with icon">
|
|
81
|
-
<Button type="primary" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
82
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
83
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
84
|
-
ea commodo consequat.
|
|
85
|
-
</Button>
|
|
86
|
-
</Section.SubSection>
|
|
87
|
-
</Section>
|
|
88
|
-
|
|
89
|
-
<Section title="Secondary">
|
|
90
|
-
<Section.SubSection title="Default">
|
|
91
|
-
<Button type="secondary" onPress={action('press')}>
|
|
92
|
-
Label
|
|
93
|
-
</Button>
|
|
94
|
-
</Section.SubSection>
|
|
95
|
-
<Section.SubSection title="Stretch">
|
|
96
|
-
<Button stretch type="secondary" onPress={action('press')}>
|
|
97
|
-
Label
|
|
98
|
-
</Button>
|
|
99
|
-
</Section.SubSection>
|
|
100
|
-
<Section.SubSection title="Disabled">
|
|
101
|
-
<Button disabled type="secondary" onPress={action('press')}>
|
|
102
|
-
Label
|
|
103
|
-
</Button>
|
|
104
|
-
</Section.SubSection>
|
|
105
|
-
<Section.SubSection title="Loading">
|
|
106
|
-
<Button iconSpin icon={<LoaderIcon />} type="secondary" onPress={action('press')}>
|
|
107
|
-
Label
|
|
108
|
-
</Button>
|
|
109
|
-
</Section.SubSection>
|
|
110
|
-
<Section.SubSection title="With icon left">
|
|
111
|
-
<Button type="secondary" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
112
|
-
Label
|
|
113
|
-
</Button>
|
|
114
|
-
</Section.SubSection>
|
|
115
|
-
<Section.SubSection title="With icon right">
|
|
116
|
-
<Button type="secondary" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
117
|
-
Label
|
|
118
|
-
</Button>
|
|
119
|
-
</Section.SubSection>
|
|
120
|
-
<Section.SubSection title="Disabled with icon left">
|
|
121
|
-
<Button disabled type="secondary" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
122
|
-
Label
|
|
123
|
-
</Button>
|
|
124
|
-
</Section.SubSection>
|
|
125
|
-
<Section.SubSection title="Disabled with icon right">
|
|
126
|
-
<Button disabled type="secondary" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
127
|
-
Label
|
|
128
|
-
</Button>
|
|
129
|
-
</Section.SubSection>
|
|
130
|
-
<Section.SubSection title="Icon only">
|
|
131
|
-
<Button type="secondary" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
132
|
-
</Section.SubSection>
|
|
133
|
-
<Section.SubSection title="Disabled Icon only">
|
|
134
|
-
<Button disabled type="secondary" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
135
|
-
</Section.SubSection>
|
|
136
|
-
<Section.SubSection title="Icon only loading">
|
|
137
|
-
<Button iconSpin icon={<LoaderIcon />} type="secondary" onPress={action('press')} />
|
|
138
|
-
</Section.SubSection>
|
|
139
|
-
<Section.SubSection title="Long text">
|
|
140
|
-
<Button type="secondary" onPress={action('press')}>
|
|
141
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
142
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
143
|
-
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
144
|
-
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
|
|
145
|
-
anim id est laborum.
|
|
146
|
-
</Button>
|
|
147
|
-
</Section.SubSection>
|
|
148
|
-
<Section.SubSection title="Long text with icon">
|
|
149
|
-
<Button type="secondary" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
150
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
151
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
152
|
-
ea commodo consequat.
|
|
153
|
-
</Button>
|
|
154
|
-
</Section.SubSection>
|
|
155
|
-
</Section>
|
|
156
|
-
|
|
157
|
-
<Section title="Subtle">
|
|
158
|
-
<Section.SubSection title="Default">
|
|
159
|
-
<Button type="subtle" onPress={action('press')}>
|
|
160
|
-
Label
|
|
161
|
-
</Button>
|
|
162
|
-
</Section.SubSection>
|
|
163
|
-
<Section.SubSection title="Stretch">
|
|
164
|
-
<Button stretch type="subtle" onPress={action('press')}>
|
|
165
|
-
Label
|
|
166
|
-
</Button>
|
|
167
|
-
</Section.SubSection>
|
|
168
|
-
<Section.SubSection title="Disabled">
|
|
169
|
-
<Button disabled type="subtle" onPress={action('press')}>
|
|
170
|
-
Label
|
|
171
|
-
</Button>
|
|
172
|
-
</Section.SubSection>
|
|
173
|
-
<Section.SubSection title="Loading">
|
|
174
|
-
<Button iconSpin icon={<LoaderIcon />} type="subtle" onPress={action('press')}>
|
|
175
|
-
Label
|
|
176
|
-
</Button>
|
|
177
|
-
</Section.SubSection>
|
|
178
|
-
<Section.SubSection title="With icon left">
|
|
179
|
-
<Button type="subtle" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
180
|
-
Label
|
|
181
|
-
</Button>
|
|
182
|
-
</Section.SubSection>
|
|
183
|
-
<Section.SubSection title="With icon right">
|
|
184
|
-
<Button type="subtle" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
185
|
-
Label
|
|
186
|
-
</Button>
|
|
187
|
-
</Section.SubSection>
|
|
188
|
-
<Section.SubSection title="Disabled with icon left">
|
|
189
|
-
<Button disabled type="subtle" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
190
|
-
Label
|
|
191
|
-
</Button>
|
|
192
|
-
</Section.SubSection>
|
|
193
|
-
<Section.SubSection title="Disabled with icon right">
|
|
194
|
-
<Button disabled type="subtle" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
195
|
-
Label
|
|
196
|
-
</Button>
|
|
197
|
-
</Section.SubSection>
|
|
198
|
-
<Section.SubSection title="Icon only">
|
|
199
|
-
<Button type="subtle" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
200
|
-
</Section.SubSection>
|
|
201
|
-
<Section.SubSection title="Disabled Icon only">
|
|
202
|
-
<Button disabled type="subtle" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
203
|
-
</Section.SubSection>
|
|
204
|
-
<Section.SubSection title="Icon only loading">
|
|
205
|
-
<Button iconSpin icon={<LoaderIcon />} type="subtle" onPress={action('press')} />
|
|
206
|
-
</Section.SubSection>
|
|
207
|
-
<Section.SubSection title="Long text">
|
|
208
|
-
<Button type="subtle" onPress={action('press')}>
|
|
209
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
210
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
211
|
-
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
212
|
-
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
|
|
213
|
-
anim id est laborum.
|
|
214
|
-
</Button>
|
|
215
|
-
</Section.SubSection>
|
|
216
|
-
<Section.SubSection title="Long text with icon">
|
|
217
|
-
<Button type="subtle" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
218
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
219
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
220
|
-
ea commodo consequat.
|
|
221
|
-
</Button>
|
|
222
|
-
</Section.SubSection>
|
|
223
|
-
</Section>
|
|
224
|
-
|
|
225
|
-
<Section title="Subtle dark">
|
|
226
|
-
<Section.SubSection title="Default">
|
|
227
|
-
<Button type="subtle-dark" onPress={action('press')}>
|
|
228
|
-
Label
|
|
229
|
-
</Button>
|
|
230
|
-
</Section.SubSection>
|
|
231
|
-
<Section.SubSection title="Stretch">
|
|
232
|
-
<Button stretch type="subtle-dark" onPress={action('press')}>
|
|
233
|
-
Label
|
|
234
|
-
</Button>
|
|
235
|
-
</Section.SubSection>
|
|
236
|
-
<Section.SubSection title="Disabled">
|
|
237
|
-
<Button disabled type="subtle-dark" onPress={action('press')}>
|
|
238
|
-
Label
|
|
239
|
-
</Button>
|
|
240
|
-
</Section.SubSection>
|
|
241
|
-
<Section.SubSection title="Loading">
|
|
242
|
-
<Button iconSpin icon={<LoaderIcon />} type="subtle-dark" onPress={action('press')}>
|
|
243
|
-
Label
|
|
244
|
-
</Button>
|
|
245
|
-
</Section.SubSection>
|
|
246
|
-
<Section.SubSection title="With icon left">
|
|
247
|
-
<Button type="subtle-dark" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
248
|
-
Label
|
|
249
|
-
</Button>
|
|
250
|
-
</Section.SubSection>
|
|
251
|
-
<Section.SubSection title="With icon right">
|
|
252
|
-
<Button type="subtle-dark" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
253
|
-
Label
|
|
254
|
-
</Button>
|
|
255
|
-
</Section.SubSection>
|
|
256
|
-
<Section.SubSection title="Disabled with icon left">
|
|
257
|
-
<Button disabled type="subtle-dark" icon={<ArrowLeftIcon />} iconPosition="left" onPress={action('press')}>
|
|
258
|
-
Label
|
|
259
|
-
</Button>
|
|
260
|
-
</Section.SubSection>
|
|
261
|
-
<Section.SubSection title="Disabled with icon right">
|
|
262
|
-
<Button disabled type="subtle-dark" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
263
|
-
Label
|
|
264
|
-
</Button>
|
|
265
|
-
</Section.SubSection>
|
|
266
|
-
<Section.SubSection title="Icon only">
|
|
267
|
-
<Button type="subtle-dark" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
268
|
-
</Section.SubSection>
|
|
269
|
-
<Section.SubSection title="Disabled Icon only">
|
|
270
|
-
<Button disabled type="subtle-dark" icon={<ArrowRightIcon />} onPress={action('press')} />
|
|
271
|
-
</Section.SubSection>
|
|
272
|
-
<Section.SubSection title="Icon only loading">
|
|
273
|
-
<Button iconSpin icon={<LoaderIcon />} type="subtle-dark" onPress={action('press')} />
|
|
274
|
-
</Section.SubSection>
|
|
275
|
-
<Section.SubSection title="Long text">
|
|
276
|
-
<Button type="subtle-dark" onPress={action('press')}>
|
|
277
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
278
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
279
|
-
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
|
|
280
|
-
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
|
|
281
|
-
anim id est laborum.
|
|
282
|
-
</Button>
|
|
283
|
-
</Section.SubSection>
|
|
284
|
-
<Section.SubSection title="Long text with icon">
|
|
285
|
-
<Button type="subtle-dark" icon={<ArrowRightIcon />} iconPosition="right" onPress={action('press')}>
|
|
286
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
287
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
|
|
288
|
-
ea commodo consequat.
|
|
289
|
-
</Button>
|
|
290
|
-
</Section.SubSection>
|
|
291
|
-
</Section>
|
|
292
|
-
</Story>
|
|
293
|
-
),
|
|
294
|
-
{
|
|
295
|
-
jest: {
|
|
296
|
-
createBeforeAfterEachCallbacks: () => ({
|
|
297
|
-
before: () => jest.useFakeTimers(),
|
|
298
|
-
}),
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
);
|
package/src/Button/Button.tsx
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ButtonContainer } from './ButtonContainer';
|
|
4
|
-
import { ButtonContent } from './ButtonContent';
|
|
5
|
-
import { useButton } from './useButton';
|
|
6
|
-
|
|
7
|
-
export type ButtonType = 'primary' | 'secondary' | 'subtle' | 'subtle-dark';
|
|
8
|
-
|
|
9
|
-
type IconPosition = 'right' | 'left';
|
|
10
|
-
|
|
11
|
-
export interface ButtonProps {
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
type?: ButtonType;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
icon?: ReactElement;
|
|
16
|
-
iconPosition?: IconPosition;
|
|
17
|
-
iconSpin?: boolean;
|
|
18
|
-
stretch?: boolean;
|
|
19
|
-
testID?: string;
|
|
20
|
-
onPress?: () => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function Button({
|
|
24
|
-
children,
|
|
25
|
-
type = 'secondary',
|
|
26
|
-
icon,
|
|
27
|
-
iconPosition = 'left',
|
|
28
|
-
iconSpin,
|
|
29
|
-
stretch,
|
|
30
|
-
disabled,
|
|
31
|
-
onPress,
|
|
32
|
-
testID,
|
|
33
|
-
}: ButtonProps): ReactElement {
|
|
34
|
-
const { isPressed, handleButtonPressIn, handleButtonPressOut } = useButton();
|
|
35
|
-
|
|
36
|
-
const sharedProps = {
|
|
37
|
-
type,
|
|
38
|
-
stretch,
|
|
39
|
-
disabled,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<ButtonContainer
|
|
44
|
-
// eslint-disable-next-line unicorn/expiring-todo-comments
|
|
45
|
-
// TODO: When designs are defined, update with the proper onPress styles to mimic TouchableHighlight
|
|
46
|
-
// underlayColor={globalTheme.button[type].pressedBackgroundColor}
|
|
47
|
-
{...sharedProps}
|
|
48
|
-
isPressed={isPressed}
|
|
49
|
-
accessibilityRole="button"
|
|
50
|
-
testID={testID}
|
|
51
|
-
onPress={onPress}
|
|
52
|
-
onPressIn={handleButtonPressIn}
|
|
53
|
-
onPressOut={handleButtonPressOut}
|
|
54
|
-
>
|
|
55
|
-
<ButtonContent {...sharedProps} icon={icon} iconPosition={iconPosition} iconSpin={iconSpin}>
|
|
56
|
-
{children}
|
|
57
|
-
</ButtonContent>
|
|
58
|
-
</ButtonContainer>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components/native';
|
|
2
|
-
import type { ButtonType } from './Button';
|
|
3
|
-
|
|
4
|
-
interface ButtonContainerProps {
|
|
5
|
-
type: ButtonType;
|
|
6
|
-
isPressed?: boolean;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
stretch?: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const ButtonContainer = styled.Pressable<ButtonContainerProps>`
|
|
12
|
-
min-width: ${({ theme }) => theme.kitt.button.minWidth};
|
|
13
|
-
max-width: ${({ theme, stretch }) => (stretch ? 'auto' : theme.kitt.button.maxWidth)};
|
|
14
|
-
width: ${({ stretch }) => (stretch ? '100%' : 'auto')};
|
|
15
|
-
min-height: ${({ theme }) => theme.kitt.button.minHeight};
|
|
16
|
-
background-color: ${({ theme, isPressed, disabled, type }) => {
|
|
17
|
-
if (disabled) {
|
|
18
|
-
return theme.kitt.button[type].disabledBackgroundColor;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return isPressed ? theme.kitt.button[type].pressedBackgroundColor : theme.kitt.button[type].backgroundColor;
|
|
22
|
-
}};
|
|
23
|
-
padding: ${({ theme }) => theme.kitt.button.contentPadding.default};
|
|
24
|
-
flex-direction: row;
|
|
25
|
-
|
|
26
|
-
/* Emulate inline-* css display by making the button taking only its necessary space */
|
|
27
|
-
align-self: flex-start;
|
|
28
|
-
border-radius: ${({ theme }) => theme.kitt.button.borderRadius};
|
|
29
|
-
border-color: ${({ theme, disabled, type }) =>
|
|
30
|
-
disabled ? theme.kitt.button[type].disabledBorderColor : 'transparent'};
|
|
31
|
-
border-width: ${({ theme }) => theme.kitt.button.borderWidth};
|
|
32
|
-
`;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { ReactElement } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled, { useTheme } from 'styled-components/native';
|
|
4
|
-
import type { TypographyColor } from '../typography/Typography';
|
|
5
|
-
import { Typography } from '../typography/Typography';
|
|
6
|
-
import { TypographyIcon } from '../typography/TypographyIcon';
|
|
7
|
-
import type { ButtonProps, ButtonType } from './Button';
|
|
8
|
-
|
|
9
|
-
const getTextColorByType = (type: ButtonType, isPressed: boolean, disabled: boolean): TypographyColor => {
|
|
10
|
-
if (disabled) return 'black-light';
|
|
11
|
-
switch (type) {
|
|
12
|
-
case 'primary':
|
|
13
|
-
return 'white';
|
|
14
|
-
case 'subtle':
|
|
15
|
-
return isPressed ? 'primary-light' : 'primary';
|
|
16
|
-
case 'subtle-dark':
|
|
17
|
-
return isPressed ? 'black-light' : 'black';
|
|
18
|
-
case 'secondary':
|
|
19
|
-
default:
|
|
20
|
-
return 'black';
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const ButtonText = styled(Typography.Text)`
|
|
25
|
-
/* On native code, this is the only way to ensure that the text is centered */
|
|
26
|
-
text-align: center;
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
interface ContentProps {
|
|
30
|
-
stretch?: boolean;
|
|
31
|
-
iconOnly?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Content = styled.View<ContentProps>`
|
|
35
|
-
flex-direction: row;
|
|
36
|
-
align-items: center;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
|
|
39
|
-
/*
|
|
40
|
-
On native code flex grow does not work as expected which cause an issue with the flex props.
|
|
41
|
-
In order to occupy only the needed space, we enable flex grow only when stretched
|
|
42
|
-
*/
|
|
43
|
-
flex: ${({ stretch, iconOnly }) => `${stretch || iconOnly ? 1 : 0} 1 auto`};
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
interface IconContainerProps {
|
|
47
|
-
iconPosition?: ButtonProps['iconPosition'];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const IconContainer = styled.View<IconContainerProps>`
|
|
51
|
-
${({ theme, iconPosition }) => {
|
|
52
|
-
const value = theme.kitt.spacing * 3;
|
|
53
|
-
|
|
54
|
-
if (iconPosition === 'left') {
|
|
55
|
-
return `margin: 0 ${value}px 0 0;`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return `margin: 0 0 0 ${value}px;`;
|
|
59
|
-
}}
|
|
60
|
-
`;
|
|
61
|
-
|
|
62
|
-
interface ButtonIconProps {
|
|
63
|
-
icon: NonNullable<ButtonContentProps['icon']>;
|
|
64
|
-
spin: ButtonProps['iconSpin'];
|
|
65
|
-
color: TypographyColor;
|
|
66
|
-
size: number;
|
|
67
|
-
iconPosition: ButtonContentProps['iconPosition'];
|
|
68
|
-
testID?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function ButtonIcon({ icon, spin, color, size, iconPosition, testID }: ButtonIconProps): ReactElement | null {
|
|
72
|
-
return (
|
|
73
|
-
<IconContainer iconPosition={iconPosition}>
|
|
74
|
-
<TypographyIcon icon={icon} spin={spin} color={color} size={size} testID={testID} />
|
|
75
|
-
</IconContainer>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
interface ButtonContentProps extends Exclude<ButtonProps, 'onPress'> {
|
|
80
|
-
isPressed?: boolean;
|
|
81
|
-
type: NonNullable<ButtonType>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function ButtonContent({
|
|
85
|
-
type,
|
|
86
|
-
isPressed,
|
|
87
|
-
stretch,
|
|
88
|
-
icon,
|
|
89
|
-
iconPosition,
|
|
90
|
-
iconSpin,
|
|
91
|
-
disabled,
|
|
92
|
-
children,
|
|
93
|
-
}: ButtonContentProps): ReactElement | null {
|
|
94
|
-
const color = getTextColorByType(type, Boolean(isPressed), Boolean(disabled));
|
|
95
|
-
const theme = useTheme();
|
|
96
|
-
|
|
97
|
-
const sharedIconProps = {
|
|
98
|
-
spin: iconSpin,
|
|
99
|
-
color,
|
|
100
|
-
size: theme.kitt.button.iconSize,
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
if (__DEV__) {
|
|
104
|
-
if (!(children || icon)) {
|
|
105
|
-
throw new Error('kitt(Button): You should provide at least a children or a icon');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!children) {
|
|
110
|
-
return (
|
|
111
|
-
<Content iconOnly stretch={stretch}>
|
|
112
|
-
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
|
113
|
-
<TypographyIcon {...sharedIconProps} icon={icon!} />
|
|
114
|
-
</Content>
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<Content stretch={stretch}>
|
|
120
|
-
{icon && iconPosition === 'left' ? (
|
|
121
|
-
<ButtonIcon {...sharedIconProps} icon={icon} iconPosition={iconPosition} testID="button-left-icon" />
|
|
122
|
-
) : null}
|
|
123
|
-
|
|
124
|
-
<ButtonText base="body" color={color} variant="bold">
|
|
125
|
-
{children}
|
|
126
|
-
</ButtonText>
|
|
127
|
-
|
|
128
|
-
{icon && iconPosition === 'right' ? (
|
|
129
|
-
<ButtonIcon {...sharedIconProps} icon={icon} iconPosition={iconPosition} />
|
|
130
|
-
) : null}
|
|
131
|
-
</Content>
|
|
132
|
-
);
|
|
133
|
-
}
|