@superdispatch/ui 0.21.6 → 0.21.13

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 (233) hide show
  1. package/.babelrc.js +5 -0
  2. package/.turbo/turbo-version.log +28 -0
  3. package/package.json +65 -39
  4. package/pkg/README.md +30 -0
  5. package/{dist-node → pkg/dist-node}/index.js +2 -1
  6. package/pkg/dist-node/index.js.map +1 -0
  7. package/{dist-src → pkg/dist-src}/number-field/NumberField.js +2 -1
  8. package/{dist-types → pkg/dist-types}/index.d.ts +364 -364
  9. package/{dist-web → pkg/dist-web}/index.js +2 -1
  10. package/pkg/dist-web/index.js.map +1 -0
  11. package/pkg/package.json +39 -0
  12. package/playroom.ts +31 -0
  13. package/src/__tests__/index.spec.ts +134 -0
  14. package/src/adaptive-toolbar/AdaptiveToolbar.stories.tsx +50 -0
  15. package/src/adaptive-toolbar/AdaptiveToolbar.tsx +199 -0
  16. package/src/adaptive-toolbar/__tests__/AdaptiveToolbar.spec.tsx +11 -0
  17. package/src/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.stories.tsx +49 -0
  18. package/src/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.tsx +171 -0
  19. package/src/app-bar/AppBar.stories.tsx +62 -0
  20. package/src/app-bar/AppBarOverrides.ts +9 -0
  21. package/src/app-bar/__tests__/AppBar.spec.tsx +86 -0
  22. package/src/autocomplete/Autocomplete.stories.tsx +76 -0
  23. package/src/autocomplete/AutocompleteOverrides.tsx +58 -0
  24. package/src/autocomplete/__tests__/Autocomplete.spec.tsx +323 -0
  25. package/src/avatar/Avatar.stories.tsx +17 -0
  26. package/src/avatar/AvatarOverrides.ts +24 -0
  27. package/src/avatar/__tests__/Avatar.spec.tsx +71 -0
  28. package/src/avatar-button/AvatarButton.stories.tsx +153 -0
  29. package/src/avatar-button/AvatarButton.tsx +223 -0
  30. package/src/avatar-button/__tests__/AvatarButton.spec.tsx +126 -0
  31. package/src/button/Button.tsx +51 -0
  32. package/src/button/ButtonOverrides.ts +375 -0
  33. package/src/button/__tests__/Button.spec.tsx +599 -0
  34. package/src/card/Card.stories.tsx +39 -0
  35. package/src/card/CardOverrides.ts +9 -0
  36. package/src/card/__tests__/Card.spec.tsx +68 -0
  37. package/src/card-button/CardButton.stories.tsx +36 -0
  38. package/src/card-button/CardButton.tsx +202 -0
  39. package/src/card-button/__tests__/CardButton.spec.tsx +95 -0
  40. package/src/checkbox/CheckboxField.stories.tsx +61 -0
  41. package/src/checkbox/CheckboxField.tsx +56 -0
  42. package/src/checkbox/CheckboxGroudField.tsx +53 -0
  43. package/src/checkbox/CheckboxOverrides.tsx +55 -0
  44. package/src/checkbox/__tests__/Checkbox.spec.tsx +105 -0
  45. package/src/chip/Chip.stories.tsx +26 -0
  46. package/src/chip/ChipOverrides.tsx +111 -0
  47. package/src/chip/__tests__/Chip.spec.tsx +308 -0
  48. package/src/columns/Column.tsx +124 -0
  49. package/src/columns/Columns.stories.tsx +426 -0
  50. package/src/columns/Columns.tsx +76 -0
  51. package/src/description-list/DescriptionList.spec.tsx +137 -0
  52. package/src/description-list/DescriptionList.stories.tsx +148 -0
  53. package/src/description-list/DescriptionList.tsx +170 -0
  54. package/src/dialog/Dialog.playroom.tsx +24 -0
  55. package/src/dialog/Dialog.stories.tsx +60 -0
  56. package/src/dialog/DialogOverrides.ts +39 -0
  57. package/src/dialog/__tests__/Dialog.spec.tsx +219 -0
  58. package/src/drawer/Drawer.playroom.tsx +22 -0
  59. package/src/drawer/Drawer.stories.tsx +194 -0
  60. package/src/drawer/DrawerActions.tsx +69 -0
  61. package/src/drawer/DrawerContent.tsx +30 -0
  62. package/src/drawer/DrawerList.tsx +60 -0
  63. package/src/drawer/DrawerOverrides.ts +19 -0
  64. package/src/drawer/DrawerTitle.tsx +143 -0
  65. package/src/drawer/__tests__/Drawer.spec.tsx +227 -0
  66. package/src/dropdown-button/DropdownButton.stories.tsx +15 -0
  67. package/src/dropdown-button/DropdownButton.tsx +131 -0
  68. package/src/grid/GridStack.tsx +45 -0
  69. package/src/grid/InlineGrid.tsx +56 -0
  70. package/src/icon-button/IconButton.stories.tsx +53 -0
  71. package/src/icon-button/IconButtonOverrides.ts +32 -0
  72. package/src/icon-button/__tests__/IconButton.spec.tsx +124 -0
  73. package/src/index.ts +47 -0
  74. package/src/info-card/InfoCard.stories.tsx +29 -0
  75. package/src/info-card/InfoCard.tsx +95 -0
  76. package/src/info-card/__tests__/InfoCard.spec.tsx +22 -0
  77. package/src/info-tooltip/InfoTooltip.stories.tsx +77 -0
  78. package/src/info-tooltip/InfoTooltip.tsx +72 -0
  79. package/src/info-tooltip/__tests__/InfoTooltip.spec.tsx +166 -0
  80. package/src/inline/Inline.stories.tsx +135 -0
  81. package/src/inline/Inline.tsx +144 -0
  82. package/src/link/Link.stories.tsx +41 -0
  83. package/src/link/LinkOverrides.ts +43 -0
  84. package/src/link/__tests__/Link.spec.tsx +98 -0
  85. package/src/list/ListOverrides.ts +11 -0
  86. package/src/list/__tests__/List.spec.tsx +182 -0
  87. package/src/menu/Menu.stories.tsx +35 -0
  88. package/src/menu/MenuOverrides.ts +17 -0
  89. package/src/menu/__tests__/Menu.spec.tsx +99 -0
  90. package/src/number-field/NumberField.stories.tsx +123 -0
  91. package/src/number-field/NumberField.tsx +98 -0
  92. package/src/overflow-text/OverflowText.stories.tsx +32 -0
  93. package/src/overflow-text/OverflowText.tsx +114 -0
  94. package/src/overflow-text/__tests__/OverflowText.spec.tsx +24 -0
  95. package/src/pagination/Pagination.stories.tsx +36 -0
  96. package/src/pagination/PaginationOverrides.ts +47 -0
  97. package/src/pagination/__tests__/Pagination.spec.tsx +228 -0
  98. package/src/paper/PaperOverrides.ts +10 -0
  99. package/src/paper/__tests__/Paper.spec.tsx +155 -0
  100. package/src/props/AlignProps.ts +22 -0
  101. package/src/props/CollapseProp.ts +13 -0
  102. package/src/props/ResponsiveProp.ts +65 -0
  103. package/src/props/SpaceProp.ts +40 -0
  104. package/src/radio/RadioField.stories.tsx +42 -0
  105. package/src/radio/RadioField.tsx +55 -0
  106. package/src/radio/RadioGroupField.tsx +64 -0
  107. package/src/radio/RadioOverrides.tsx +51 -0
  108. package/src/radio/__tests__/Radio.spec.tsx +90 -0
  109. package/src/responsive/CollapseBreakpoint.ts +21 -0
  110. package/src/responsive/MinBreakpoint.ts +21 -0
  111. package/src/responsive/ResponsiveContext.tsx +57 -0
  112. package/src/snackbar/Snackbar.stories.tsx +196 -0
  113. package/src/snackbar/Snackbar.tsx +83 -0
  114. package/src/snackbar/SnackbarContent.tsx +147 -0
  115. package/src/snackbar/SnackbarOverrides.ts +23 -0
  116. package/src/snackbar/SnackbarStack.tsx +160 -0
  117. package/src/snackbar/__tests__/Snackbar.spec.tsx +196 -0
  118. package/src/stack/Stack.stories.tsx +113 -0
  119. package/src/stack/Stack.tsx +86 -0
  120. package/src/svg-icon/SvgIcon.stories.tsx +29 -0
  121. package/src/svg-icon/SvgIconOverrides.ts +32 -0
  122. package/src/svg-icon/__tests__/SvgIcon.spec.tsx +67 -0
  123. package/src/switch/Switch.stories.tsx +60 -0
  124. package/src/switch/SwitchOverrides.ts +88 -0
  125. package/src/switch/__tests__/Switch.spec.tsx +204 -0
  126. package/src/tabs/Tabs.stories.tsx +40 -0
  127. package/src/tabs/TabsOverrides.ts +45 -0
  128. package/src/tabs/__tests__/Tabs.spec.tsx +226 -0
  129. package/src/tag/Tag.stories.tsx +53 -0
  130. package/src/tag/Tag.tsx +130 -0
  131. package/src/tag/__tests__/Tag.spec.tsx +82 -0
  132. package/src/text-field/TextField.stories.tsx +50 -0
  133. package/src/text-field/TextFieldOverrides.tsx +149 -0
  134. package/src/text-field/__tests__/TextField.spec.tsx +662 -0
  135. package/src/theme/Color.ts +117 -0
  136. package/src/theme/SuperDispatchTheme.ts +3 -0
  137. package/src/theme/ThemeProvider.tsx +179 -0
  138. package/src/theme/__tests__/CssBaseline.spec.tsx +49 -0
  139. package/src/theme/__tests__/ThemeProvider.spec.ts +40 -0
  140. package/src/theme/__tests__/__snapshots__/ThemeProvider.spec.ts.snap +204 -0
  141. package/src/tiles/Tiles.stories.tsx +69 -0
  142. package/src/tiles/Tiles.tsx +163 -0
  143. package/src/tiles/__tests__/Tiles.spec.tsx +221 -0
  144. package/src/toolbar/ToolbarOverrides.ts +14 -0
  145. package/src/toolbar/__tests__/Toolbar.spec.tsx +50 -0
  146. package/src/tooltip/Tooltip.stories.tsx +32 -0
  147. package/src/tooltip/TooltipOverrides.ts +34 -0
  148. package/src/tooltip/__tests__/Tooltip.spec.tsx +182 -0
  149. package/src/typography/Typography.stories.tsx +132 -0
  150. package/src/typography/TypographyOverrides.ts +125 -0
  151. package/src/typography/__tests__/Typography.spec.tsx +253 -0
  152. package/src/utils/ExitTransitionPlaceholder.tsx +22 -0
  153. package/src/utils/ResizeObserver.tsx +28 -0
  154. package/src/utils/VisibilityObserver.tsx +75 -0
  155. package/src/utils/__tests__/ExitTransitionPlaceholder.spec.tsx +34 -0
  156. package/src/utils/isEmptyReactNode.ts +11 -0
  157. package/src/utils/mergeRefs.ts +21 -0
  158. package/src/utils/renderChildren.ts +10 -0
  159. package/src/utils/useUID.ts +9 -0
  160. package/tsconfig.json +19 -0
  161. package/LICENSE +0 -21
  162. package/dist-node/index.js.map +0 -1
  163. package/dist-web/index.js.map +0 -1
  164. /package/{dist-src → pkg/dist-src}/adaptive-toolbar/AdaptiveToolbar.js +0 -0
  165. /package/{dist-src → pkg/dist-src}/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.js +0 -0
  166. /package/{dist-src → pkg/dist-src}/app-bar/AppBarOverrides.js +0 -0
  167. /package/{dist-src → pkg/dist-src}/autocomplete/AutocompleteOverrides.js +0 -0
  168. /package/{dist-src → pkg/dist-src}/avatar/AvatarOverrides.js +0 -0
  169. /package/{dist-src → pkg/dist-src}/avatar-button/AvatarButton.js +0 -0
  170. /package/{dist-src → pkg/dist-src}/button/Button.js +0 -0
  171. /package/{dist-src → pkg/dist-src}/button/ButtonOverrides.js +0 -0
  172. /package/{dist-src → pkg/dist-src}/card/CardOverrides.js +0 -0
  173. /package/{dist-src → pkg/dist-src}/card-button/CardButton.js +0 -0
  174. /package/{dist-src → pkg/dist-src}/checkbox/CheckboxField.js +0 -0
  175. /package/{dist-src → pkg/dist-src}/checkbox/CheckboxGroudField.js +0 -0
  176. /package/{dist-src → pkg/dist-src}/checkbox/CheckboxOverrides.js +0 -0
  177. /package/{dist-src → pkg/dist-src}/chip/ChipOverrides.js +0 -0
  178. /package/{dist-src → pkg/dist-src}/columns/Column.js +0 -0
  179. /package/{dist-src → pkg/dist-src}/columns/Columns.js +0 -0
  180. /package/{dist-src → pkg/dist-src}/description-list/DescriptionList.js +0 -0
  181. /package/{dist-src → pkg/dist-src}/dialog/DialogOverrides.js +0 -0
  182. /package/{dist-src → pkg/dist-src}/drawer/DrawerActions.js +0 -0
  183. /package/{dist-src → pkg/dist-src}/drawer/DrawerContent.js +0 -0
  184. /package/{dist-src → pkg/dist-src}/drawer/DrawerList.js +0 -0
  185. /package/{dist-src → pkg/dist-src}/drawer/DrawerOverrides.js +0 -0
  186. /package/{dist-src → pkg/dist-src}/drawer/DrawerTitle.js +0 -0
  187. /package/{dist-src → pkg/dist-src}/dropdown-button/DropdownButton.js +0 -0
  188. /package/{dist-src → pkg/dist-src}/grid/GridStack.js +0 -0
  189. /package/{dist-src → pkg/dist-src}/grid/InlineGrid.js +0 -0
  190. /package/{dist-src → pkg/dist-src}/icon-button/IconButtonOverrides.js +0 -0
  191. /package/{dist-src → pkg/dist-src}/index.js +0 -0
  192. /package/{dist-src → pkg/dist-src}/info-card/InfoCard.js +0 -0
  193. /package/{dist-src → pkg/dist-src}/inline/Inline.js +0 -0
  194. /package/{dist-src → pkg/dist-src}/link/LinkOverrides.js +0 -0
  195. /package/{dist-src → pkg/dist-src}/list/ListOverrides.js +0 -0
  196. /package/{dist-src → pkg/dist-src}/menu/MenuOverrides.js +0 -0
  197. /package/{dist-src → pkg/dist-src}/overflow-text/OverflowText.js +0 -0
  198. /package/{dist-src → pkg/dist-src}/pagination/PaginationOverrides.js +0 -0
  199. /package/{dist-src → pkg/dist-src}/paper/PaperOverrides.js +0 -0
  200. /package/{dist-src → pkg/dist-src}/props/AlignProps.js +0 -0
  201. /package/{dist-src → pkg/dist-src}/props/CollapseProp.js +0 -0
  202. /package/{dist-src → pkg/dist-src}/props/ResponsiveProp.js +0 -0
  203. /package/{dist-src → pkg/dist-src}/props/SpaceProp.js +0 -0
  204. /package/{dist-src → pkg/dist-src}/radio/RadioField.js +0 -0
  205. /package/{dist-src → pkg/dist-src}/radio/RadioGroupField.js +0 -0
  206. /package/{dist-src → pkg/dist-src}/radio/RadioOverrides.js +0 -0
  207. /package/{dist-src → pkg/dist-src}/responsive/CollapseBreakpoint.js +0 -0
  208. /package/{dist-src → pkg/dist-src}/responsive/MinBreakpoint.js +0 -0
  209. /package/{dist-src → pkg/dist-src}/responsive/ResponsiveContext.js +0 -0
  210. /package/{dist-src → pkg/dist-src}/snackbar/Snackbar.js +0 -0
  211. /package/{dist-src → pkg/dist-src}/snackbar/SnackbarContent.js +0 -0
  212. /package/{dist-src → pkg/dist-src}/snackbar/SnackbarOverrides.js +0 -0
  213. /package/{dist-src → pkg/dist-src}/snackbar/SnackbarStack.js +0 -0
  214. /package/{dist-src → pkg/dist-src}/stack/Stack.js +0 -0
  215. /package/{dist-src → pkg/dist-src}/svg-icon/SvgIconOverrides.js +0 -0
  216. /package/{dist-src → pkg/dist-src}/switch/SwitchOverrides.js +0 -0
  217. /package/{dist-src → pkg/dist-src}/tabs/TabsOverrides.js +0 -0
  218. /package/{dist-src → pkg/dist-src}/tag/Tag.js +0 -0
  219. /package/{dist-src → pkg/dist-src}/text-field/TextFieldOverrides.js +0 -0
  220. /package/{dist-src → pkg/dist-src}/theme/Color.js +0 -0
  221. /package/{dist-src → pkg/dist-src}/theme/SuperDispatchTheme.js +0 -0
  222. /package/{dist-src → pkg/dist-src}/theme/ThemeProvider.js +0 -0
  223. /package/{dist-src → pkg/dist-src}/tiles/Tiles.js +0 -0
  224. /package/{dist-src → pkg/dist-src}/toolbar/ToolbarOverrides.js +0 -0
  225. /package/{dist-src → pkg/dist-src}/tooltip/TooltipOverrides.js +0 -0
  226. /package/{dist-src → pkg/dist-src}/typography/TypographyOverrides.js +0 -0
  227. /package/{dist-src → pkg/dist-src}/utils/ExitTransitionPlaceholder.js +0 -0
  228. /package/{dist-src → pkg/dist-src}/utils/ResizeObserver.js +0 -0
  229. /package/{dist-src → pkg/dist-src}/utils/VisibilityObserver.js +0 -0
  230. /package/{dist-src → pkg/dist-src}/utils/isEmptyReactNode.js +0 -0
  231. /package/{dist-src → pkg/dist-src}/utils/mergeRefs.js +0 -0
  232. /package/{dist-src → pkg/dist-src}/utils/renderChildren.js +0 -0
  233. /package/{dist-src → pkg/dist-src}/utils/useUID.js +0 -0
@@ -0,0 +1,132 @@
1
+ import { Typography } from '@material-ui/core';
2
+ import { PropsLink } from '@superdispatch/ui-docs';
3
+ import { Stack } from '../stack/Stack';
4
+
5
+ export default {
6
+ title: 'Data Display/Typography',
7
+ parameters: {
8
+ componentSubtitle: (
9
+ <PropsLink url="https://material-ui.com/api/typography/#props" />
10
+ ),
11
+ },
12
+ };
13
+
14
+ export const basic = () => (
15
+ <Stack>
16
+ <Typography variant="h1">h1</Typography>
17
+ <Typography variant="h2">h2</Typography>
18
+ <Typography variant="h3">h3</Typography>
19
+ <Typography variant="h4">h4</Typography>
20
+ <Typography variant="h5">h5</Typography>
21
+ <Typography variant="h6">h6</Typography>
22
+ <Typography variant="subtitle1">subtitle1</Typography>
23
+ <Typography variant="subtitle2">subtitle2</Typography>
24
+ <Typography variant="body1">body1</Typography>
25
+ <Typography variant="body2">body2</Typography>
26
+ </Stack>
27
+ );
28
+
29
+ export const secondary = () => (
30
+ <Stack>
31
+ <Typography variant="h1" color="textSecondary">
32
+ h1
33
+ </Typography>
34
+ <Typography variant="h2" color="textSecondary">
35
+ h2
36
+ </Typography>
37
+ <Typography variant="h3" color="textSecondary">
38
+ h3
39
+ </Typography>
40
+ <Typography variant="h4" color="textSecondary">
41
+ h4
42
+ </Typography>
43
+ <Typography variant="h5" color="textSecondary">
44
+ h5
45
+ </Typography>
46
+ <Typography variant="h6" color="textSecondary">
47
+ h6
48
+ </Typography>
49
+ <Typography variant="subtitle1" color="textSecondary">
50
+ subtitle1
51
+ </Typography>
52
+ <Typography variant="subtitle2" color="textSecondary">
53
+ subtitle2
54
+ </Typography>
55
+ <Typography variant="body1" color="textSecondary">
56
+ body1
57
+ </Typography>
58
+ <Typography variant="body2" color="textSecondary">
59
+ body2
60
+ </Typography>
61
+ </Stack>
62
+ );
63
+
64
+ export const primary = () => (
65
+ <Stack>
66
+ <Typography variant="h1" color="textPrimary">
67
+ h1
68
+ </Typography>
69
+ <Typography variant="h2" color="textPrimary">
70
+ h2
71
+ </Typography>
72
+ <Typography variant="h3" color="textPrimary">
73
+ h3
74
+ </Typography>
75
+ <Typography variant="h4" color="textPrimary">
76
+ h4
77
+ </Typography>
78
+ <Typography variant="h5" color="textPrimary">
79
+ h5
80
+ </Typography>
81
+ <Typography variant="h6" color="textPrimary">
82
+ h6
83
+ </Typography>
84
+ <Typography variant="subtitle1" color="textPrimary">
85
+ subtitle1
86
+ </Typography>
87
+ <Typography variant="subtitle2" color="textPrimary">
88
+ subtitle2
89
+ </Typography>
90
+ <Typography variant="body1" color="textPrimary">
91
+ body1
92
+ </Typography>
93
+ <Typography variant="body2" color="textPrimary">
94
+ body2
95
+ </Typography>
96
+ </Stack>
97
+ );
98
+
99
+ export const error = () => (
100
+ <Stack>
101
+ <Typography variant="h1" color="error">
102
+ h1
103
+ </Typography>
104
+ <Typography variant="h2" color="error">
105
+ h2
106
+ </Typography>
107
+ <Typography variant="h3" color="error">
108
+ h3
109
+ </Typography>
110
+ <Typography variant="h4" color="error">
111
+ h4
112
+ </Typography>
113
+ <Typography variant="h5" color="error">
114
+ h5
115
+ </Typography>
116
+ <Typography variant="h6" color="error">
117
+ h6
118
+ </Typography>
119
+ <Typography variant="subtitle1" color="error">
120
+ subtitle1
121
+ </Typography>
122
+ <Typography variant="subtitle2" color="error">
123
+ subtitle2
124
+ </Typography>
125
+ <Typography variant="body1" color="error">
126
+ body1
127
+ </Typography>
128
+ <Typography variant="body2" color="error">
129
+ body2
130
+ </Typography>
131
+ </Stack>
132
+ );
@@ -0,0 +1,125 @@
1
+ import { Breakpoints } from '@material-ui/core/styles/createBreakpoints';
2
+ import { TypographyOptions } from '@material-ui/core/styles/createTypography';
3
+ import { SuperDispatchTheme } from '../theme/SuperDispatchTheme';
4
+
5
+ export function createTypographyOptions(
6
+ breakpoints: Breakpoints,
7
+ ): TypographyOptions {
8
+ const xsOnly = breakpoints.only('xs');
9
+
10
+ return {
11
+ fontSize: 14,
12
+ fontWeightLight: 300,
13
+ fontWeightRegular: 400,
14
+ fontWeightMedium: 500,
15
+ fontWeightBold: 600,
16
+ fontFamily: '"Inter", sans-serif',
17
+
18
+ h1: {
19
+ fontSize: '32px',
20
+ lineHeight: '40px',
21
+ fontWeight: 700,
22
+ [xsOnly]: {
23
+ fontSize: '28px',
24
+ lineHeight: '36px',
25
+ },
26
+ },
27
+
28
+ h2: {
29
+ fontSize: '24px',
30
+ lineHeight: '28px',
31
+ fontWeight: 500,
32
+ [xsOnly]: {
33
+ fontSize: '22px',
34
+ lineHeight: '26px',
35
+ },
36
+ },
37
+
38
+ h3: {
39
+ fontSize: '20px',
40
+ lineHeight: '28px',
41
+ fontWeight: 500,
42
+ [xsOnly]: {
43
+ fontSize: '20px',
44
+ lineHeight: '26px',
45
+ },
46
+ },
47
+
48
+ h4: {
49
+ fontSize: '16px',
50
+ lineHeight: '24px',
51
+ fontWeight: 500,
52
+ [xsOnly]: {
53
+ fontSize: '17px',
54
+ lineHeight: '26px',
55
+ },
56
+ },
57
+
58
+ h5: {
59
+ fontSize: '14px',
60
+ lineHeight: '20px',
61
+ fontWeight: 600,
62
+ [xsOnly]: {
63
+ fontSize: '16px',
64
+ lineHeight: '24px',
65
+ },
66
+ },
67
+
68
+ h6: {
69
+ fontSize: '12px',
70
+ lineHeight: '16px',
71
+ fontWeight: 700,
72
+ letterSpacing: '0.1em',
73
+ textTransform: 'uppercase',
74
+ [xsOnly]: {
75
+ fontSize: '14px',
76
+ lineHeight: '20px',
77
+ },
78
+ },
79
+
80
+ body1: {
81
+ fontSize: '14px',
82
+ lineHeight: '20px',
83
+ fontWeight: 600,
84
+ [xsOnly]: {
85
+ fontSize: '16px',
86
+ lineHeight: '24px',
87
+ },
88
+ },
89
+
90
+ body2: {
91
+ fontSize: '14px',
92
+ lineHeight: '20px',
93
+ fontWeight: 400,
94
+ [xsOnly]: {
95
+ fontSize: '16px',
96
+ lineHeight: '24px',
97
+ },
98
+ },
99
+
100
+ caption: {
101
+ fontSize: '12px',
102
+ lineHeight: '16px',
103
+ fontWeight: 400,
104
+ [xsOnly]: {
105
+ fontSize: '14px',
106
+ lineHeight: '20px',
107
+ },
108
+ },
109
+
110
+ button: {
111
+ fontSize: '14px',
112
+ lineHeight: '20px',
113
+ fontWeight: 600,
114
+ textTransform: undefined,
115
+ [xsOnly]: {
116
+ fontSize: '16px',
117
+ lineHeight: '24px',
118
+ },
119
+ },
120
+ };
121
+ }
122
+
123
+ export function overrideTypography(theme: SuperDispatchTheme): void {
124
+ theme.props.MuiTypography = { variant: 'body2' };
125
+ }
@@ -0,0 +1,253 @@
1
+ import { Typography } from '@material-ui/core';
2
+ import { renderCSS, renderTheme } from '@superdispatch/ui-testutils';
3
+
4
+ it('checks default props', () => {
5
+ const { props } = renderTheme();
6
+
7
+ expect(props.MuiTypography).toMatchInlineSnapshot(`
8
+ Object {
9
+ "variant": "body2",
10
+ }
11
+ `);
12
+ });
13
+
14
+ it('checks component css', () => {
15
+ expect(renderCSS(<Typography />, ['MuiTypography'])).toMatchInlineSnapshot(`
16
+ .MuiTypography-root {
17
+ margin: 0;
18
+ }
19
+
20
+ .MuiTypography-body2 {
21
+ font-size: 14px;
22
+ font-family: 'Inter', sans-serif;
23
+ font-weight: 400;
24
+ line-height: 20px;
25
+ }
26
+
27
+ @media (min-width: 0px) and (max-width: 599.95px) {
28
+ .MuiTypography-body2 {
29
+ font-size: 16px;
30
+ line-height: 24px;
31
+ }
32
+ }
33
+
34
+ .MuiTypography-body1 {
35
+ font-size: 14px;
36
+ font-family: 'Inter', sans-serif;
37
+ font-weight: 600;
38
+ line-height: 20px;
39
+ }
40
+
41
+ @media (min-width: 0px) and (max-width: 599.95px) {
42
+ .MuiTypography-body1 {
43
+ font-size: 16px;
44
+ line-height: 24px;
45
+ }
46
+ }
47
+
48
+ .MuiTypography-caption {
49
+ font-size: 12px;
50
+ font-family: 'Inter', sans-serif;
51
+ font-weight: 400;
52
+ line-height: 16px;
53
+ }
54
+
55
+ @media (min-width: 0px) and (max-width: 599.95px) {
56
+ .MuiTypography-caption {
57
+ font-size: 14px;
58
+ line-height: 20px;
59
+ }
60
+ }
61
+
62
+ .MuiTypography-button {
63
+ font-size: 14px;
64
+ font-family: 'Inter', sans-serif;
65
+ font-weight: 600;
66
+ line-height: 20px;
67
+ }
68
+
69
+ @media (min-width: 0px) and (max-width: 599.95px) {
70
+ .MuiTypography-button {
71
+ font-size: 16px;
72
+ line-height: 24px;
73
+ }
74
+ }
75
+
76
+ .MuiTypography-h1 {
77
+ font-size: 32px;
78
+ font-family: 'Inter', sans-serif;
79
+ font-weight: 700;
80
+ line-height: 40px;
81
+ }
82
+
83
+ @media (min-width: 0px) and (max-width: 599.95px) {
84
+ .MuiTypography-h1 {
85
+ font-size: 28px;
86
+ line-height: 36px;
87
+ }
88
+ }
89
+
90
+ .MuiTypography-h2 {
91
+ font-size: 24px;
92
+ font-family: 'Inter', sans-serif;
93
+ font-weight: 500;
94
+ line-height: 28px;
95
+ }
96
+
97
+ @media (min-width: 0px) and (max-width: 599.95px) {
98
+ .MuiTypography-h2 {
99
+ font-size: 22px;
100
+ line-height: 26px;
101
+ }
102
+ }
103
+
104
+ .MuiTypography-h3 {
105
+ font-size: 20px;
106
+ font-family: 'Inter', sans-serif;
107
+ font-weight: 500;
108
+ line-height: 28px;
109
+ }
110
+
111
+ @media (min-width: 0px) and (max-width: 599.95px) {
112
+ .MuiTypography-h3 {
113
+ font-size: 20px;
114
+ line-height: 26px;
115
+ }
116
+ }
117
+
118
+ .MuiTypography-h4 {
119
+ font-size: 16px;
120
+ font-family: 'Inter', sans-serif;
121
+ font-weight: 500;
122
+ line-height: 24px;
123
+ }
124
+
125
+ @media (min-width: 0px) and (max-width: 599.95px) {
126
+ .MuiTypography-h4 {
127
+ font-size: 17px;
128
+ line-height: 26px;
129
+ }
130
+ }
131
+
132
+ .MuiTypography-h5 {
133
+ font-size: 14px;
134
+ font-family: 'Inter', sans-serif;
135
+ font-weight: 600;
136
+ line-height: 20px;
137
+ }
138
+
139
+ @media (min-width: 0px) and (max-width: 599.95px) {
140
+ .MuiTypography-h5 {
141
+ font-size: 16px;
142
+ line-height: 24px;
143
+ }
144
+ }
145
+
146
+ .MuiTypography-h6 {
147
+ font-size: 12px;
148
+ font-family: 'Inter', sans-serif;
149
+ font-weight: 700;
150
+ line-height: 16px;
151
+ letter-spacing: 0.1em;
152
+ text-transform: uppercase;
153
+ }
154
+
155
+ @media (min-width: 0px) and (max-width: 599.95px) {
156
+ .MuiTypography-h6 {
157
+ font-size: 14px;
158
+ line-height: 20px;
159
+ }
160
+ }
161
+
162
+ .MuiTypography-subtitle1 {
163
+ font-size: 1rem;
164
+ font-family: 'Inter', sans-serif;
165
+ font-weight: 400;
166
+ line-height: 1.75;
167
+ }
168
+
169
+ .MuiTypography-subtitle2 {
170
+ font-size: 0.875rem;
171
+ font-family: 'Inter', sans-serif;
172
+ font-weight: 500;
173
+ line-height: 1.57;
174
+ }
175
+
176
+ .MuiTypography-overline {
177
+ font-size: 0.75rem;
178
+ font-family: 'Inter', sans-serif;
179
+ font-weight: 400;
180
+ line-height: 2.66;
181
+ text-transform: uppercase;
182
+ }
183
+
184
+ .MuiTypography-srOnly {
185
+ width: 1px;
186
+ height: 1px;
187
+ overflow: hidden;
188
+ position: absolute;
189
+ }
190
+
191
+ .MuiTypography-alignLeft {
192
+ text-align: left;
193
+ }
194
+
195
+ .MuiTypography-alignCenter {
196
+ text-align: center;
197
+ }
198
+
199
+ .MuiTypography-alignRight {
200
+ text-align: right;
201
+ }
202
+
203
+ .MuiTypography-alignJustify {
204
+ text-align: justify;
205
+ }
206
+
207
+ .MuiTypography-noWrap {
208
+ overflow: hidden;
209
+ white-space: nowrap;
210
+ text-overflow: ellipsis;
211
+ }
212
+
213
+ .MuiTypography-gutterBottom {
214
+ margin-bottom: 0.35em;
215
+ }
216
+
217
+ .MuiTypography-paragraph {
218
+ margin-bottom: 16px;
219
+ }
220
+
221
+ .MuiTypography-colorInherit {
222
+ color: inherit;
223
+ }
224
+
225
+ .MuiTypography-colorPrimary {
226
+ color: Color.Blue300;
227
+ }
228
+
229
+ .MuiTypography-colorSecondary {
230
+ color: #f50057;
231
+ }
232
+
233
+ .MuiTypography-colorTextPrimary {
234
+ color: Color.Dark500;
235
+ }
236
+
237
+ .MuiTypography-colorTextSecondary {
238
+ color: Color.Dark200;
239
+ }
240
+
241
+ .MuiTypography-colorError {
242
+ color: Color.Red300;
243
+ }
244
+
245
+ .MuiTypography-displayInline {
246
+ display: inline;
247
+ }
248
+
249
+ .MuiTypography-displayBlock {
250
+ display: block;
251
+ }
252
+ `);
253
+ });
@@ -0,0 +1,22 @@
1
+ import { ReactElement, ReactNode, useEffect, useState } from 'react';
2
+ import { renderChildren } from './renderChildren';
3
+
4
+ interface ExitTransitionPlaceholderProps {
5
+ in: boolean;
6
+ children: ReactNode;
7
+ }
8
+
9
+ export function ExitTransitionPlaceholder({
10
+ in: inProp,
11
+ children: childrenProp,
12
+ }: ExitTransitionPlaceholderProps): null | ReactElement {
13
+ const [children, setChildren] = useState(childrenProp);
14
+
15
+ useEffect(() => {
16
+ if (inProp) {
17
+ setChildren(childrenProp);
18
+ }
19
+ }, [inProp, childrenProp]);
20
+
21
+ return renderChildren(children);
22
+ }
@@ -0,0 +1,28 @@
1
+ import { ResizeObserver } from '@juggle/resize-observer';
2
+ import { useEventHandler } from '@superdispatch/hooks';
3
+ import { useLayoutEffect } from 'react';
4
+
5
+ export function useResizeObserver<T extends HTMLElement>(
6
+ node: null | undefined | T,
7
+ observer: (node: T) => void,
8
+ ): void {
9
+ const handler = useEventHandler(observer);
10
+
11
+ useLayoutEffect(() => {
12
+ if (!node) {
13
+ return;
14
+ }
15
+
16
+ const resizeObserver = new ResizeObserver(() => {
17
+ handler(node);
18
+ });
19
+
20
+ resizeObserver.observe(node);
21
+
22
+ handler(node);
23
+
24
+ return () => {
25
+ resizeObserver.disconnect();
26
+ };
27
+ }, [node, handler]);
28
+ }
@@ -0,0 +1,75 @@
1
+ import { useValueObserver } from '@superdispatch/hooks';
2
+ import { ReactElement, ReactNode, useLayoutEffect, useState } from 'react';
3
+ import { renderChildren } from './renderChildren';
4
+
5
+ export type ElementVisibility = 'undetermined' | 'visible' | 'invisible';
6
+
7
+ export interface VisibilityObserverOptions {
8
+ threshold?: number;
9
+ marginTop?: string;
10
+ marginLeft?: string;
11
+ marginRight?: string;
12
+ marginBottom?: string;
13
+ }
14
+
15
+ export function useVisibilityObserver<T extends Element>(
16
+ node: null | undefined | T,
17
+ {
18
+ threshold = 0,
19
+ marginTop = '0px',
20
+ marginLeft = '0px',
21
+ marginRight = '0px',
22
+ marginBottom = '0px',
23
+ }: VisibilityObserverOptions = {},
24
+ ): ElementVisibility {
25
+ const [state, setState] = useState<ElementVisibility>('undetermined');
26
+ const rootMargin = `${marginTop} ${marginRight} ${marginBottom} ${marginLeft}`;
27
+
28
+ useLayoutEffect(() => {
29
+ if (!node || !('IntersectionObserver' in window)) {
30
+ setState('undetermined');
31
+ return;
32
+ }
33
+
34
+ const observer = new IntersectionObserver(
35
+ ([entry]) => {
36
+ setState(entry?.isIntersecting ? 'visible' : 'invisible');
37
+ },
38
+ { rootMargin, threshold },
39
+ );
40
+
41
+ observer.observe(node);
42
+
43
+ return () => {
44
+ observer.disconnect();
45
+ };
46
+ }, [node, threshold, rootMargin]);
47
+
48
+ return state;
49
+ }
50
+
51
+ export interface VisibilityObserverRenderProps {
52
+ visibility: ElementVisibility;
53
+ ref: <T extends HTMLElement>(node: null | T) => void;
54
+ }
55
+
56
+ export interface VisibilityObserverProps extends VisibilityObserverOptions {
57
+ render: (props: VisibilityObserverRenderProps) => ReactNode;
58
+ onChange?: (visibility: ElementVisibility) => void;
59
+ }
60
+
61
+ export function VisibilityObserver({
62
+ render,
63
+ onChange,
64
+ ...options
65
+ }: VisibilityObserverProps): null | ReactElement {
66
+ const [node, setNode] = useState<null | HTMLElement>(null);
67
+ const visibility = useVisibilityObserver(node, options);
68
+ const children = render({ ref: setNode, visibility });
69
+
70
+ useValueObserver(visibility, () => {
71
+ onChange?.(visibility);
72
+ });
73
+
74
+ return renderChildren(children);
75
+ }
@@ -0,0 +1,34 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { ExitTransitionPlaceholder } from '../ExitTransitionPlaceholder';
3
+
4
+ it('render null child', () => {
5
+ const child = null;
6
+ const { container } = render(
7
+ <ExitTransitionPlaceholder in={true}>{child}</ExitTransitionPlaceholder>,
8
+ );
9
+ expect(container).toBeEmptyDOMElement();
10
+ });
11
+
12
+ it('render null with boolean child', () => {
13
+ const child = true;
14
+ const { container } = render(
15
+ <ExitTransitionPlaceholder in={true}>{child}</ExitTransitionPlaceholder>,
16
+ );
17
+ expect(container).toBeEmptyDOMElement();
18
+ });
19
+
20
+ it('render child', () => {
21
+ const { rerender } = render(
22
+ <ExitTransitionPlaceholder in={true}>
23
+ <p>Test</p>
24
+ </ExitTransitionPlaceholder>,
25
+ );
26
+ expect(screen.getByText('Test')).toBeInTheDocument();
27
+
28
+ rerender(
29
+ <ExitTransitionPlaceholder in={false}>
30
+ <p />
31
+ </ExitTransitionPlaceholder>,
32
+ );
33
+ expect(screen.getByText('Test')).toBeInTheDocument();
34
+ });
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ export function isEmptyReactNode(
4
+ node: ReactNode,
5
+ ): node is null | undefined | boolean | string {
6
+ return (
7
+ node == null ||
8
+ typeof node == 'boolean' ||
9
+ (typeof node == 'string' && node.length === 0)
10
+ );
11
+ }
@@ -0,0 +1,21 @@
1
+ import { MutableRefObject, Ref } from 'react';
2
+
3
+ export function mergeRefs<T>(
4
+ ...refs: Array<null | undefined | Ref<T>>
5
+ ): (node: T) => void {
6
+ return (node) => {
7
+ refs.forEach((ref) => {
8
+ assignRef(ref, node);
9
+ });
10
+ };
11
+ }
12
+
13
+ export function assignRef<T>(ref: Ref<T> | undefined, value: T): void {
14
+ if (ref) {
15
+ if (typeof ref === 'function') {
16
+ ref(value);
17
+ } else {
18
+ (ref as MutableRefObject<T>).current = value;
19
+ }
20
+ }
21
+ }