@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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-prerelease.5](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v0.0.2-prerelease.4...@telus-uds/components-base/v0.0.2-prerelease.5) (2021-10-27)
6
+
7
+ ### Features
8
+
9
+ - **allium-web:** Add `ExpandCollapseMiniControl` component ([#661](https://github.com/telus/universal-design-system/issues/661)) ([227407e](https://github.com/telus/universal-design-system/commit/227407ec6a48c0a170b8e39761ba33293f13eb3c)), closes [#605](https://github.com/telus/universal-design-system/issues/605) [#605](https://github.com/telus/universal-design-system/issues/605) [#605](https://github.com/telus/universal-design-system/issues/605) [#605](https://github.com/telus/universal-design-system/issues/605) [#605](https://github.com/telus/universal-design-system/issues/605)
10
+ - **allium:** add Allium `Card` ([#639](https://github.com/telus/universal-design-system/issues/639)) ([f88179c](https://github.com/telus/universal-design-system/commit/f88179c503dfe574bf7bac6bb36ce4726a9af338))
11
+ - **base, allium:** add reverse directions and switch Allium card to using `StackView` ([#676](https://github.com/telus/universal-design-system/issues/676)) ([819a15f](https://github.com/telus/universal-design-system/commit/819a15f059faa47d1bc4e96c6370e9694effc003))
12
+ - **base:** add StackView and Spacer ([#662](https://github.com/telus/universal-design-system/issues/662)) ([cc3965e](https://github.com/telus/universal-design-system/commit/cc3965e83c1ec2fa0f0dd006a03eeeeda5384940))
13
+ - **base:** add StackWrap component ([#666](https://github.com/telus/universal-design-system/issues/666)) ([f34fb60](https://github.com/telus/universal-design-system/commit/f34fb60d0a923b1e4b3105c21b4a762b630ab309))
14
+ - **base:** add TextInput component ([#649](https://github.com/telus/universal-design-system/issues/649)) ([245c073](https://github.com/telus/universal-design-system/commit/245c073ed3ba3a022f989d234fbf5cf972edec25))
15
+ - **base:** add the Feedback component ([#656](https://github.com/telus/universal-design-system/issues/656)) ([5d7a5b6](https://github.com/telus/universal-design-system/commit/5d7a5b69c870ce1077adfdb230fddd1aa120b373))
16
+
17
+ ### Bug Fixes
18
+
19
+ - **base:** control stretch from a row parent ([#668](https://github.com/telus/universal-design-system/issues/668)) ([fa13c37](https://github.com/telus/universal-design-system/commit/fa13c37b2bd6b4118dbeb39bc2cdf59d13d5b151))
20
+ - **base:** fix icon link width in block container ([#645](https://github.com/telus/universal-design-system/issues/645)) ([ff60d1d](https://github.com/telus/universal-design-system/commit/ff60d1d1d0a66b7735b902098c7ca22e442265e1))
21
+
22
+ ### [0.0.2-prerelease.4](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v0.0.2-prerelease.3...@telus-uds/components-base/v0.0.2-prerelease.4) (2021-10-13)
23
+
24
+ ### Bug Fixes
25
+
26
+ - same rnw dep specification for base as components-allium-web ([#642](https://github.com/telus/universal-design-system/issues/642)) ([d40a9a2](https://github.com/telus/universal-design-system/commit/d40a9a2eade0a6ab276f13d02758fff0a88c2ecd))
27
+
28
+ ### [0.0.2-prerelease.3](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v0.0.2-prerelease.2...@telus-uds/components-base/v0.0.2-prerelease.3) (2021-10-12)
29
+
30
+ ### Features
31
+
32
+ - **base:** add `Card` component ([#597](https://github.com/telus/universal-design-system/issues/597)) ([9e29d3c](https://github.com/telus/universal-design-system/commit/9e29d3c426c7082ec4d54a0c9d353986c0cc0b01))
33
+ - **base:** add useSpacingScale hook, apply to Box ([#606](https://github.com/telus/universal-design-system/issues/606)) ([5109b4f](https://github.com/telus/universal-design-system/commit/5109b4f7537b8a732b86e34675bef992a54873e5))
34
+
35
+ ### [0.0.2-prerelease.2](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v0.0.2-prerelease.1...@telus-uds/components-base/v0.0.2-prerelease.2) (2021-10-08)
36
+
37
+ ### Features
38
+
39
+ - **base:** add the Pagination component ([#577](https://github.com/telus/universal-design-system/issues/577)) ([e24b644](https://github.com/telus/universal-design-system/commit/e24b6441b3d31be01187c0cac728f2c8e25f5157))
40
+
5
41
  ### [0.0.2-prerelease.1](https://github.com/telus/universal-design-system/compare/@telus-uds/components-base/v0.0.2-prerelease.0...@telus-uds/components-base/v0.0.2-prerelease.1) (2021-10-04)
6
42
 
7
43
  ### Features
@@ -2,7 +2,9 @@ const {
2
2
  buttonAppearances,
3
3
  linkAppearances,
4
4
  sideNavItemAppearances,
5
- toggleSwitchAppearances
5
+ toggleSwitchAppearances,
6
+ textInputAppearances,
7
+ feedbackAppearances
6
8
  } = require('@telus-uds/tools-theme')
7
9
  const { appearances: systemAppearances } = require('@telus-uds/system-constants')
8
10
 
@@ -21,80 +23,48 @@ module.exports = {
21
23
  name: 'test'
22
24
  },
23
25
  components: {
24
- Box: {
25
- style: {},
26
- levels: {
27
- xs: {
28
- 0: 0,
29
- 1: 4,
30
- 2: 8,
31
- 3: 16,
32
- 4: 24,
33
- 5: 32,
34
- 6: 36,
35
- 7: 40,
36
- 8: 48,
37
- 9: 64,
38
- 10: 80,
39
- 11: 96
40
- },
41
- sm: {
42
- 0: 0,
43
- 1: 4,
44
- 2: 8,
45
- 3: 16,
46
- 4: 24,
47
- 5: 32,
48
- 6: 36,
49
- 7: 40,
50
- 8: 48,
51
- 9: 64,
52
- 10: 80,
53
- 11: 96
54
- },
55
- md: {
56
- 0: 0,
57
- 1: 4,
58
- 2: 8,
59
- 3: 16,
60
- 4: 24,
61
- 5: 32,
62
- 6: 36,
63
- 7: 40,
64
- 8: 48,
65
- 9: 64,
66
- 10: 80,
67
- 11: 96
68
- },
69
- lg: {
70
- 0: 0,
71
- 1: 4,
72
- 2: 8,
73
- 3: 16,
74
- 4: 24,
75
- 5: 32,
76
- 6: 40,
77
- 7: 48,
78
- 8: 64,
79
- 9: 72,
80
- 10: 96,
81
- 11: 120
82
- },
83
- xl: {
84
- 0: 0,
85
- 1: 4,
86
- 2: 8,
87
- 3: 16,
88
- 4: 24,
89
- 5: 32,
90
- 6: 40,
91
- 7: 48,
92
- 8: 64,
93
- 9: 72,
94
- 10: 96,
95
- 11: 120
96
- }
26
+ spacingScale: {
27
+ tokens: {
28
+ size: 36
97
29
  },
30
+ rules: [
31
+ { if: { space: 5 }, tokens: { size: 32 } },
32
+ { if: { space: 4 }, tokens: { size: 24 } },
33
+ { if: { space: 3 }, tokens: { size: 16 } },
34
+ { if: { space: 2 }, tokens: { size: 8 } },
35
+ { if: { space: 1 }, tokens: { size: 4 } },
36
+
37
+ { if: { compact: true }, tokens: { size: 12 } },
38
+ { if: { compact: true, space: 5 }, tokens: { size: 10 } },
39
+ { if: { compact: true, space: 4 }, tokens: { size: 8 } },
40
+ { if: { compact: true, space: 3 }, tokens: { size: 6 } },
41
+ { if: { compact: true, space: 2 }, tokens: { size: 4 } },
42
+ { if: { compact: true, space: 1 }, tokens: { size: 2 } },
43
+
44
+ { if: { responsive: true }, tokens: { size: 6 } },
45
+ { if: { responsive: true, space: 5 }, tokens: { size: 5 } },
46
+ { if: { responsive: true, space: 4 }, tokens: { size: 4 } },
47
+ { if: { responsive: true, space: 3 }, tokens: { size: 3 } },
48
+ { if: { responsive: true, space: 2 }, tokens: { size: 2 } },
49
+ { if: { responsive: true, space: 1 }, tokens: { size: 1 } },
50
+ { if: { responsive: true, viewport: ['sm', 'md'] }, tokens: { size: 8 } },
51
+ { if: { responsive: true, viewport: ['sm', 'md'], space: 5 }, tokens: { size: 7 } },
52
+ { if: { responsive: true, viewport: ['sm', 'md'], space: 4 }, tokens: { size: 6 } },
53
+ { if: { responsive: true, viewport: ['sm', 'md'], space: 3 }, tokens: { size: 5 } },
54
+ { if: { responsive: true, viewport: ['sm', 'md'], space: 2 }, tokens: { size: 4 } },
55
+ { if: { responsive: true, viewport: ['sm', 'md'], space: 1 }, tokens: { size: 3 } },
56
+ { if: { responsive: true, viewport: ['lg', 'xl'] }, tokens: { size: 12 } },
57
+ { if: { responsive: true, viewport: ['lg', 'xl'], space: 5 }, tokens: { size: 11 } },
58
+ { if: { responsive: true, viewport: ['lg', 'xl'], space: 4 }, tokens: { size: 10 } },
59
+ { if: { responsive: true, viewport: ['lg', 'xl'], space: 3 }, tokens: { size: 9 } },
60
+ { if: { responsive: true, viewport: ['lg', 'xl'], space: 2 }, tokens: { size: 8 } },
61
+ { if: { responsive: true, viewport: ['lg', 'xl'], space: 1 }, tokens: { size: 7 } },
62
+
63
+ { if: { space: 0 }, tokens: { size: 0 } }
64
+ ]
65
+ },
66
+ Box: {
67
+ tokens: {},
98
68
  variants: {
99
69
  lightest: {
100
70
  backgroundColor: '#ffffff'
@@ -169,12 +139,7 @@ module.exports = {
169
139
  paddingTop: 8,
170
140
  paddingBottom: 8,
171
141
 
172
- width: null,
173
-
174
- marginLeft: 0,
175
- marginRight: 0,
176
- marginTop: 0,
177
- marginBottom: 0
142
+ width: null
178
143
  },
179
144
  rules: [
180
145
  {
@@ -329,6 +294,100 @@ module.exports = {
329
294
  direction: 'row'
330
295
  }
331
296
  },
297
+ Card: {
298
+ appearances: {
299
+ background: {
300
+ values: ['alternative'],
301
+ type: 'variant'
302
+ },
303
+ padding: {
304
+ values: ['narrow', 'intermediate', 'compact', 'custom'],
305
+ type: 'variant'
306
+ },
307
+ viewport: systemAppearances.viewport
308
+ },
309
+ tokens: {
310
+ backgroundColor: '#ffffff',
311
+ borderColor: '#666666',
312
+ borderRadius: 6,
313
+ borderWidth: 1,
314
+ paddingBottom: 32,
315
+ paddingLeft: 24,
316
+ paddingRight: 24,
317
+ paddingTop: 32
318
+ },
319
+ rules: [
320
+ {
321
+ if: { background: 'alternative' },
322
+ tokens: {
323
+ backgroundColor: '#f4f4f7'
324
+ }
325
+ },
326
+ {
327
+ if: { viewport: ['md', 'lg', 'xl'] },
328
+ tokens: {
329
+ paddingBottom: 48,
330
+ paddingLeft: 32,
331
+ paddingRight: 32,
332
+ paddingTop: 48
333
+ }
334
+ },
335
+ {
336
+ if: { padding: 'narrow' },
337
+ tokens: {
338
+ paddingBottom: 24,
339
+ paddingLeft: 16,
340
+ paddingRight: 16,
341
+ paddingTop: 24
342
+ }
343
+ },
344
+ {
345
+ if: { padding: 'narrow', viewport: ['md', 'lg', 'xl'] },
346
+ tokens: {
347
+ paddingBottom: 32,
348
+ paddingLeft: 16,
349
+ paddingRight: 16,
350
+ paddingTop: 32
351
+ }
352
+ },
353
+ {
354
+ if: { padding: 'intermediate' },
355
+ tokens: {
356
+ paddingBottom: 24,
357
+ paddingLeft: 24,
358
+ paddingRight: 24,
359
+ paddingTop: 24
360
+ }
361
+ },
362
+ {
363
+ if: { padding: 'intermediate', viewport: ['md', 'lg', 'xl'] },
364
+ tokens: {
365
+ paddingBottom: 32,
366
+ paddingLeft: 32,
367
+ paddingRight: 32,
368
+ paddingTop: 32
369
+ }
370
+ },
371
+ {
372
+ if: { padding: 'compact' },
373
+ tokens: {
374
+ paddingBottom: 16,
375
+ paddingLeft: 16,
376
+ paddingRight: 16,
377
+ paddingTop: 16
378
+ }
379
+ },
380
+ {
381
+ if: { padding: 'custom' },
382
+ tokens: {
383
+ paddingBottom: 0,
384
+ paddingLeft: 0,
385
+ paddingRight: 0,
386
+ paddingTop: 0
387
+ }
388
+ }
389
+ ]
390
+ },
332
391
  Divider: {
333
392
  appearances: {
334
393
  weight: {
@@ -442,8 +501,6 @@ module.exports = {
442
501
  fontSize: 16,
443
502
  color: '#2c2e30',
444
503
  lineHeight: 1.5,
445
- marginTop: 8,
446
- marginBottom: 8,
447
504
  fontScaleCap: 64
448
505
  },
449
506
  rules: [
@@ -677,8 +734,6 @@ module.exports = {
677
734
  blockFontWeight: '400',
678
735
  blockFontSize: 16,
679
736
  blockLineHeight: 1.5,
680
- blockMarginTop: 8,
681
- blockMarginBottom: 8,
682
737
 
683
738
  outerBorderColor: transparent,
684
739
  outerBorderOutline: 'none',
@@ -724,6 +779,52 @@ module.exports = {
724
779
  }
725
780
  ]
726
781
  },
782
+ Pagination: {
783
+ tokens: {
784
+ gap: 3
785
+ }
786
+ },
787
+ PaginationPageButton: {
788
+ tokens: {
789
+ paddingLeft: 4,
790
+ paddingRight: 4
791
+ },
792
+ rules: [
793
+ {
794
+ if: {
795
+ selected: true
796
+ },
797
+ tokens: {
798
+ fontWeight: '600',
799
+ textLine: 'underline'
800
+ }
801
+ },
802
+ {
803
+ if: {
804
+ hover: true
805
+ },
806
+ tokens: {
807
+ color: 'blue'
808
+ }
809
+ }
810
+ ]
811
+ },
812
+ PaginationSideButton: {
813
+ tokens: {
814
+ paddingLeft: 4,
815
+ paddingRight: 4
816
+ },
817
+ rules: [
818
+ {
819
+ if: {
820
+ hover: true
821
+ },
822
+ tokens: {
823
+ color: 'blue'
824
+ }
825
+ }
826
+ ]
827
+ },
727
828
  SideNav: {},
728
829
  SideNavItem: {
729
830
  appearances: {
@@ -741,6 +842,9 @@ module.exports = {
741
842
  ]
742
843
  },
743
844
  SideNavItemsGroup: {},
845
+ StackView: {
846
+ tokens: {}
847
+ },
744
848
  ToggleSwitch: {
745
849
  appearances: {
746
850
  focus: toggleSwitchAppearances.focus,
@@ -815,6 +919,82 @@ module.exports = {
815
919
  tokens: { opacity: 0.4 }
816
920
  }
817
921
  ]
922
+ },
923
+ TextInput: {
924
+ appearances: {
925
+ ...textInputAppearances
926
+ },
927
+ tokens: {
928
+ borderRadius: 4,
929
+ borderWidth: 1,
930
+ borderColor: '#00000044',
931
+ paddingTop: 6,
932
+ paddingBottom: 6,
933
+ paddingLeft: 6,
934
+ paddingRight: 6,
935
+ outerBorderWidth: 1,
936
+ outerBorderColor: transparent,
937
+ outerBorderRadius: 4
938
+ },
939
+ rules: [
940
+ {
941
+ if: { validation: 'success' },
942
+ tokens: {
943
+ outerBorderColor: '#99ff99'
944
+ }
945
+ },
946
+ {
947
+ if: { validation: 'error' },
948
+ tokens: {
949
+ outerBorderColor: '#990000'
950
+ }
951
+ },
952
+ {
953
+ if: { focus: true },
954
+ tokens: {
955
+ outerBorderColor: '#debc06'
956
+ }
957
+ },
958
+ {
959
+ if: { hover: true },
960
+ tokens: {
961
+ outerBorderColor: '#6666cc'
962
+ }
963
+ },
964
+ {
965
+ if: { inactive: true },
966
+ tokens: {
967
+ outerBorderColor: transparent,
968
+ backgroundColor: '#00000044'
969
+ }
970
+ }
971
+ ]
972
+ },
973
+ InputLabel: {
974
+ tokens: {
975
+ gap: 20,
976
+ hintFontSize: 12
977
+ }
978
+ },
979
+ Feedback: {
980
+ appearances: {
981
+ ...feedbackAppearances
982
+ },
983
+ tokens: {
984
+ borderColor: '#eee',
985
+ borderWidth: 1,
986
+ borderRadius: 3,
987
+ titleFontSize: 16,
988
+ contentFontSize: 14,
989
+ paddingTop: 12,
990
+ paddingBottom: 12,
991
+ paddingLeft: 12,
992
+ paddingRight: 12
993
+ },
994
+ rules: [
995
+ { if: { state: 'success' }, tokens: { color: 'green' } },
996
+ { if: { state: 'error' }, tokens: { color: 'red' } }
997
+ ]
818
998
  }
819
999
  }
820
1000
  }
@@ -1,30 +1,20 @@
1
1
  import React from 'react'
2
2
  import { Text } from 'react-native'
3
3
  import { render, fireEvent } from '@testing-library/react-native'
4
- import { viewports } from '@telus-uds/system-constants'
5
4
  import { Box } from '../../src'
6
5
  import Theme from '../../__fixtures__/Theme'
7
- import Viewport from '../../__fixtures__/Viewport'
8
- import testTheme from '../../__fixtures__/testTheme'
9
6
 
10
7
  const textContent = 'Some text content'
11
8
 
12
- function getSpacing(level, viewport) {
13
- const spacing = testTheme.components.Box.levels[viewport][level]
14
- if (typeof spacing !== 'number') {
15
- throw new Error(
16
- `Invalid spacing ${spacing} (${typeof spacing}) for level ${level}, viewport ${viewport}`
17
- )
18
- }
19
- return spacing
20
- }
9
+ // Based on testTheme
10
+ const expectedScale = [0, 4, 8, 16, 24, 32, 36]
21
11
 
22
12
  describe('Box', () => {
23
13
  it('is scrollable if scroll props provided', async () => {
24
14
  const onScroll = jest.fn()
25
15
  const { getByText } = render(
26
16
  <Theme>
27
- <Box scroll scrollProps={{ onScroll }}>
17
+ <Box scroll={{ onScroll }}>
28
18
  <Text>{textContent}</Text>
29
19
  </Box>
30
20
  </Theme>
@@ -36,53 +26,86 @@ describe('Box', () => {
36
26
  expect(onScroll).toHaveBeenCalledTimes(1)
37
27
  })
38
28
 
39
- // Test the style resolution in every viewport
40
- viewports.keys.forEach((viewport) => {
41
- it(`maps regular props to RN styles at viewport ${viewport}`, () => {
42
- const props = {
43
- top: 1,
44
- below: 2,
45
- bottom: 3,
46
- left: 4,
47
- right: 5
48
- }
49
- const { getByText } = render(
50
- <Theme>
51
- <Viewport viewport={viewport}>
52
- <Box {...props}>
53
- <Text>{textContent}</Text>
54
- </Box>
55
- </Viewport>
56
- </Theme>
57
- )
58
- expect(getByText(textContent).parent).toHaveStyle({
59
- paddingTop: getSpacing(1, viewport),
60
- marginBottom: getSpacing(2, viewport),
61
- paddingBottom: getSpacing(3, viewport),
62
- paddingLeft: getSpacing(4, viewport),
63
- paddingRight: getSpacing(5, viewport)
64
- })
29
+ it('maps regular props to RN styles', () => {
30
+ const props = {
31
+ top: 1,
32
+ bottom: 2,
33
+ left: 3,
34
+ right: 4
35
+ }
36
+ const { getByText } = render(
37
+ <Theme>
38
+ <Box {...props}>
39
+ <Text>{textContent}</Text>
40
+ </Box>
41
+ </Theme>
42
+ )
43
+ expect(getByText(textContent).parent).toHaveStyle({
44
+ paddingTop: expectedScale[1],
45
+ paddingBottom: expectedScale[2],
46
+ paddingLeft: expectedScale[3],
47
+ paddingRight: expectedScale[4]
48
+ })
49
+ })
50
+
51
+ it(`maps horizontal and vertical props to RN styles`, () => {
52
+ const props = {
53
+ horizontal: 1,
54
+ vertical: 2
55
+ }
56
+ const { getByText } = render(
57
+ <Theme>
58
+ <Box {...props}>
59
+ <Text>{textContent}</Text>
60
+ </Box>
61
+ </Theme>
62
+ )
63
+ expect(getByText(textContent).parent).toHaveStyle({
64
+ paddingLeft: expectedScale[1],
65
+ paddingRight: expectedScale[1],
66
+ paddingTop: expectedScale[2],
67
+ paddingBottom: expectedScale[2]
68
+ })
69
+ })
70
+
71
+ it(`maps all-sides space prop to RN styles`, () => {
72
+ const props = {
73
+ space: 3
74
+ }
75
+ const { getByText } = render(
76
+ <Theme>
77
+ <Box {...props}>
78
+ <Text>{textContent}</Text>
79
+ </Box>
80
+ </Theme>
81
+ )
82
+ expect(getByText(textContent).parent).toHaveStyle({
83
+ paddingLeft: expectedScale[3],
84
+ paddingRight: expectedScale[3],
85
+ paddingTop: expectedScale[3],
86
+ paddingBottom: expectedScale[3]
65
87
  })
88
+ })
66
89
 
67
- it(`maps shorthand props to RN styles at viewport ${viewport}`, () => {
68
- const props = {
69
- horizontal: 6,
70
- vertical: 7
71
- }
72
- const { getByText } = render(
73
- <Theme>
74
- <Viewport viewport={viewport}>
75
- <Box {...props}>
76
- <Text>{textContent}</Text>
77
- </Box>
78
- </Viewport>
79
- </Theme>
80
- )
81
- expect(getByText(textContent).parent).toHaveStyle({
82
- // Can't test for paddingTop etc - .toHaveStyle isn't that smart
83
- paddingHorizontal: getSpacing(6, viewport),
84
- paddingVertical: getSpacing(7, viewport)
85
- })
90
+ it(`applies side overrides in increasing specificity`, () => {
91
+ const props = {
92
+ space: 1,
93
+ horizontal: 2,
94
+ top: 3,
95
+ right: 4
96
+ }
97
+ const { getByText } = render(
98
+ <Theme>
99
+ <Box {...props}>
100
+ <Text>{textContent}</Text>
101
+ </Box>
102
+ </Theme>
103
+ )
104
+ expect(getByText(textContent).parent).toHaveStyle({
105
+ paddingLeft: expectedScale[2],
106
+ paddingRight: expectedScale[4],
107
+ paddingTop: expectedScale[3],
108
+ paddingBottom: expectedScale[1]
86
109
  })
87
110
  })
88
111
  })
@@ -0,0 +1,63 @@
1
+ import React from 'react'
2
+ import { render } from '@testing-library/react-native'
3
+ import { Text } from 'react-native'
4
+
5
+ import { Card } from '../../src'
6
+ import Theme from '../../__fixtures__/Theme'
7
+ import testTheme from '../../__fixtures__/testTheme'
8
+
9
+ const contentText = 'This is a card'
10
+
11
+ const setup = ({ tokens } = {}) =>
12
+ render(
13
+ <Theme>
14
+ <Card tokens={tokens}>
15
+ <Text>{contentText}</Text>
16
+ </Card>
17
+ </Theme>
18
+ )
19
+
20
+ describe('Card', () => {
21
+ it('renders the card content', () => {
22
+ const { getByText } = setup()
23
+ const cardContent = getByText(contentText)
24
+ expect(cardContent).toBeTruthy()
25
+ })
26
+
27
+ it('renders the default style properly', () => {
28
+ const defaultStyle = testTheme.components.Card.tokens
29
+ const { getByText } = setup()
30
+ const card = getByText(contentText).parent
31
+ expect(card).toHaveStyle(defaultStyle)
32
+ })
33
+
34
+ it('renders a card with a custom background color', () => {
35
+ const backgroundColor = '#0F0F0F'
36
+ const { getByText } = setup({ tokens: { backgroundColor } })
37
+ const card = getByText(contentText).parent
38
+ expect(card).toHaveStyle({ backgroundColor })
39
+ })
40
+
41
+ it('renders a card with a custom border', () => {
42
+ const border = {
43
+ borderColor: '#123456',
44
+ borderWidth: 7,
45
+ borderRadius: 8
46
+ }
47
+ const { getByText } = setup({ tokens: { ...border } })
48
+ const card = getByText(contentText).parent
49
+ expect(card).toHaveStyle({ ...border })
50
+ })
51
+
52
+ it('renders a card with a custom padding', () => {
53
+ const padding = {
54
+ paddingBottom: 1,
55
+ paddingLeft: 2,
56
+ paddingRight: 3,
57
+ paddingTop: 4
58
+ }
59
+ const { getByText } = setup({ tokens: { ...padding } })
60
+ const card = getByText(contentText).parent
61
+ expect(card).toHaveStyle({ ...padding })
62
+ })
63
+ })