@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,227 @@
1
+ import { Drawer } from '@material-ui/core';
2
+ import { renderCSS, renderTheme } from '@superdispatch/ui-testutils';
3
+ import { DrawerActions } from '../DrawerActions';
4
+ import { DrawerContent } from '../DrawerContent';
5
+ import { DrawerList } from '../DrawerList';
6
+ import { DrawerTitle } from '../DrawerTitle';
7
+
8
+ it('checks default props', () => {
9
+ const { props } = renderTheme();
10
+
11
+ expect(props.MuiDrawer).toMatchInlineSnapshot(`
12
+ Object {
13
+ "anchor": "right",
14
+ }
15
+ `);
16
+ });
17
+
18
+ it('checks component css', () => {
19
+ expect(
20
+ renderCSS(
21
+ <Drawer open={true}>
22
+ <DrawerTitle title="Title" />
23
+ <DrawerContent />
24
+ <DrawerList />
25
+ <DrawerActions />
26
+ </Drawer>,
27
+ [
28
+ 'MuiDrawer',
29
+ 'SD-DrawerActions',
30
+ 'SD-DrawerContent',
31
+ 'SD-DrawerList',
32
+ 'SD-DrawerTitle',
33
+ ],
34
+ ),
35
+ ).toMatchInlineSnapshot(`
36
+ .MuiDrawer-docked {
37
+ flex: 0 0 auto;
38
+ }
39
+
40
+ .MuiDrawer-paper {
41
+ top: 0;
42
+ flex: 1 0 auto;
43
+ height: 100%;
44
+ display: flex;
45
+ outline: 0;
46
+ z-index: 1200;
47
+ position: fixed;
48
+ max-width: 100%;
49
+ min-width: 100%;
50
+ overflow-y: auto;
51
+ flex-direction: column;
52
+ -webkit-overflow-scrolling: touch;
53
+ }
54
+
55
+ @media (min-width: 600px) {
56
+ .MuiDrawer-paper {
57
+ max-width: 600px;
58
+ min-width: 432px;
59
+ }
60
+ }
61
+
62
+ .MuiDrawer-paperAnchorLeft {
63
+ left: 0;
64
+ right: auto;
65
+ }
66
+
67
+ .MuiDrawer-paperAnchorRight {
68
+ left: auto;
69
+ right: 0;
70
+ }
71
+
72
+ .MuiDrawer-paperAnchorTop {
73
+ top: 0;
74
+ left: 0;
75
+ right: 0;
76
+ bottom: auto;
77
+ height: auto;
78
+ max-height: 100%;
79
+ }
80
+
81
+ .MuiDrawer-paperAnchorBottom {
82
+ top: auto;
83
+ left: 0;
84
+ right: 0;
85
+ bottom: 0;
86
+ height: auto;
87
+ max-height: 100%;
88
+ }
89
+
90
+ .MuiDrawer-paperAnchorDockedLeft {
91
+ border-right: 1px solid Color.Silver400;
92
+ }
93
+
94
+ .MuiDrawer-paperAnchorDockedTop {
95
+ border-bottom: 1px solid Color.Silver400;
96
+ }
97
+
98
+ .MuiDrawer-paperAnchorDockedRight {
99
+ border-left: 1px solid Color.Silver400;
100
+ }
101
+
102
+ .MuiDrawer-paperAnchorDockedBottom {
103
+ border-top: 1px solid Color.Silver400;
104
+ }
105
+
106
+ .SD-DrawerActions-appBar.SD-DrawerActions-appBar {
107
+ top: auto;
108
+ bottom: 0;
109
+ transition: border-color 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
110
+ border-left: none;
111
+ border-right: none;
112
+ border-bottom: none;
113
+ }
114
+
115
+ .SD-DrawerActions-appBar.SD-DrawerActions-appBar:not(.SD-DrawerActions-appBarSticky) {
116
+ border-top-color: Color.Transparent;
117
+ }
118
+
119
+ .SD-DrawerActions-toolbar.MuiToolbar-gutters {
120
+ padding-left: 24px;
121
+ padding-right: 24px;
122
+ }
123
+
124
+ @media (min-width: 960px) {
125
+ .SD-DrawerActions-toolbar.MuiToolbar-gutters {
126
+ padding-left: 32px;
127
+ padding-right: 32px;
128
+ }
129
+ }
130
+
131
+ .SD-DrawerContent-root {
132
+ padding: 16px 24px;
133
+ max-width: 100%;
134
+ }
135
+
136
+ @media (min-width: 960px) {
137
+ .SD-DrawerContent-root {
138
+ padding: 16px 32px;
139
+ }
140
+ }
141
+
142
+ .SD-DrawerList-root {
143
+ max-width: 100%;
144
+ }
145
+
146
+ .SD-DrawerList-root .MuiListItem-gutters {
147
+ padding-left: 24px;
148
+ padding-right: 24px;
149
+ }
150
+
151
+ @media (min-width: 960px) {
152
+ .SD-DrawerList-root .MuiListItem-gutters {
153
+ padding-left: 32px;
154
+ padding-right: 32px;
155
+ }
156
+
157
+ .SD-DrawerList-root .MuiListItem-gutters.MuiListItem-secondaryAction {
158
+ padding-right: 64px;
159
+ }
160
+
161
+ .SD-DrawerList-root .MuiListItem-gutters .MuiListItemSecondaryAction-root {
162
+ right: 32px;
163
+ }
164
+
165
+ .SD-DrawerList-root
166
+ .MuiListItem-gutters
167
+ .MuiListItemSecondaryAction-root
168
+ .MuiIconButton-edgeEnd {
169
+ margin-right: -16px;
170
+ }
171
+ }
172
+
173
+ .SD-DrawerList-root .MuiListItem-gutters.MuiListItem-secondaryAction {
174
+ padding-right: 48px;
175
+ }
176
+
177
+ .SD-DrawerList-root .MuiListItem-gutters .MuiListItemSecondaryAction-root {
178
+ right: 24px;
179
+ }
180
+
181
+ .SD-DrawerList-root
182
+ .MuiListItem-gutters
183
+ .MuiListItemSecondaryAction-root
184
+ .MuiIconButton-edgeEnd {
185
+ margin-right: -12px;
186
+ }
187
+
188
+ .SD-DrawerTitle-appBar.SD-DrawerTitle-appBar {
189
+ border-top: none;
190
+ transition: border-color 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
191
+ border-left: none;
192
+ border-right: none;
193
+ }
194
+
195
+ .SD-DrawerTitle-appBar.SD-DrawerTitle-appBar:not(.SD-DrawerTitle-appBarSticky) {
196
+ border-bottom-color: Color.Transparent;
197
+ }
198
+
199
+ .SD-DrawerTitle-toolbar.MuiToolbar-gutters {
200
+ padding-left: 24px;
201
+ padding-right: 24px;
202
+ }
203
+
204
+ @media (min-width: 960px) {
205
+ .SD-DrawerTitle-toolbar.MuiToolbar-gutters {
206
+ padding-left: 32px;
207
+ padding-right: 32px;
208
+ }
209
+ }
210
+
211
+ .SD-DrawerTitle-startAction {
212
+ margin-right: 4px;
213
+ }
214
+
215
+ .SD-DrawerTitle-startAction .MuiIconButton-edgeStart {
216
+ margin-left: -16px;
217
+ }
218
+
219
+ .SD-DrawerTitle-endAction {
220
+ margin-left: 4px;
221
+ }
222
+
223
+ .SD-DrawerTitle-endAction .MuiIconButton-edgeEnd {
224
+ margin-right: -16px;
225
+ }
226
+ `);
227
+ });
@@ -0,0 +1,15 @@
1
+ import { MenuItem } from '@material-ui/core';
2
+ import { Meta } from '@storybook/react';
3
+ import { DropdownButton } from './DropdownButton';
4
+
5
+ export default {
6
+ title: 'Navigation/DropdownButton',
7
+ component: DropdownButton,
8
+ } as Meta;
9
+
10
+ export const basic = () => (
11
+ <DropdownButton label="Post to SLB">
12
+ <MenuItem>Post to SLB & CD</MenuItem>
13
+ <MenuItem>Post to CD</MenuItem>
14
+ </DropdownButton>
15
+ );
@@ -0,0 +1,131 @@
1
+ import {
2
+ ButtonGroup,
3
+ ButtonGroupProps as MuiButtonGroupProps,
4
+ MenuList,
5
+ MenuListProps as MuiMenuListProps,
6
+ Popover,
7
+ } from '@material-ui/core';
8
+ import * as React from 'react';
9
+ import { forwardRef, MouseEvent, ReactElement, ReactNode } from 'react';
10
+ import styled from 'styled-components';
11
+ import { Color, mergeRefs, useUID } from '..';
12
+ import { Button, ButtonProps } from '../button/Button';
13
+
14
+ function CaretDownIcon(): ReactElement {
15
+ return (
16
+ <svg viewBox="0 0 8 4">
17
+ <path
18
+ fill="currentColor"
19
+ d="M0.666687 0.666656L4.00002 3.99999L7.33335 0.666656H0.666687Z"
20
+ />
21
+ </svg>
22
+ );
23
+ }
24
+
25
+ const CaretButton = styled(Button)`
26
+ width: auto;
27
+ ${({ variant }) =>
28
+ variant === 'contained' && `border-left: 1px solid ${Color.Blue500}`};
29
+ `;
30
+
31
+ interface DropdownButtonProps extends Omit<ButtonProps, 'children'> {
32
+ label?: ReactNode;
33
+ children: ReactNode;
34
+ MenuListProps?: Omit<MuiMenuListProps, 'id'>;
35
+ ButtonGroupProps?: MuiButtonGroupProps;
36
+ }
37
+
38
+ export const DropdownButton = forwardRef<
39
+ HTMLButtonElement,
40
+ DropdownButtonProps
41
+ >(
42
+ (
43
+ {
44
+ MenuListProps,
45
+ ButtonGroupProps,
46
+
47
+ children,
48
+ isLoading,
49
+ onClick,
50
+ label,
51
+ ...buttonProps
52
+ },
53
+ ref,
54
+ ) => {
55
+ const uid = useUID();
56
+ const [open, setOpen] = React.useState(false);
57
+ const anchorRef = React.useRef<HTMLDivElement | null>(null);
58
+
59
+ function handleClick(event: MouseEvent<HTMLButtonElement>): void {
60
+ setOpen(false);
61
+ onClick?.(event);
62
+ }
63
+
64
+ function handleToggle(): void {
65
+ setOpen((prevOpen) => !prevOpen);
66
+ }
67
+
68
+ function handleClose(event: React.MouseEvent<Document>): void {
69
+ if (anchorRef.current?.contains(event.currentTarget)) {
70
+ return;
71
+ }
72
+ setOpen(false);
73
+ }
74
+
75
+ return (
76
+ <>
77
+ <ButtonGroup
78
+ {...ButtonGroupProps}
79
+ ref={mergeRefs(ButtonGroupProps?.ref, anchorRef)}
80
+ fullWidth={ButtonGroupProps?.fullWidth || buttonProps.fullWidth}
81
+ >
82
+ <Button
83
+ ref={ref}
84
+ onClick={handleClick}
85
+ disabled={isLoading}
86
+ isLoading={isLoading}
87
+ {...buttonProps}
88
+ >
89
+ {label}
90
+ </Button>
91
+
92
+ <CaretButton
93
+ onClick={handleToggle}
94
+ disabled={isLoading}
95
+ color={buttonProps.color}
96
+ variant={buttonProps.variant}
97
+ aria-haspopup="menu"
98
+ aria-controls={open ? uid : undefined}
99
+ aria-expanded={open ? 'true' : undefined}
100
+ >
101
+ <CaretDownIcon />
102
+ </CaretButton>
103
+ </ButtonGroup>
104
+
105
+ <Popover
106
+ open={open}
107
+ onClose={handleClose}
108
+ anchorEl={anchorRef.current}
109
+ anchorOrigin={{
110
+ vertical: 'bottom',
111
+ horizontal: 'left',
112
+ }}
113
+ >
114
+ <div style={{ minWidth: anchorRef.current?.clientWidth }}>
115
+ <MenuList
116
+ {...MenuListProps}
117
+ id={uid}
118
+ onClick={() => {
119
+ setOpen(false);
120
+ }}
121
+ >
122
+ {children}
123
+ </MenuList>
124
+ </div>
125
+ </Popover>
126
+ </>
127
+ );
128
+ },
129
+ );
130
+
131
+ export default DropdownButton;
@@ -0,0 +1,45 @@
1
+ import { Grid, GridProps } from '@material-ui/core';
2
+ import {
3
+ Children,
4
+ forwardRef,
5
+ ForwardRefExoticComponent,
6
+ RefAttributes,
7
+ } from 'react';
8
+
9
+ export interface GridStackProps
10
+ extends RefAttributes<HTMLDivElement>,
11
+ Pick<
12
+ GridProps,
13
+ 'style' | 'className' | 'children' | 'spacing' | 'alignItems'
14
+ > {}
15
+
16
+ /**
17
+ * @deprecated in favor of `Stack`.
18
+ */
19
+ export const GridStack: ForwardRefExoticComponent<GridStackProps> = forwardRef(
20
+ ({ children, alignItems = 'stretch' as const, ...props }, ref) => {
21
+ const items = Children.toArray(children);
22
+
23
+ return (
24
+ <Grid
25
+ {...props}
26
+ ref={ref}
27
+ container={true}
28
+ wrap="nowrap"
29
+ direction="column"
30
+ alignItems={alignItems}
31
+ >
32
+ {items.map((item, idx) => (
33
+ <Grid
34
+ key={idx}
35
+ item={true}
36
+ zeroMinWidth={true}
37
+ xs={alignItems === 'stretch' ? 12 : undefined}
38
+ >
39
+ {item}
40
+ </Grid>
41
+ ))}
42
+ </Grid>
43
+ );
44
+ },
45
+ );
@@ -0,0 +1,56 @@
1
+ import { Grid, GridProps } from '@material-ui/core';
2
+ import {
3
+ Children,
4
+ forwardRef,
5
+ ForwardRefExoticComponent,
6
+ RefAttributes,
7
+ } from 'react';
8
+
9
+ export interface InlineGridProps
10
+ extends RefAttributes<HTMLDivElement>,
11
+ Pick<
12
+ GridProps,
13
+ | 'style'
14
+ | 'className'
15
+ | 'children'
16
+ | 'wrap'
17
+ | 'spacing'
18
+ | 'justify'
19
+ | 'alignItems'
20
+ > {}
21
+
22
+ /**
23
+ * @deprecated in favor of `Inline` component.
24
+ */
25
+ export const InlineGrid: ForwardRefExoticComponent<InlineGridProps> =
26
+ forwardRef(
27
+ (
28
+ {
29
+ children,
30
+ wrap = 'wrap' as const,
31
+ justify = 'flex-start' as const,
32
+ alignItems = 'flex-start' as const,
33
+ ...props
34
+ },
35
+ ref,
36
+ ) => {
37
+ const items = Children.toArray(children);
38
+
39
+ return (
40
+ <Grid
41
+ {...props}
42
+ ref={ref}
43
+ wrap={wrap}
44
+ container={true}
45
+ justify={justify}
46
+ alignItems={alignItems}
47
+ >
48
+ {items.map((item, idx) => (
49
+ <Grid key={idx} item={true} zeroMinWidth={true}>
50
+ {item}
51
+ </Grid>
52
+ ))}
53
+ </Grid>
54
+ );
55
+ },
56
+ );
@@ -0,0 +1,53 @@
1
+ import { IconButton } from '@material-ui/core';
2
+ import { Save as SaveIcon } from '@material-ui/icons';
3
+ import { PropsLink } from '@superdispatch/ui-docs';
4
+ import { Inline } from '..';
5
+
6
+ export default {
7
+ title: 'Inputs/IconButton',
8
+ parameters: {
9
+ componentSubtitle: (
10
+ <PropsLink url="https://material-ui.com/api/icon-button/#props" />
11
+ ),
12
+ },
13
+ };
14
+
15
+ export const basic = () => (
16
+ <IconButton>
17
+ <SaveIcon />
18
+ </IconButton>
19
+ );
20
+
21
+ export const disabled = () => (
22
+ <IconButton disabled={true}>
23
+ <SaveIcon />
24
+ </IconButton>
25
+ );
26
+
27
+ export const colors = () => (
28
+ <Inline>
29
+ <IconButton>
30
+ <SaveIcon />
31
+ </IconButton>
32
+
33
+ <IconButton color="primary">
34
+ <SaveIcon />
35
+ </IconButton>
36
+
37
+ <IconButton color="inherit">
38
+ <SaveIcon />
39
+ </IconButton>
40
+ </Inline>
41
+ );
42
+
43
+ export const sizes = () => (
44
+ <Inline verticalAlign="center">
45
+ <IconButton size="small">
46
+ <SaveIcon fontSize="inherit" />
47
+ </IconButton>
48
+
49
+ <IconButton>
50
+ <SaveIcon fontSize="inherit" />
51
+ </IconButton>
52
+ </Inline>
53
+ );
@@ -0,0 +1,32 @@
1
+ import { Color } from '../theme/Color';
2
+ import { SuperDispatchTheme } from '../theme/SuperDispatchTheme';
3
+
4
+ export function overrideIconButton(theme: SuperDispatchTheme): void {
5
+ theme.overrides.MuiIconButton = {
6
+ root: {
7
+ color: Color.Dark100,
8
+
9
+ backgroundColor: Color.Transparent,
10
+
11
+ transition: theme.transitions.create(['color', 'background-color'], {
12
+ duration: theme.transitions.duration.short,
13
+ }),
14
+
15
+ '&:hover': { backgroundColor: Color.Transparent },
16
+ '&:active': { color: Color.Dark500 },
17
+ '&:hover ': { color: Color.Dark300 },
18
+ '&:focus': { backgroundColor: Color.Silver400 },
19
+
20
+ '&$disabled': { color: Color.Silver500 },
21
+ },
22
+ colorPrimary: {
23
+ '&:active': { color: Color.Blue500 },
24
+ '&:hover ': { color: Color.Blue300 },
25
+ '&:focus': { backgroundColor: Color.Blue50 },
26
+ },
27
+
28
+ edgeEnd: { marginRight: theme.spacing(-1) },
29
+
30
+ edgeStart: { marginLeft: theme.spacing(-1) },
31
+ };
32
+ }
@@ -0,0 +1,124 @@
1
+ import { IconButton } 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.MuiIconButton).toMatchInlineSnapshot(`undefined`);
8
+ });
9
+
10
+ it('checks component css', () => {
11
+ expect(renderCSS(<IconButton />, ['MuiIconButton'])).toMatchInlineSnapshot(`
12
+ .MuiIconButton-root {
13
+ flex: 0 0 auto;
14
+ color: Color.Dark100;
15
+ padding: 12px;
16
+ overflow: visible;
17
+ font-size: 1.5rem;
18
+ text-align: center;
19
+ transition: color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
20
+ background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
21
+ border-radius: 50%;
22
+ background-color: Color.Transparent;
23
+ }
24
+
25
+ .MuiIconButton-root:hover {
26
+ background-color: Color.Transparent;
27
+ }
28
+
29
+ .MuiIconButton-root.Mui-disabled {
30
+ color: Color.Silver500;
31
+ background-color: transparent;
32
+ }
33
+
34
+ .MuiIconButton-root:active {
35
+ color: Color.Dark500;
36
+ }
37
+
38
+ .MuiIconButton-root:hover {
39
+ color: Color.Dark300;
40
+ }
41
+
42
+ .MuiIconButton-root:focus {
43
+ background-color: Color.Silver400;
44
+ }
45
+
46
+ @media (hover: none) {
47
+ .MuiIconButton-root:hover {
48
+ background-color: transparent;
49
+ }
50
+ }
51
+
52
+ .MuiIconButton-edgeStart {
53
+ margin-left: -8px;
54
+ }
55
+
56
+ .MuiIconButton-sizeSmall.MuiIconButton-edgeStart {
57
+ margin-left: -3px;
58
+ }
59
+
60
+ .MuiIconButton-edgeEnd {
61
+ margin-right: -8px;
62
+ }
63
+
64
+ .MuiIconButton-sizeSmall.MuiIconButton-edgeEnd {
65
+ margin-right: -3px;
66
+ }
67
+
68
+ .MuiIconButton-colorInherit {
69
+ color: inherit;
70
+ }
71
+
72
+ .MuiIconButton-colorPrimary {
73
+ color: Color.Blue300;
74
+ }
75
+
76
+ .MuiIconButton-colorPrimary:hover {
77
+ background-color: rgba(0, 117, 255, 0.04);
78
+ }
79
+
80
+ .MuiIconButton-colorPrimary:active {
81
+ color: Color.Blue500;
82
+ }
83
+
84
+ .MuiIconButton-colorPrimary:hover {
85
+ color: Color.Blue300;
86
+ }
87
+
88
+ .MuiIconButton-colorPrimary:focus {
89
+ background-color: Color.Blue50;
90
+ }
91
+
92
+ @media (hover: none) {
93
+ .MuiIconButton-colorPrimary:hover {
94
+ background-color: transparent;
95
+ }
96
+ }
97
+
98
+ .MuiIconButton-colorSecondary {
99
+ color: #f50057;
100
+ }
101
+
102
+ .MuiIconButton-colorSecondary:hover {
103
+ background-color: rgba(245, 0, 87, 0.04);
104
+ }
105
+
106
+ @media (hover: none) {
107
+ .MuiIconButton-colorSecondary:hover {
108
+ background-color: transparent;
109
+ }
110
+ }
111
+
112
+ .MuiIconButton-sizeSmall {
113
+ padding: 3px;
114
+ font-size: 1.125rem;
115
+ }
116
+
117
+ .MuiIconButton-label {
118
+ width: 100%;
119
+ display: flex;
120
+ align-items: inherit;
121
+ justify-content: inherit;
122
+ }
123
+ `);
124
+ });