@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.
- package/README.md +20 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +3 -3
- package/dist/types/ActionBar/context.d.ts +6 -1
- package/dist/types/Chip/Chip.d.ts +8 -0
- package/dist/types/Chip/ChipAdornment.d.ts +6 -0
- package/dist/types/Chip/ChipMovable.d.ts +5 -0
- package/dist/types/Chip/ChipRemovable.d.ts +6 -0
- package/dist/types/Chip/ChipSwatch.d.ts +7 -0
- package/dist/types/Chip/ColorSwatch.d.ts +6 -0
- package/dist/types/Chip/common/ChipMovable.d.ts +5 -0
- package/dist/types/Chip/common/ChipRemovable.d.ts +6 -0
- package/dist/types/Chip/common/ChipSwatch.d.ts +7 -0
- package/dist/types/Chip/common/index.d.ts +3 -0
- package/dist/types/Chip/index.d.ts +5 -0
- package/dist/types/Chip/private/ColorSwatch.d.ts +6 -0
- package/dist/{ActionBar → types/Chip}/styles.d.ts +1 -1
- package/dist/types/CircleIndicator/index.d.ts +1 -1
- package/dist/types/IconButton/styles.d.ts +1 -1
- package/dist/types/Sidebar/MenuItem.d.ts +9 -3
- package/dist/types/Sidebar/types.d.ts +8 -0
- package/dist/types/Sidebar/utils.d.ts +12 -0
- package/dist/types/SidebarDrawer/MenuItemBtn.d.ts +2 -1
- package/dist/types/utils/guideStyles.d.ts +1 -1
- package/package.json +2 -8
- package/src/ActionBar/context.tsx +14 -2
- package/src/Chip/.DS_Store +0 -0
- package/src/Chip/Chip.tsx +52 -0
- package/src/Chip/ChipAdornment.tsx +53 -0
- package/src/Chip/ChipMovable.tsx +40 -0
- package/src/Chip/ChipRemovable.tsx +29 -0
- package/src/Chip/ChipSwatch.tsx +42 -0
- package/src/Chip/index.ts +5 -0
- package/src/Chip/private/ColorSwatch.tsx +21 -0
- package/src/Chip/styles.ts +45 -0
- package/src/CircleIndicator/CircleIndicator.stories.tsx +6 -6
- package/src/CircleIndicator/index.ts +1 -1
- package/src/Filter/FilterField/MultipleSelectFilterField.tsx +4 -2
- package/src/IconButton/IconButton.tsx +7 -5
- package/src/IconButton/styles.ts +34 -14
- package/src/Sidebar/MenuItem.tsx +35 -14
- package/src/Sidebar/Sidebar.tsx +27 -11
- package/src/Sidebar/types.ts +9 -0
- package/src/Sidebar/utils.ts +23 -0
- package/src/SidebarDrawer/MenuItemBtn.tsx +12 -6
- package/src/SidebarDrawer/SidebarDrawer.tsx +8 -2
- package/src/index.tsx +1 -1
- package/src/theme/createSaleorTheme/overrides/inputs.ts +1 -1
- package/src/theme/themes.ts +1 -1
- package/src/utils/guideStyles.ts +5 -0
- package/dist/ActionBar/ActionBar.d.ts +0 -8
- package/dist/ActionBar/ActionBar.stories.d.ts +0 -4
- package/dist/ActionBar/context.d.ts +0 -9
- package/dist/ActionBar/index.d.ts +0 -2
- package/dist/Alert/Alert.d.ts +0 -8
- package/dist/Alert/Alert.stories.d.ts +0 -12
- package/dist/Alert/AlertBase.d.ts +0 -8
- package/dist/Alert/index.d.ts +0 -2
- package/dist/Alert/styles.d.ts +0 -2
- package/dist/Backlink/Backlink.d.ts +0 -8
- package/dist/Backlink/Backlink.stories.d.ts +0 -5
- package/dist/Backlink/context.d.ts +0 -5
- package/dist/Backlink/index.d.ts +0 -2
- package/dist/Backlink/styles.d.ts +0 -2
- package/dist/BaseList/BaseList.d.ts +0 -26
- package/dist/BaseList/context.d.ts +0 -7
- package/dist/BaseList/index.d.ts +0 -1
- package/dist/BaseList/styles.d.ts +0 -5
- package/dist/Button/Button.d.ts +0 -16
- package/dist/Button/index.d.ts +0 -1
- package/dist/Button/styles.d.ts +0 -2
- package/dist/ConfirmButton/ConfirmButton.d.ts +0 -11
- package/dist/ConfirmButton/ConfirmButton.stories.d.ts +0 -8
- package/dist/ConfirmButton/index.d.ts +0 -1
- package/dist/ConfirmButton/styles.d.ts +0 -2
- package/dist/DialogHeader/DialogHeader.d.ts +0 -6
- package/dist/DialogHeader/index.d.ts +0 -1
- package/dist/DialogHeader/styles.d.ts +0 -1
- package/dist/DialogTable/DialogTable.d.ts +0 -6
- package/dist/DialogTable/index.d.ts +0 -1
- package/dist/DialogTable/styles.d.ts +0 -1
- package/dist/Filter/Filter.d.ts +0 -10
- package/dist/Filter/Filter.stories.d.ts +0 -5
- package/dist/Filter/FilterBar.d.ts +0 -11
- package/dist/Filter/FilterContent.d.ts +0 -7
- package/dist/Filter/FilterField/MultipleSelectFilterField.d.ts +0 -6
- package/dist/Filter/FilterField/RangeFilterField.d.ts +0 -7
- package/dist/Filter/FilterField/SelectFilterField.d.ts +0 -6
- package/dist/Filter/FilterField/TextFilterField.d.ts +0 -6
- package/dist/Filter/FilterMenu.d.ts +0 -9
- package/dist/Filter/context.d.ts +0 -4
- package/dist/Filter/index.d.ts +0 -4
- package/dist/Filter/styles.d.ts +0 -2
- package/dist/Filter/types.d.ts +0 -49
- package/dist/Filter/utils.d.ts +0 -8
- package/dist/IconButton/IconButton.d.ts +0 -8
- package/dist/IconButton/index.d.ts +0 -1
- package/dist/IconButton/partials.d.ts +0 -14
- package/dist/IconButton/styles.d.ts +0 -2
- package/dist/LayoutButton/LayoutButton.d.ts +0 -7
- package/dist/LayoutButton/index.d.ts +0 -1
- package/dist/LayoutButton/styles.d.ts +0 -2
- package/dist/List/List.d.ts +0 -13
- package/dist/List/List.stories.d.ts +0 -5
- package/dist/List/context.d.ts +0 -8
- package/dist/List/index.d.ts +0 -1
- package/dist/List/styles.d.ts +0 -1
- package/dist/Notification/Notification.d.ts +0 -3
- package/dist/Notification/Notification.stories.d.ts +0 -10
- package/dist/Notification/index.d.ts +0 -2
- package/dist/Notification/styles.d.ts +0 -2
- package/dist/Notification/types.d.ts +0 -16
- package/dist/OffsettedList/OffsettedList.d.ts +0 -12
- package/dist/OffsettedList/OffsettedList.stories.d.ts +0 -5
- package/dist/OffsettedList/index.d.ts +0 -1
- package/dist/OffsettedList/styles.d.ts +0 -2
- package/dist/PageTabs/PageTab.d.ts +0 -3
- package/dist/PageTabs/PageTab.stories.d.ts +0 -4
- package/dist/PageTabs/PageTabPanel.d.ts +0 -4
- package/dist/PageTabs/PageTabs.d.ts +0 -5
- package/dist/PageTabs/index.d.ts +0 -3
- package/dist/PageTabs/styles.d.ts +0 -2
- package/dist/Pagination/Pagination.d.ts +0 -10
- package/dist/Pagination/PaginationActions.d.ts +0 -11
- package/dist/Pagination/PaginationRowNumberSelect.d.ts +0 -11
- package/dist/Pagination/TablePagination.d.ts +0 -6
- package/dist/Pagination/index.d.ts +0 -4
- package/dist/Pagination/styles.d.ts +0 -2
- package/dist/PillLink/PillLink.d.ts +0 -15
- package/dist/PillLink/index.d.ts +0 -1
- package/dist/PillLink/styles.d.ts +0 -2
- package/dist/ResponsiveTable/ResponsiveTable.d.ts +0 -8
- package/dist/ResponsiveTable/index.d.ts +0 -1
- package/dist/ResponsiveTable/styles.d.ts +0 -2
- package/dist/Savebar/ButtonTooltipDecorator.d.ts +0 -6
- package/dist/Savebar/Savebar.d.ts +0 -14
- package/dist/Savebar/Savebar.stories.d.ts +0 -6
- package/dist/Savebar/index.d.ts +0 -1
- package/dist/Savebar/styles.d.ts +0 -2
- package/dist/ScrollShadow/ScrollShadow.d.ts +0 -6
- package/dist/ScrollShadow/index.d.ts +0 -1
- package/dist/ScrollShadow/styles.d.ts +0 -1
- package/dist/Sidebar/ExpandButton.d.ts +0 -6
- package/dist/Sidebar/MenuItem.d.ts +0 -11
- package/dist/Sidebar/Sidebar.d.ts +0 -6
- package/dist/Sidebar/Sidebar.stories.d.ts +0 -6
- package/dist/Sidebar/fixtures.d.ts +0 -2
- package/dist/Sidebar/index.d.ts +0 -4
- package/dist/Sidebar/types.d.ts +0 -16
- package/dist/SidebarDrawer/MenuItemBtn.d.ts +0 -7
- package/dist/SidebarDrawer/SidebarDrawer.d.ts +0 -4
- package/dist/SidebarDrawer/SidebarDrawer.stories.d.ts +0 -4
- package/dist/SidebarDrawer/index.d.ts +0 -2
- package/dist/SidebarDrawer/styles.d.ts +0 -2
- package/dist/SquareButton/SquareButton.d.ts +0 -3
- package/dist/SquareButton/SquareButton.stories.d.ts +0 -5
- package/dist/SquareButton/index.d.ts +0 -1
- package/dist/StatusChip/StatusChip.d.ts +0 -3
- package/dist/StatusChip/StatusChip.stories.d.ts +0 -8
- package/dist/StatusChip/index.d.ts +0 -2
- package/dist/StatusChip/styles.d.ts +0 -3
- package/dist/StatusChip/types.d.ts +0 -8
- package/dist/Tooltip/Tooltip.d.ts +0 -6
- package/dist/Tooltip/Tooltip.stories.d.ts +0 -7
- package/dist/Tooltip/index.d.ts +0 -1
- package/dist/Tooltip/styles.d.ts +0 -3
- package/dist/UserChipMenu/UserChipMenu.d.ts +0 -9
- package/dist/UserChipMenu/UserChipMenu.stories.d.ts +0 -6
- package/dist/UserChipMenu/UserChipMenuItem.d.ts +0 -6
- package/dist/UserChipMenu/context.d.ts +0 -4
- package/dist/UserChipMenu/index.d.ts +0 -2
- package/dist/UserChipMenu/styles.d.ts +0 -2
- package/dist/extensions/index.d.ts +0 -3
- package/dist/extensions/sendMessage.d.ts +0 -3
- package/dist/extensions/types.d.ts +0 -22
- package/dist/extensions/useExtensionMessage.d.ts +0 -2
- package/dist/icons/ArrowDropdownIcon.d.ts +0 -2
- package/dist/icons/ArrowRightIcon.d.ts +0 -1
- package/dist/icons/CheckboxCheckedIcon.d.ts +0 -1
- package/dist/icons/CheckboxIcon.d.ts +0 -1
- package/dist/icons/CheckboxIndeterminateIcon.d.ts +0 -1
- package/dist/icons/CloseIcon.d.ts +0 -1
- package/dist/icons/CompleteIcon.d.ts +0 -2
- package/dist/icons/DeleteIcon.d.ts +0 -1
- package/dist/icons/EditIcon.d.ts +0 -1
- package/dist/icons/FilteringIcon.d.ts +0 -1
- package/dist/icons/ImageIcon.d.ts +0 -1
- package/dist/icons/InfoIcon.d.ts +0 -2
- package/dist/icons/Logo.d.ts +0 -2
- package/dist/icons/LogoLight.d.ts +0 -2
- package/dist/icons/MoreIcon.d.ts +0 -1
- package/dist/icons/NavigatorIcon.d.ts +0 -1
- package/dist/icons/NotAllowedIcon.d.ts +0 -2
- package/dist/icons/NotAllowedInvertedIcon.d.ts +0 -2
- package/dist/icons/PlusIcon.d.ts +0 -1
- package/dist/icons/RadioCheckedIcon.d.ts +0 -1
- package/dist/icons/RadioIcon.d.ts +0 -1
- package/dist/icons/SearchIcon.d.ts +0 -1
- package/dist/icons/WarningIcon.d.ts +0 -2
- package/dist/icons/index.d.ts +0 -18
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -7
- package/dist/localStorageKeys.d.ts +0 -4
- package/dist/mjs/index.js +0 -5
- package/dist/mjs/index.js.map +0 -7
- package/dist/theme/Baseline.d.ts +0 -2
- package/dist/theme/ThemeProvider.d.ts +0 -17
- package/dist/theme/context.d.ts +0 -3
- package/dist/theme/createSaleorTheme/createSaleorTheme.d.ts +0 -3
- package/dist/theme/createSaleorTheme/index.d.ts +0 -2
- package/dist/theme/createSaleorTheme/overrides/buttons.d.ts +0 -3
- package/dist/theme/createSaleorTheme/overrides/controls.d.ts +0 -3
- package/dist/theme/createSaleorTheme/overrides/index.d.ts +0 -3
- package/dist/theme/createSaleorTheme/overrides/inputs.d.ts +0 -3
- package/dist/theme/createSaleorTheme/overrides/tables.d.ts +0 -3
- package/dist/theme/createSaleorTheme/palette.d.ts +0 -2
- package/dist/theme/createSaleorTheme/shadows.d.ts +0 -2
- package/dist/theme/createSaleorTheme/types.d.ts +0 -51
- package/dist/theme/index.d.ts +0 -4
- package/dist/theme/styles.d.ts +0 -5
- package/dist/theme/themes.d.ts +0 -3
- package/dist/theme/types.d.ts +0 -6
- package/dist/theme/utils.d.ts +0 -1
- package/dist/theme/utils.test.d.ts +0 -1
- package/dist/tools/index.d.ts +0 -2
- package/dist/tools/useElementScroll.d.ts +0 -12
- package/dist/tools/useLocalStorage.d.ts +0 -5
- package/dist/tools/useWindowScroll.d.ts +0 -4
- package/dist/types/StatusChip/styles.d.ts +0 -3
- package/dist/utils/Decorator.d.ts +0 -4
- 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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
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}
|
|
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}
|
package/src/IconButton/styles.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
}),
|
package/src/Sidebar/MenuItem.tsx
CHANGED
|
@@ -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
|
|
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<
|
|
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
|
|
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
|
-
<
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
|
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
|
|
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
|
-
</
|
|
260
|
+
</RootNavComponent>
|
|
240
261
|
);
|
|
241
262
|
};
|
|
242
263
|
|
package/src/Sidebar/Sidebar.tsx
CHANGED
|
@@ -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
|
-
<
|
|
75
|
+
<Link href={logoHref} className={classes.logo}>
|
|
70
76
|
{themeType === "dark" ? <LogoDark /> : <Logo />}
|
|
71
|
-
</
|
|
72
|
-
{menuItems.map((menuItem) =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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}
|
package/src/Sidebar/types.ts
CHANGED
|
@@ -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
|
|
18
|
-
|
|
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
|
|
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
|
-
<
|
|
74
|
+
<Link href={logoHref} className={classes.logo}>
|
|
71
75
|
{themeType === "dark" ? <LogoDark /> : <Logo />}
|
|
72
|
-
</
|
|
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
|
@@ -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:
|
|
174
|
+
fontWeight: 400,
|
|
175
175
|
},
|
|
176
176
|
notchedOutline: {
|
|
177
177
|
// It's so much easier to put it here with important tag rather than
|
package/src/theme/themes.ts
CHANGED
package/src/utils/guideStyles.ts
CHANGED
|
@@ -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,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;
|
package/dist/Alert/Alert.d.ts
DELETED
|
@@ -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>;
|
package/dist/Alert/index.d.ts
DELETED
package/dist/Alert/styles.d.ts
DELETED
|
@@ -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 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;
|
package/dist/Backlink/index.d.ts
DELETED