@saleor/macaw-ui 0.3.3 → 0.4.0

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 (234) hide show
  1. package/README.md +20 -0
  2. package/dist/cjs/index.js +2 -2
  3. package/dist/cjs/index.js.map +3 -3
  4. package/dist/esm/index.js +2 -2
  5. package/dist/esm/index.js.map +3 -3
  6. package/dist/types/ActionBar/context.d.ts +6 -1
  7. package/dist/types/Chip/Chip.d.ts +8 -0
  8. package/dist/types/Chip/ChipAdornment.d.ts +6 -0
  9. package/dist/types/Chip/ChipMovable.d.ts +5 -0
  10. package/dist/types/Chip/ChipRemovable.d.ts +6 -0
  11. package/dist/types/Chip/ChipSwatch.d.ts +7 -0
  12. package/dist/types/Chip/ColorSwatch.d.ts +6 -0
  13. package/dist/types/Chip/common/ChipMovable.d.ts +5 -0
  14. package/dist/types/Chip/common/ChipRemovable.d.ts +6 -0
  15. package/dist/types/Chip/common/ChipSwatch.d.ts +7 -0
  16. package/dist/types/Chip/common/index.d.ts +3 -0
  17. package/dist/types/Chip/index.d.ts +5 -0
  18. package/dist/types/Chip/private/ColorSwatch.d.ts +6 -0
  19. package/dist/{ActionBar → types/Chip}/styles.d.ts +1 -1
  20. package/dist/types/CircleIndicator/index.d.ts +1 -1
  21. package/dist/types/IconButton/styles.d.ts +1 -1
  22. package/dist/types/Sidebar/MenuItem.d.ts +9 -3
  23. package/dist/types/Sidebar/types.d.ts +8 -0
  24. package/dist/types/Sidebar/utils.d.ts +12 -0
  25. package/dist/types/SidebarDrawer/MenuItemBtn.d.ts +2 -1
  26. package/dist/types/utils/guideStyles.d.ts +1 -1
  27. package/package.json +2 -8
  28. package/src/ActionBar/context.tsx +14 -2
  29. package/src/Chip/.DS_Store +0 -0
  30. package/src/Chip/Chip.tsx +52 -0
  31. package/src/Chip/ChipAdornment.tsx +53 -0
  32. package/src/Chip/ChipMovable.tsx +40 -0
  33. package/src/Chip/ChipRemovable.tsx +29 -0
  34. package/src/Chip/ChipSwatch.tsx +42 -0
  35. package/src/Chip/index.ts +5 -0
  36. package/src/Chip/private/ColorSwatch.tsx +21 -0
  37. package/src/Chip/styles.ts +45 -0
  38. package/src/CircleIndicator/CircleIndicator.stories.tsx +6 -6
  39. package/src/CircleIndicator/index.ts +1 -1
  40. package/src/Filter/FilterField/MultipleSelectFilterField.tsx +4 -2
  41. package/src/IconButton/IconButton.tsx +7 -5
  42. package/src/IconButton/styles.ts +34 -14
  43. package/src/Sidebar/MenuItem.tsx +35 -14
  44. package/src/Sidebar/Sidebar.tsx +27 -11
  45. package/src/Sidebar/types.ts +9 -0
  46. package/src/Sidebar/utils.ts +23 -0
  47. package/src/SidebarDrawer/MenuItemBtn.tsx +12 -6
  48. package/src/SidebarDrawer/SidebarDrawer.tsx +8 -2
  49. package/src/index.tsx +1 -1
  50. package/src/theme/createSaleorTheme/overrides/inputs.ts +1 -1
  51. package/src/theme/themes.ts +1 -1
  52. package/src/utils/guideStyles.ts +5 -0
  53. package/dist/ActionBar/ActionBar.d.ts +0 -8
  54. package/dist/ActionBar/ActionBar.stories.d.ts +0 -4
  55. package/dist/ActionBar/context.d.ts +0 -9
  56. package/dist/ActionBar/index.d.ts +0 -2
  57. package/dist/Alert/Alert.d.ts +0 -8
  58. package/dist/Alert/Alert.stories.d.ts +0 -12
  59. package/dist/Alert/AlertBase.d.ts +0 -8
  60. package/dist/Alert/index.d.ts +0 -2
  61. package/dist/Alert/styles.d.ts +0 -2
  62. package/dist/Backlink/Backlink.d.ts +0 -8
  63. package/dist/Backlink/Backlink.stories.d.ts +0 -5
  64. package/dist/Backlink/context.d.ts +0 -5
  65. package/dist/Backlink/index.d.ts +0 -2
  66. package/dist/Backlink/styles.d.ts +0 -2
  67. package/dist/BaseList/BaseList.d.ts +0 -26
  68. package/dist/BaseList/context.d.ts +0 -7
  69. package/dist/BaseList/index.d.ts +0 -1
  70. package/dist/BaseList/styles.d.ts +0 -5
  71. package/dist/Button/Button.d.ts +0 -16
  72. package/dist/Button/index.d.ts +0 -1
  73. package/dist/Button/styles.d.ts +0 -2
  74. package/dist/ConfirmButton/ConfirmButton.d.ts +0 -11
  75. package/dist/ConfirmButton/ConfirmButton.stories.d.ts +0 -8
  76. package/dist/ConfirmButton/index.d.ts +0 -1
  77. package/dist/ConfirmButton/styles.d.ts +0 -2
  78. package/dist/DialogHeader/DialogHeader.d.ts +0 -6
  79. package/dist/DialogHeader/index.d.ts +0 -1
  80. package/dist/DialogHeader/styles.d.ts +0 -1
  81. package/dist/DialogTable/DialogTable.d.ts +0 -6
  82. package/dist/DialogTable/index.d.ts +0 -1
  83. package/dist/DialogTable/styles.d.ts +0 -1
  84. package/dist/Filter/Filter.d.ts +0 -10
  85. package/dist/Filter/Filter.stories.d.ts +0 -5
  86. package/dist/Filter/FilterBar.d.ts +0 -11
  87. package/dist/Filter/FilterContent.d.ts +0 -7
  88. package/dist/Filter/FilterField/MultipleSelectFilterField.d.ts +0 -6
  89. package/dist/Filter/FilterField/RangeFilterField.d.ts +0 -7
  90. package/dist/Filter/FilterField/SelectFilterField.d.ts +0 -6
  91. package/dist/Filter/FilterField/TextFilterField.d.ts +0 -6
  92. package/dist/Filter/FilterMenu.d.ts +0 -9
  93. package/dist/Filter/context.d.ts +0 -4
  94. package/dist/Filter/index.d.ts +0 -4
  95. package/dist/Filter/styles.d.ts +0 -2
  96. package/dist/Filter/types.d.ts +0 -49
  97. package/dist/Filter/utils.d.ts +0 -8
  98. package/dist/IconButton/IconButton.d.ts +0 -8
  99. package/dist/IconButton/index.d.ts +0 -1
  100. package/dist/IconButton/partials.d.ts +0 -14
  101. package/dist/IconButton/styles.d.ts +0 -2
  102. package/dist/LayoutButton/LayoutButton.d.ts +0 -7
  103. package/dist/LayoutButton/index.d.ts +0 -1
  104. package/dist/LayoutButton/styles.d.ts +0 -2
  105. package/dist/List/List.d.ts +0 -13
  106. package/dist/List/List.stories.d.ts +0 -5
  107. package/dist/List/context.d.ts +0 -8
  108. package/dist/List/index.d.ts +0 -1
  109. package/dist/List/styles.d.ts +0 -1
  110. package/dist/Notification/Notification.d.ts +0 -3
  111. package/dist/Notification/Notification.stories.d.ts +0 -10
  112. package/dist/Notification/index.d.ts +0 -2
  113. package/dist/Notification/styles.d.ts +0 -2
  114. package/dist/Notification/types.d.ts +0 -16
  115. package/dist/OffsettedList/OffsettedList.d.ts +0 -12
  116. package/dist/OffsettedList/OffsettedList.stories.d.ts +0 -5
  117. package/dist/OffsettedList/index.d.ts +0 -1
  118. package/dist/OffsettedList/styles.d.ts +0 -2
  119. package/dist/PageTabs/PageTab.d.ts +0 -3
  120. package/dist/PageTabs/PageTab.stories.d.ts +0 -4
  121. package/dist/PageTabs/PageTabPanel.d.ts +0 -4
  122. package/dist/PageTabs/PageTabs.d.ts +0 -5
  123. package/dist/PageTabs/index.d.ts +0 -3
  124. package/dist/PageTabs/styles.d.ts +0 -2
  125. package/dist/Pagination/Pagination.d.ts +0 -10
  126. package/dist/Pagination/PaginationActions.d.ts +0 -11
  127. package/dist/Pagination/PaginationRowNumberSelect.d.ts +0 -11
  128. package/dist/Pagination/TablePagination.d.ts +0 -6
  129. package/dist/Pagination/index.d.ts +0 -4
  130. package/dist/Pagination/styles.d.ts +0 -2
  131. package/dist/PillLink/PillLink.d.ts +0 -15
  132. package/dist/PillLink/index.d.ts +0 -1
  133. package/dist/PillLink/styles.d.ts +0 -2
  134. package/dist/ResponsiveTable/ResponsiveTable.d.ts +0 -8
  135. package/dist/ResponsiveTable/index.d.ts +0 -1
  136. package/dist/ResponsiveTable/styles.d.ts +0 -2
  137. package/dist/Savebar/ButtonTooltipDecorator.d.ts +0 -6
  138. package/dist/Savebar/Savebar.d.ts +0 -14
  139. package/dist/Savebar/Savebar.stories.d.ts +0 -6
  140. package/dist/Savebar/index.d.ts +0 -1
  141. package/dist/Savebar/styles.d.ts +0 -2
  142. package/dist/ScrollShadow/ScrollShadow.d.ts +0 -6
  143. package/dist/ScrollShadow/index.d.ts +0 -1
  144. package/dist/ScrollShadow/styles.d.ts +0 -1
  145. package/dist/Sidebar/ExpandButton.d.ts +0 -6
  146. package/dist/Sidebar/MenuItem.d.ts +0 -11
  147. package/dist/Sidebar/Sidebar.d.ts +0 -6
  148. package/dist/Sidebar/Sidebar.stories.d.ts +0 -6
  149. package/dist/Sidebar/fixtures.d.ts +0 -2
  150. package/dist/Sidebar/index.d.ts +0 -4
  151. package/dist/Sidebar/types.d.ts +0 -16
  152. package/dist/SidebarDrawer/MenuItemBtn.d.ts +0 -7
  153. package/dist/SidebarDrawer/SidebarDrawer.d.ts +0 -4
  154. package/dist/SidebarDrawer/SidebarDrawer.stories.d.ts +0 -4
  155. package/dist/SidebarDrawer/index.d.ts +0 -2
  156. package/dist/SidebarDrawer/styles.d.ts +0 -2
  157. package/dist/SquareButton/SquareButton.d.ts +0 -3
  158. package/dist/SquareButton/SquareButton.stories.d.ts +0 -5
  159. package/dist/SquareButton/index.d.ts +0 -1
  160. package/dist/StatusChip/StatusChip.d.ts +0 -3
  161. package/dist/StatusChip/StatusChip.stories.d.ts +0 -8
  162. package/dist/StatusChip/index.d.ts +0 -2
  163. package/dist/StatusChip/styles.d.ts +0 -3
  164. package/dist/StatusChip/types.d.ts +0 -8
  165. package/dist/Tooltip/Tooltip.d.ts +0 -6
  166. package/dist/Tooltip/Tooltip.stories.d.ts +0 -7
  167. package/dist/Tooltip/index.d.ts +0 -1
  168. package/dist/Tooltip/styles.d.ts +0 -3
  169. package/dist/UserChipMenu/UserChipMenu.d.ts +0 -9
  170. package/dist/UserChipMenu/UserChipMenu.stories.d.ts +0 -6
  171. package/dist/UserChipMenu/UserChipMenuItem.d.ts +0 -6
  172. package/dist/UserChipMenu/context.d.ts +0 -4
  173. package/dist/UserChipMenu/index.d.ts +0 -2
  174. package/dist/UserChipMenu/styles.d.ts +0 -2
  175. package/dist/extensions/index.d.ts +0 -3
  176. package/dist/extensions/sendMessage.d.ts +0 -3
  177. package/dist/extensions/types.d.ts +0 -22
  178. package/dist/extensions/useExtensionMessage.d.ts +0 -2
  179. package/dist/icons/ArrowDropdownIcon.d.ts +0 -2
  180. package/dist/icons/ArrowRightIcon.d.ts +0 -1
  181. package/dist/icons/CheckboxCheckedIcon.d.ts +0 -1
  182. package/dist/icons/CheckboxIcon.d.ts +0 -1
  183. package/dist/icons/CheckboxIndeterminateIcon.d.ts +0 -1
  184. package/dist/icons/CloseIcon.d.ts +0 -1
  185. package/dist/icons/CompleteIcon.d.ts +0 -2
  186. package/dist/icons/DeleteIcon.d.ts +0 -1
  187. package/dist/icons/EditIcon.d.ts +0 -1
  188. package/dist/icons/FilteringIcon.d.ts +0 -1
  189. package/dist/icons/ImageIcon.d.ts +0 -1
  190. package/dist/icons/InfoIcon.d.ts +0 -2
  191. package/dist/icons/Logo.d.ts +0 -2
  192. package/dist/icons/LogoLight.d.ts +0 -2
  193. package/dist/icons/MoreIcon.d.ts +0 -1
  194. package/dist/icons/NavigatorIcon.d.ts +0 -1
  195. package/dist/icons/NotAllowedIcon.d.ts +0 -2
  196. package/dist/icons/NotAllowedInvertedIcon.d.ts +0 -2
  197. package/dist/icons/PlusIcon.d.ts +0 -1
  198. package/dist/icons/RadioCheckedIcon.d.ts +0 -1
  199. package/dist/icons/RadioIcon.d.ts +0 -1
  200. package/dist/icons/SearchIcon.d.ts +0 -1
  201. package/dist/icons/WarningIcon.d.ts +0 -2
  202. package/dist/icons/index.d.ts +0 -18
  203. package/dist/index.d.ts +0 -29
  204. package/dist/index.js +0 -2
  205. package/dist/index.js.map +0 -7
  206. package/dist/localStorageKeys.d.ts +0 -4
  207. package/dist/mjs/index.js +0 -5
  208. package/dist/mjs/index.js.map +0 -7
  209. package/dist/theme/Baseline.d.ts +0 -2
  210. package/dist/theme/ThemeProvider.d.ts +0 -17
  211. package/dist/theme/context.d.ts +0 -3
  212. package/dist/theme/createSaleorTheme/createSaleorTheme.d.ts +0 -3
  213. package/dist/theme/createSaleorTheme/index.d.ts +0 -2
  214. package/dist/theme/createSaleorTheme/overrides/buttons.d.ts +0 -3
  215. package/dist/theme/createSaleorTheme/overrides/controls.d.ts +0 -3
  216. package/dist/theme/createSaleorTheme/overrides/index.d.ts +0 -3
  217. package/dist/theme/createSaleorTheme/overrides/inputs.d.ts +0 -3
  218. package/dist/theme/createSaleorTheme/overrides/tables.d.ts +0 -3
  219. package/dist/theme/createSaleorTheme/palette.d.ts +0 -2
  220. package/dist/theme/createSaleorTheme/shadows.d.ts +0 -2
  221. package/dist/theme/createSaleorTheme/types.d.ts +0 -51
  222. package/dist/theme/index.d.ts +0 -4
  223. package/dist/theme/styles.d.ts +0 -5
  224. package/dist/theme/themes.d.ts +0 -3
  225. package/dist/theme/types.d.ts +0 -6
  226. package/dist/theme/utils.d.ts +0 -1
  227. package/dist/theme/utils.test.d.ts +0 -1
  228. package/dist/tools/index.d.ts +0 -2
  229. package/dist/tools/useElementScroll.d.ts +0 -12
  230. package/dist/tools/useLocalStorage.d.ts +0 -5
  231. package/dist/tools/useWindowScroll.d.ts +0 -4
  232. package/dist/types/StatusChip/styles.d.ts +0 -3
  233. package/dist/utils/Decorator.d.ts +0 -4
  234. package/dist/utils/useListStory.d.ts +0 -21
@@ -0,0 +1,45 @@
1
+ import { makeStyles } from "../theme";
2
+
3
+ const useStyles = makeStyles(
4
+ (theme) => ({
5
+ chip: {
6
+ background: theme.palette.saleor.active[1],
7
+ color: theme.palette.primary.contrastText,
8
+ borderRadius: "8px",
9
+ display: "flex",
10
+ alignItems: "center",
11
+ padding: `3px ${theme.spacing(2)}`,
12
+ gap: "4px",
13
+ lineHeight: 1,
14
+ minHeight: theme.spacing(4),
15
+ cursor: "default",
16
+ userSelect: "none",
17
+ textAlign: "center",
18
+ "& > span": {
19
+ overflow: "hidden",
20
+ textOverflow: "ellipsis",
21
+ },
22
+ },
23
+ startAdornment: {
24
+ marginLeft: "-8px",
25
+ flexShrink: 0,
26
+ },
27
+ endAdornment: {
28
+ marginRight: "-8px",
29
+ flexShrink: 0,
30
+ },
31
+ swatch: {
32
+ width: theme.spacing(3),
33
+ height: theme.spacing(3),
34
+ border: `2px solid #fff`,
35
+ flexShrink: 0,
36
+ marginRight: "7px",
37
+ borderRadius: "4px",
38
+ // default background when no style specified
39
+ background: "transparent",
40
+ },
41
+ }),
42
+ { name: "Chip" }
43
+ );
44
+
45
+ export default useStyles;
@@ -2,9 +2,9 @@ import { Typography } from "@material-ui/core";
2
2
  import { Meta, Story } from "@storybook/react";
3
3
  import clsx from "clsx";
4
4
  import React from "react";
5
+
5
6
  import { Decorator, GuideDecorator } from "../utils/Decorator";
6
7
  import useGuideStyles from "../utils/guideStyles";
7
-
8
8
  import { CircleIndicator } from "./CircleIndicator";
9
9
 
10
10
  const StoryWrapper: React.FC = () => {
@@ -16,7 +16,7 @@ const StoryWrapper: React.FC = () => {
16
16
  Circle Indicators
17
17
  </Typography>
18
18
  <Typography className={guideClasses.paragraph} component="p">
19
- Circle Indicators represent status of a certain element.
19
+ Circle Indicators represent status of a certain element.
20
20
  </Typography>
21
21
  <div style={{ display: "flex", gap: "24px" }}>
22
22
  <div
@@ -30,10 +30,10 @@ const StoryWrapper: React.FC = () => {
30
30
  padding: 24,
31
31
  }}
32
32
  >
33
- Error <CircleIndicator color="error" />
34
- Warning <CircleIndicator color="warning" />
35
- Success <CircleIndicator color="success" />
36
- Info <CircleIndicator color="info" />
33
+ Error <CircleIndicator color="error" />
34
+ Warning <CircleIndicator color="warning" />
35
+ Success <CircleIndicator color="success" />
36
+ Info <CircleIndicator color="info" />
37
37
  </div>
38
38
  </div>
39
39
  </div>
@@ -1 +1 @@
1
- export * from './CircleIndicator';
1
+ export * from "./CircleIndicator";
@@ -1,10 +1,10 @@
1
1
  import Checkbox from "@material-ui/core/Checkbox";
2
- import Chip from "@material-ui/core/Chip";
3
2
  import MenuItem from "@material-ui/core/MenuItem";
4
3
  import Select from "@material-ui/core/Select";
5
4
  import clsx from "clsx";
6
5
  import React from "react";
7
6
 
7
+ import { Chip } from "../../Chip";
8
8
  import { useFilters } from "../context";
9
9
  import useStyles from "../styles";
10
10
  import { EventTarget, FilterData } from "../types";
@@ -41,7 +41,9 @@ export const MultipleSelectFilterField: React.FC<FilterContentProps> = ({
41
41
  return (
42
42
  <div className={classes.filterChipContainer}>
43
43
  {typedValues.map((value) => (
44
- <Chip className={classes.filterChip} key={value} label={value} />
44
+ <Chip className={classes.filterChip} key={value}>
45
+ {value}
46
+ </Chip>
45
47
  ))}
46
48
  </div>
47
49
  );
@@ -38,8 +38,10 @@ export const IconButton: React.FC<IconButtonProps> = React.forwardRef(
38
38
  ref={ref}
39
39
  className={clsx(classes.secondary, className, {
40
40
  [classes.hoverOutline]: hoverOutline && !props.disabled,
41
- [classes.hover]: state === "hover",
42
- [classes.active]: state === "active",
41
+ [classes.hover]: state === "hover" && !props.disabled,
42
+ [classes.active]: state === "active" && !props.disabled,
43
+ [classes.error]: error,
44
+ [classes.disabledError]: error && props.disabled,
43
45
  })}
44
46
  disableRipple
45
47
  {...props}
@@ -50,11 +52,11 @@ export const IconButton: React.FC<IconButtonProps> = React.forwardRef(
50
52
  return (
51
53
  <MuiIconButton
52
54
  ref={ref}
53
- className={clsx(className, {
55
+ className={clsx(classes.primary, className, {
56
+ [classes.hover]: state === "hover" && !props.disabled,
57
+ [classes.active]: state === "active" && !props.disabled,
54
58
  [classes.error]: error,
55
59
  [classes.disabledError]: error && props.disabled,
56
- [classes.hover]: state === "hover",
57
- [classes.active]: state === "active",
58
60
  })}
59
61
  disableRipple
60
62
  {...props}
@@ -3,17 +3,49 @@ import { getSecondaryButtonStyles } from "./partials";
3
3
 
4
4
  const useStyles = makeStyles(
5
5
  (theme) => ({
6
+ primary: {
7
+ "&:hover, &.Mui-focusVisible, &$hover, &$active": {
8
+ color: theme.palette.saleor.active[1],
9
+ borderColor: theme.palette.saleor.active[1],
10
+ },
11
+ "&:active, &$active": {
12
+ background: theme.palette.saleor.active[5],
13
+ },
14
+ },
15
+ secondary: getSecondaryButtonStyles(theme.palette.saleor),
16
+ hoverOutline: {
17
+ "&$secondary": {
18
+ "&:hover, &:focus-visible, &$hover": {
19
+ background: theme.palette.saleor.active[5],
20
+ borderColor: theme.palette.saleor.active[4],
21
+ },
22
+ "&:active, &$active": {
23
+ background: theme.palette.saleor.active[4],
24
+ },
25
+ },
26
+ },
6
27
  error: {
7
- "&&": {
28
+ "&&&": {
8
29
  "&:hover, &.Mui-focusVisible, &$hover": {
9
30
  borderColor: theme.palette.saleor.errorAction[1],
10
31
  color: theme.palette.saleor.errorAction[1],
11
32
  },
12
33
  "&:active, &$active": {
13
34
  background: theme.palette.saleor.errorAction[5],
35
+ color: theme.palette.saleor.errorAction[1],
36
+ borderColor: theme.palette.saleor.errorAction[2],
37
+ },
38
+ "&$secondary": {
39
+ "&:hover, &.Mui-focusVisible, &$hover": {
40
+ background: theme.palette.saleor.errorAction[5],
41
+ },
42
+ "&:active, &$active": {
43
+ background: theme.palette.saleor.errorAction[4],
44
+ color: theme.palette.saleor.errorAction[1],
45
+ },
14
46
  },
15
47
  },
16
- borderColor: theme.palette.saleor.errorAction[4],
48
+
17
49
  color: theme.palette.saleor.errorAction[2],
18
50
  },
19
51
  disabledError: {
@@ -22,18 +54,6 @@ const useStyles = makeStyles(
22
54
  color: theme.palette.saleor.errorAction[5],
23
55
  },
24
56
  },
25
- secondary: getSecondaryButtonStyles(theme.palette.saleor),
26
- hoverOutline: {
27
- "&$secondary": {
28
- "&:hover, &:focus-visible, &$hover": {
29
- background: theme.palette.saleor.active[5],
30
- borderColor: theme.palette.saleor.active[4],
31
- },
32
- "&:active, &$active": {
33
- background: theme.palette.saleor.active[4],
34
- },
35
- },
36
- },
37
57
  active: {},
38
58
  hover: {},
39
59
  }),
@@ -9,15 +9,27 @@ import React from "react";
9
9
  import SVG from "react-inlinesvg";
10
10
 
11
11
  import { makeStyles } from "../theme";
12
- import { SidebarMenuItem } from "./types";
12
+ import { CustomLinkComponent, SidebarMenuItem } from "./types";
13
+ import { getLinkComponent, getLinkProps } from "./utils";
13
14
 
14
- export interface MenuItemProps {
15
+ export interface MenuItemCommonProps {
15
16
  activeId: string;
16
17
  isMenuShrunk: boolean;
17
18
  menuItem: SidebarMenuItem;
18
- onClick: (menuItem: SidebarMenuItem) => void;
19
19
  }
20
20
 
21
+ export type MenuItemProps = MenuItemCommonProps &
22
+ (
23
+ | {
24
+ onClick: (menuItem: SidebarMenuItem) => void;
25
+ linkComponent?: never;
26
+ }
27
+ | {
28
+ onClick?: never;
29
+ linkComponent: CustomLinkComponent;
30
+ }
31
+ );
32
+
21
33
  export const menuWidth = 210;
22
34
  export const shrunkMenuWidth = 72;
23
35
 
@@ -139,23 +151,33 @@ export const MenuItem: React.FC<MenuItemProps> = ({
139
151
  menuItem,
140
152
  isMenuShrunk,
141
153
  onClick,
154
+ linkComponent,
142
155
  }) => {
143
156
  const classes = useStyles({});
144
157
  const [open, setOpen] = React.useState(false);
145
- const anchor = React.useRef<HTMLDivElement>(null);
158
+ const anchor = React.useRef<any>(null);
146
159
 
147
160
  const handleClick = (event: React.MouseEvent, menuItem: SidebarMenuItem) => {
148
161
  event.stopPropagation();
149
162
  if (menuItem.children) {
150
163
  setOpen(true);
151
164
  } else {
152
- onClick(menuItem);
165
+ if (onClick) {
166
+ onClick(menuItem);
167
+ }
168
+
169
+ if (menuItem.onClick) {
170
+ menuItem.onClick();
171
+ }
172
+
153
173
  setOpen(false);
154
174
  }
155
175
  };
156
176
 
177
+ const RootNavComponent = menuItem.children ? "div" : linkComponent ?? "div";
178
+
157
179
  return (
158
- <div
180
+ <RootNavComponent
159
181
  className={clsx(classes.root, {
160
182
  [classes.rootOpen]: open,
161
183
  [classes.rootActive]: [
@@ -165,9 +187,10 @@ export const MenuItem: React.FC<MenuItemProps> = ({
165
187
  [classes.rootExpanded]: !isMenuShrunk,
166
188
  })}
167
189
  ref={anchor}
168
- onClick={(event) => handleClick(event, menuItem)}
190
+ onClick={(event: React.MouseEvent) => handleClick(event, menuItem)}
191
+ {...getLinkProps(menuItem)}
169
192
  >
170
- <button
193
+ <span
171
194
  className={classes.menuItemBtn}
172
195
  data-test="menu-item-label"
173
196
  data-test-id={menuItem.id}
@@ -184,7 +207,7 @@ export const MenuItem: React.FC<MenuItemProps> = ({
184
207
  >
185
208
  {menuItem.label}
186
209
  </Typography>
187
- </button>
210
+ </span>
188
211
  {menuItem.children && (
189
212
  <Popper
190
213
  className={clsx(classes.popper, {
@@ -199,14 +222,12 @@ export const MenuItem: React.FC<MenuItemProps> = ({
199
222
  <Paper className={classes.paper}>
200
223
  {menuItem.children.map((subMenuItem) => {
201
224
  if (subMenuItem.url || subMenuItem.children) {
202
- const linkProps = subMenuItem.external
203
- ? { href: subMenuItem.url, target: "_blank" }
204
- : {};
225
+ const linkProps = getLinkProps(subMenuItem);
205
226
 
206
227
  return (
207
228
  <MuiMenuItem
208
229
  aria-label={subMenuItem.ariaLabel}
209
- component={subMenuItem.external ? "a" : "button"}
230
+ component={getLinkComponent(subMenuItem, linkComponent)}
210
231
  className={clsx(classes.label, classes.subMenuLabel)}
211
232
  key={subMenuItem.url}
212
233
  onClick={(event: React.MouseEvent) =>
@@ -236,7 +257,7 @@ export const MenuItem: React.FC<MenuItemProps> = ({
236
257
  </ClickAwayListener>
237
258
  </Popper>
238
259
  )}
239
- </div>
260
+ </RootNavComponent>
240
261
  );
241
262
  };
242
263
 
@@ -23,7 +23,9 @@ const useStyles = makeStyles(
23
23
  paddingBottom: theme.spacing(3),
24
24
  },
25
25
  logo: {
26
+ display: "block",
26
27
  margin: `36px 0 ${theme.spacing(3)} ${theme.spacing(2.5)}`,
28
+ color: "inherit",
27
29
  },
28
30
  root: {
29
31
  transition: "width 0.5s ease",
@@ -50,6 +52,8 @@ export const Sidebar: React.FC<SidebarProps> = ({
50
52
  menuItems,
51
53
  toolbar,
52
54
  onMenuItemClick,
55
+ logoHref,
56
+ linkComponent,
53
57
  }) => {
54
58
  const classes = useStyles({});
55
59
  const { value: isShrunkStr, setValue: setShrink } = useLocalStorage(
@@ -59,6 +63,8 @@ export const Sidebar: React.FC<SidebarProps> = ({
59
63
  const isShrunk = isShrunkStr === "true";
60
64
  const { themeType } = useTheme();
61
65
 
66
+ const Link = linkComponent ?? "a";
67
+
62
68
  return (
63
69
  <div
64
70
  className={clsx(classes.root, {
@@ -66,18 +72,28 @@ export const Sidebar: React.FC<SidebarProps> = ({
66
72
  })}
67
73
  >
68
74
  <div className={classes.float}>
69
- <div className={classes.logo}>
75
+ <Link href={logoHref} className={classes.logo}>
70
76
  {themeType === "dark" ? <LogoDark /> : <Logo />}
71
- </div>
72
- {menuItems.map((menuItem) => (
73
- <MenuItem
74
- activeId={activeId}
75
- isMenuShrunk={isShrunk}
76
- menuItem={menuItem}
77
- onClick={onMenuItemClick}
78
- key={menuItem.ariaLabel}
79
- />
80
- ))}
77
+ </Link>
78
+ {menuItems.map((menuItem) =>
79
+ linkComponent ? (
80
+ <MenuItem
81
+ activeId={activeId}
82
+ isMenuShrunk={isShrunk}
83
+ menuItem={menuItem}
84
+ key={menuItem.ariaLabel}
85
+ linkComponent={linkComponent}
86
+ />
87
+ ) : (
88
+ <MenuItem
89
+ activeId={activeId}
90
+ isMenuShrunk={isShrunk}
91
+ menuItem={menuItem}
92
+ onClick={onMenuItemClick}
93
+ key={menuItem.ariaLabel}
94
+ />
95
+ )
96
+ )}
81
97
  {toolbar && <div className={classes.toolbarContainer}>{toolbar}</div>}
82
98
  <ExpandButton
83
99
  className={classes.expandButton}
@@ -8,11 +8,20 @@ export interface SidebarMenuItem {
8
8
  iconSrc?: string;
9
9
  url?: string;
10
10
  external?: boolean;
11
+ onClick?: () => void;
11
12
  }
12
13
 
14
+ export type CustomLinkComponent = React.ForwardRefExoticComponent<{
15
+ href?: string;
16
+ onClick?: (...params: any) => void;
17
+ className?: string;
18
+ }>;
19
+
13
20
  export interface BaseSidebarProps {
14
21
  className?: string;
15
22
  menuItems: SidebarMenuItem[];
16
23
  toolbar?: React.ReactNode;
17
24
  onMenuItemClick: (menuItem: SidebarMenuItem) => void;
25
+ linkComponent?: CustomLinkComponent;
26
+ logoHref?: string;
18
27
  }
@@ -0,0 +1,23 @@
1
+ import { CustomLinkComponent, SidebarMenuItem } from "./types";
2
+
3
+ export const getLinkProps = (menuItem: SidebarMenuItem) => {
4
+ if (menuItem.external) {
5
+ return { href: menuItem.url, target: "_blank" };
6
+ }
7
+ if (menuItem.url) {
8
+ return {
9
+ href: menuItem.url,
10
+ };
11
+ }
12
+ return {};
13
+ };
14
+
15
+ export const getLinkComponent = (
16
+ menuItem: SidebarMenuItem,
17
+ customComponent?: CustomLinkComponent
18
+ ) => {
19
+ if (menuItem.external) {
20
+ return "a";
21
+ }
22
+ return customComponent ?? "button";
23
+ };
@@ -2,22 +2,24 @@ import Typography from "@material-ui/core/Typography";
2
2
  import React from "react";
3
3
  import SVG from "react-inlinesvg";
4
4
 
5
- import { SidebarMenuItem } from "../Sidebar/types";
5
+ import { CustomLinkComponent, SidebarMenuItem } from "../Sidebar/types";
6
+ import { getLinkComponent, getLinkProps } from "../Sidebar/utils";
6
7
  import useStyles from "./styles";
7
8
 
8
9
  export interface MenuItemBtnProps {
9
10
  menuItem: SidebarMenuItem;
10
11
  onClick: (menuItem: SidebarMenuItem) => void;
12
+ linkComponent?: CustomLinkComponent;
11
13
  }
14
+
12
15
  export const MenuItemBtn: React.FC<MenuItemBtnProps> = ({
13
16
  menuItem,
14
17
  onClick,
18
+ linkComponent,
15
19
  }) => {
16
20
  const classes = useStyles();
17
- const linkProps = menuItem.external
18
- ? { href: menuItem.url, target: "_blank" }
19
- : {};
20
- const Component = menuItem.external ? "a" : "button";
21
+ const linkProps = getLinkProps(menuItem);
22
+ const Component = getLinkComponent(menuItem, linkComponent);
21
23
 
22
24
  return (
23
25
  <Component
@@ -30,7 +32,11 @@ export const MenuItemBtn: React.FC<MenuItemBtnProps> = ({
30
32
  {menuItem.iconSrc && (
31
33
  <SVG className={classes.icon} src={menuItem.iconSrc} />
32
34
  )}
33
- <Typography aria-label={menuItem.ariaLabel} className={classes.label}>
35
+ <Typography
36
+ component="span"
37
+ aria-label={menuItem.ariaLabel}
38
+ className={classes.label}
39
+ >
34
40
  {menuItem.label}
35
41
  </Typography>
36
42
  </Component>
@@ -19,6 +19,8 @@ export type SideBarDrawerProps = BaseSidebarProps;
19
19
  export const SidebarDrawer: React.FC<SideBarDrawerProps> = ({
20
20
  menuItems,
21
21
  onMenuItemClick,
22
+ linkComponent,
23
+ logoHref,
22
24
  }) => {
23
25
  const [isOpened, setOpened] = React.useState(false);
24
26
  const classes = useStyles({});
@@ -43,6 +45,8 @@ export const SidebarDrawer: React.FC<SideBarDrawerProps> = ({
43
45
  });
44
46
  };
45
47
 
48
+ const Link = linkComponent ?? "a";
49
+
46
50
  return (
47
51
  <>
48
52
  <SquareButton onClick={() => setOpened(true)}>
@@ -67,9 +71,9 @@ export const SidebarDrawer: React.FC<SideBarDrawerProps> = ({
67
71
  })}
68
72
  >
69
73
  <div className={classes.content}>
70
- <div className={classes.logo}>
74
+ <Link href={logoHref} className={classes.logo}>
71
75
  {themeType === "dark" ? <LogoDark /> : <Logo />}
72
- </div>
76
+ </Link>
73
77
  {menuItems.map((menuItem) => (
74
78
  <MenuItemBtn
75
79
  menuItem={menuItem}
@@ -78,6 +82,7 @@ export const SidebarDrawer: React.FC<SideBarDrawerProps> = ({
78
82
  ? () => handleMenuItemWithChildrenClick(menuItem)
79
83
  : handleMenuItemClick
80
84
  }
85
+ linkComponent={linkComponent}
81
86
  key={menuItem.ariaLabel}
82
87
  />
83
88
  ))}
@@ -104,6 +109,7 @@ export const SidebarDrawer: React.FC<SideBarDrawerProps> = ({
104
109
  menuItem={subMenuItem}
105
110
  onClick={handleMenuItemClick}
106
111
  key={subMenuItem.ariaLabel}
112
+ linkComponent={linkComponent}
107
113
  />
108
114
  );
109
115
  }
package/src/index.tsx CHANGED
@@ -32,4 +32,4 @@ export * from "./OffsettedList";
32
32
  export * from "./List";
33
33
  export * from "./NavigationCard";
34
34
  export * from "./Pill";
35
- export * from "./CircleIndicator"
35
+ export * from "./CircleIndicator";
@@ -171,7 +171,7 @@ export const inputOverrides = (
171
171
  backgroundColor: colors.background.paper,
172
172
  transition: "box-shadow 200ms",
173
173
  top: 0,
174
- fontWeight: 500,
174
+ fontWeight: 400,
175
175
  },
176
176
  notchedOutline: {
177
177
  // It's so much easier to put it here with important tag rather than
@@ -160,7 +160,7 @@ export const light: SaleorThemeColors = {
160
160
  5: "#FBDDD8",
161
161
  },
162
162
 
163
- disabled: "#CCDDDD",
163
+ disabled: "#C2D1E4",
164
164
  paperBorder: "#EAEAEA",
165
165
  theme: "light",
166
166
  };
@@ -38,6 +38,11 @@ const useStyles = makeStyles(
38
38
  padding: theme.spacing(3),
39
39
  rowGap: theme.spacing(3),
40
40
  },
41
+ gridCell: {
42
+ display: "grid",
43
+ gridTemplateColumns: "repeat(3, 1fr)",
44
+ gap: theme.spacing(3),
45
+ },
41
46
  }),
42
47
  { name: "Guide" }
43
48
  );
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { ConfirmButtonTransitionState } from "../ConfirmButton";
3
- export interface ActionBarProps {
4
- disabled: boolean;
5
- state: ConfirmButtonTransitionState;
6
- children: React.ReactNode[] | React.ReactNode;
7
- }
8
- export declare const ActionBar: React.FC<ActionBarProps>;
@@ -1,4 +0,0 @@
1
- import { Meta, Story } from "@storybook/react";
2
- export declare const WithContent: Story;
3
- declare const _default: Meta<import("@storybook/react").Args>;
4
- export default _default;
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- export interface ActionBarContextType {
3
- anchor: React.RefObject<HTMLDivElement>;
4
- docked: boolean;
5
- setDocked: (docked: boolean) => void;
6
- }
7
- export declare const ActionBarContext: React.Context<ActionBarContextType | undefined>;
8
- export declare const useActionBar: () => ActionBarContextType;
9
- export declare const ActionBarProvider: React.FC;
@@ -1,2 +0,0 @@
1
- export * from "./ActionBar";
2
- export * from "./context";
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { AlertBaseProps, AlertVariant } from "./AlertBase";
3
- export interface AlertProps extends AlertBaseProps {
4
- close?: boolean;
5
- variant: AlertVariant;
6
- title?: string;
7
- }
8
- export declare const Alert: React.FC<AlertProps>;
@@ -1,12 +0,0 @@
1
- import { Meta, Story } from "@storybook/react";
2
- export declare const Info: Story;
3
- export declare const Warn: Story;
4
- export declare const Success: Story;
5
- export declare const Error: Story;
6
- export declare const WithClose: Story;
7
- export declare const WithContent: Story;
8
- export declare const WithContentAndClose: Story;
9
- export declare const Custom: Story;
10
- export declare const WithoutTitle: Story;
11
- declare const _default: Meta<import("@storybook/react").Args>;
12
- export default _default;
@@ -1,8 +0,0 @@
1
- import { CardProps } from "@material-ui/core/Card";
2
- import React from "react";
3
- export declare type AlertVariant = "error" | "warning" | "success" | "info";
4
- export interface AlertBaseProps extends Omit<CardProps, "variant"> {
5
- className?: string;
6
- variant: AlertVariant;
7
- }
8
- export declare const AlertBase: React.FC<AlertBaseProps>;
@@ -1,2 +0,0 @@
1
- export * from "./Alert";
2
- export * from "./AlertBase";
@@ -1,2 +0,0 @@
1
- declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"error" | "close" | "success" | "warning" | "root" | "content" | "container" | "closeNoContent" | "titleBar">;
2
- export default useStyles;
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { LayoutButtonProps } from "../LayoutButton";
3
- export interface AppHeaderProps extends LayoutButtonProps {
4
- children: React.ReactNode;
5
- disabled?: boolean;
6
- onClick: () => void;
7
- }
8
- export declare const Backlink: React.FC<AppHeaderProps>;
@@ -1,5 +0,0 @@
1
- import { Meta, Story } from "@storybook/react";
2
- export declare const Default: Story;
3
- export declare const Loading: Story;
4
- declare const _default: Meta<import("@storybook/react").Args>;
5
- export default _default;
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- export declare type BacklinkContextType = React.RefObject<HTMLDivElement>;
3
- export declare const BacklinkContext: React.Context<BacklinkContextType | undefined>;
4
- export declare const useBacklink: () => BacklinkContextType;
5
- export declare const BacklinkProvider: React.FC;
@@ -1,2 +0,0 @@
1
- export * from "./Backlink";
2
- export * from "./context";