@mitodl/smoot-design 0.0.0-preview215f7ae3fa

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 (190) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +27 -0
  3. package/dist/bundles/aiChat.es.js +24812 -0
  4. package/dist/bundles/aiChat.umd.js +161 -0
  5. package/dist/cjs/ai.d.ts +2 -0
  6. package/dist/cjs/ai.js +5 -0
  7. package/dist/cjs/bundles/aiChat.d.ts +6 -0
  8. package/dist/cjs/bundles/aiChat.js +13 -0
  9. package/dist/cjs/components/AiChat/AiChat.d.ts +5 -0
  10. package/dist/cjs/components/AiChat/AiChat.js +150 -0
  11. package/dist/cjs/components/AiChat/AiChat.stories.d.ts +11 -0
  12. package/dist/cjs/components/AiChat/AiChat.stories.js +76 -0
  13. package/dist/cjs/components/AiChat/AiChat.test.d.ts +1 -0
  14. package/dist/cjs/components/AiChat/AiChat.test.js +130 -0
  15. package/dist/cjs/components/AiChat/story-utils.d.ts +3 -0
  16. package/dist/cjs/components/AiChat/story-utils.js +100 -0
  17. package/dist/cjs/components/AiChat/types.d.ts +45 -0
  18. package/dist/cjs/components/AiChat/types.js +3 -0
  19. package/dist/cjs/components/AiChat/utils.d.ts +9 -0
  20. package/dist/cjs/components/AiChat/utils.js +31 -0
  21. package/dist/cjs/components/Button/ActionButton.d.ts +30 -0
  22. package/dist/cjs/components/Button/ActionButton.js +73 -0
  23. package/dist/cjs/components/Button/ActionButton.stories.d.ts +15 -0
  24. package/dist/cjs/components/Button/ActionButton.stories.js +116 -0
  25. package/dist/cjs/components/Button/Button.d.ts +56 -0
  26. package/dist/cjs/components/Button/Button.js +273 -0
  27. package/dist/cjs/components/Button/Button.stories.d.ts +17 -0
  28. package/dist/cjs/components/Button/Button.stories.js +138 -0
  29. package/dist/cjs/components/Button/Button.test.d.ts +1 -0
  30. package/dist/cjs/components/Button/Button.test.js +46 -0
  31. package/dist/cjs/components/Input/Input.d.ts +115 -0
  32. package/dist/cjs/components/Input/Input.js +219 -0
  33. package/dist/cjs/components/Input/Input.stories.d.ts +19 -0
  34. package/dist/cjs/components/Input/Input.stories.js +134 -0
  35. package/dist/cjs/components/Input/Input.test.d.ts +1 -0
  36. package/dist/cjs/components/Input/Input.test.js +32 -0
  37. package/dist/cjs/components/LinkAdapter/LinkAdapter.d.ts +23 -0
  38. package/dist/cjs/components/LinkAdapter/LinkAdapter.js +34 -0
  39. package/dist/cjs/components/ScrollSnap/ScrollSnap.d.ts +19 -0
  40. package/dist/cjs/components/ScrollSnap/ScrollSnap.js +59 -0
  41. package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
  42. package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.js +43 -0
  43. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
  44. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.js +43 -0
  45. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
  46. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.js +44 -0
  47. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
  48. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.js +62 -0
  49. package/dist/cjs/components/TextField/TextField.d.ts +29 -0
  50. package/dist/cjs/components/TextField/TextField.js +33 -0
  51. package/dist/cjs/components/TextField/TextField.stories.d.ts +10 -0
  52. package/dist/cjs/components/TextField/TextField.stories.js +135 -0
  53. package/dist/cjs/components/TextField/TextField.test.d.ts +1 -0
  54. package/dist/cjs/components/TextField/TextField.test.js +77 -0
  55. package/dist/cjs/components/ThemeProvider/ThemeProvider.d.ts +23 -0
  56. package/dist/cjs/components/ThemeProvider/ThemeProvider.js +90 -0
  57. package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.d.ts +58 -0
  58. package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.js +97 -0
  59. package/dist/cjs/components/ThemeProvider/Typography.stories.d.ts +39 -0
  60. package/dist/cjs/components/ThemeProvider/Typography.stories.js +65 -0
  61. package/dist/cjs/components/ThemeProvider/breakpoints.d.ts +4 -0
  62. package/dist/cjs/components/ThemeProvider/breakpoints.js +20 -0
  63. package/dist/cjs/components/ThemeProvider/buttons.d.ts +7 -0
  64. package/dist/cjs/components/ThemeProvider/buttons.js +20 -0
  65. package/dist/cjs/components/ThemeProvider/chips.d.ts +3 -0
  66. package/dist/cjs/components/ThemeProvider/chips.js +154 -0
  67. package/dist/cjs/components/ThemeProvider/colors.d.ts +32 -0
  68. package/dist/cjs/components/ThemeProvider/colors.js +35 -0
  69. package/dist/cjs/components/ThemeProvider/typography.d.ts +18 -0
  70. package/dist/cjs/components/ThemeProvider/typography.js +174 -0
  71. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
  72. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.js +33 -0
  73. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
  74. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.js +13 -0
  75. package/dist/cjs/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
  76. package/dist/cjs/components/internal/FormHelpers/FormHelpers.js +78 -0
  77. package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
  78. package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.js +93 -0
  79. package/dist/cjs/index.d.ts +16 -0
  80. package/dist/cjs/index.js +28 -0
  81. package/dist/cjs/jest-setup.d.ts +1 -0
  82. package/dist/cjs/jest-setup.js +18 -0
  83. package/dist/cjs/jsdom-extended.d.ts +6 -0
  84. package/dist/cjs/jsdom-extended.js +14 -0
  85. package/dist/cjs/story-utils/index.d.ts +6 -0
  86. package/dist/cjs/story-utils/index.js +17 -0
  87. package/dist/cjs/utils/composeRefs.d.ts +7 -0
  88. package/dist/cjs/utils/composeRefs.js +20 -0
  89. package/dist/cjs/utils/composeRefs.test.d.ts +1 -0
  90. package/dist/cjs/utils/composeRefs.test.js +19 -0
  91. package/dist/cjs/utils/useDevCheckStable.d.ts +8 -0
  92. package/dist/cjs/utils/useDevCheckStable.js +29 -0
  93. package/dist/cjs/utils/useInterval.d.ts +7 -0
  94. package/dist/cjs/utils/useInterval.js +25 -0
  95. package/dist/esm/ai.d.ts +2 -0
  96. package/dist/esm/ai.js +1 -0
  97. package/dist/esm/bundles/aiChat.d.ts +6 -0
  98. package/dist/esm/bundles/aiChat.js +10 -0
  99. package/dist/esm/components/AiChat/AiChat.d.ts +5 -0
  100. package/dist/esm/components/AiChat/AiChat.js +147 -0
  101. package/dist/esm/components/AiChat/AiChat.stories.d.ts +11 -0
  102. package/dist/esm/components/AiChat/AiChat.stories.js +73 -0
  103. package/dist/esm/components/AiChat/AiChat.test.d.ts +1 -0
  104. package/dist/esm/components/AiChat/AiChat.test.js +128 -0
  105. package/dist/esm/components/AiChat/story-utils.d.ts +3 -0
  106. package/dist/esm/components/AiChat/story-utils.js +96 -0
  107. package/dist/esm/components/AiChat/types.d.ts +45 -0
  108. package/dist/esm/components/AiChat/types.js +2 -0
  109. package/dist/esm/components/AiChat/utils.d.ts +9 -0
  110. package/dist/esm/components/AiChat/utils.js +28 -0
  111. package/dist/esm/components/Button/ActionButton.d.ts +30 -0
  112. package/dist/esm/components/Button/ActionButton.js +68 -0
  113. package/dist/esm/components/Button/ActionButton.stories.d.ts +15 -0
  114. package/dist/esm/components/Button/ActionButton.stories.js +113 -0
  115. package/dist/esm/components/Button/Button.d.ts +56 -0
  116. package/dist/esm/components/Button/Button.js +265 -0
  117. package/dist/esm/components/Button/Button.stories.d.ts +17 -0
  118. package/dist/esm/components/Button/Button.stories.js +135 -0
  119. package/dist/esm/components/Button/Button.test.d.ts +1 -0
  120. package/dist/esm/components/Button/Button.test.js +44 -0
  121. package/dist/esm/components/Input/Input.d.ts +115 -0
  122. package/dist/esm/components/Input/Input.js +214 -0
  123. package/dist/esm/components/Input/Input.stories.d.ts +19 -0
  124. package/dist/esm/components/Input/Input.stories.js +131 -0
  125. package/dist/esm/components/Input/Input.test.d.ts +1 -0
  126. package/dist/esm/components/Input/Input.test.js +30 -0
  127. package/dist/esm/components/LinkAdapter/LinkAdapter.d.ts +23 -0
  128. package/dist/esm/components/LinkAdapter/LinkAdapter.js +31 -0
  129. package/dist/esm/components/ScrollSnap/ScrollSnap.d.ts +19 -0
  130. package/dist/esm/components/ScrollSnap/ScrollSnap.js +56 -0
  131. package/dist/esm/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
  132. package/dist/esm/components/ScrollSnap/ScrollSnap.stories.js +40 -0
  133. package/dist/esm/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
  134. package/dist/esm/components/SrAnnouncer/SrAnnouncer.js +40 -0
  135. package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
  136. package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.js +41 -0
  137. package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
  138. package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.js +60 -0
  139. package/dist/esm/components/TextField/TextField.d.ts +29 -0
  140. package/dist/esm/components/TextField/TextField.js +30 -0
  141. package/dist/esm/components/TextField/TextField.stories.d.ts +10 -0
  142. package/dist/esm/components/TextField/TextField.stories.js +132 -0
  143. package/dist/esm/components/TextField/TextField.test.d.ts +1 -0
  144. package/dist/esm/components/TextField/TextField.test.js +75 -0
  145. package/dist/esm/components/ThemeProvider/ThemeProvider.d.ts +23 -0
  146. package/dist/esm/components/ThemeProvider/ThemeProvider.js +86 -0
  147. package/dist/esm/components/ThemeProvider/ThemeProvider.stories.d.ts +58 -0
  148. package/dist/esm/components/ThemeProvider/ThemeProvider.stories.js +94 -0
  149. package/dist/esm/components/ThemeProvider/Typography.stories.d.ts +39 -0
  150. package/dist/esm/components/ThemeProvider/Typography.stories.js +62 -0
  151. package/dist/esm/components/ThemeProvider/breakpoints.d.ts +4 -0
  152. package/dist/esm/components/ThemeProvider/breakpoints.js +16 -0
  153. package/dist/esm/components/ThemeProvider/buttons.d.ts +7 -0
  154. package/dist/esm/components/ThemeProvider/buttons.js +17 -0
  155. package/dist/esm/components/ThemeProvider/chips.d.ts +3 -0
  156. package/dist/esm/components/ThemeProvider/chips.js +151 -0
  157. package/dist/esm/components/ThemeProvider/colors.d.ts +32 -0
  158. package/dist/esm/components/ThemeProvider/colors.js +32 -0
  159. package/dist/esm/components/ThemeProvider/typography.d.ts +18 -0
  160. package/dist/esm/components/ThemeProvider/typography.js +168 -0
  161. package/dist/esm/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
  162. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +30 -0
  163. package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
  164. package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.js +10 -0
  165. package/dist/esm/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
  166. package/dist/esm/components/internal/FormHelpers/FormHelpers.js +73 -0
  167. package/dist/esm/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
  168. package/dist/esm/components/internal/FormHelpers/FormHelpers.test.js +91 -0
  169. package/dist/esm/index.d.ts +16 -0
  170. package/dist/esm/index.js +11 -0
  171. package/dist/esm/jest-setup.d.ts +1 -0
  172. package/dist/esm/jest-setup.js +16 -0
  173. package/dist/esm/jsdom-extended.d.ts +6 -0
  174. package/dist/esm/jsdom-extended.js +12 -0
  175. package/dist/esm/story-utils/index.d.ts +6 -0
  176. package/dist/esm/story-utils/index.js +13 -0
  177. package/dist/esm/utils/composeRefs.d.ts +7 -0
  178. package/dist/esm/utils/composeRefs.js +17 -0
  179. package/dist/esm/utils/composeRefs.test.d.ts +1 -0
  180. package/dist/esm/utils/composeRefs.test.js +17 -0
  181. package/dist/esm/utils/useDevCheckStable.d.ts +8 -0
  182. package/dist/esm/utils/useDevCheckStable.js +26 -0
  183. package/dist/esm/utils/useInterval.d.ts +7 -0
  184. package/dist/esm/utils/useInterval.js +22 -0
  185. package/dist/tsconfig.tsbuildinfo +1 -0
  186. package/dist/type-augmentation/TypescriptDocs.mdx +17 -0
  187. package/dist/type-augmentation/index.d.ts +2 -0
  188. package/dist/type-augmentation/theme.d.ts +103 -0
  189. package/dist/type-augmentation/typography.d.ts +54 -0
  190. package/package.json +141 -0
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.DEFAULT_PROPS = exports.ActionButtonLink = exports.ActionButton = void 0;
15
+ const React = require("react");
16
+ const styled_1 = require("@emotion/styled");
17
+ const typography_1 = require("../ThemeProvider/typography");
18
+ const Button_1 = require("./Button");
19
+ Object.defineProperty(exports, "DEFAULT_PROPS", { enumerable: true, get: function () { return Button_1.DEFAULT_PROPS; } });
20
+ const actionStyles = (size) => {
21
+ return {
22
+ minWidth: "auto",
23
+ padding: 0,
24
+ height: {
25
+ small: "32px",
26
+ medium: "40px",
27
+ large: "48px",
28
+ }[size],
29
+ width: {
30
+ small: "32px",
31
+ medium: "40px",
32
+ large: "48px",
33
+ }[size],
34
+ "& svg, & .MuiSvgIcon-root": {
35
+ width: "1em",
36
+ height: "1em",
37
+ fontSize: (0, typography_1.pxToRem)({
38
+ small: 20,
39
+ medium: 24,
40
+ large: 32,
41
+ }[size]),
42
+ },
43
+ };
44
+ };
45
+ /**
46
+ * A button that should contain a remixicon icon and nothing else.
47
+ * See [ActionButton docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs).
48
+ *
49
+ * See also:
50
+ * - [ActionButtonLink](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs#links)
51
+ * - [Button](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs) for text buttons
52
+ */
53
+ const ActionButton = (0, styled_1.default)(React.forwardRef(function Root(props, ref) {
54
+ return React.createElement(Button_1.ButtonRoot, Object.assign({ ref: ref, type: "button" }, props));
55
+ }))(({ size = Button_1.DEFAULT_PROPS.size, responsive, theme }) => {
56
+ return [
57
+ actionStyles(size),
58
+ responsive && {
59
+ [theme.breakpoints.down("sm")]: actionStyles(Button_1.RESPONSIVE_SIZES[size]),
60
+ },
61
+ ];
62
+ });
63
+ exports.ActionButton = ActionButton;
64
+ ActionButton.displayName = "ActionButton";
65
+ /**
66
+ * See [ActionButtonLink docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs#links)
67
+ */
68
+ const ActionButtonLink = ActionButton.withComponent((_a) => {
69
+ var { Component } = _a, props = __rest(_a, ["Component"]);
70
+ return React.createElement(Button_1.ButtonLinkRoot, Object.assign({ Component: Component }, props));
71
+ });
72
+ exports.ActionButtonLink = ActionButtonLink;
73
+ ActionButtonLink.displayName = "ActionButtonLink";
@@ -0,0 +1,15 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { ActionButton } from "./ActionButton";
3
+ declare const meta: Meta<typeof ActionButton>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ActionButton>;
6
+ export declare const VariantsAndEdge: Story;
7
+ /**
8
+ * `ActionButtonLink` is styled as a `ActionButton` that renders an anchor tag.
9
+ *
10
+ * To use a custom link component (E.g. `Link` from `react-router` or `next/link`),
11
+ * pass it as the `Component` prop. Alternatively, customize the project-wide
12
+ * default link adapter via [Theme's LinkAdapter](../?path=/docs/smoot-design-themeprovider--docs)
13
+ */
14
+ export declare const Links: Story;
15
+ export declare const Showcase: Story;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Showcase = exports.Links = exports.VariantsAndEdge = void 0;
4
+ const React = require("react");
5
+ const ActionButton_1 = require("./ActionButton");
6
+ const Grid2_1 = require("@mui/material/Grid2");
7
+ const Stack_1 = require("@mui/material/Stack");
8
+ const react_1 = require("@remixicon/react");
9
+ const test_1 = require("@storybook/test");
10
+ const story_utils_1 = require("../../story-utils");
11
+ const ICONS = {
12
+ None: undefined,
13
+ ArrowBackIcon: React.createElement(react_1.RiArrowLeftLine, null),
14
+ DeleteIcon: React.createElement(react_1.RiDeleteBinLine, null),
15
+ TestTubeIcon: React.createElement(react_1.RiTestTubeLine, null),
16
+ };
17
+ const VARIANTS = (0, story_utils_1.enumValues)({
18
+ primary: true,
19
+ secondary: true,
20
+ tertiary: true,
21
+ bordered: true,
22
+ text: true,
23
+ unstable_noBorder: true,
24
+ unstable_inverted: true,
25
+ unstable_success: true,
26
+ });
27
+ const STABLE_VARIANTS = VARIANTS.filter((v) => !v.startsWith("unstable"));
28
+ const SIZES = (0, story_utils_1.enumValues)({
29
+ small: true,
30
+ medium: true,
31
+ large: true,
32
+ });
33
+ const EDGES = (0, story_utils_1.enumValues)({
34
+ circular: true,
35
+ rounded: true,
36
+ none: true,
37
+ });
38
+ const meta = {
39
+ title: "smoot-design/ActionButton",
40
+ component: ActionButton_1.ActionButton,
41
+ argTypes: {
42
+ variant: {
43
+ control: { type: "select" },
44
+ table: {
45
+ defaultValue: { summary: ActionButton_1.DEFAULT_PROPS.variant },
46
+ },
47
+ },
48
+ size: {
49
+ control: { type: "select" },
50
+ table: {
51
+ defaultValue: { summary: ActionButton_1.DEFAULT_PROPS.size },
52
+ },
53
+ },
54
+ edge: {
55
+ control: { type: "select" },
56
+ table: {
57
+ defaultValue: { summary: ActionButton_1.DEFAULT_PROPS.edge },
58
+ },
59
+ },
60
+ },
61
+ args: {
62
+ onClick: (0, test_1.fn)(),
63
+ },
64
+ };
65
+ exports.default = meta;
66
+ exports.VariantsAndEdge = {
67
+ render: (args) => (React.createElement(React.Fragment, null,
68
+ React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
69
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "none", variant: "primary" }), ICONS.DeleteIcon),
70
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "none", variant: "secondary" }), ICONS.DeleteIcon),
71
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "none", variant: "tertiary" }), ICONS.DeleteIcon),
72
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "none", variant: "bordered" }), ICONS.DeleteIcon),
73
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "none", variant: "text" }), ICONS.DeleteIcon)),
74
+ React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
75
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "rounded", variant: "primary" }), ICONS.DeleteIcon),
76
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "rounded", variant: "secondary" }), ICONS.DeleteIcon),
77
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "rounded", variant: "tertiary" }), ICONS.DeleteIcon),
78
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "rounded", variant: "bordered" }), ICONS.DeleteIcon),
79
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "rounded", variant: "text" }), ICONS.DeleteIcon)),
80
+ React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
81
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "circular", variant: "primary" }), ICONS.DeleteIcon),
82
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "circular", variant: "secondary" }), ICONS.DeleteIcon),
83
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "circular", variant: "tertiary" }), ICONS.DeleteIcon),
84
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "circular", variant: "bordered" }), ICONS.DeleteIcon),
85
+ React.createElement(ActionButton_1.ActionButton, Object.assign({}, args, { edge: "circular", variant: "text" }), ICONS.DeleteIcon)))),
86
+ tags: ["main"],
87
+ };
88
+ /**
89
+ * `ActionButtonLink` is styled as a `ActionButton` that renders an anchor tag.
90
+ *
91
+ * To use a custom link component (E.g. `Link` from `react-router` or `next/link`),
92
+ * pass it as the `Component` prop. Alternatively, customize the project-wide
93
+ * default link adapter via [Theme's LinkAdapter](../?path=/docs/smoot-design-themeprovider--docs)
94
+ */
95
+ exports.Links = {
96
+ render: () => (React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
97
+ React.createElement(ActionButton_1.ActionButtonLink, { href: "#fake", variant: "primary" }, ICONS.DeleteIcon),
98
+ React.createElement(ActionButton_1.ActionButtonLink, { href: "#fake", variant: "secondary" }, ICONS.DeleteIcon),
99
+ React.createElement(ActionButton_1.ActionButtonLink, { href: "#fake", variant: "tertiary" }, ICONS.DeleteIcon),
100
+ React.createElement(ActionButton_1.ActionButtonLink, { href: "#fake", variant: "bordered" }, ICONS.DeleteIcon),
101
+ React.createElement(ActionButton_1.ActionButtonLink, { href: "#fake", variant: "text" }, ICONS.DeleteIcon))),
102
+ };
103
+ exports.Showcase = {
104
+ render: (args) => (React.createElement(Grid2_1.default, { container: true, sx: { maxWidth: "750px" }, rowGap: 2 }, STABLE_VARIANTS.flatMap((variant) => EDGES.flatMap((edge) => (React.createElement(React.Fragment, { key: `${variant}-${edge}` },
105
+ React.createElement(Grid2_1.default, { size: { xs: 12, sm: 3 }, alignItems: "center" },
106
+ React.createElement("code", null,
107
+ "variant=",
108
+ variant,
109
+ React.createElement("br", null),
110
+ "edge=",
111
+ edge)),
112
+ SIZES.flatMap((size) => Object.entries(ICONS)
113
+ .filter(([_key, icon]) => icon)
114
+ .map(([iconKey, icon]) => (React.createElement(Grid2_1.default, { size: { xs: 4, sm: 1 }, key: `${size}-${iconKey}` },
115
+ React.createElement(ActionButton_1.ActionButton, Object.assign({ variant: variant, edge: edge, size: size }, args), icon))))))))))),
116
+ };
@@ -0,0 +1,56 @@
1
+ import * as React from "react";
2
+ import { LinkAdapterPropsOverrides } from "../LinkAdapter/LinkAdapter";
3
+ type ButtonVariant = "primary" | "secondary" | "tertiary" | "text" | "bordered" | "unstable_noBorder" | "unstable_inverted" | "unstable_success";
4
+ type ButtonSize = "small" | "medium" | "large";
5
+ type ButtonEdge = "circular" | "rounded" | "none";
6
+ type ButtonStyleProps = {
7
+ variant?: ButtonVariant;
8
+ size?: ButtonSize;
9
+ edge?: ButtonEdge;
10
+ /**
11
+ * Display an icon before the button text
12
+ */
13
+ startIcon?: React.ReactNode;
14
+ /**
15
+ * Display an icon after the button text.
16
+ */
17
+ endIcon?: React.ReactNode;
18
+ /**
19
+ * If true (default: `false`), the button will become one size smaller at the
20
+ * `sm` breakpoint.
21
+ * - large -> medium
22
+ * - medium -> small
23
+ * - small -> small
24
+ */
25
+ responsive?: boolean;
26
+ color?: "secondary";
27
+ };
28
+ declare const DEFAULT_PROPS: Required<Omit<ButtonStyleProps, "startIcon" | "endIcon" | "color">>;
29
+ declare const RESPONSIVE_SIZES: Record<ButtonSize, ButtonSize>;
30
+ declare const ButtonRoot: import("@emotion/styled").StyledComponent<{
31
+ theme?: import("@emotion/react").Theme;
32
+ as?: React.ElementType;
33
+ } & ButtonStyleProps, React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
34
+ declare const ButtonLinkRoot: import("@emotion/styled").StyledComponent<Omit<React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
35
+ Component?: React.ElementType;
36
+ } & LinkAdapterPropsOverrides, "ref"> & React.RefAttributes<HTMLAnchorElement> & {
37
+ theme?: import("@emotion/react").Theme;
38
+ } & ButtonStyleProps, {}, {}>;
39
+ type ButtonProps = ButtonStyleProps & React.ComponentProps<"button">;
40
+ /**
41
+ * Our standard button component. See [Button Docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs).
42
+ *
43
+ * See also:
44
+ * - [ButtonLink](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs#links)
45
+ * - [ActionButton](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs) for icon-only uses
46
+ */
47
+ declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
48
+ type ButtonLinkProps = ButtonStyleProps & React.ComponentProps<"a"> & {
49
+ Component?: React.ElementType;
50
+ } & LinkAdapterPropsOverrides;
51
+ /**
52
+ * See [ButtonLink docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs#links)
53
+ */
54
+ declare const ButtonLink: React.ForwardRefExoticComponent<Omit<ButtonLinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
55
+ export { Button, ButtonLink, ButtonRoot, DEFAULT_PROPS, ButtonLinkRoot, RESPONSIVE_SIZES, };
56
+ export type { ButtonProps, ButtonLinkProps, ButtonStyleProps, ButtonSize };
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.RESPONSIVE_SIZES = exports.ButtonLinkRoot = exports.DEFAULT_PROPS = exports.ButtonRoot = exports.ButtonLink = exports.Button = void 0;
15
+ const React = require("react");
16
+ const styled_1 = require("@emotion/styled");
17
+ const react_1 = require("@emotion/react");
18
+ const typography_1 = require("../ThemeProvider/typography");
19
+ const LinkAdapter_1 = require("../LinkAdapter/LinkAdapter");
20
+ const styleProps = {
21
+ variant: true,
22
+ size: true,
23
+ edge: true,
24
+ startIcon: true,
25
+ endIcon: true,
26
+ responsive: true,
27
+ color: true,
28
+ };
29
+ const shouldForwardButtonProp = (prop) => !styleProps[prop];
30
+ const DEFAULT_PROPS = {
31
+ variant: "primary",
32
+ size: "medium",
33
+ edge: "rounded",
34
+ responsive: false,
35
+ };
36
+ exports.DEFAULT_PROPS = DEFAULT_PROPS;
37
+ const BORDER_WIDTHS = {
38
+ small: 1,
39
+ medium: 1,
40
+ large: 2,
41
+ };
42
+ const RESPONSIVE_SIZES = {
43
+ small: "small",
44
+ medium: "small",
45
+ large: "medium",
46
+ };
47
+ exports.RESPONSIVE_SIZES = RESPONSIVE_SIZES;
48
+ const sizeStyles = (size, hasBorder, theme) => {
49
+ const paddingAdjust = hasBorder ? BORDER_WIDTHS[size] : 0;
50
+ return [
51
+ {
52
+ boxSizing: "border-box",
53
+ borderWidth: BORDER_WIDTHS[size],
54
+ },
55
+ size === "large" && Object.assign({ padding: `${14 - paddingAdjust}px 24px` }, theme.typography.buttonLarge),
56
+ size === "medium" && Object.assign({ padding: `${11 - paddingAdjust}px 16px` }, theme.typography.button),
57
+ size === "small" && Object.assign({ padding: `${8 - paddingAdjust}px 12px` }, theme.typography.buttonSmall),
58
+ ];
59
+ };
60
+ const buttonStyles = (props) => {
61
+ const { size, variant, edge, theme, color, responsive } = Object.assign(Object.assign({}, DEFAULT_PROPS), props);
62
+ const { colors } = theme.custom;
63
+ const hasBorder = variant === "secondary" || variant === "bordered";
64
+ return (0, react_1.css)([
65
+ {
66
+ color: theme.palette.text.primary,
67
+ textAlign: "center",
68
+ // display
69
+ display: "inline-flex",
70
+ justifyContent: "center",
71
+ alignItems: "center",
72
+ // transitions
73
+ transition: `background ${theme.transitions.duration.short}ms`,
74
+ // cursor
75
+ cursor: "pointer",
76
+ ":disabled": {
77
+ cursor: "default",
78
+ },
79
+ minWidth: "100px",
80
+ },
81
+ ...sizeStyles(size, hasBorder, theme),
82
+ // responsive
83
+ responsive && {
84
+ [theme.breakpoints.down("sm")]: sizeStyles(RESPONSIVE_SIZES[size], hasBorder, theme),
85
+ },
86
+ // variant
87
+ variant === "primary" && {
88
+ backgroundColor: colors.mitRed,
89
+ color: colors.white,
90
+ border: "none",
91
+ /* Shadow/04dp */
92
+ boxShadow: "0px 2px 4px 0px rgba(37, 38, 43, 0.10), 0px 3px 8px 0px rgba(37, 38, 43, 0.12)",
93
+ ":hover:not(:disabled)": {
94
+ backgroundColor: colors.red,
95
+ boxShadow: "none",
96
+ },
97
+ ":disabled": {
98
+ backgroundColor: colors.silverGray,
99
+ boxShadow: "none",
100
+ },
101
+ },
102
+ variant === "unstable_success" && {
103
+ backgroundColor: colors.darkGreen,
104
+ color: colors.white,
105
+ border: "none",
106
+ /* Shadow/04dp */
107
+ boxShadow: "0px 2px 4px 0px rgba(37, 38, 43, 0.10), 0px 3px 8px 0px rgba(37, 38, 43, 0.12)",
108
+ ":hover:not(:disabled)": {
109
+ backgroundColor: colors.darkGreen,
110
+ boxShadow: "none",
111
+ },
112
+ ":disabled": {
113
+ backgroundColor: colors.silverGray,
114
+ boxShadow: "none",
115
+ },
116
+ },
117
+ variant === "secondary" && {
118
+ color: colors.red,
119
+ backgroundColor: "transparent",
120
+ borderColor: "currentcolor",
121
+ borderStyle: "solid",
122
+ ":hover:not(:disabled)": {
123
+ // brightRed at 0.06 alpha
124
+ backgroundColor: "rgba(255, 20, 35, 0.06)",
125
+ },
126
+ ":disabled": {
127
+ color: colors.silverGray,
128
+ },
129
+ },
130
+ variant === "text" && {
131
+ backgroundColor: "transparent",
132
+ borderStyle: "none",
133
+ color: colors.darkGray2,
134
+ ":hover:not(:disabled)": {
135
+ // darkGray1 at 6% alpha
136
+ backgroundColor: "rgba(64, 70, 76, 0.06)",
137
+ },
138
+ ":disabled": {
139
+ color: colors.silverGray,
140
+ },
141
+ },
142
+ variant === "bordered" && {
143
+ backgroundColor: colors.white,
144
+ color: colors.silverGrayDark,
145
+ border: `1px solid ${colors.silverGrayLight}`,
146
+ ":hover:not(:disabled)": {
147
+ backgroundColor: colors.lightGray1,
148
+ color: colors.darkGray2,
149
+ },
150
+ ":disabled": {
151
+ backgroundColor: colors.lightGray2,
152
+ border: `1px solid ${colors.lightGray2}`,
153
+ color: colors.silverGrayDark,
154
+ },
155
+ },
156
+ variant === "unstable_noBorder" && {
157
+ backgroundColor: colors.white,
158
+ color: colors.darkGray2,
159
+ border: "none",
160
+ ":hover:not(:disabled)": {
161
+ // darkGray1 at 6% alpha
162
+ backgroundColor: "rgba(64, 70, 76, 0.06)",
163
+ },
164
+ ":disabled": {
165
+ color: colors.silverGray,
166
+ },
167
+ },
168
+ variant === "tertiary" && {
169
+ color: colors.darkGray2,
170
+ border: "none",
171
+ backgroundColor: colors.lightGray2,
172
+ ":hover:not(:disabled)": {
173
+ backgroundColor: colors.white,
174
+ },
175
+ ":disabled": {
176
+ backgroundColor: colors.lightGray2,
177
+ color: colors.silverGrayLight,
178
+ },
179
+ },
180
+ variant === "unstable_inverted" && {
181
+ backgroundColor: colors.white,
182
+ color: colors.mitRed,
183
+ borderColor: colors.mitRed,
184
+ borderStyle: "solid",
185
+ },
186
+ // edge
187
+ edge === "rounded" && {
188
+ borderRadius: "4px",
189
+ },
190
+ edge === "circular" && {
191
+ // Pill-shaped buttons... Overlapping border radius get clipped to pill.
192
+ borderRadius: "100vh",
193
+ },
194
+ // color
195
+ color === "secondary" && {
196
+ color: theme.custom.colors.silverGray,
197
+ borderColor: theme.custom.colors.silverGray,
198
+ ":hover:not(:disabled)": {
199
+ backgroundColor: theme.custom.colors.lightGray1,
200
+ },
201
+ },
202
+ ]);
203
+ };
204
+ const ButtonRoot = (0, styled_1.default)("button", {
205
+ shouldForwardProp: shouldForwardButtonProp,
206
+ })(buttonStyles);
207
+ exports.ButtonRoot = ButtonRoot;
208
+ const ButtonLinkRoot = (0, styled_1.default)(LinkAdapter_1.LinkAdapter, {
209
+ shouldForwardProp: shouldForwardButtonProp,
210
+ })(buttonStyles);
211
+ exports.ButtonLinkRoot = ButtonLinkRoot;
212
+ const IconContainer = styled_1.default.span(({ size, side }) => [
213
+ {
214
+ height: "1em",
215
+ display: "flex",
216
+ alignItems: "center",
217
+ },
218
+ side === "start" && {
219
+ /**
220
+ * The negative margin is to counteract the padding on the button itself.
221
+ * Without icons, the left space is 24/16/12 px.
222
+ * With icons, the left space is 20/12/8 px.
223
+ */
224
+ marginLeft: "-4px",
225
+ marginRight: "8px",
226
+ },
227
+ side === "end" && {
228
+ marginLeft: "8px",
229
+ marginRight: "-4px",
230
+ },
231
+ {
232
+ "& svg, & .MuiSvgIcon-root": {
233
+ width: "1em",
234
+ height: "1em",
235
+ fontSize: (0, typography_1.pxToRem)({
236
+ small: 16,
237
+ medium: 20,
238
+ large: 24,
239
+ }[size]),
240
+ },
241
+ },
242
+ ]);
243
+ const ButtonInner = (props) => {
244
+ const { children, size = DEFAULT_PROPS.size } = props;
245
+ return (React.createElement(React.Fragment, null,
246
+ props.startIcon ? (React.createElement(IconContainer, { size: size, side: "start" }, props.startIcon)) : null,
247
+ children,
248
+ props.endIcon ? (React.createElement(IconContainer, { size: size, side: "end" }, props.endIcon)) : null));
249
+ };
250
+ /**
251
+ * Our standard button component. See [Button Docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs).
252
+ *
253
+ * See also:
254
+ * - [ButtonLink](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs#links)
255
+ * - [ActionButton](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs) for icon-only uses
256
+ */
257
+ const Button = React.forwardRef((_a, ref) => {
258
+ var { children } = _a, props = __rest(_a, ["children"]);
259
+ return (React.createElement(ButtonRoot, Object.assign({ ref: ref, type: "button" }, props),
260
+ React.createElement(ButtonInner, Object.assign({}, props), children)));
261
+ });
262
+ exports.Button = Button;
263
+ Button.displayName = "Button";
264
+ /**
265
+ * See [ButtonLink docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs#links)
266
+ */
267
+ const ButtonLink = React.forwardRef((_a, ref) => {
268
+ var { children, Component } = _a, props = __rest(_a, ["children", "Component"]);
269
+ return (React.createElement(ButtonLinkRoot, Object.assign({ Component: Component, ref: ref }, props),
270
+ React.createElement(ButtonInner, Object.assign({}, props), children)));
271
+ });
272
+ exports.ButtonLink = ButtonLink;
273
+ ButtonLink.displayName = "ButtonLink";
@@ -0,0 +1,17 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Button } from "./Button";
3
+ declare const meta: Meta<typeof Button>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Button>;
6
+ export declare const VariantsAndEdge: Story;
7
+ export declare const Sizes: Story;
8
+ export declare const WithIcons: Story;
9
+ /**
10
+ * `ButtonLink` is a styled `Button` that renders an anchor tag.
11
+ *
12
+ * To use a custom link component (E.g. `Link` from `react-router` or `next/link`),
13
+ * pass it as the `Component` prop. Alternatively, customize the project-wide
14
+ * default link adapter via [Theme's LinkAdapter](../?path=/docs/smoot-design-themeprovider--docs)
15
+ */
16
+ export declare const Links: Story;
17
+ export declare const Showcase: Story;