@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,19 @@
1
+ import { Meta, Story } from "@storybook/react";
2
+ import React from "react";
3
+
4
+ import { SquareButton } from "../SquareButton";
5
+ import { Tooltip, TooltipProps } from "./Tooltip";
6
+
7
+ const props: TooltipProps = {
8
+ title: "Tooltip",
9
+ children: <SquareButton>Hover</SquareButton>,
10
+ };
11
+
12
+ export const Info: Story = () => <Tooltip variant="info" {...props} />;
13
+ export const Success: Story = () => <Tooltip variant="success" {...props} />;
14
+ export const Error: Story = () => <Tooltip variant="error" {...props} />;
15
+ export const Warning: Story = () => <Tooltip variant="warning" {...props} />;
16
+
17
+ export default {
18
+ title: "Tooltip",
19
+ } as Meta;
@@ -0,0 +1,25 @@
1
+ import { Tooltip as MUITooltip } from "@material-ui/core";
2
+ import { TooltipProps as MUITooltipProps } from "@material-ui/core/Tooltip";
3
+ import React from "react";
4
+
5
+ import useStyles from "./styles";
6
+
7
+ export interface TooltipProps extends MUITooltipProps {
8
+ variant?: "info" | "success" | "warning" | "error";
9
+ }
10
+
11
+ export const Tooltip: React.FC<TooltipProps> = ({
12
+ children,
13
+ variant = "info",
14
+ ...rest
15
+ }) => {
16
+ const classes = useStyles({ variant, children, ...rest });
17
+
18
+ return (
19
+ <MUITooltip classes={classes} {...rest}>
20
+ {children}
21
+ </MUITooltip>
22
+ );
23
+ };
24
+
25
+ Tooltip.displayName = "Tooltip";
@@ -0,0 +1 @@
1
+ export * from "./Tooltip";
@@ -0,0 +1,28 @@
1
+ import { makeStyles } from "../theme";
2
+ import { TooltipProps } from "./Tooltip";
3
+
4
+ const useStyles = makeStyles<TooltipProps, "tooltip">(
5
+ (theme) => ({
6
+ tooltip: {
7
+ backgroundColor: (props) => {
8
+ switch (props.variant) {
9
+ case "info":
10
+ return theme.palette.info.main;
11
+ case "success":
12
+ return theme.palette.success.main;
13
+ case "warning":
14
+ return theme.palette.warning.main;
15
+ case "error":
16
+ return theme.palette.error.main;
17
+ default:
18
+ return theme.palette.info.main;
19
+ }
20
+ },
21
+ },
22
+ }),
23
+ {
24
+ name: "Tooltip",
25
+ }
26
+ );
27
+
28
+ export default useStyles;
@@ -0,0 +1,40 @@
1
+ import { Meta, Story } from "@storybook/react";
2
+ import React from "react";
3
+
4
+ import placeholder from "../assets/placeholder_64x64.png";
5
+ import { UserChipMenu, UserChipProps } from "./UserChipMenu";
6
+ import { UserChipMenuItem } from "./UserChipMenuItem";
7
+
8
+ const props: UserChipProps = {
9
+ avatar: null,
10
+ initials: "LI",
11
+ name: "Lorem Ipsum",
12
+ };
13
+
14
+ const Options: React.FC = () => (
15
+ <>
16
+ {["First Option", "Second Option"].map((option) => (
17
+ <UserChipMenuItem key={option}>{option}</UserChipMenuItem>
18
+ ))}
19
+ </>
20
+ );
21
+
22
+ export const Default: Story = () => (
23
+ <UserChipMenu {...props}>
24
+ <Options />
25
+ </UserChipMenu>
26
+ );
27
+ export const WithSubtext: Story = () => (
28
+ <UserChipMenu {...props} subtext="Lorem ipsum dolor sit amet">
29
+ <Options />
30
+ </UserChipMenu>
31
+ );
32
+ export const WithAvatar: Story = () => (
33
+ <UserChipMenu {...props} avatar={placeholder}>
34
+ <Options />
35
+ </UserChipMenu>
36
+ );
37
+
38
+ export default {
39
+ title: "User Chip",
40
+ } as Meta;
@@ -0,0 +1,113 @@
1
+ import Avatar from "@material-ui/core/Avatar";
2
+ import Chip from "@material-ui/core/Chip";
3
+ import ClickAwayListener from "@material-ui/core/ClickAwayListener";
4
+ import Grow from "@material-ui/core/Grow";
5
+ import Hidden from "@material-ui/core/Hidden";
6
+ import Menu from "@material-ui/core/MenuList";
7
+ import Paper from "@material-ui/core/Paper";
8
+ import Popper from "@material-ui/core/Popper";
9
+ import Typography from "@material-ui/core/Typography";
10
+ import clsx from "clsx";
11
+ import React from "react";
12
+
13
+ import ArrowDropdownIcon from "../icons/ArrowDropdownIcon";
14
+ import { UserChipMenuContext } from "./context";
15
+ import useStyles from "./styles";
16
+
17
+ export interface UserChipProps {
18
+ avatar: string | null;
19
+ initials: string;
20
+ name: string;
21
+ subtext?: string;
22
+ }
23
+
24
+ export const UserChipMenu: React.FC<UserChipProps> = ({
25
+ avatar,
26
+ initials,
27
+ name,
28
+ subtext,
29
+ children,
30
+ ...props
31
+ }) => {
32
+ const classes = useStyles({});
33
+ const [isMenuOpened, setMenuState] = React.useState(false);
34
+ const anchor = React.useRef<HTMLDivElement>(null);
35
+
36
+ const closeMenu = () => setMenuState(false);
37
+
38
+ return (
39
+ <div className={classes.userMenuContainer} {...props}>
40
+ <Chip
41
+ avatar={
42
+ avatar ? (
43
+ <Avatar alt="user" src={avatar} />
44
+ ) : (
45
+ <div className={classes.avatarPlaceholder}>
46
+ <div className={classes.avatarInitials}>{initials}</div>
47
+ </div>
48
+ )
49
+ }
50
+ classes={{
51
+ avatar: classes.avatar,
52
+ }}
53
+ className={classes.userChip}
54
+ label={
55
+ <div className={classes.labelContainer}>
56
+ <Hidden smDown>
57
+ <div>
58
+ <Typography className={classes.label} variant="body2">
59
+ {name}
60
+ </Typography>
61
+ {subtext && (
62
+ <Typography
63
+ className={classes.label}
64
+ variant="body2"
65
+ color="textSecondary"
66
+ >
67
+ {subtext}
68
+ </Typography>
69
+ )}
70
+ </div>
71
+ </Hidden>
72
+ <ArrowDropdownIcon
73
+ className={clsx(classes.arrow, {
74
+ [classes.rotate]: isMenuOpened,
75
+ })}
76
+ />
77
+ </div>
78
+ }
79
+ onClick={() => setMenuState(!isMenuOpened)}
80
+ ref={anchor}
81
+ data-test="userMenu"
82
+ />
83
+ <Popper
84
+ className={classes.popover}
85
+ open={isMenuOpened}
86
+ anchorEl={anchor.current}
87
+ transition
88
+ placement="bottom-end"
89
+ >
90
+ {({ TransitionProps, placement }) => (
91
+ <Grow
92
+ {...TransitionProps}
93
+ style={{
94
+ transformOrigin:
95
+ placement === "bottom" ? "right top" : "right bottom",
96
+ }}
97
+ >
98
+ <Paper>
99
+ <ClickAwayListener onClickAway={closeMenu} mouseEvent="onClick">
100
+ <Menu>
101
+ <UserChipMenuContext.Provider value={closeMenu}>
102
+ {children}
103
+ </UserChipMenuContext.Provider>
104
+ </Menu>
105
+ </ClickAwayListener>
106
+ </Paper>
107
+ </Grow>
108
+ )}
109
+ </Popper>
110
+ </div>
111
+ );
112
+ };
113
+ UserChipMenu.displayName = "UserChip";
@@ -0,0 +1,33 @@
1
+ import MenuItem, { MenuItemProps } from "@material-ui/core/MenuItem";
2
+ import React from "react";
3
+
4
+ import { useUserChipMenu } from "./context";
5
+
6
+ export interface UserChipMenuItemProps extends Omit<MenuItemProps, "button"> {
7
+ leaveOpen?: boolean;
8
+ }
9
+
10
+ export const UserChipMenuItem: React.FC<UserChipMenuItemProps> = ({
11
+ leaveOpen,
12
+ onClick,
13
+ ...props
14
+ }) => {
15
+ const closeMenu = useUserChipMenu();
16
+
17
+ // We're not really interested in event type here
18
+ const handleClickWithClose = (event: unknown) => {
19
+ closeMenu();
20
+ if (onClick) {
21
+ onClick(event as any);
22
+ }
23
+ };
24
+
25
+ return (
26
+ <MenuItem
27
+ {...props}
28
+ onClick={leaveOpen ? onClick : handleClickWithClose}
29
+ button
30
+ />
31
+ );
32
+ };
33
+ UserChipMenuItem.displayName = "UserChipMenuItem";
@@ -0,0 +1,19 @@
1
+ import { createContext, useContext } from "react";
2
+
3
+ export type UserChipMenuContextType = () => void;
4
+
5
+ export const UserChipMenuContext = createContext<
6
+ UserChipMenuContextType | undefined
7
+ >(undefined);
8
+ UserChipMenuContext.displayName = "UserChipMenuContext";
9
+
10
+ export const useUserChipMenu = () => {
11
+ const ctx = useContext(UserChipMenuContext);
12
+ if (ctx === undefined) {
13
+ throw new Error(
14
+ "useUserChipMenu must be used within a UserChipMenuContext"
15
+ );
16
+ }
17
+
18
+ return ctx;
19
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./UserChipMenu";
2
+ export * from "./UserChipMenuItem";
@@ -0,0 +1,65 @@
1
+ import { makeStyles } from "../theme";
2
+
3
+ const useStyles = makeStyles(
4
+ (theme) => ({
5
+ arrow: {
6
+ [theme.breakpoints.down("sm")]: {
7
+ marginLeft: 0,
8
+ },
9
+ marginLeft: theme.spacing(2),
10
+ transition: theme.transitions.duration.standard + "ms",
11
+ },
12
+ avatar: {
13
+ "&&": {
14
+ [theme.breakpoints.down("sm")]: {
15
+ height: 40,
16
+ width: 40,
17
+ },
18
+ height: 32,
19
+ width: 32,
20
+ },
21
+ },
22
+ avatarInitials: {
23
+ color: theme.palette.primary.contrastText,
24
+ },
25
+ avatarPlaceholder: {
26
+ alignItems: "center",
27
+ background: theme.palette.primary.main,
28
+ borderRadius: "100%",
29
+ display: "flex",
30
+ justifyContent: "center",
31
+ },
32
+ label: {
33
+ lineHeight: 1.2,
34
+ },
35
+ labelContainer: {
36
+ display: "inline-flex",
37
+ alignItems: "center",
38
+ },
39
+ popover: {
40
+ marginTop: theme.spacing(2),
41
+ zIndex: 10,
42
+ },
43
+ rotate: {
44
+ transform: "rotate(180deg)",
45
+ },
46
+ userChip: {
47
+ [theme.breakpoints.down("sm")]: {
48
+ height: 48,
49
+ },
50
+ backgroundColor: theme.palette.background.paper,
51
+ borderRadius: 24,
52
+ color: theme.palette.text.primary,
53
+ height: 40,
54
+ padding: theme.spacing(0.5),
55
+ },
56
+ userMenuContainer: {
57
+ position: "relative",
58
+ },
59
+ }),
60
+ {
61
+ name: "UserChipMenu",
62
+ }
63
+ );
64
+
65
+ export default useStyles;
Binary file
@@ -0,0 +1,3 @@
1
+ export * from "./sendMessage";
2
+ export * from "./types";
3
+ export * from "./useExtensionMessage";
@@ -0,0 +1,23 @@
1
+ import { BaseExtensionMessageData } from "./types";
2
+
3
+ export function sendMessageToDashboard<T extends BaseExtensionMessageData>(
4
+ message: T,
5
+ targetOrigin: string
6
+ ) {
7
+ if (!!window.parent) {
8
+ window.parent.postMessage(message, targetOrigin);
9
+ }
10
+ }
11
+
12
+ export function sendMessageToExtension<T extends BaseExtensionMessageData>(
13
+ message: T,
14
+ targetOrigin: string
15
+ ) {
16
+ const appFrame: HTMLIFrameElement | null = document.querySelector(
17
+ "#extension-app"
18
+ );
19
+
20
+ if (!!appFrame?.contentWindow) {
21
+ appFrame.contentWindow.postMessage(message, targetOrigin);
22
+ }
23
+ }
@@ -0,0 +1,26 @@
1
+ import { ThemeType } from "../theme";
2
+
3
+ export enum ExtensionMessageType {
4
+ BREADCRUMB_CLICK,
5
+ BREADCRUMB_SET,
6
+ THEME,
7
+ }
8
+ export interface BaseExtensionMessageData {
9
+ type: ExtensionMessageType;
10
+ }
11
+
12
+ export type Breadcrumb = Record<"label" | "value", string>;
13
+ export interface BreadcrumbClickMessage extends BaseExtensionMessageData {
14
+ breadcrumb: string;
15
+ }
16
+ export interface BreadcrumbChangeMessage extends BaseExtensionMessageData {
17
+ breadcrumbs: Breadcrumb[];
18
+ }
19
+
20
+ export interface ThemeChangeMessage extends BaseExtensionMessageData {
21
+ theme: ThemeType;
22
+ }
23
+
24
+ export interface ExtensionMessageEvent<T extends BaseExtensionMessageData> {
25
+ data: T;
26
+ }
@@ -0,0 +1,13 @@
1
+ import { useEffect } from "react";
2
+
3
+ import { BaseExtensionMessageData, ExtensionMessageEvent } from "./types";
4
+
5
+ export function useExtensionMessage<T extends BaseExtensionMessageData>(
6
+ handle: (message: ExtensionMessageEvent<T>) => void
7
+ ) {
8
+ useEffect(() => {
9
+ window.addEventListener("message", handle);
10
+
11
+ return () => window.removeEventListener("message", handle);
12
+ }, [handle]);
13
+ }
@@ -0,0 +1,11 @@
1
+ import { createSvgIcon } from "@material-ui/core/utils";
2
+ import React from "react";
3
+
4
+ const ArrowDropdownIcon = createSvgIcon(
5
+ <g style={{ fillRule: "evenodd" }}>
6
+ <path d="M7 10l5 5 5-5z" />
7
+ </g>,
8
+ "ArrowDropdownIcon"
9
+ );
10
+
11
+ export default ArrowDropdownIcon;
@@ -0,0 +1,15 @@
1
+ import { createSvgIcon } from "@material-ui/core/utils";
2
+ import React from "react";
3
+
4
+ export const CheckboxCheckedIcon = createSvgIcon(
5
+ <>
6
+ <rect x="5" y="5" width="14" height="14" fill="currentColor" />
7
+ <path
8
+ fillRule="evenodd"
9
+ clipRule="evenodd"
10
+ d="M 16.7527 9.33783 L 10.86618 15.7595 L 8 12.32006 L 8.76822 11.67988 L 10.90204 14.24046 L 16.0155 8.66211 L 16.7527 9.33783 Z"
11
+ fill="white"
12
+ />
13
+ </>,
14
+ "CheckboxCheckedIcon"
15
+ );
@@ -0,0 +1,7 @@
1
+ import { createSvgIcon } from "@material-ui/core/utils";
2
+ import React from "react";
3
+
4
+ export const CheckboxIcon = createSvgIcon(
5
+ <rect x="5" y="5" width="14" height="14" stroke="currentColor" fill="none" />,
6
+ "CheckboxIcon"
7
+ );
@@ -0,0 +1,17 @@
1
+ import { createSvgIcon } from "@material-ui/core/utils";
2
+ import React from "react";
3
+
4
+ export const CheckboxIndeterminateIcon = createSvgIcon(
5
+ <>
6
+ <rect
7
+ x="5"
8
+ y="5"
9
+ width="14"
10
+ height="14"
11
+ stroke="currentColor"
12
+ fill="none"
13
+ />
14
+ <rect x="8" y="11" width="8" height="2" fill="currentColor" />
15
+ </>,
16
+ "CheckboxIndeterminateIcon"
17
+ );
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+
3
+ export const CompleteIcon: React.FC<React.SVGProps<SVGSVGElement>> = (
4
+ props
5
+ ) => (
6
+ <svg
7
+ width="40"
8
+ height="40"
9
+ viewBox="0 0 40 40"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ {...props}
13
+ >
14
+ <circle cx="20" cy="20" r="20" fill="white" />
15
+ <circle cx="20" cy="20" r="14" stroke="#5DC292" strokeWidth="4" />
16
+ <path
17
+ fillRule="evenodd"
18
+ clipRule="evenodd"
19
+ d="M28.7678 13.7678C29.3536 14.3536 29.3536 15.3033 28.7678 15.8891L17.4142 27.2426L12.0607 21.8891C11.4749 21.3033 11.4749 20.3536 12.0607 19.7678L12.7678 19.0607C13.3536 18.4749 14.3033 18.4749 14.8891 19.0607L17.4142 21.5858L25.9393 13.0607C26.5251 12.4749 27.4749 12.4749 28.0607 13.0607L28.7678 13.7678Z"
20
+ fill="#5DC292"
21
+ />
22
+ </svg>
23
+ );
24
+
25
+ CompleteIcon.displayName = "CompleteIcon";
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+
3
+ export const InfoIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
4
+ <svg
5
+ width="40"
6
+ height="40"
7
+ viewBox="0 0 40 40"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {...props}
11
+ >
12
+ <circle cx="20" cy="20" r="20" fill="white" />
13
+ <circle cx="20" cy="20" r="14" stroke="#28234A" strokeWidth="4" />
14
+ <path
15
+ fillRule="evenodd"
16
+ clipRule="evenodd"
17
+ d="M19.5 11C18.6716 11 18 11.6716 18 12.5V20.5C18 21.3284 18.6716 22 19.5 22H20.5C21.3284 22 22 21.3284 22 20.5V12.5C22 11.6716 21.3284 11 20.5 11H19.5ZM19.5 25C18.6716 25 18 25.6716 18 26.5V27.5C18 28.3284 18.6716 29 19.5 29H20.5C21.3284 29 22 28.3284 22 27.5V26.5C22 25.6716 21.3284 25 20.5 25H19.5Z"
18
+ fill="#28234A"
19
+ />
20
+ </svg>
21
+ );
22
+
23
+ InfoIcon.displayName = "InfoIcon";
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+
3
+ export const Logo: React.FC = () => (
4
+ <svg
5
+ width="36"
6
+ height="33"
7
+ viewBox="0 0 36 33"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ >
11
+ <path
12
+ fillRule="evenodd"
13
+ clipRule="evenodd"
14
+ d="M16.6072 33C22.4977 33 23.9789 30.6214 23.9789 27.3629C23.9789 23.3549 20.3772 22.6056 17.3814 22.1167C15.0924 21.7258 14.0489 21.5304 14.0489 20.1292C14.0489 19.0867 14.9577 18.6954 16.4389 18.6954C18.2566 18.6954 18.7614 19.2168 18.9298 20.7482L23.7097 20.0314C23.3055 16.7404 21.4542 15.0787 16.5735 15.0787C11.2216 15.0787 9.33654 17.2293 9.33654 20.6504C9.30299 25.082 13.4768 25.5382 16.5735 26.0594C18.492 26.418 19.2328 26.7437 19.2328 28.0146C19.2328 29.0573 18.5933 29.5135 16.6745 29.5135C14.5539 29.5135 13.9144 29.1551 13.6451 27.4281L9 28.1124C9.43753 31.599 11.4908 33 16.6072 33Z"
15
+ fill="#28234A"
16
+ />
17
+ <path
18
+ fillRule="evenodd"
19
+ clipRule="evenodd"
20
+ d="M19.7838 0L13.4043 6.64709H29.1638L35.5433 0H19.7838Z"
21
+ fill="#8AC4EB"
22
+ />
23
+ <path
24
+ fillRule="evenodd"
25
+ clipRule="evenodd"
26
+ d="M6.15911 2.31187C6.27552 2.1958 6.4332 2.13062 6.59759 2.13062H27.3248C27.5761 2.13062 27.8026 2.28211 27.8987 2.51437C27.9947 2.74664 27.9412 3.01388 27.7632 3.19134L21.7867 9.1508C21.6703 9.26687 21.5126 9.33205 21.3482 9.33205H0.621008C0.369679 9.33205 0.143131 9.18056 0.0471181 8.94829C-0.0488948 8.71603 0.00456112 8.44879 0.182532 8.27133L6.15911 2.31187ZM6.85429 3.37259L2.12325 8.09007H21.0915L25.8225 3.37259H6.85429Z"
27
+ fill="#28234A"
28
+ />
29
+ </svg>
30
+ );
31
+
32
+ Logo.displayName = "Logo";
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+
3
+ export const NotAllowedIcon: React.FC<React.SVGProps<SVGSVGElement>> = (
4
+ props
5
+ ) => (
6
+ <svg
7
+ width="40"
8
+ height="40"
9
+ viewBox="0 0 40 40"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ {...props}
13
+ >
14
+ <circle cx="20" cy="20" r="16" fill="#F5FAFB" />
15
+ <circle cx="20" cy="20" r="20" fill="white" />
16
+ <path
17
+ fillRule="evenodd"
18
+ clipRule="evenodd"
19
+ d="M26.9531 29.7815C24.9914 31.1784 22.5917 32 20 32C13.3726 32 8 26.6274 8 20C8 17.4083 8.82158 15.0086 10.2185 13.0469L26.9531 29.7815ZM29.7815 26.9531L13.0469 10.2185C15.0086 8.82158 17.4083 8 20 8C26.6274 8 32 13.3726 32 20C32 22.5917 31.1784 24.9914 29.7815 26.9531ZM36 20C36 28.8366 28.8366 36 20 36C11.1634 36 4 28.8366 4 20C4 11.1634 11.1634 4 20 4C28.8366 4 36 11.1634 36 20Z"
20
+ fill="#FE6E76"
21
+ />
22
+ </svg>
23
+ );
24
+
25
+ NotAllowedIcon.displayName = "NotAllowedIcon";
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+
3
+ export const NotAllowedInvertedIcon: React.FC<React.SVGProps<SVGSVGElement>> = (
4
+ props
5
+ ) => (
6
+ <svg
7
+ width="40"
8
+ height="40"
9
+ viewBox="0 0 40 40"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ {...props}
13
+ >
14
+ <circle cx="20" cy="20" r="16" fill="#F5FAFB" />
15
+ <circle cx="20" cy="20" r="20" fill="#FE6E76" />
16
+ <path
17
+ fillRule="evenodd"
18
+ clipRule="evenodd"
19
+ d="M26.9531 29.7815C24.9914 31.1784 22.5917 32 20 32C13.3726 32 8 26.6274 8 20C8 17.4083 8.82158 15.0086 10.2185 13.0469L26.9531 29.7815ZM29.7815 26.9531L13.0469 10.2185C15.0086 8.82158 17.4083 8 20 8C26.6274 8 32 13.3726 32 20C32 22.5917 31.1784 24.9914 29.7815 26.9531ZM36 20C36 28.8366 28.8366 36 20 36C11.1634 36 4 28.8366 4 20C4 11.1634 11.1634 4 20 4C28.8366 4 36 11.1634 36 20Z"
20
+ fill="white"
21
+ />
22
+ </svg>
23
+ );
24
+
25
+ NotAllowedInvertedIcon.displayName = "NotAllowedInvertedIcon";
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+
3
+ export const WarningIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
4
+ <svg
5
+ width="40"
6
+ height="40"
7
+ viewBox="0 0 40 40"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ {...props}
11
+ >
12
+ <circle cx="20" cy="20" r="20" fill="white" />
13
+ <circle cx="20" cy="20" r="14" stroke="#FFB84E" strokeWidth="4" />
14
+ <path
15
+ fillRule="evenodd"
16
+ clipRule="evenodd"
17
+ d="M19.5 11C18.6716 11 18 11.6716 18 12.5V20.5C18 21.3284 18.6716 22 19.5 22H20.5C21.3284 22 22 21.3284 22 20.5V12.5C22 11.6716 21.3284 11 20.5 11H19.5ZM19.5 25C18.6716 25 18 25.6716 18 26.5V27.5C18 28.3284 18.6716 29 19.5 29H20.5C21.3284 29 22 28.3284 22 27.5V26.5C22 25.6716 21.3284 25 20.5 25H19.5Z"
18
+ fill="#FFB84E"
19
+ />
20
+ </svg>
21
+ );
22
+
23
+ WarningIcon.displayName = "WarningIcon";
@@ -0,0 +1,9 @@
1
+ export * from "./CompleteIcon";
2
+ export * from "./InfoIcon";
3
+ export * from "./NotAllowedIcon";
4
+ export * from "./NotAllowedInvertedIcon";
5
+ export * from "./WarningIcon";
6
+ export * from "./ArrowDropdownIcon";
7
+ export * from "./CheckboxIcon";
8
+ export * from "./CheckboxCheckedIcon";
9
+ export * from "./CheckboxIndeterminateIcon";
package/src/index.tsx ADDED
@@ -0,0 +1,15 @@
1
+ export * from "./theme";
2
+ export * from "./extensions";
3
+ export * from "./icons";
4
+ export * from "./Savebar";
5
+ export * from "./Backlink";
6
+ export * from "./ConfirmButton";
7
+ export * from "./Sidebar";
8
+ export * from "./SidebarDrawer";
9
+ export * from "./SquareButton";
10
+ export * from "./Alert";
11
+ export * from "./Notification";
12
+ export * from "./UserChipMenu";
13
+ export * from "./ResponsiveTable";
14
+ export * from "./Tooltip";
15
+ export * from "./ActionBar";