@saleor/macaw-ui 0.2.4

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 (186) hide show
  1. package/README.md +40 -0
  2. package/dist/ActionBar/ActionBar.d.ts +8 -0
  3. package/dist/ActionBar/context.d.ts +9 -0
  4. package/dist/ActionBar/index.d.ts +2 -0
  5. package/dist/ActionBar/styles.d.ts +2 -0
  6. package/dist/Alert/Alert.d.ts +9 -0
  7. package/dist/Alert/index.d.ts +1 -0
  8. package/dist/Alert/styles.d.ts +2 -0
  9. package/dist/Backlink/Backlink.d.ts +6 -0
  10. package/dist/Backlink/context.d.ts +5 -0
  11. package/dist/Backlink/index.d.ts +2 -0
  12. package/dist/Backlink/styles.d.ts +2 -0
  13. package/dist/ConfirmButton/ConfirmButton.d.ts +11 -0
  14. package/dist/ConfirmButton/index.d.ts +1 -0
  15. package/dist/ConfirmButton/styles.d.ts +2 -0
  16. package/dist/Notification/Notification.d.ts +3 -0
  17. package/dist/Notification/index.d.ts +2 -0
  18. package/dist/Notification/styles.d.ts +2 -0
  19. package/dist/Notification/types.d.ts +16 -0
  20. package/dist/ResponsiveTable/ResponsiveTable.d.ts +8 -0
  21. package/dist/ResponsiveTable/index.d.ts +1 -0
  22. package/dist/ResponsiveTable/styles.d.ts +2 -0
  23. package/dist/Savebar/ButtonTooltipDecorator.d.ts +6 -0
  24. package/dist/Savebar/Savebar.d.ts +14 -0
  25. package/dist/Savebar/index.d.ts +1 -0
  26. package/dist/Savebar/styles.d.ts +2 -0
  27. package/dist/Sidebar/ExpandButton.d.ts +6 -0
  28. package/dist/Sidebar/MenuItem.d.ts +11 -0
  29. package/dist/Sidebar/Sidebar.d.ts +6 -0
  30. package/dist/Sidebar/fixtures.d.ts +2 -0
  31. package/dist/Sidebar/index.d.ts +4 -0
  32. package/dist/Sidebar/types.d.ts +16 -0
  33. package/dist/SidebarDrawer/MenuItemBtn.d.ts +7 -0
  34. package/dist/SidebarDrawer/SidebarDrawer.d.ts +4 -0
  35. package/dist/SidebarDrawer/index.d.ts +2 -0
  36. package/dist/SidebarDrawer/styles.d.ts +2 -0
  37. package/dist/SquareButton/SquareButton.d.ts +3 -0
  38. package/dist/SquareButton/index.d.ts +1 -0
  39. package/dist/Tooltip/Tooltip.d.ts +6 -0
  40. package/dist/Tooltip/index.d.ts +1 -0
  41. package/dist/Tooltip/styles.d.ts +3 -0
  42. package/dist/UserChipMenu/UserChipMenu.d.ts +8 -0
  43. package/dist/UserChipMenu/UserChipMenuItem.d.ts +6 -0
  44. package/dist/UserChipMenu/context.d.ts +4 -0
  45. package/dist/UserChipMenu/index.d.ts +2 -0
  46. package/dist/UserChipMenu/styles.d.ts +2 -0
  47. package/dist/extensions/index.d.ts +3 -0
  48. package/dist/extensions/sendMessage.d.ts +3 -0
  49. package/dist/extensions/types.d.ts +22 -0
  50. package/dist/extensions/useExtensionMessage.d.ts +2 -0
  51. package/dist/icons/ArrowDropdownIcon.d.ts +2 -0
  52. package/dist/icons/CheckboxCheckedIcon.d.ts +1 -0
  53. package/dist/icons/CheckboxIcon.d.ts +1 -0
  54. package/dist/icons/CheckboxIndeterminateIcon.d.ts +1 -0
  55. package/dist/icons/CompleteIcon.d.ts +2 -0
  56. package/dist/icons/InfoIcon.d.ts +2 -0
  57. package/dist/icons/Logo.d.ts +2 -0
  58. package/dist/icons/NotAllowedIcon.d.ts +2 -0
  59. package/dist/icons/NotAllowedInvertedIcon.d.ts +2 -0
  60. package/dist/icons/WarningIcon.d.ts +2 -0
  61. package/dist/icons/index.d.ts +9 -0
  62. package/dist/index.d.ts +15 -0
  63. package/dist/index.js +8 -0
  64. package/dist/localStorageKeys.d.ts +4 -0
  65. package/dist/macaw-ui.cjs.development.js +2582 -0
  66. package/dist/macaw-ui.cjs.development.js.map +1 -0
  67. package/dist/macaw-ui.cjs.production.min.js +2 -0
  68. package/dist/macaw-ui.cjs.production.min.js.map +1 -0
  69. package/dist/macaw-ui.esm.js +2536 -0
  70. package/dist/macaw-ui.esm.js.map +1 -0
  71. package/dist/theme/Baseline.d.ts +2 -0
  72. package/dist/theme/ThemeProvider.d.ts +17 -0
  73. package/dist/theme/context.d.ts +3 -0
  74. package/dist/theme/createSaleorTheme/createSaleorTheme.d.ts +3 -0
  75. package/dist/theme/createSaleorTheme/index.d.ts +2 -0
  76. package/dist/theme/createSaleorTheme/overrides/buttons.d.ts +3 -0
  77. package/dist/theme/createSaleorTheme/overrides/index.d.ts +3 -0
  78. package/dist/theme/createSaleorTheme/overrides/inputs.d.ts +3 -0
  79. package/dist/theme/createSaleorTheme/overrides/tables.d.ts +3 -0
  80. package/dist/theme/createSaleorTheme/palette.d.ts +2 -0
  81. package/dist/theme/createSaleorTheme/shadows.d.ts +2 -0
  82. package/dist/theme/createSaleorTheme/types.d.ts +53 -0
  83. package/dist/theme/index.d.ts +4 -0
  84. package/dist/theme/styles.d.ts +5 -0
  85. package/dist/theme/themes.d.ts +3 -0
  86. package/dist/theme/types.d.ts +6 -0
  87. package/dist/theme/utils.d.ts +1 -0
  88. package/dist/tools/useLocalStorage.d.ts +5 -0
  89. package/dist/tools/useWindowScroll.d.ts +5 -0
  90. package/dist/utils/Decorator.d.ts +4 -0
  91. package/package.json +117 -0
  92. package/src/ActionBar/ActionBar.stories.tsx +34 -0
  93. package/src/ActionBar/ActionBar.tsx +58 -0
  94. package/src/ActionBar/context.tsx +32 -0
  95. package/src/ActionBar/index.ts +2 -0
  96. package/src/ActionBar/styles.ts +27 -0
  97. package/src/Alert/Alert.stories.tsx +30 -0
  98. package/src/Alert/Alert.tsx +86 -0
  99. package/src/Alert/index.ts +1 -0
  100. package/src/Alert/styles.ts +46 -0
  101. package/src/Backlink/Backlink.stories.tsx +51 -0
  102. package/src/Backlink/Backlink.tsx +40 -0
  103. package/src/Backlink/context.tsx +27 -0
  104. package/src/Backlink/index.ts +2 -0
  105. package/src/Backlink/styles.ts +41 -0
  106. package/src/ConfirmButton/ConfirmButton.stories.tsx +72 -0
  107. package/src/ConfirmButton/ConfirmButton.tsx +119 -0
  108. package/src/ConfirmButton/index.ts +1 -0
  109. package/src/ConfirmButton/styles.ts +44 -0
  110. package/src/Notification/Notification.stories.tsx +42 -0
  111. package/src/Notification/Notification.tsx +98 -0
  112. package/src/Notification/index.ts +2 -0
  113. package/src/Notification/styles.ts +74 -0
  114. package/src/Notification/types.ts +18 -0
  115. package/src/ResponsiveTable/ResponsiveTable.tsx +24 -0
  116. package/src/ResponsiveTable/index.ts +1 -0
  117. package/src/ResponsiveTable/styles.ts +23 -0
  118. package/src/Savebar/ButtonTooltipDecorator.tsx +22 -0
  119. package/src/Savebar/Savebar.stories.tsx +57 -0
  120. package/src/Savebar/Savebar.tsx +79 -0
  121. package/src/Savebar/index.ts +1 -0
  122. package/src/Savebar/styles.ts +25 -0
  123. package/src/Sidebar/ExpandButton.tsx +44 -0
  124. package/src/Sidebar/MenuItem.tsx +217 -0
  125. package/src/Sidebar/Sidebar.stories.tsx +21 -0
  126. package/src/Sidebar/Sidebar.tsx +88 -0
  127. package/src/Sidebar/fixtures.ts +39 -0
  128. package/src/Sidebar/index.ts +4 -0
  129. package/src/Sidebar/types.ts +18 -0
  130. package/src/SidebarDrawer/MenuItemBtn.tsx +40 -0
  131. package/src/SidebarDrawer/SidebarDrawer.stories.tsx +13 -0
  132. package/src/SidebarDrawer/SidebarDrawer.tsx +113 -0
  133. package/src/SidebarDrawer/index.ts +2 -0
  134. package/src/SidebarDrawer/styles.ts +69 -0
  135. package/src/SquareButton/SquareButton.stories.tsx +15 -0
  136. package/src/SquareButton/SquareButton.tsx +35 -0
  137. package/src/SquareButton/index.ts +1 -0
  138. package/src/Tooltip/Tooltip.stories.tsx +19 -0
  139. package/src/Tooltip/Tooltip.tsx +25 -0
  140. package/src/Tooltip/index.ts +1 -0
  141. package/src/Tooltip/styles.ts +28 -0
  142. package/src/UserChipMenu/UserChipMenu.stories.tsx +40 -0
  143. package/src/UserChipMenu/UserChipMenu.tsx +113 -0
  144. package/src/UserChipMenu/UserChipMenuItem.tsx +33 -0
  145. package/src/UserChipMenu/context.ts +19 -0
  146. package/src/UserChipMenu/index.ts +2 -0
  147. package/src/UserChipMenu/styles.ts +65 -0
  148. package/src/assets/placeholder_64x64.png +0 -0
  149. package/src/extensions/index.ts +3 -0
  150. package/src/extensions/sendMessage.ts +23 -0
  151. package/src/extensions/types.ts +26 -0
  152. package/src/extensions/useExtensionMessage.ts +13 -0
  153. package/src/icons/ArrowDropdownIcon.tsx +11 -0
  154. package/src/icons/CheckboxCheckedIcon.tsx +15 -0
  155. package/src/icons/CheckboxIcon.tsx +7 -0
  156. package/src/icons/CheckboxIndeterminateIcon.tsx +17 -0
  157. package/src/icons/CompleteIcon.tsx +25 -0
  158. package/src/icons/InfoIcon.tsx +23 -0
  159. package/src/icons/Logo.tsx +32 -0
  160. package/src/icons/NotAllowedIcon.tsx +25 -0
  161. package/src/icons/NotAllowedInvertedIcon.tsx +25 -0
  162. package/src/icons/WarningIcon.tsx +23 -0
  163. package/src/icons/index.ts +9 -0
  164. package/src/index.tsx +15 -0
  165. package/src/localStorageKeys.ts +4 -0
  166. package/src/theme/Baseline.tsx +30 -0
  167. package/src/theme/ThemeProvider.tsx +84 -0
  168. package/src/theme/context.ts +8 -0
  169. package/src/theme/createSaleorTheme/createSaleorTheme.ts +267 -0
  170. package/src/theme/createSaleorTheme/index.ts +2 -0
  171. package/src/theme/createSaleorTheme/overrides/buttons.ts +94 -0
  172. package/src/theme/createSaleorTheme/overrides/index.ts +15 -0
  173. package/src/theme/createSaleorTheme/overrides/inputs.ts +149 -0
  174. package/src/theme/createSaleorTheme/overrides/tables.ts +74 -0
  175. package/src/theme/createSaleorTheme/palette.ts +38 -0
  176. package/src/theme/createSaleorTheme/shadows.ts +46 -0
  177. package/src/theme/createSaleorTheme/types.ts +84 -0
  178. package/src/theme/index.ts +4 -0
  179. package/src/theme/styles.ts +40 -0
  180. package/src/theme/themes.ts +113 -0
  181. package/src/theme/types.ts +7 -0
  182. package/src/theme/utils.test.ts +43 -0
  183. package/src/theme/utils.ts +13 -0
  184. package/src/tools/useLocalStorage.ts +56 -0
  185. package/src/tools/useWindowScroll.ts +26 -0
  186. package/src/utils/Decorator.tsx +23 -0
@@ -0,0 +1,4 @@
1
+ export const localStorageKeys = {
2
+ theme: "macaw-ui-theme",
3
+ menuShrink: "macaw-ui-menu-shrink",
4
+ };
@@ -0,0 +1,30 @@
1
+ import CssBaseline from "@material-ui/core/CssBaseline";
2
+ import { fade } from "@material-ui/core/styles";
3
+ import React from "react";
4
+
5
+ import { makeStyles } from "./styles";
6
+
7
+ const useStyles = makeStyles(
8
+ (theme) => ({
9
+ "@global": {
10
+ "@import": "url('https://rsms.me/inter/inter.css')",
11
+
12
+ // For some reason @import clause must be put on top
13
+ // eslint-disable-next-line sort-keys
14
+ "::selection": {
15
+ background: fade(theme.palette.primary.main, 0.2),
16
+ },
17
+ html: {
18
+ fontSize: "62.5%",
19
+ },
20
+ },
21
+ }),
22
+ { name: "Baseline" }
23
+ );
24
+
25
+ export const Baseline: React.FC = () => {
26
+ useStyles();
27
+
28
+ return <CssBaseline />;
29
+ };
30
+ Baseline.displayName = "Baseline";
@@ -0,0 +1,84 @@
1
+ import type { Theme } from "@material-ui/core/styles";
2
+ import { MuiThemeProvider } from "@material-ui/core/styles";
3
+ import { merge } from "lodash";
4
+ import React, { useEffect } from "react";
5
+
6
+ import { ActionBarProvider } from "../ActionBar/context";
7
+ import { BacklinkProvider } from "../Backlink/context";
8
+ import {
9
+ ExtensionMessageType,
10
+ sendMessageToExtension,
11
+ ThemeChangeMessage,
12
+ } from "../extensions";
13
+ import { localStorageKeys } from "../localStorageKeys";
14
+ import useLocalStorage from "../tools/useLocalStorage";
15
+ import { Baseline } from "./Baseline";
16
+ import { ThemeContext } from "./context";
17
+ import { createTheme, Themes, ThemeType } from "./createSaleorTheme";
18
+ import { dark, light } from "./themes";
19
+ import { changeColorMeta } from "./utils";
20
+
21
+ export interface ThemeProviderProps {
22
+ defaultTheme?: ThemeType;
23
+ /**
24
+ * Passing an object here will result in losing visual consistency with
25
+ * Saleor's Dashboard. Use with caution.
26
+ */
27
+ palettes?: Partial<Themes>;
28
+ /**
29
+ * Passing an object here will result in losing visual consistency with
30
+ * Saleor's Dashboard. Use with caution.
31
+ */
32
+ overrides?: Partial<Theme>;
33
+ }
34
+ export const ThemeProvider: React.FC<ThemeProviderProps> = ({
35
+ children,
36
+ defaultTheme = "light",
37
+ palettes = {},
38
+ overrides = {},
39
+ }) => {
40
+ const { value: themeTypeName, setValue: setThemeType } = useLocalStorage(
41
+ localStorageKeys.theme,
42
+ defaultTheme
43
+ );
44
+ const themeType = themeTypeName as ThemeType;
45
+ const themes = {
46
+ light,
47
+ dark,
48
+ ...palettes,
49
+ };
50
+ const theme = merge(createTheme(themes[themeType]), overrides);
51
+ const sendThemeToExtension = () =>
52
+ sendMessageToExtension<ThemeChangeMessage>(
53
+ {
54
+ theme: themeType,
55
+ type: ExtensionMessageType.THEME,
56
+ },
57
+ "*"
58
+ );
59
+
60
+ useEffect(() => {
61
+ sendThemeToExtension();
62
+ changeColorMeta(theme.palette.background.default);
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ }, [themeType]);
65
+
66
+ return (
67
+ <ThemeContext.Provider
68
+ value={{
69
+ themeType,
70
+ sendThemeToExtension,
71
+ setTheme: setThemeType,
72
+ }}
73
+ >
74
+ <MuiThemeProvider theme={theme}>
75
+ <ActionBarProvider>
76
+ <BacklinkProvider>
77
+ <Baseline />
78
+ {children}
79
+ </BacklinkProvider>
80
+ </ActionBarProvider>
81
+ </MuiThemeProvider>
82
+ </ThemeContext.Provider>
83
+ );
84
+ };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+
3
+ import { SaleorThemeContext } from "./types";
4
+
5
+ export const ThemeContext = React.createContext<SaleorThemeContext | undefined>(
6
+ undefined
7
+ );
8
+ ThemeContext.displayName = "ThemeContext";
@@ -0,0 +1,267 @@
1
+ import { createMuiTheme } from "@material-ui/core/styles";
2
+ import { fade } from "@material-ui/core/styles";
3
+ import type { TypographyProps } from "@material-ui/core/Typography";
4
+
5
+ import { overrides } from "./overrides";
6
+ import { createPalette } from "./palette";
7
+ import { shadows } from "./shadows";
8
+ import { SaleorTheme, SaleorThemeColors } from "./types";
9
+
10
+ export const ICONBUTTON_SIZE = 48;
11
+
12
+ const fontFamily = '"Inter", "roboto", "sans-serif"';
13
+
14
+ export const createTheme = (colors: SaleorThemeColors): SaleorTheme =>
15
+ (createMuiTheme({
16
+ overrides: {
17
+ ...overrides(colors, fontFamily),
18
+ MuiCard: {
19
+ root: {
20
+ borderColor: colors.paperBorder,
21
+ borderRadius: 8,
22
+ borderStyle: "solid",
23
+ borderWidth: 1,
24
+ overflow: "visible",
25
+ },
26
+ },
27
+ MuiCardActions: {
28
+ root: {
29
+ flexDirection: "row-reverse" as "row-reverse",
30
+ },
31
+ },
32
+ MuiCardContent: {
33
+ root: {
34
+ padding: "2.4rem",
35
+ },
36
+ },
37
+ MuiCardHeader: {
38
+ action: {
39
+ position: "relative",
40
+ top: 4,
41
+ },
42
+ root: {
43
+ padding: "1.6rem 2.4rem",
44
+ },
45
+ },
46
+ MuiChip: {
47
+ avatar: {
48
+ fontSize: "1.2rem",
49
+ height: 32,
50
+ left: -5,
51
+ position: "relative",
52
+ width: 32,
53
+ },
54
+ root: {
55
+ "& $avatar": {
56
+ fontSize: "1.2rem",
57
+ },
58
+ fontSize: "1.3rem",
59
+ },
60
+ },
61
+ MuiDialogActions: {
62
+ root: {
63
+ borderTop: `1px solid ${colors.divider}`,
64
+ padding: "16px 24px",
65
+ },
66
+ },
67
+ MuiDialogContent: {
68
+ root: {
69
+ padding: `24px 0px`,
70
+ margin: `0px 24px`,
71
+ },
72
+ },
73
+ MuiDialogContentText: {
74
+ root: {
75
+ "&:last-child": {
76
+ marginBottom: 0,
77
+ },
78
+ },
79
+ },
80
+ MuiDialogTitle: {
81
+ root: {
82
+ borderBottom: `1px solid ${colors.divider}`,
83
+ },
84
+ },
85
+ MuiFormControlLabel: {
86
+ label: {
87
+ lineHeight: 1.2,
88
+ marginLeft: 4,
89
+ },
90
+ },
91
+ MuiFormLabel: {
92
+ filled: {
93
+ "&&:not($error)": {
94
+ color: colors.primary,
95
+ },
96
+ },
97
+ root: {
98
+ "&&$focused:not($error)": {
99
+ color: colors.font.gray,
100
+ },
101
+ },
102
+ },
103
+ MuiSvgIcon: {
104
+ root: {
105
+ fontSize: "2.4rem",
106
+ height: "1em",
107
+ width: "1em",
108
+ },
109
+ },
110
+ MuiList: {
111
+ root: {
112
+ display: "grid",
113
+ gridRowGap: 8 + "px",
114
+ padding: "8px !important",
115
+ },
116
+ },
117
+ MuiListItem: {
118
+ button: {
119
+ "&:focus": {
120
+ backgroundColor: colors.input.default,
121
+ },
122
+ },
123
+ root: {
124
+ "&$selected": {
125
+ "&:hover": {
126
+ backgroundColor: colors.input.default,
127
+ },
128
+ backgroundColor: colors.input.default,
129
+ },
130
+ },
131
+ },
132
+ MuiMenu: {
133
+ paper: {
134
+ borderRadius: 8,
135
+ },
136
+ },
137
+ MuiMenuItem: {
138
+ root: {
139
+ "&$selected, &$selected:focus, &$selected:hover": {
140
+ backgroundColor: [colors.background.default, "!important"] as any,
141
+ color: colors.primary,
142
+ fontWeight: 700,
143
+ },
144
+ "&:hover": {
145
+ backgroundColor: [colors.background.default, "!important"] as any,
146
+ color: colors.font.default,
147
+ fontWeight: 400,
148
+ },
149
+ borderRadius: 4,
150
+ },
151
+ },
152
+ MuiSelect: {
153
+ root: {
154
+ "&$disabled": {
155
+ backgroundColor: colors.input.disabledBackground,
156
+ },
157
+ },
158
+ },
159
+ MuiSnackbarContent: {
160
+ action: {
161
+ "& $MuiIconButton": {
162
+ "& svg": {
163
+ color: colors.font.default,
164
+ },
165
+ },
166
+ display: "block",
167
+ paddingBottom: 10,
168
+ paddingLeft: 0,
169
+ paddingRight: 45,
170
+ },
171
+ message: {
172
+ fontSize: 16,
173
+ },
174
+ root: {
175
+ backgroundColor: colors.background.paper,
176
+ boxShadow:
177
+ "0 6px 10px 0px rgba(0, 0, 0, 0.15), 0 1px 18px 0px rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.10)",
178
+ color: colors.font.default,
179
+ display: "block",
180
+ maxWidth: 480,
181
+ },
182
+ },
183
+ MuiTooltip: {
184
+ tooltip: {
185
+ fontSize: "0.8em",
186
+ },
187
+ },
188
+ MuiTouchRipple: {
189
+ child: {
190
+ backgroundColor: fade(colors.primary, 0.2),
191
+ },
192
+ childLeaving: {
193
+ backgroundColor: fade(colors.primary, 0.2),
194
+ },
195
+ ripple: {
196
+ "&$rippleVisible": {
197
+ backgroundColor: fade(colors.primary, 0.2),
198
+ },
199
+ borderRadius: "100%",
200
+ },
201
+ },
202
+ },
203
+ palette: createPalette(colors),
204
+ props: {
205
+ MuiFormControl: {
206
+ variant: "filled",
207
+ },
208
+ MuiTextField: {
209
+ variant: "outlined",
210
+ },
211
+ MuiCard: {
212
+ elevation: 0,
213
+ },
214
+ MuiTypography: {
215
+ component: "div",
216
+ } as TypographyProps,
217
+ MuiCheckbox: {
218
+ color: "primary",
219
+ },
220
+ MuiTooltip: {
221
+ placement: "right-end",
222
+ },
223
+ },
224
+ shadows,
225
+ spacing: (value: number = 1) => `${(value * 8) / 10}rem`,
226
+ typography: {
227
+ allVariants: {
228
+ fontFamily,
229
+ },
230
+ body1: {
231
+ color: colors.font.default,
232
+ fontSize: "1.6rem",
233
+ },
234
+ body2: {
235
+ fontSize: "1.4rem",
236
+ },
237
+ button: {
238
+ fontSize: "1.4rem",
239
+ },
240
+ caption: {
241
+ fontSize: "1.2rem",
242
+ },
243
+ fontFamily,
244
+ h1: {
245
+ fontSize: "4.8rem",
246
+ fontWeight: 700,
247
+ },
248
+ h4: {
249
+ fontSize: "3.4rem",
250
+ color: colors.font.default,
251
+ },
252
+ h5: {
253
+ fontSize: "2.1rem",
254
+ fontWeight: 500,
255
+ },
256
+ h6: {
257
+ fontSize: "2rem",
258
+ fontWeight: 500,
259
+ },
260
+ subtitle1: {
261
+ fontSize: "1.6rem",
262
+ },
263
+ subtitle2: {
264
+ fontSize: "1.4rem",
265
+ },
266
+ },
267
+ }) as unknown) as SaleorTheme;
@@ -0,0 +1,2 @@
1
+ export * from "./createSaleorTheme";
2
+ export * from "./types";
@@ -0,0 +1,94 @@
1
+ import { darken, fade } from "@material-ui/core/styles";
2
+ import type { Overrides } from "@material-ui/core/styles/overrides";
3
+
4
+ import { SaleorThemeColors } from "../types";
5
+
6
+ export const buttonOverrides = (colors: SaleorThemeColors): Overrides => ({
7
+ MuiButton: {
8
+ contained: {
9
+ "&$disabled": {
10
+ backgroundColor: fade(colors.primary, 0.12),
11
+ color: "#FFFFFF",
12
+ },
13
+ "&:active": {
14
+ boxShadow: "none",
15
+ },
16
+ "&:hover": {
17
+ boxShadow: "none",
18
+ },
19
+ boxShadow: "none",
20
+ },
21
+ containedPrimary: {
22
+ "&:active": {
23
+ backgroundColor: darken(colors.primary, 0.4),
24
+ },
25
+ "&:hover": {
26
+ backgroundColor: darken(colors.primary, 0.1),
27
+ },
28
+ },
29
+ label: {
30
+ fontWeight: 600,
31
+ },
32
+ root: {
33
+ "& svg": {
34
+ marginLeft: 8,
35
+ },
36
+ borderRadius: 4,
37
+ },
38
+ textPrimary: {
39
+ "&:not($disabled) span": {
40
+ color: colors.primary,
41
+ },
42
+ },
43
+ textSizeSmall: {
44
+ fontSize: "1.3rem",
45
+ },
46
+ },
47
+ MuiIconButton: {
48
+ root: {
49
+ "&:hover": {
50
+ backgroundColor: fade(colors.primary, 0.12),
51
+ },
52
+ },
53
+ },
54
+ MuiSwitch: {
55
+ colorPrimary: {
56
+ "&$checked": {
57
+ color: colors.background.paper,
58
+ },
59
+ },
60
+ root: {
61
+ "&$disabled": {
62
+ "&$switchBase": {
63
+ "& + $thumb": {
64
+ backgroundColor: colors.gray.disabled,
65
+ },
66
+ },
67
+ },
68
+ height: 48,
69
+ width: 72,
70
+ },
71
+ switchBase: {
72
+ "&$checked": {
73
+ transform: "translateX(23px)",
74
+ },
75
+ boxShadow: "none",
76
+ left: 1,
77
+ marginLeft: 4,
78
+ top: 5,
79
+ },
80
+ thumb: {
81
+ boxShadow: "none",
82
+ },
83
+ track: {
84
+ "$colorPrimary$checked + &": {
85
+ backgroundColor: colors.primary,
86
+ },
87
+ backgroundColor: colors.gray.default,
88
+ borderRadius: 12,
89
+ height: 24,
90
+ opacity: [["1"], "!important"] as any,
91
+ width: 48,
92
+ },
93
+ },
94
+ });
@@ -0,0 +1,15 @@
1
+ import type { Overrides } from "@material-ui/core/styles/overrides";
2
+
3
+ import { SaleorThemeColors } from "../types";
4
+ import { buttonOverrides } from "./buttons";
5
+ import { inputOverrides } from "./inputs";
6
+ import { tableOverrides } from "./tables";
7
+
8
+ export const overrides = (
9
+ colors: SaleorThemeColors,
10
+ fontFamily: string
11
+ ): Overrides => ({
12
+ ...inputOverrides(colors),
13
+ ...tableOverrides(colors, fontFamily),
14
+ ...buttonOverrides(colors),
15
+ });
@@ -0,0 +1,149 @@
1
+ import { fade } from "@material-ui/core/styles";
2
+ import type { Overrides } from "@material-ui/core/styles/overrides";
3
+
4
+ import { SaleorThemeColors } from "../types";
5
+
6
+ export const inputOverrides = (colors: SaleorThemeColors): Overrides => ({
7
+ MuiInput: {
8
+ input: {
9
+ "&:-webkit-autofill": {
10
+ WebkitTextFillColor: colors.font.default,
11
+ boxShadow: `inset 0 0 0px 9999px ${colors.autofill}`,
12
+ },
13
+ "&::placeholder": {
14
+ opacity: "1 !important" as any,
15
+ },
16
+ color: colors.font.default,
17
+ },
18
+ underline: {
19
+ "&:after": {
20
+ borderBottomColor: colors.primary,
21
+ },
22
+ },
23
+ },
24
+ MuiInputBase: {
25
+ input: {
26
+ "&$disabled": {
27
+ color: colors.input.disabledText,
28
+ },
29
+ "&::placeholder": {
30
+ color: colors.font.gray,
31
+ opacity: "1 !important" as any,
32
+ },
33
+ },
34
+ },
35
+ MuiInputLabel: {
36
+ formControl: {
37
+ transform: "translate(0, 1.5px) scale(0.75)",
38
+ transformOrigin: "top left" as "top left",
39
+ width: "100%",
40
+ },
41
+ outlined: {
42
+ "&$shrink": {
43
+ transform: "translate(12px, 9px) scale(0.75)",
44
+ },
45
+ transform: "translate(14px, 18px) scale(1)",
46
+ },
47
+ root: {
48
+ "&$disabled": {
49
+ color: `${fade(colors.primary, 0.4)} !important` as any,
50
+ },
51
+ "&$error": {
52
+ "&$focused": {
53
+ color: colors.error,
54
+ },
55
+ color: colors.error,
56
+ },
57
+ "&&$focused": {
58
+ "&:not($error)": {
59
+ color: colors.primary,
60
+ },
61
+ },
62
+ color: fade(colors.input.text, 0.6),
63
+ },
64
+ shrink: {
65
+ // Negates x0.75 scale
66
+ width: "133%",
67
+ },
68
+ },
69
+ MuiOutlinedInput: {
70
+ input: {
71
+ "&:-webkit-autofill": {
72
+ borderRadius: 4,
73
+ boxShadow: "0 0 0px 1000px rgba(19, 190, 187, 0.1) inset",
74
+ },
75
+ color: colors.input.text,
76
+ padding: "23px 12px 10px 12px",
77
+ },
78
+ inputMultiline: {
79
+ left: -2,
80
+ padding: "10px 0",
81
+ position: "relative",
82
+ },
83
+ root: {
84
+ "& fieldset": {
85
+ "&&:not($error)": {
86
+ borderColor: colors.input.border,
87
+ },
88
+ top: 0,
89
+ },
90
+ "& legend": {
91
+ display: "none",
92
+ },
93
+ "&$disabled": {
94
+ "& fieldset": {
95
+ borderColor: [[colors.input.disabled], "!important"] as any,
96
+ },
97
+ "& input": {
98
+ backgroundColor: colors.input.disabledBackground,
99
+ color: colors.input.disabledText,
100
+ },
101
+ },
102
+ "&$error": {
103
+ "&$focused": {
104
+ "& fieldset": {
105
+ borderColor: colors.error,
106
+ },
107
+ "& input": {
108
+ color: colors.error,
109
+ },
110
+ },
111
+ "&:hover": {
112
+ "& fieldset": {
113
+ borderColor: colors.error,
114
+ },
115
+ "& input": {
116
+ color: colors.error,
117
+ },
118
+ },
119
+ },
120
+ "&$focused": {
121
+ "& input": {
122
+ "& fieldset": {
123
+ borderColor: colors.primary,
124
+ },
125
+ "&::placeholder": {
126
+ opacity: [[1], "!important"] as any,
127
+ },
128
+ color: colors.font.default,
129
+ },
130
+ },
131
+ "&:hover": {
132
+ "& input": {
133
+ color: colors.font.default,
134
+ },
135
+ "&&&": {
136
+ "& fieldset": {
137
+ borderColor: colors.primary,
138
+ },
139
+ "&$error fieldset": {
140
+ borderColor: colors.input.error,
141
+ },
142
+ },
143
+ },
144
+ backgroundColor: colors.background.paper,
145
+ borderColor: colors.input.border,
146
+ top: 0,
147
+ },
148
+ },
149
+ });