@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.
Files changed (161) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/__fixtures__/testTheme.js +264 -84
  3. package/__tests__/Box/Box.test.jsx +81 -58
  4. package/__tests__/Card/Card.test.jsx +63 -0
  5. package/__tests__/Divider/Divider.test.jsx +26 -5
  6. package/__tests__/Feedback/Feedback.test.jsx +42 -0
  7. package/__tests__/FlexGrid/Col.test.jsx +5 -0
  8. package/__tests__/Pagination/Pagination.test.jsx +160 -0
  9. package/__tests__/Spacer/Spacer.test.jsx +63 -0
  10. package/__tests__/StackView/StackView.test.jsx +242 -0
  11. package/__tests__/StackView/StackWrap.test.jsx +47 -0
  12. package/__tests__/StackView/getStackedContent.test.jsx +295 -0
  13. package/__tests__/TextInput/TextInput.test.jsx +146 -0
  14. package/__tests__/ThemeProvider/useThemeTokens.test.jsx +5 -3
  15. package/__tests__/utils/spacing.test.jsx +273 -0
  16. package/__tests__/utils/useUniqueId.test.js +31 -0
  17. package/babel.config.json +8 -0
  18. package/jest.config.js +7 -6
  19. package/lib/A11yInfoProvider/index.js +2 -2
  20. package/lib/A11yText/index.js +1 -3
  21. package/lib/ActivityIndicator/Spinner.web.js +3 -5
  22. package/lib/Box/Box.js +117 -82
  23. package/lib/Button/Button.js +1 -3
  24. package/lib/Button/ButtonBase.js +9 -21
  25. package/lib/Button/ButtonGroup.js +14 -25
  26. package/lib/Button/ButtonLink.js +1 -3
  27. package/lib/Card/Card.js +103 -0
  28. package/lib/Card/index.js +2 -0
  29. package/lib/Divider/Divider.js +40 -4
  30. package/lib/ExpandCollapse/Accordion.js +1 -3
  31. package/lib/ExpandCollapse/Control.js +3 -5
  32. package/lib/ExpandCollapse/Panel.js +2 -4
  33. package/lib/Feedback/Feedback.js +110 -0
  34. package/lib/Feedback/index.js +2 -0
  35. package/lib/FlexGrid/Col/Col.js +3 -5
  36. package/lib/FlexGrid/FlexGrid.js +1 -3
  37. package/lib/FlexGrid/Row/Row.js +1 -3
  38. package/lib/FlexGrid/providers/GutterContext.js +1 -1
  39. package/lib/Icon/Icon.js +1 -1
  40. package/lib/InputLabel/InputLabel.js +86 -0
  41. package/lib/InputLabel/LabelContent.native.js +8 -0
  42. package/lib/InputLabel/LabelContent.web.js +17 -0
  43. package/lib/InputLabel/index.js +2 -0
  44. package/lib/Link/ChevronLink.js +1 -3
  45. package/lib/Link/Link.js +1 -3
  46. package/lib/Link/LinkBase.js +11 -7
  47. package/lib/Link/TextButton.js +1 -3
  48. package/lib/Pagination/PageButton.js +85 -0
  49. package/lib/Pagination/Pagination.js +118 -0
  50. package/lib/Pagination/SideButton.js +108 -0
  51. package/lib/Pagination/dictionary.js +18 -0
  52. package/lib/Pagination/index.js +2 -0
  53. package/lib/Pagination/useCopy.js +10 -0
  54. package/lib/Pagination/usePagination.js +70 -0
  55. package/lib/SideNav/Item.js +4 -6
  56. package/lib/SideNav/ItemsGroup.js +11 -11
  57. package/lib/SideNav/SideNav.js +2 -4
  58. package/lib/Spacer/Spacer.js +98 -0
  59. package/lib/Spacer/index.js +2 -0
  60. package/lib/StackView/StackView.js +105 -0
  61. package/lib/StackView/StackWrap.js +32 -0
  62. package/lib/StackView/StackWrap.native.js +3 -0
  63. package/lib/StackView/StackWrapBox.js +85 -0
  64. package/lib/StackView/StackWrapGap.js +45 -0
  65. package/lib/StackView/common.js +30 -0
  66. package/lib/StackView/getStackedContent.js +111 -0
  67. package/lib/StackView/index.js +5 -0
  68. package/lib/TextInput/TextInput.js +337 -0
  69. package/lib/TextInput/index.js +2 -0
  70. package/lib/ThemeProvider/ThemeProvider.js +2 -2
  71. package/lib/ThemeProvider/useThemeTokens.js +34 -6
  72. package/lib/ThemeProvider/utils/theme-tokens.js +37 -9
  73. package/lib/ToggleSwitch/ToggleSwitch.js +17 -47
  74. package/lib/Typography/Typography.js +1 -7
  75. package/lib/ViewportProvider/index.js +1 -1
  76. package/lib/index.js +8 -1
  77. package/lib/utils/index.js +2 -1
  78. package/lib/utils/input.js +3 -1
  79. package/lib/utils/propTypes.js +103 -8
  80. package/lib/utils/spacing/index.js +2 -0
  81. package/lib/utils/spacing/useSpacingScale.js +102 -0
  82. package/lib/utils/spacing/utils.js +32 -0
  83. package/lib/utils/useUniqueId.js +12 -0
  84. package/package.json +6 -9
  85. package/release-context.json +4 -4
  86. package/src/Box/Box.jsx +117 -80
  87. package/src/Button/ButtonBase.jsx +8 -21
  88. package/src/Button/ButtonGroup.jsx +13 -17
  89. package/src/Card/Card.jsx +101 -0
  90. package/src/Card/index.js +3 -0
  91. package/src/Divider/Divider.jsx +38 -3
  92. package/src/ExpandCollapse/Control.jsx +2 -3
  93. package/src/Feedback/Feedback.jsx +99 -0
  94. package/src/Feedback/index.js +3 -0
  95. package/src/FlexGrid/Col/Col.jsx +4 -2
  96. package/src/Icon/Icon.jsx +2 -1
  97. package/src/InputLabel/InputLabel.jsx +99 -0
  98. package/src/InputLabel/LabelContent.native.jsx +6 -0
  99. package/src/InputLabel/LabelContent.web.jsx +13 -0
  100. package/src/InputLabel/index.js +3 -0
  101. package/src/Link/LinkBase.jsx +9 -3
  102. package/src/Pagination/PageButton.jsx +80 -0
  103. package/src/Pagination/Pagination.jsx +135 -0
  104. package/src/Pagination/SideButton.jsx +93 -0
  105. package/src/Pagination/dictionary.js +18 -0
  106. package/src/Pagination/index.js +3 -0
  107. package/src/Pagination/useCopy.js +7 -0
  108. package/src/Pagination/usePagination.js +69 -0
  109. package/src/SideNav/Item.jsx +3 -3
  110. package/src/SideNav/ItemsGroup.jsx +11 -13
  111. package/src/Spacer/Spacer.jsx +91 -0
  112. package/src/Spacer/index.js +3 -0
  113. package/src/StackView/StackView.jsx +103 -0
  114. package/src/StackView/StackWrap.jsx +33 -0
  115. package/src/StackView/StackWrap.native.jsx +4 -0
  116. package/src/StackView/StackWrapBox.jsx +82 -0
  117. package/src/StackView/StackWrapGap.jsx +39 -0
  118. package/src/StackView/common.jsx +28 -0
  119. package/src/StackView/getStackedContent.jsx +106 -0
  120. package/src/StackView/index.js +6 -0
  121. package/src/TextInput/TextInput.jsx +325 -0
  122. package/src/TextInput/index.js +3 -0
  123. package/src/ThemeProvider/useThemeTokens.js +34 -7
  124. package/src/ThemeProvider/utils/theme-tokens.js +37 -8
  125. package/src/ToggleSwitch/ToggleSwitch.jsx +23 -43
  126. package/src/Typography/Typography.jsx +0 -4
  127. package/src/index.js +8 -1
  128. package/src/utils/index.js +1 -0
  129. package/src/utils/input.js +2 -1
  130. package/src/utils/propTypes.js +105 -16
  131. package/src/utils/spacing/index.js +3 -0
  132. package/src/utils/spacing/useSpacingScale.js +93 -0
  133. package/src/utils/spacing/utils.js +28 -0
  134. package/src/utils/useUniqueId.js +14 -0
  135. package/stories/A11yText/A11yText.stories.jsx +11 -5
  136. package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +11 -2
  137. package/stories/Box/Box.stories.jsx +46 -17
  138. package/stories/Button/Button.stories.jsx +17 -21
  139. package/stories/Button/ButtonGroup.stories.jsx +2 -1
  140. package/stories/Button/ButtonLink.stories.jsx +6 -4
  141. package/stories/Card/Card.stories.jsx +62 -0
  142. package/stories/Divider/Divider.stories.jsx +26 -2
  143. package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +74 -79
  144. package/stories/Feedback/Feedback.stories.jsx +97 -0
  145. package/stories/FlexGrid/01 FlexGrid.stories.jsx +20 -7
  146. package/stories/Icon/Icon.stories.jsx +11 -3
  147. package/stories/InputLabel/InputLabel.stories.jsx +37 -0
  148. package/stories/Link/ChevronLink.stories.jsx +20 -4
  149. package/stories/Link/Link.stories.jsx +24 -3
  150. package/stories/Link/TextButton.stories.jsx +24 -3
  151. package/stories/Pagination/Pagination.stories.jsx +64 -0
  152. package/stories/SideNav/SideNav.stories.jsx +17 -2
  153. package/stories/Spacer/Spacer.stories.jsx +33 -0
  154. package/stories/StackView/StackView.stories.jsx +65 -0
  155. package/stories/StackView/StackWrap.stories.jsx +52 -0
  156. package/stories/TextInput/TextInput.stories.jsx +103 -0
  157. package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +16 -3
  158. package/stories/Typography/Typography.stories.jsx +12 -3
  159. package/stories/platform-supports.web.jsx +1 -1
  160. package/stories/supports.jsx +113 -13
  161. package/babel.config.js +0 -3
@@ -1,7 +1,8 @@
1
+ /* eslint-disable react/no-multi-comp */
1
2
  import React from 'react'
2
3
  import { StyleSheet, Text } from 'react-native'
3
4
  import AccessibleIcon from '../../__fixtures__/accessible.icon.svg'
4
- import { Container, useVariants } from '../supports'
5
+ import { Container, useVariants, EachParentType, parentTypesParams } from '../supports'
5
6
 
6
7
  export default {
7
8
  title: 'Base/Icon',
@@ -29,7 +30,9 @@ export default {
29
30
  }
30
31
  }
31
32
 
32
- const Template = (args) => {
33
+ export const ExampleIcon = (args) => <AccessibleIcon {...args} />
34
+
35
+ export const IconVariants = (args) => {
33
36
  const variants = useVariants('Icon')
34
37
  return variants.map(([key, value, label]) => (
35
38
  <Container key={label} dark={value === 'white'}>
@@ -39,7 +42,12 @@ const Template = (args) => {
39
42
  ))
40
43
  }
41
44
 
42
- export const Icon = Template.bind({})
45
+ export const ParentTypes = (args) => (
46
+ <EachParentType {...args}>
47
+ {({ label }) => <AccessibleIcon {...args} label={label} />}
48
+ </EachParentType>
49
+ )
50
+ ParentTypes.parameters = parentTypesParams
43
51
 
44
52
  const styles = StyleSheet.create({
45
53
  subtle: {
@@ -0,0 +1,37 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React from 'react'
3
+
4
+ import InputLabel from '../../lib/InputLabel/InputLabel'
5
+
6
+ export default {
7
+ title: 'Base/InputLabel',
8
+ component: InputLabel
9
+ }
10
+
11
+ export const Default = () => <InputLabel label="Test label" />
12
+
13
+ export const HintInline = () => (
14
+ <InputLabel label="Test label" hint="Short hint" hintPosition="inline" />
15
+ )
16
+
17
+ export const HintAndTooltip = () => (
18
+ <InputLabel label="Test label" hint="Short hint" hintPosition="inline" tooltip="?" />
19
+ )
20
+
21
+ export const HintInlineLong = () => (
22
+ <InputLabel
23
+ label="Test label"
24
+ hint="A rather long hint that won't actually fit"
25
+ hintPosition="inline"
26
+ tooltip="?"
27
+ />
28
+ )
29
+
30
+ export const HintBelow = () => (
31
+ <InputLabel
32
+ label="Test label"
33
+ hint="A rather long hint that won't actually fit"
34
+ hintPosition="below"
35
+ tooltip="?"
36
+ />
37
+ )
@@ -1,7 +1,8 @@
1
+ /* eslint-disable react/no-multi-comp */
1
2
  import React from 'react'
2
3
 
3
4
  import { ChevronLink } from '../../lib'
4
- import { Container, useVariants } from '../supports'
5
+ import { Container, EachParentType, parentTypesParams, useVariants } from '../supports'
5
6
 
6
7
  export default {
7
8
  title: 'Base/ChevronLink',
@@ -26,7 +27,22 @@ const Template = (args) => {
26
27
  .filter((exists) => exists)
27
28
  }
28
29
 
29
- export const ChevronLinkRight = Template.bind({})
30
+ export const Default = (args) => <ChevronLink {...args} />
31
+ Default.storyName = 'ChevronLink'
32
+ Default.args = { children: "I'm a chevron link" }
30
33
 
31
- export const ChevronLinkLeft = Template.bind({})
32
- ChevronLinkLeft.args = { direction: 'left' }
34
+ export const VariantsRight = Template.bind({})
35
+
36
+ export const VariantsLeft = Template.bind({})
37
+ VariantsLeft.args = { direction: 'left' }
38
+
39
+ export const ParentTypes = (args) => (
40
+ <EachParentType componentThemeName="Link" {...args}>
41
+ {({ label, variant }) => (
42
+ <ChevronLink {...args} variant={variant}>
43
+ {label}
44
+ </ChevronLink>
45
+ )}
46
+ </EachParentType>
47
+ )
48
+ ParentTypes.parameters = parentTypesParams
@@ -1,4 +1,4 @@
1
- /* eslint-disable react/jsx-one-expression-per-line */
1
+ /* eslint-disable react/no-multi-comp */
2
2
  import React from 'react'
3
3
  import { View } from 'react-native'
4
4
 
@@ -7,7 +7,7 @@ import { View } from 'react-native'
7
7
  import * as Icons from '@telus-uds/palette-allium/build/rn/icons'
8
8
 
9
9
  import { Link, variantProp } from '../../lib'
10
- import { Container, useVariants } from '../supports'
10
+ import { Container, EachParentType, parentTypesParams, useVariants } from '../supports'
11
11
 
12
12
  export default {
13
13
  title: 'Base/Link',
@@ -48,7 +48,11 @@ const EveryIconTemplate = (args) => (
48
48
  </View>
49
49
  )
50
50
 
51
- export const Regular = Template.bind({})
51
+ export const Default = (args) => <Link {...args} />
52
+ Default.storyName = 'Link'
53
+ Default.args = { children: "I'm a link" }
54
+
55
+ export const Variants = Template.bind({})
52
56
 
53
57
  export const IconLeft = Template.bind({})
54
58
  IconLeft.args = { icon: SampleIcon, iconPosition: 'left' }
@@ -57,3 +61,20 @@ export const IconRight = Template.bind({})
57
61
  IconRight.args = { icon: SampleIcon, iconPosition: 'right' }
58
62
 
59
63
  export const EveryIcon = EveryIconTemplate.bind({})
64
+
65
+ export const ParentTypes = (args) => (
66
+ <EachParentType componentThemeName="Link" {...args}>
67
+ {({ label, variant }) => (
68
+ <Link {...args} key={label} variant={variant}>
69
+ {label}
70
+ </Link>
71
+ )}
72
+ </EachParentType>
73
+ )
74
+ ParentTypes.parameters = parentTypesParams
75
+
76
+ export const IconLeftParentTypes = ParentTypes.bind({})
77
+ IconLeftParentTypes.args = { ...IconLeft.args }
78
+
79
+ export const IconRightParentTypes = ParentTypes.bind({})
80
+ IconRightParentTypes.args = { ...IconRight.args }
@@ -1,4 +1,4 @@
1
- /* eslint-disable react/jsx-one-expression-per-line */
1
+ /* eslint-disable react/no-multi-comp */
2
2
  import React from 'react'
3
3
  import { View } from 'react-native'
4
4
 
@@ -7,7 +7,7 @@ import { View } from 'react-native'
7
7
  import * as Icons from '@telus-uds/palette-allium/build/rn/icons'
8
8
 
9
9
  import { TextButton, variantProp } from '../../lib'
10
- import { Container, useVariants } from '../supports'
10
+ import { Container, EachParentType, useVariants, parentTypesParams } from '../supports'
11
11
 
12
12
  export default {
13
13
  title: 'Base/TextButton',
@@ -47,7 +47,11 @@ const EveryIconTemplate = (args) => (
47
47
  </View>
48
48
  )
49
49
 
50
- export const Regular = Template.bind({})
50
+ export const Default = (args) => <TextButton {...args} />
51
+ Default.storyName = 'TextButton'
52
+ Default.args = { children: "I'm a button that looks like a link" }
53
+
54
+ export const Variants = Template.bind({})
51
55
 
52
56
  export const IconLeft = Template.bind({})
53
57
  IconLeft.args = { icon: SampleIcon }
@@ -56,3 +60,20 @@ export const IconRight = Template.bind({})
56
60
  IconRight.args = { icon: SampleIcon, iconPosition: 'right' }
57
61
 
58
62
  export const EveryIcon = EveryIconTemplate.bind({})
63
+
64
+ export const ParentTypes = (args) => (
65
+ <EachParentType componentThemeName="Link" {...args}>
66
+ {({ label, variant }) => (
67
+ <TextButton {...args} key={label} variant={variant}>
68
+ {label}
69
+ </TextButton>
70
+ )}
71
+ </EachParentType>
72
+ )
73
+ ParentTypes.parameters = parentTypesParams
74
+
75
+ export const IconLeftParentTypes = ParentTypes.bind({})
76
+ IconLeftParentTypes.args = { ...IconLeft.args }
77
+
78
+ export const IconRightParentTypes = ParentTypes.bind({})
79
+ IconRightParentTypes.args = { ...IconRight.args }
@@ -0,0 +1,64 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React, { useState } from 'react'
3
+ import PropTypes from 'prop-types'
4
+
5
+ import { Pagination, Typography } from '../../lib'
6
+ import { Container, EachParentType, parentTypesParams } from '../supports'
7
+
8
+ export default {
9
+ title: 'Base/Pagination',
10
+ component: Pagination
11
+ }
12
+
13
+ export const Default = (args) => (
14
+ <Pagination {...args}>
15
+ <Pagination.PageButton href="#test" hrefAttrs={{ target: '_blank' }} />
16
+ <Pagination.PageButton onPress={() => {}} isActive />
17
+ <Pagination.PageButton onPress={() => {}} />
18
+ <Pagination.PageButton onPress={() => {}} />
19
+ </Pagination>
20
+ )
21
+ Default.storyName = 'Pagination'
22
+
23
+ export const LocalTabs = ({ label, ...args }) => {
24
+ const [activeItemIndex, setActiveItemIndex] = useState(0)
25
+
26
+ const items = []
27
+
28
+ for (let i = 0; i < 7; i += 1) {
29
+ items.push(`Panel ${i + 1}`)
30
+ }
31
+
32
+ const activeItem = items[activeItemIndex]
33
+ const labelText = label ? `${activeItem} (${label}). ` : activeItem
34
+
35
+ /* eslint-disable react/no-array-index-key */
36
+ return (
37
+ <>
38
+ <Container>
39
+ <Typography>{labelText}</Typography>
40
+ </Container>
41
+ <Pagination {...args}>
42
+ {items.map((item, index) => (
43
+ <Pagination.PageButton
44
+ key={index}
45
+ onPress={() => setActiveItemIndex(index)}
46
+ isActive={index === activeItemIndex}
47
+ />
48
+ ))}
49
+ </Pagination>
50
+ </>
51
+ )
52
+ /* eslint-enable react/no-array-index-key */
53
+ }
54
+ LocalTabs.propTypes = {
55
+ ...Pagination.propTypes,
56
+ label: PropTypes.string
57
+ }
58
+
59
+ export const ParentTypes = (args) => (
60
+ <EachParentType componentThemeName="Pagination" {...args}>
61
+ {({ label, variant }) => <LocalTabs {...args} variant={variant} label={label} />}
62
+ </EachParentType>
63
+ )
64
+ ParentTypes.parameters = parentTypesParams
@@ -1,14 +1,17 @@
1
+ /* eslint-disable react/no-multi-comp */
1
2
  import React from 'react'
3
+ import PropTypes from 'prop-types'
2
4
  import { SideNav } from '../../lib'
5
+ import { EachParentType, parentTypesParams } from '../supports'
3
6
 
4
7
  export default {
5
8
  title: 'Base/SideNav',
6
9
  component: SideNav
7
10
  }
8
11
 
9
- const Template = (args) => (
12
+ const Template = ({ label = 'Level 1 - 1', ...args }) => (
10
13
  <SideNav {...args}>
11
- <SideNav.Item href="#level-1-1">Level 1 - 1</SideNav.Item>
14
+ <SideNav.Item href="#level-1-1">{label}</SideNav.Item>
12
15
  <SideNav.ItemsGroup label="Group 1">
13
16
  <SideNav.Item href="#level-2-1">Level 2 - 1</SideNav.Item>
14
17
  <SideNav.Item href="#level-2-2">Level 2 - 2</SideNav.Item>
@@ -20,8 +23,20 @@ const Template = (args) => (
20
23
  </SideNav.ItemsGroup>
21
24
  </SideNav>
22
25
  )
26
+ Template.propTypes = {
27
+ ...SideNav.propTypes,
28
+ label: PropTypes.string
29
+ }
23
30
 
24
31
  export const Default = Template.bind({})
32
+ Default.storyName = 'SideNav'
25
33
 
26
34
  export const NonAccordion = Template.bind({})
27
35
  NonAccordion.args = { accordion: false }
36
+
37
+ export const ParentTypes = (args) => (
38
+ <EachParentType componentThemeName="SideNav" {...args}>
39
+ {({ label, variant }) => <Template {...args} variant={variant} label={label} />}
40
+ </EachParentType>
41
+ )
42
+ ParentTypes.parameters = parentTypesParams
@@ -0,0 +1,33 @@
1
+ import React from 'react'
2
+ import { View } from 'react-native'
3
+
4
+ import { Spacer, Typography } from '../../lib'
5
+ import { Container } from '../supports'
6
+
7
+ export default {
8
+ title: 'Base/Spacer',
9
+ component: Spacer
10
+ }
11
+
12
+ export const Default = (args) => <Spacer {...args} />
13
+ Default.storyName = 'Spacer'
14
+
15
+ export const InColumn = (args) => (
16
+ <>
17
+ <Container margin={0} offWhite>
18
+ <Typography>First item, before spacer.</Typography>
19
+ </Container>
20
+ <Spacer {...args} />
21
+ <Container margin={0} offWhite>
22
+ <Typography>Second item, after spacer.</Typography>
23
+ </Container>
24
+ </>
25
+ )
26
+ InColumn.args = { space: 2 }
27
+
28
+ export const InRow = (args) => (
29
+ <View style={{ flexDirection: 'row' }}>
30
+ <InColumn {...args} />
31
+ </View>
32
+ )
33
+ InRow.args = { space: 2 }
@@ -0,0 +1,65 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React from 'react'
3
+ import PropTypes from 'prop-types'
4
+ import { View } from 'react-native'
5
+
6
+ import { StackView, Card, Typography, Button } from '../../lib'
7
+
8
+ export default {
9
+ title: 'Base/StackView',
10
+ component: StackView
11
+ }
12
+
13
+ const content = (
14
+ <>
15
+ <Card>
16
+ <Typography>First item.</Typography>
17
+ </Card>
18
+ <Card>
19
+ <Typography>Second item.</Typography>
20
+ <Typography>Has two lines.</Typography>
21
+ </Card>
22
+ <Card>
23
+ <Typography>Third item.</Typography>
24
+ <Typography>This one is longer.</Typography>
25
+ <Typography>It has three lines.</Typography>
26
+ </Card>
27
+ <Button onPress={() => {}}>Different item</Button>
28
+ </>
29
+ )
30
+
31
+ export const Default = (args) => <StackView {...args} />
32
+ Default.storyName = 'StackView'
33
+ Default.args = { children: content }
34
+ // By default the JSX object is shown as a huge human-unreadable JSON tree control; turn it off
35
+ Default.argTypes = { children: { control: { disable: true } } }
36
+
37
+ export const Tokens = ({ flexGrow, alignItems, justifyContent, ...args }) => (
38
+ <View
39
+ style={{
40
+ flexGrow,
41
+ flexDirection: args.direction,
42
+ alignItems,
43
+ justifyContent
44
+ }}
45
+ >
46
+ <StackView {...args}>{content}</StackView>
47
+ </View>
48
+ )
49
+ Tokens.args = { inherit: true, space: 4, direction: 'row' }
50
+ Tokens.parameters = {
51
+ docs: {
52
+ storyDescription:
53
+ "A set of common layout styles may be set using the `tokens` prop, and selected from a parent theme using `selectTokens('StackView', themeTokens)`."
54
+ }
55
+ }
56
+ Tokens.propTypes = {
57
+ flexGrow: PropTypes.number,
58
+ alignItems: PropTypes.string,
59
+ justifyContent: PropTypes.string
60
+ }
61
+ Tokens.argTypes = {
62
+ flexGrow: { type: 'number', defaultValue: 1 },
63
+ alignItems: { type: 'string', defaultValue: 'flex-end' },
64
+ justifyContent: { type: 'string', defaultValue: 'flex-end' }
65
+ }
@@ -0,0 +1,52 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React from 'react'
3
+ import { StyleSheet, View } from 'react-native'
4
+
5
+ import { StackWrap, Button } from '../../lib'
6
+
7
+ export default {
8
+ title: 'Base/StackWrap',
9
+ component: StackWrap
10
+ }
11
+
12
+ // Mixed length labels
13
+ const labels = ['Button ', 'Longer label ', '#', 'Mid-length ']
14
+
15
+ const getLabels = (length) =>
16
+ Array(length)
17
+ .fill('')
18
+ .map((_, index) => `${labels[index % 4]}${index}`)
19
+
20
+ export const Default = (args) => <StackWrap {...args} />
21
+ Default.storyName = 'StackWrap'
22
+ Default.args = {
23
+ children: getLabels(15).map((label) => (
24
+ <Button onPress={() => {}} key={label}>
25
+ {label}
26
+ </Button>
27
+ )),
28
+ // Storybook does a bad job picking these up automatically due to the indirection; make them easy to edit
29
+ space: 1,
30
+ gap: 1,
31
+ tokens: {}
32
+ }
33
+ // By default the JSX object is shown as a huge human-unreadable JSON tree control; turn it off
34
+ Default.argTypes = { children: { control: { disable: true } } }
35
+
36
+ export const Column = (args) => (
37
+ <View style={styles.constrainedHeight}>
38
+ <StackWrap {...args} />
39
+ </View>
40
+ )
41
+ Column.args = {
42
+ ...Default.args,
43
+ direction: 'column'
44
+ }
45
+ Column.argTypes = { ...Default.argTypes }
46
+
47
+ const styles = StyleSheet.create({
48
+ constrainedHeight: {
49
+ height: 350,
50
+ alignItems: 'flex-start'
51
+ }
52
+ })
@@ -0,0 +1,103 @@
1
+ import React, { useEffect, useState } from 'react'
2
+
3
+ import { TextInput } from '../../lib'
4
+ import { Container } from '../supports'
5
+
6
+ export default {
7
+ title: 'Base/TextInput',
8
+ component: TextInput
9
+ }
10
+
11
+ /* eslint-disable react/no-multi-comp */
12
+
13
+ const Template = (args) => (
14
+ <Container>
15
+ <TextInput {...args} />
16
+ </Container>
17
+ )
18
+
19
+ export const Default = Template.bind({})
20
+ Default.args = {
21
+ label: 'Label'
22
+ }
23
+
24
+ export const WithHint = () => {
25
+ return (
26
+ <>
27
+ <Container>
28
+ <TextInput label="Label" hint="An inline hint" tooltip="Tooltip content" />
29
+ </Container>
30
+ <Container>
31
+ <TextInput
32
+ label="Label"
33
+ hint="A usually much longer hint below"
34
+ hintPosition="below"
35
+ tooltip="Tooltip content"
36
+ />
37
+ </Container>
38
+ </>
39
+ )
40
+ }
41
+
42
+ export const WithFeedback = () => {
43
+ return (
44
+ <>
45
+ <Container>
46
+ <TextInput label="Instructional" feedback="An instructional feedback" />
47
+ </Container>
48
+ <Container>
49
+ <TextInput label="Success" validation="success" feedback="A detailed success message" />
50
+ </Container>
51
+ <Container>
52
+ <TextInput label="Error" validation="error" feedback="A detailed error message" />
53
+ </Container>
54
+ </>
55
+ )
56
+ }
57
+
58
+ export const InactiveAndReadOnly = () => {
59
+ return (
60
+ <>
61
+ <Container>
62
+ <TextInput label="Inactive" inactive initialValue="can't touch this" />
63
+ </Container>
64
+ <Container>
65
+ <TextInput label="Read only" readOnly value="won't change" />
66
+ </Container>
67
+ </>
68
+ )
69
+ }
70
+
71
+ export const Controlled = () => {
72
+ const [value, setValue] = useState('')
73
+ const [validation, setValidation] = useState()
74
+
75
+ useEffect(() => {
76
+ if (value !== undefined && value.length > 0)
77
+ setValidation(value.length < 6 ? 'success' : 'error')
78
+ }, [value])
79
+
80
+ const defaultFeedbackContent =
81
+ 'Will show an error if longer than 6 characters and success otherwise'
82
+
83
+ const feedbackContent = {
84
+ error: 'The value must be shorter than 6 characters',
85
+ success: 'Yay! The value has less than 6 characters'
86
+ }
87
+
88
+ const feedback = validation === undefined ? defaultFeedbackContent : feedbackContent[validation]
89
+
90
+ return (
91
+ <>
92
+ <Container>
93
+ <TextInput
94
+ label="Controlled"
95
+ validation={validation}
96
+ feedback={feedback}
97
+ value={value}
98
+ onChange={setValue}
99
+ />
100
+ </Container>
101
+ </>
102
+ )
103
+ }
@@ -1,10 +1,11 @@
1
1
  /* eslint-disable react/no-multi-comp */
2
2
  import React, { useState } from 'react'
3
3
  import { View } from 'react-native'
4
- import { ToggleSwitch as ToggleSwitchComponent, Typography } from '../../lib'
5
- import { Container } from '../supports'
4
+ import { ToggleSwitch, Typography } from '../../lib'
5
+ import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
 
7
- export const ToggleSwitch = ToggleSwitchComponent
7
+ export const Default = (args) => <ToggleSwitch {...args} />
8
+ Default.storyName = 'ToggleSwitch'
8
9
 
9
10
  export default {
10
11
  title: 'Base/ToggleSwitch',
@@ -45,3 +46,15 @@ export const ToggleSwitchInactive = (args) => (
45
46
  </Container>
46
47
  </>
47
48
  )
49
+
50
+ export const ParentTypes = (args) => (
51
+ <EachParentType componentThemeName="ToggleSwitch" {...args}>
52
+ {({ label, variant }) => (
53
+ <>
54
+ <Typography>{`${label} `}</Typography>
55
+ <ToggleSwitch {...args} variant={variant} />
56
+ </>
57
+ )}
58
+ </EachParentType>
59
+ )
60
+ ParentTypes.parameters = parentTypesParams
@@ -1,9 +1,11 @@
1
+ /* eslint-disable react/no-multi-comp */
1
2
  import React from 'react'
2
3
 
3
- import { useVariants, Container } from '../supports'
4
- import { Typography as TypographyComponent } from '../../lib'
4
+ import { useVariants, Container, EachParentType, parentTypesParams } from '../supports'
5
+ import { Typography } from '../../lib'
5
6
 
6
- export const Typography = TypographyComponent
7
+ export const Default = (args) => <Typography {...args} />
8
+ Default.storyName = 'Typography'
7
9
 
8
10
  const defaultChildren = 'The quick brown fox jumps over the lazy dog'
9
11
 
@@ -38,3 +40,10 @@ LongTextTypographyVariants.args = {
38
40
  'and what the current screen size is of the window in which this component is being shown.'
39
41
  ]
40
42
  }
43
+
44
+ export const ParentTypes = (args) => (
45
+ <EachParentType componentThemeName="Typography" {...args}>
46
+ {({ label, variant }) => <Typography {...args} variant={variant}>{`${label}. `}</Typography>}
47
+ </EachParentType>
48
+ )
49
+ ParentTypes.parameters = parentTypesParams
@@ -14,7 +14,7 @@ InlineBlockDiv.propTypes = { children: PropTypes.node }
14
14
 
15
15
  const FloatDiv = ({ children }) => (
16
16
  <div>
17
- <div style={{ float: 'right' }}>{children}</div>
17
+ <div style={{ float: 'right', maxWidth: '85%', marginLeft: '10px' }}>{children}</div>
18
18
  <Typography block>
19
19
  Some lengthy text in a paragraph with a block above it containing the components to test,
20
20
  where the block above it has the style "float: right" applied and no other styles, giving the