@telus-uds/components-base 0.0.2-prerelease.1 → 0.0.2-prerelease.5
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/CHANGELOG.md +36 -0
- package/__fixtures__/testTheme.js +264 -84
- package/__tests__/Box/Box.test.jsx +81 -58
- package/__tests__/Card/Card.test.jsx +63 -0
- package/__tests__/Divider/Divider.test.jsx +26 -5
- package/__tests__/Feedback/Feedback.test.jsx +42 -0
- package/__tests__/FlexGrid/Col.test.jsx +5 -0
- package/__tests__/Pagination/Pagination.test.jsx +160 -0
- package/__tests__/Spacer/Spacer.test.jsx +63 -0
- package/__tests__/StackView/StackView.test.jsx +242 -0
- package/__tests__/StackView/StackWrap.test.jsx +47 -0
- package/__tests__/StackView/getStackedContent.test.jsx +295 -0
- package/__tests__/TextInput/TextInput.test.jsx +146 -0
- package/__tests__/ThemeProvider/useThemeTokens.test.jsx +5 -3
- package/__tests__/utils/spacing.test.jsx +273 -0
- package/__tests__/utils/useUniqueId.test.js +31 -0
- package/babel.config.json +8 -0
- package/jest.config.js +7 -6
- package/lib/A11yInfoProvider/index.js +2 -2
- package/lib/A11yText/index.js +1 -3
- package/lib/ActivityIndicator/Spinner.web.js +3 -5
- package/lib/Box/Box.js +117 -82
- package/lib/Button/Button.js +1 -3
- package/lib/Button/ButtonBase.js +9 -21
- package/lib/Button/ButtonGroup.js +14 -25
- package/lib/Button/ButtonLink.js +1 -3
- package/lib/Card/Card.js +103 -0
- package/lib/Card/index.js +2 -0
- package/lib/Divider/Divider.js +40 -4
- package/lib/ExpandCollapse/Accordion.js +1 -3
- package/lib/ExpandCollapse/Control.js +3 -5
- package/lib/ExpandCollapse/Panel.js +2 -4
- package/lib/Feedback/Feedback.js +110 -0
- package/lib/Feedback/index.js +2 -0
- package/lib/FlexGrid/Col/Col.js +3 -5
- package/lib/FlexGrid/FlexGrid.js +1 -3
- package/lib/FlexGrid/Row/Row.js +1 -3
- package/lib/FlexGrid/providers/GutterContext.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/InputLabel/InputLabel.js +86 -0
- package/lib/InputLabel/LabelContent.native.js +8 -0
- package/lib/InputLabel/LabelContent.web.js +17 -0
- package/lib/InputLabel/index.js +2 -0
- package/lib/Link/ChevronLink.js +1 -3
- package/lib/Link/Link.js +1 -3
- package/lib/Link/LinkBase.js +11 -7
- package/lib/Link/TextButton.js +1 -3
- package/lib/Pagination/PageButton.js +85 -0
- package/lib/Pagination/Pagination.js +118 -0
- package/lib/Pagination/SideButton.js +108 -0
- package/lib/Pagination/dictionary.js +18 -0
- package/lib/Pagination/index.js +2 -0
- package/lib/Pagination/useCopy.js +10 -0
- package/lib/Pagination/usePagination.js +70 -0
- package/lib/SideNav/Item.js +4 -6
- package/lib/SideNav/ItemsGroup.js +11 -11
- package/lib/SideNav/SideNav.js +2 -4
- package/lib/Spacer/Spacer.js +98 -0
- package/lib/Spacer/index.js +2 -0
- package/lib/StackView/StackView.js +105 -0
- package/lib/StackView/StackWrap.js +32 -0
- package/lib/StackView/StackWrap.native.js +3 -0
- package/lib/StackView/StackWrapBox.js +85 -0
- package/lib/StackView/StackWrapGap.js +45 -0
- package/lib/StackView/common.js +30 -0
- package/lib/StackView/getStackedContent.js +111 -0
- package/lib/StackView/index.js +5 -0
- package/lib/TextInput/TextInput.js +337 -0
- package/lib/TextInput/index.js +2 -0
- package/lib/ThemeProvider/ThemeProvider.js +2 -2
- package/lib/ThemeProvider/useThemeTokens.js +34 -6
- package/lib/ThemeProvider/utils/theme-tokens.js +37 -9
- package/lib/ToggleSwitch/ToggleSwitch.js +17 -47
- package/lib/Typography/Typography.js +1 -7
- package/lib/ViewportProvider/index.js +1 -1
- package/lib/index.js +8 -1
- package/lib/utils/index.js +2 -1
- package/lib/utils/input.js +3 -1
- package/lib/utils/propTypes.js +103 -8
- package/lib/utils/spacing/index.js +2 -0
- package/lib/utils/spacing/useSpacingScale.js +102 -0
- package/lib/utils/spacing/utils.js +32 -0
- package/lib/utils/useUniqueId.js +12 -0
- package/package.json +6 -9
- package/release-context.json +4 -4
- package/src/Box/Box.jsx +117 -80
- package/src/Button/ButtonBase.jsx +8 -21
- package/src/Button/ButtonGroup.jsx +13 -17
- package/src/Card/Card.jsx +101 -0
- package/src/Card/index.js +3 -0
- package/src/Divider/Divider.jsx +38 -3
- package/src/ExpandCollapse/Control.jsx +2 -3
- package/src/Feedback/Feedback.jsx +99 -0
- package/src/Feedback/index.js +3 -0
- package/src/FlexGrid/Col/Col.jsx +4 -2
- package/src/Icon/Icon.jsx +2 -1
- package/src/InputLabel/InputLabel.jsx +99 -0
- package/src/InputLabel/LabelContent.native.jsx +6 -0
- package/src/InputLabel/LabelContent.web.jsx +13 -0
- package/src/InputLabel/index.js +3 -0
- package/src/Link/LinkBase.jsx +9 -3
- package/src/Pagination/PageButton.jsx +80 -0
- package/src/Pagination/Pagination.jsx +135 -0
- package/src/Pagination/SideButton.jsx +93 -0
- package/src/Pagination/dictionary.js +18 -0
- package/src/Pagination/index.js +3 -0
- package/src/Pagination/useCopy.js +7 -0
- package/src/Pagination/usePagination.js +69 -0
- package/src/SideNav/Item.jsx +3 -3
- package/src/SideNav/ItemsGroup.jsx +11 -13
- package/src/Spacer/Spacer.jsx +91 -0
- package/src/Spacer/index.js +3 -0
- package/src/StackView/StackView.jsx +103 -0
- package/src/StackView/StackWrap.jsx +33 -0
- package/src/StackView/StackWrap.native.jsx +4 -0
- package/src/StackView/StackWrapBox.jsx +82 -0
- package/src/StackView/StackWrapGap.jsx +39 -0
- package/src/StackView/common.jsx +28 -0
- package/src/StackView/getStackedContent.jsx +106 -0
- package/src/StackView/index.js +6 -0
- package/src/TextInput/TextInput.jsx +325 -0
- package/src/TextInput/index.js +3 -0
- package/src/ThemeProvider/useThemeTokens.js +34 -7
- package/src/ThemeProvider/utils/theme-tokens.js +37 -8
- package/src/ToggleSwitch/ToggleSwitch.jsx +23 -43
- package/src/Typography/Typography.jsx +0 -4
- package/src/index.js +8 -1
- package/src/utils/index.js +1 -0
- package/src/utils/input.js +2 -1
- package/src/utils/propTypes.js +105 -16
- package/src/utils/spacing/index.js +3 -0
- package/src/utils/spacing/useSpacingScale.js +93 -0
- package/src/utils/spacing/utils.js +28 -0
- package/src/utils/useUniqueId.js +14 -0
- package/stories/A11yText/A11yText.stories.jsx +11 -5
- package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +11 -2
- package/stories/Box/Box.stories.jsx +46 -17
- package/stories/Button/Button.stories.jsx +17 -21
- package/stories/Button/ButtonGroup.stories.jsx +2 -1
- package/stories/Button/ButtonLink.stories.jsx +6 -4
- package/stories/Card/Card.stories.jsx +62 -0
- package/stories/Divider/Divider.stories.jsx +26 -2
- package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +74 -79
- package/stories/Feedback/Feedback.stories.jsx +97 -0
- package/stories/FlexGrid/01 FlexGrid.stories.jsx +20 -7
- package/stories/Icon/Icon.stories.jsx +11 -3
- package/stories/InputLabel/InputLabel.stories.jsx +37 -0
- package/stories/Link/ChevronLink.stories.jsx +20 -4
- package/stories/Link/Link.stories.jsx +24 -3
- package/stories/Link/TextButton.stories.jsx +24 -3
- package/stories/Pagination/Pagination.stories.jsx +64 -0
- package/stories/SideNav/SideNav.stories.jsx +17 -2
- package/stories/Spacer/Spacer.stories.jsx +33 -0
- package/stories/StackView/StackView.stories.jsx +65 -0
- package/stories/StackView/StackWrap.stories.jsx +52 -0
- package/stories/TextInput/TextInput.stories.jsx +103 -0
- package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +16 -3
- package/stories/Typography/Typography.stories.jsx +12 -3
- package/stories/platform-supports.web.jsx +1 -1
- package/stories/supports.jsx +113 -13
- package/babel.config.js +0 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
1
2
|
import React from 'react'
|
|
2
3
|
import { ActivityIndicator } from '../../lib'
|
|
4
|
+
import { EachParentType, parentTypesParams } from '../supports'
|
|
3
5
|
|
|
4
6
|
export default {
|
|
5
7
|
title: 'Base/ActivityIndicator',
|
|
@@ -9,5 +11,12 @@ export default {
|
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
+
export const Default = (args) => <ActivityIndicator {...args} />
|
|
15
|
+
Default.storyName = 'ActivityIndicator'
|
|
16
|
+
|
|
17
|
+
export const ParentTypes = (args) => (
|
|
18
|
+
<EachParentType {...args}>
|
|
19
|
+
{({ label }) => <ActivityIndicator {...args} label={label} />}
|
|
20
|
+
</EachParentType>
|
|
21
|
+
)
|
|
22
|
+
ParentTypes.parameters = parentTypesParams
|
|
@@ -2,21 +2,26 @@
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
4
|
import { View, StyleSheet } from 'react-native'
|
|
5
|
-
import { Box } from '../../lib'
|
|
6
|
-
import {
|
|
5
|
+
import { Box, Typography } from '../../lib'
|
|
6
|
+
import {
|
|
7
|
+
spacingObjectArg,
|
|
8
|
+
Container,
|
|
9
|
+
Placeholder,
|
|
10
|
+
EachParentType,
|
|
11
|
+
parentTypesParams
|
|
12
|
+
} from '../supports'
|
|
7
13
|
|
|
8
14
|
export default {
|
|
9
15
|
title: 'Base/Box',
|
|
10
|
-
component: Box
|
|
11
|
-
parameters: {
|
|
12
|
-
padded: false
|
|
13
|
-
}
|
|
16
|
+
component: Box
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
const Template = (args) => (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
+
<Container margin={0} padding={0} borderWidth={1} offWhite>
|
|
21
|
+
<Box {...args}>
|
|
22
|
+
<Placeholder>Box</Placeholder>
|
|
23
|
+
</Box>
|
|
24
|
+
</Container>
|
|
20
25
|
)
|
|
21
26
|
|
|
22
27
|
const ScrollTemplate = (args) => (
|
|
@@ -68,39 +73,49 @@ const ScrollTemplate = (args) => (
|
|
|
68
73
|
</View>
|
|
69
74
|
)
|
|
70
75
|
|
|
71
|
-
const spacings = { xs: 2, sm: 4, md: 6, lg: 8, xl: 10 }
|
|
72
|
-
|
|
73
76
|
const styles = StyleSheet.create({
|
|
74
77
|
fixedHeight: { height: 200, overflow: 'hidden' }
|
|
75
78
|
})
|
|
79
|
+
|
|
80
|
+
export const Default = (args) => <Box {...args} />
|
|
81
|
+
Default.storyName = 'Box'
|
|
82
|
+
Default.args = { children: <Typography>Box</Typography> }
|
|
83
|
+
// By default the JSX object is shown as a huge human-unreadable JSON tree control; turn it off
|
|
84
|
+
Default.argTypes = { children: { control: { disable: true } } }
|
|
85
|
+
|
|
76
86
|
export const Top = Template.bind({})
|
|
77
87
|
Top.args = {
|
|
78
|
-
top:
|
|
88
|
+
top: spacingObjectArg
|
|
79
89
|
}
|
|
80
90
|
|
|
81
91
|
export const Bottom = Template.bind({})
|
|
82
92
|
Bottom.args = {
|
|
83
|
-
bottom:
|
|
93
|
+
bottom: spacingObjectArg
|
|
84
94
|
}
|
|
85
95
|
|
|
86
96
|
export const Left = Template.bind({})
|
|
87
97
|
Left.args = {
|
|
88
|
-
left:
|
|
98
|
+
left: spacingObjectArg
|
|
89
99
|
}
|
|
90
100
|
|
|
91
101
|
export const Right = Template.bind({})
|
|
92
102
|
Right.args = {
|
|
93
|
-
right:
|
|
103
|
+
right: spacingObjectArg
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
export const Horizontal = Template.bind({})
|
|
97
107
|
Horizontal.args = {
|
|
98
|
-
horizontal:
|
|
108
|
+
horizontal: spacingObjectArg
|
|
99
109
|
}
|
|
100
110
|
|
|
101
111
|
export const Vertical = Template.bind({})
|
|
102
112
|
Vertical.args = {
|
|
103
|
-
vertical:
|
|
113
|
+
vertical: spacingObjectArg
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const AllSides = Template.bind({})
|
|
117
|
+
AllSides.args = {
|
|
118
|
+
space: spacingObjectArg
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
export const Scroll = ScrollTemplate.bind({})
|
|
@@ -112,3 +127,17 @@ export const NoScroll = ScrollTemplate.bind({})
|
|
|
112
127
|
NoScroll.args = {
|
|
113
128
|
scroll: false
|
|
114
129
|
}
|
|
130
|
+
|
|
131
|
+
export const ParentTypes = (args) => (
|
|
132
|
+
<EachParentType componentThemeName="Box" {...args}>
|
|
133
|
+
{({ label, variant }) => (
|
|
134
|
+
<Container key={label} margin={0} padding={0} borderWidth={1} dark>
|
|
135
|
+
<Box {...args} variant={variant}>
|
|
136
|
+
<Placeholder>{label}</Placeholder>
|
|
137
|
+
</Box>
|
|
138
|
+
</Container>
|
|
139
|
+
)}
|
|
140
|
+
</EachParentType>
|
|
141
|
+
)
|
|
142
|
+
ParentTypes.args = { space: 2 }
|
|
143
|
+
ParentTypes.parameters = parentTypesParams
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
1
2
|
import React from 'react'
|
|
2
|
-
import { Button
|
|
3
|
-
import { Container, useVariants,
|
|
3
|
+
import { Button, useTheme } from '../../lib'
|
|
4
|
+
import { Container, useVariants, EachParentType, parentTypesParams } from '../supports'
|
|
4
5
|
import { getComponentTheme } from '../../lib/ThemeProvider/utils'
|
|
5
6
|
|
|
6
|
-
export const
|
|
7
|
+
export const Default = (args) => <Button {...args} />
|
|
8
|
+
Default.storyName = 'Button'
|
|
7
9
|
|
|
8
10
|
const defaultLabel = "I'm a button"
|
|
9
11
|
|
|
@@ -14,7 +16,8 @@ export default {
|
|
|
14
16
|
// eslint-disable-next-line no-console
|
|
15
17
|
onPress: () => console.log('Button pressed'),
|
|
16
18
|
children: defaultLabel,
|
|
17
|
-
variant: {} // @TODO work out why this isn't coming from jsdoc
|
|
19
|
+
variant: {}, // @TODO work out why this isn't coming from jsdoc
|
|
20
|
+
tokens: {}
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -52,20 +55,13 @@ LongLabelButtonVariants.args = {
|
|
|
52
55
|
children: 'This button has a label that is much longer than is considered advisable'
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
export const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
</Button>
|
|
66
|
-
)
|
|
67
|
-
})}
|
|
68
|
-
</ParentType>
|
|
69
|
-
</Container>
|
|
70
|
-
))
|
|
71
|
-
}
|
|
58
|
+
export const ParentTypes = (args) => (
|
|
59
|
+
<EachParentType componentThemeName="Button" {...args}>
|
|
60
|
+
{({ label, variant }) => (
|
|
61
|
+
<Button {...args} key={label} variant={variant}>
|
|
62
|
+
{label}
|
|
63
|
+
</Button>
|
|
64
|
+
)}
|
|
65
|
+
</EachParentType>
|
|
66
|
+
)
|
|
67
|
+
ParentTypes.parameters = parentTypesParams
|
|
@@ -59,7 +59,8 @@ const ControlledTemplate = ({ values, ...args }) => {
|
|
|
59
59
|
|
|
60
60
|
ControlledTemplate.propTypes = ButtonGroup.propTypes
|
|
61
61
|
|
|
62
|
-
export const
|
|
62
|
+
export const Default = UncontrolledTemplate.bind({})
|
|
63
|
+
Default.storyName = 'ButtonGroup'
|
|
63
64
|
|
|
64
65
|
export const ButtonGroupMaxThree = UncontrolledTemplate.bind({})
|
|
65
66
|
ButtonGroupMaxThree.args = { maxValues: 3 }
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
title: 'Base/ButtonLink',
|
|
7
7
|
component: ButtonLink,
|
|
8
8
|
args: {
|
|
9
|
-
|
|
9
|
+
children: "I'm a button link",
|
|
10
10
|
href: 'https://telus.com',
|
|
11
11
|
target: '_blank',
|
|
12
12
|
rel: 'nofollow'
|
|
@@ -18,11 +18,13 @@ const Template = (args) => {
|
|
|
18
18
|
return variants.map(([key, value, label]) => (
|
|
19
19
|
<Container key={`${key}:${value}`} dark={key === 'inverse'}>
|
|
20
20
|
<ButtonLink {...args} href="https://telus.com" variant={{ [key]: value }}>
|
|
21
|
-
{args.label || `
|
|
21
|
+
{args.label || `ButtonLink ${label}`}
|
|
22
22
|
</ButtonLink>
|
|
23
23
|
</Container>
|
|
24
24
|
))
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
28
|
-
|
|
27
|
+
export const Default = (args) => <ButtonLink {...args} />
|
|
28
|
+
Default.storyName = 'ButtonLink'
|
|
29
|
+
|
|
30
|
+
export const Variants = Template.bind({})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { StyleSheet, Text, View } from 'react-native'
|
|
4
|
+
|
|
5
|
+
import { Card } from '../../lib'
|
|
6
|
+
import { Container, useVariants, EachParentType, parentTypesParams } from '../supports'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Base/Card',
|
|
10
|
+
component: Card
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
cardContent: {
|
|
15
|
+
padding: 4,
|
|
16
|
+
borderWidth: 1,
|
|
17
|
+
borderColor: '#C12335',
|
|
18
|
+
borderStyle: 'dashed',
|
|
19
|
+
backgroundColor: '#FFF6F8'
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export const Default = (args) => (
|
|
24
|
+
<Card {...args}>
|
|
25
|
+
<View style={styles.cardContent}>
|
|
26
|
+
<Text>This is a card</Text>
|
|
27
|
+
</View>
|
|
28
|
+
</Card>
|
|
29
|
+
)
|
|
30
|
+
Default.storyName = 'Card'
|
|
31
|
+
Default.argTypes = {
|
|
32
|
+
children: { table: { disable: true } }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const CardVariants = (args) => {
|
|
36
|
+
const variants = useVariants('Card')
|
|
37
|
+
const cardVariants = variants.map(([key, value, label]) => (
|
|
38
|
+
<Container key={`${key}:${value}`} padding={16}>
|
|
39
|
+
<Card {...args} variant={{ [key]: value }}>
|
|
40
|
+
<View style={styles.cardContent}>
|
|
41
|
+
<Text>
|
|
42
|
+
Card with
|
|
43
|
+
{` ${label}`}
|
|
44
|
+
</Text>
|
|
45
|
+
</View>
|
|
46
|
+
</Card>
|
|
47
|
+
</Container>
|
|
48
|
+
))
|
|
49
|
+
|
|
50
|
+
return cardVariants
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const ParentTypes = (args) => (
|
|
54
|
+
<EachParentType componentThemeName="Card" {...args}>
|
|
55
|
+
{({ label, variant }) => (
|
|
56
|
+
<Card {...args} variant={variant}>
|
|
57
|
+
<Text>{label}</Text>
|
|
58
|
+
</Card>
|
|
59
|
+
)}
|
|
60
|
+
</EachParentType>
|
|
61
|
+
)
|
|
62
|
+
ParentTypes.parameters = parentTypesParams
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
1
2
|
import React from 'react'
|
|
2
3
|
import { View, StyleSheet } from 'react-native'
|
|
3
4
|
import { Divider, Typography } from '../../lib'
|
|
5
|
+
import { EachParentType, parentTypesParams } from '../supports'
|
|
4
6
|
|
|
5
7
|
export default {
|
|
6
8
|
title: 'Base/Divider',
|
|
7
9
|
component: Divider
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
export const Default = (args) => <Divider {...args} />
|
|
13
|
+
Default.storyName = 'Divider'
|
|
14
|
+
|
|
10
15
|
const Template = ({ vertical, ...rest }) => (
|
|
11
16
|
<View style={vertical ? styles.row : styles.column}>
|
|
12
17
|
<View style={vertical ? styles.contentRow : styles.contentColumn}>
|
|
@@ -24,8 +29,27 @@ const Template = ({ vertical, ...rest }) => (
|
|
|
24
29
|
|
|
25
30
|
Template.propTypes = Divider.propTypes
|
|
26
31
|
|
|
27
|
-
export const
|
|
28
|
-
|
|
32
|
+
export const Horizontal = Template.bind({})
|
|
33
|
+
|
|
34
|
+
export const Vertical = Template.bind({})
|
|
35
|
+
Vertical.args = { vertical: true }
|
|
36
|
+
|
|
37
|
+
export const ParentTypes = (args) => (
|
|
38
|
+
<EachParentType componentThemeName="Divider" {...args}>
|
|
39
|
+
{({ label, variant, index }) =>
|
|
40
|
+
label.match(/Row/) ? (
|
|
41
|
+
<Typography>{index ? '' : 'Skipping Row examples; see Vertical story. '}</Typography>
|
|
42
|
+
) : (
|
|
43
|
+
<>
|
|
44
|
+
<Typography>{`"${label}" is below this moderately lengthy text appearing before the Divider.`}</Typography>
|
|
45
|
+
<Divider {...args} variant={variant} />
|
|
46
|
+
<Typography>{`"${label}" is above.`}</Typography>
|
|
47
|
+
</>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
</EachParentType>
|
|
51
|
+
)
|
|
52
|
+
ParentTypes.parameters = parentTypesParams
|
|
29
53
|
|
|
30
54
|
const styles = StyleSheet.create({
|
|
31
55
|
row: {
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react/no-multi-comp */
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
ButtonGroup,
|
|
7
|
-
Divider,
|
|
8
|
-
ExpandCollapse,
|
|
9
|
-
Typography
|
|
10
|
-
} from '../../lib'
|
|
11
|
-
import { Container } from '../supports'
|
|
4
|
+
import { Accordion, ButtonGroup, ExpandCollapse, StackView, Typography } from '../../lib'
|
|
5
|
+
import { Container, EachParentType, parentTypesParams } from '../supports'
|
|
12
6
|
import { useMultipleInputValues } from '../../lib/utils'
|
|
13
7
|
|
|
14
8
|
export default {
|
|
@@ -27,48 +21,42 @@ SimpleText.propTypes = {
|
|
|
27
21
|
children: PropTypes.node
|
|
28
22
|
}
|
|
29
23
|
|
|
30
|
-
const
|
|
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
|
-
panelId="third"
|
|
59
|
-
control={<SimpleText bold>Last panel</SimpleText>}
|
|
60
|
-
>
|
|
61
|
-
<SimpleText>Some content within the last panel</SimpleText>
|
|
62
|
-
</ExpandCollapse.Panel>
|
|
63
|
-
</>
|
|
64
|
-
)}
|
|
65
|
-
</ExpandComponent>
|
|
66
|
-
)
|
|
67
|
-
return Template
|
|
68
|
-
}
|
|
24
|
+
const exampleRenderFunction = (expandProps, label = 'Non-interactive item') => (
|
|
25
|
+
<StackView divider space={2}>
|
|
26
|
+
<ExpandCollapse.Panel
|
|
27
|
+
{...expandProps}
|
|
28
|
+
panelId="first"
|
|
29
|
+
control={<SimpleText bold>First panel</SimpleText>}
|
|
30
|
+
>
|
|
31
|
+
<SimpleText>Some content within the first panel</SimpleText>
|
|
32
|
+
</ExpandCollapse.Panel>
|
|
33
|
+
<ExpandCollapse.Panel
|
|
34
|
+
{...expandProps}
|
|
35
|
+
panelId="second"
|
|
36
|
+
control={<SimpleText bold>Second panel</SimpleText>}
|
|
37
|
+
>
|
|
38
|
+
<SimpleText>Some content within the second panel</SimpleText>
|
|
39
|
+
</ExpandCollapse.Panel>
|
|
40
|
+
<Container>
|
|
41
|
+
<SimpleText>{label}</SimpleText>
|
|
42
|
+
</Container>
|
|
43
|
+
<ExpandCollapse.Panel
|
|
44
|
+
{...expandProps}
|
|
45
|
+
panelId="third"
|
|
46
|
+
control={<SimpleText bold>Last panel</SimpleText>}
|
|
47
|
+
>
|
|
48
|
+
<SimpleText>Some content within the last panel</SimpleText>
|
|
49
|
+
</ExpandCollapse.Panel>
|
|
50
|
+
</StackView>
|
|
51
|
+
)
|
|
69
52
|
|
|
70
|
-
export const Default =
|
|
71
|
-
|
|
53
|
+
export const Default = (args) => <ExpandCollapse {...args} />
|
|
54
|
+
Default.storyName = 'ExpandCollapse'
|
|
55
|
+
Default.args = { children: exampleRenderFunction }
|
|
56
|
+
|
|
57
|
+
export const AccordionStory = (args) => <Accordion {...args} />
|
|
58
|
+
AccordionStory.storyName = 'Accordion'
|
|
59
|
+
AccordionStory.args = { children: exampleRenderFunction }
|
|
72
60
|
|
|
73
61
|
// This is an edge case but TDS's ExpandCollapse only worked in this externally-controlled
|
|
74
62
|
// way, so supporting it cleanly will make transition easier at low cost. Button group
|
|
@@ -79,39 +67,46 @@ export const Controlled = ({ maxOpen = null, ...args }) => {
|
|
|
79
67
|
})
|
|
80
68
|
const itemNames = ['one', 'two', 'three', 'four']
|
|
81
69
|
return (
|
|
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
|
-
</ExpandCollapse>
|
|
110
|
-
</Container>
|
|
111
|
-
</>
|
|
70
|
+
<StackView space={6}>
|
|
71
|
+
<ButtonGroup
|
|
72
|
+
items={itemNames.map((item) => ({
|
|
73
|
+
label: item
|
|
74
|
+
}))}
|
|
75
|
+
maxValues={null}
|
|
76
|
+
values={currentValues}
|
|
77
|
+
onChange={setValues}
|
|
78
|
+
/>
|
|
79
|
+
<ExpandCollapse {...args} open={currentValues} onChange={setValues} maxValues={maxOpen}>
|
|
80
|
+
{(expandProps) => (
|
|
81
|
+
<StackView divider>
|
|
82
|
+
{itemNames.map((itemName) => (
|
|
83
|
+
<ExpandCollapse.Panel
|
|
84
|
+
{...expandProps}
|
|
85
|
+
key={itemName}
|
|
86
|
+
panelId={itemName}
|
|
87
|
+
control={<SimpleText bold>{itemName}</SimpleText>}
|
|
88
|
+
>
|
|
89
|
+
<SimpleText>{`Some content within panel number ${itemName}`}</SimpleText>
|
|
90
|
+
</ExpandCollapse.Panel>
|
|
91
|
+
))}
|
|
92
|
+
</StackView>
|
|
93
|
+
)}
|
|
94
|
+
</ExpandCollapse>
|
|
95
|
+
</StackView>
|
|
112
96
|
)
|
|
113
97
|
}
|
|
114
98
|
Controlled.propTypes = {
|
|
115
99
|
maxOpen: PropTypes.number
|
|
116
100
|
}
|
|
117
101
|
Controlled.args = {}
|
|
102
|
+
|
|
103
|
+
export const ParentTypes = (args) => (
|
|
104
|
+
<EachParentType componentThemeName="ExpandCollapse" {...args}>
|
|
105
|
+
{({ label, variant }) => (
|
|
106
|
+
<ExpandCollapse {...args} variant={variant}>
|
|
107
|
+
{(expandProps) => exampleRenderFunction(expandProps, label)}
|
|
108
|
+
</ExpandCollapse>
|
|
109
|
+
)}
|
|
110
|
+
</EachParentType>
|
|
111
|
+
)
|
|
112
|
+
ParentTypes.parameters = parentTypesParams
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Text } from 'react-native'
|
|
3
|
+
|
|
4
|
+
import { Feedback, Typography } from '../../lib'
|
|
5
|
+
import { Container } from '../supports'
|
|
6
|
+
import TextInput from '../../lib/TextInput'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Base/Feedback',
|
|
10
|
+
component: Feedback
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* eslint-disable react/no-multi-comp */
|
|
14
|
+
|
|
15
|
+
const Template = (args) => (
|
|
16
|
+
<Container>
|
|
17
|
+
<Feedback {...args} />
|
|
18
|
+
</Container>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
export const Default = Template.bind({})
|
|
22
|
+
Default.args = { title: 'Title', children: 'String content' }
|
|
23
|
+
Default.storyName = 'Feedback'
|
|
24
|
+
|
|
25
|
+
export const RenderFunctionAndChildren = () => (
|
|
26
|
+
<>
|
|
27
|
+
<Container>
|
|
28
|
+
<Feedback title="Render function">
|
|
29
|
+
{({ textStyles }) => <Text style={textStyles}>Content from function</Text>}
|
|
30
|
+
</Feedback>
|
|
31
|
+
</Container>
|
|
32
|
+
<Container>
|
|
33
|
+
<Feedback title="Children">
|
|
34
|
+
<Typography>Content from children</Typography>
|
|
35
|
+
</Feedback>
|
|
36
|
+
</Container>
|
|
37
|
+
</>
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
export const Variants = () => (
|
|
41
|
+
<>
|
|
42
|
+
<Container>
|
|
43
|
+
<Feedback variant={{ state: 'success' }} title="Success">
|
|
44
|
+
{({ textStyles }) => <Text style={textStyles}>Content from function</Text>}
|
|
45
|
+
</Feedback>
|
|
46
|
+
</Container>
|
|
47
|
+
<Container>
|
|
48
|
+
<Feedback variant={{ state: 'success', icon: true }} title="Success with icon">
|
|
49
|
+
{({ textStyles }) => <Text style={textStyles}>Content from function</Text>}
|
|
50
|
+
</Feedback>
|
|
51
|
+
</Container>
|
|
52
|
+
<Container>
|
|
53
|
+
<Feedback variant={{ state: 'error' }} title="Error">
|
|
54
|
+
{({ textStyles }) => <Text style={textStyles}>Content from function</Text>}
|
|
55
|
+
</Feedback>
|
|
56
|
+
</Container>
|
|
57
|
+
<Container>
|
|
58
|
+
<Feedback variant={{ state: 'error', icon: true }} title="Error with icon">
|
|
59
|
+
{({ textStyles }) => <Text style={textStyles}>Content from function</Text>}
|
|
60
|
+
</Feedback>
|
|
61
|
+
</Container>
|
|
62
|
+
</>
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
export const WithinInput = () => {
|
|
66
|
+
const [value, setValue] = useState('')
|
|
67
|
+
const [validation, setValidation] = useState()
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (value !== undefined && value.length > 0)
|
|
71
|
+
setValidation(value.length < 6 ? 'success' : 'error')
|
|
72
|
+
}, [value])
|
|
73
|
+
|
|
74
|
+
const defaultFeedbackContent =
|
|
75
|
+
'Will show an error if longer than 6 characters and success otherwise'
|
|
76
|
+
|
|
77
|
+
const feedbackContent = {
|
|
78
|
+
error: 'The value must be shorter than 6 characters',
|
|
79
|
+
success: 'Yay! The value has less than 6 characters'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const feedback = validation === undefined ? defaultFeedbackContent : feedbackContent[validation]
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<Container>
|
|
87
|
+
<TextInput
|
|
88
|
+
label="Controlled"
|
|
89
|
+
validation={validation}
|
|
90
|
+
feedback={feedback}
|
|
91
|
+
value={value}
|
|
92
|
+
onChange={setValue}
|
|
93
|
+
/>
|
|
94
|
+
</Container>
|
|
95
|
+
</>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
1
2
|
import React from 'react'
|
|
2
3
|
|
|
3
4
|
import { FlexGrid } from '../../lib'
|
|
4
|
-
import { Placeholder } from '../supports'
|
|
5
|
+
import { Placeholder, EachParentType, parentTypesParams } from '../supports'
|
|
5
6
|
|
|
6
7
|
const { Row, Col } = FlexGrid
|
|
7
8
|
|
|
@@ -10,11 +11,11 @@ export default {
|
|
|
10
11
|
component: FlexGrid
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
|
|
14
|
+
const getContent = (label = '1/6') => (
|
|
15
|
+
<>
|
|
15
16
|
<Row>
|
|
16
17
|
<Col>
|
|
17
|
-
<Placeholder margin>
|
|
18
|
+
<Placeholder margin>{label}</Placeholder>
|
|
18
19
|
</Col>
|
|
19
20
|
<Col>
|
|
20
21
|
<Placeholder margin>2/6</Placeholder>
|
|
@@ -34,8 +35,20 @@ const Template = (args) => (
|
|
|
34
35
|
<Placeholder margin>6/6</Placeholder>
|
|
35
36
|
</Col>
|
|
36
37
|
</Row>
|
|
37
|
-
|
|
38
|
+
</>
|
|
38
39
|
)
|
|
39
40
|
|
|
40
|
-
export const
|
|
41
|
-
|
|
41
|
+
export const Default = (args) => <FlexGrid {...args} />
|
|
42
|
+
Default.storyName = 'FlexGrid'
|
|
43
|
+
Default.args = { children: getContent() }
|
|
44
|
+
|
|
45
|
+
export const ParentTypes = (args) => (
|
|
46
|
+
<EachParentType {...args}>
|
|
47
|
+
{({ label, variant }) => (
|
|
48
|
+
<FlexGrid {...args} variant={variant}>
|
|
49
|
+
{getContent(label)}
|
|
50
|
+
</FlexGrid>
|
|
51
|
+
)}
|
|
52
|
+
</EachParentType>
|
|
53
|
+
)
|
|
54
|
+
ParentTypes.parameters = parentTypesParams
|