@mitodl/smoot-design 0.0.0-7bc0c0f
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/LICENSE +28 -0
- package/README.md +31 -0
- package/dist/bundles/remoteTutorDrawer.es.js +38347 -0
- package/dist/bundles/remoteTutorDrawer.umd.js +207 -0
- package/dist/cjs/ai.d.ts +3 -0
- package/dist/cjs/ai.js +5 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/FlashcardsScreen.d.ts +9 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/FlashcardsScreen.js +87 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.d.ts +57 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.js +276 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts +16 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.js +283 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts +1 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.js +241 -0
- package/dist/cjs/bundles/remoteTutorDrawer.d.ts +7 -0
- package/dist/cjs/bundles/remoteTutorDrawer.js +40 -0
- package/dist/cjs/components/AiChat/AiChat.d.ts +5 -0
- package/dist/cjs/components/AiChat/AiChat.js +247 -0
- package/dist/cjs/components/AiChat/AiChat.stories.d.ts +21 -0
- package/dist/cjs/components/AiChat/AiChat.stories.js +243 -0
- package/dist/cjs/components/AiChat/AiChat.test.d.ts +1 -0
- package/dist/cjs/components/AiChat/AiChat.test.js +211 -0
- package/dist/cjs/components/AiChat/ChatTitle.d.ts +8 -0
- package/dist/cjs/components/AiChat/ChatTitle.js +43 -0
- package/dist/cjs/components/AiChat/EntryScreen.d.ts +11 -0
- package/dist/cjs/components/AiChat/EntryScreen.js +123 -0
- package/dist/cjs/components/AiChat/TimLogo.d.ts +5 -0
- package/dist/cjs/components/AiChat/TimLogo.js +15 -0
- package/dist/cjs/components/AiChat/test-utils/api.d.ts +2 -0
- package/dist/cjs/components/AiChat/test-utils/api.js +125 -0
- package/dist/cjs/components/AiChat/types.d.ts +82 -0
- package/dist/cjs/components/AiChat/types.js +3 -0
- package/dist/cjs/components/AiChat/utils.d.ts +9 -0
- package/dist/cjs/components/AiChat/utils.js +41 -0
- package/dist/cjs/components/Alert/Alert.d.ts +15 -0
- package/dist/cjs/components/Alert/Alert.js +62 -0
- package/dist/cjs/components/Alert/Alert.stories.d.ts +8 -0
- package/dist/cjs/components/Alert/Alert.stories.js +53 -0
- package/dist/cjs/components/Button/ActionButton.d.ts +30 -0
- package/dist/cjs/components/Button/ActionButton.js +73 -0
- package/dist/cjs/components/Button/ActionButton.stories.d.ts +15 -0
- package/dist/cjs/components/Button/ActionButton.stories.js +113 -0
- package/dist/cjs/components/Button/Button.d.ts +54 -0
- package/dist/cjs/components/Button/Button.js +240 -0
- package/dist/cjs/components/Button/Button.stories.d.ts +17 -0
- package/dist/cjs/components/Button/Button.stories.js +135 -0
- package/dist/cjs/components/Button/Button.test.d.ts +1 -0
- package/dist/cjs/components/Button/Button.test.js +46 -0
- package/dist/cjs/components/ImageAdapter/ImageAdapter.d.ts +23 -0
- package/dist/cjs/components/ImageAdapter/ImageAdapter.js +30 -0
- package/dist/cjs/components/Input/Input.d.ts +116 -0
- package/dist/cjs/components/Input/Input.js +237 -0
- package/dist/cjs/components/Input/Input.stories.d.ts +19 -0
- package/dist/cjs/components/Input/Input.stories.js +135 -0
- package/dist/cjs/components/Input/Input.test.d.ts +1 -0
- package/dist/cjs/components/Input/Input.test.js +32 -0
- package/dist/cjs/components/LinkAdapter/LinkAdapter.d.ts +23 -0
- package/dist/cjs/components/LinkAdapter/LinkAdapter.js +34 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.d.ts +19 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.js +59 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.js +43 -0
- package/dist/cjs/components/ScrollSnap/useScrollSnap.d.ts +6 -0
- package/dist/cjs/components/ScrollSnap/useScrollSnap.js +36 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.js +43 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.js +44 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.js +62 -0
- package/dist/cjs/components/TabButtons/TabButtonList.d.ts +25 -0
- package/dist/cjs/components/TabButtons/TabButtonList.js +97 -0
- package/dist/cjs/components/TabButtons/TabButtonList.stories.d.ts +24 -0
- package/dist/cjs/components/TabButtons/TabButtonList.stories.js +139 -0
- package/dist/cjs/components/TextField/TextField.d.ts +29 -0
- package/dist/cjs/components/TextField/TextField.js +33 -0
- package/dist/cjs/components/TextField/TextField.stories.d.ts +10 -0
- package/dist/cjs/components/TextField/TextField.stories.js +136 -0
- package/dist/cjs/components/TextField/TextField.test.d.ts +1 -0
- package/dist/cjs/components/TextField/TextField.test.js +77 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.d.ts +21 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.js +86 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.d.ts +63 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.js +102 -0
- package/dist/cjs/components/ThemeProvider/Typography.stories.d.ts +39 -0
- package/dist/cjs/components/ThemeProvider/Typography.stories.js +65 -0
- package/dist/cjs/components/ThemeProvider/breakpoints.d.ts +4 -0
- package/dist/cjs/components/ThemeProvider/breakpoints.js +19 -0
- package/dist/cjs/components/ThemeProvider/buttons.d.ts +7 -0
- package/dist/cjs/components/ThemeProvider/buttons.js +20 -0
- package/dist/cjs/components/ThemeProvider/chips.d.ts +3 -0
- package/dist/cjs/components/ThemeProvider/chips.js +154 -0
- package/dist/cjs/components/ThemeProvider/colors.d.ts +32 -0
- package/dist/cjs/components/ThemeProvider/colors.js +35 -0
- package/dist/cjs/components/ThemeProvider/typography.d.ts +18 -0
- package/dist/cjs/components/ThemeProvider/typography.js +173 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.js +33 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.js +13 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.js +78 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.js +93 -0
- package/dist/cjs/index.d.ts +16 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/jest-setup.d.ts +1 -0
- package/dist/cjs/jest-setup.js +18 -0
- package/dist/cjs/jsdom-extended.d.ts +6 -0
- package/dist/cjs/jsdom-extended.js +14 -0
- package/dist/cjs/story-utils/index.d.ts +6 -0
- package/dist/cjs/story-utils/index.js +17 -0
- package/dist/cjs/utils/composeRefs.d.ts +7 -0
- package/dist/cjs/utils/composeRefs.js +20 -0
- package/dist/cjs/utils/composeRefs.test.d.ts +1 -0
- package/dist/cjs/utils/composeRefs.test.js +19 -0
- package/dist/cjs/utils/useDevCheckStable.d.ts +8 -0
- package/dist/cjs/utils/useDevCheckStable.js +29 -0
- package/dist/cjs/utils/useInterval.d.ts +7 -0
- package/dist/cjs/utils/useInterval.js +25 -0
- package/dist/esm/ai.d.ts +3 -0
- package/dist/esm/ai.js +1 -0
- package/dist/esm/bundles/RemoteTutorDrawer/FlashcardsScreen.d.ts +9 -0
- package/dist/esm/bundles/RemoteTutorDrawer/FlashcardsScreen.js +83 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.d.ts +57 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.js +273 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts +16 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.js +280 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts +1 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.js +239 -0
- package/dist/esm/bundles/remoteTutorDrawer.d.ts +7 -0
- package/dist/esm/bundles/remoteTutorDrawer.js +37 -0
- package/dist/esm/components/AiChat/AiChat.d.ts +5 -0
- package/dist/esm/components/AiChat/AiChat.js +244 -0
- package/dist/esm/components/AiChat/AiChat.stories.d.ts +21 -0
- package/dist/esm/components/AiChat/AiChat.stories.js +240 -0
- package/dist/esm/components/AiChat/AiChat.test.d.ts +1 -0
- package/dist/esm/components/AiChat/AiChat.test.js +209 -0
- package/dist/esm/components/AiChat/ChatTitle.d.ts +8 -0
- package/dist/esm/components/AiChat/ChatTitle.js +40 -0
- package/dist/esm/components/AiChat/EntryScreen.d.ts +11 -0
- package/dist/esm/components/AiChat/EntryScreen.js +120 -0
- package/dist/esm/components/AiChat/TimLogo.d.ts +5 -0
- package/dist/esm/components/AiChat/TimLogo.js +13 -0
- package/dist/esm/components/AiChat/test-utils/api.d.ts +2 -0
- package/dist/esm/components/AiChat/test-utils/api.js +122 -0
- package/dist/esm/components/AiChat/types.d.ts +82 -0
- package/dist/esm/components/AiChat/types.js +2 -0
- package/dist/esm/components/AiChat/utils.d.ts +9 -0
- package/dist/esm/components/AiChat/utils.js +38 -0
- package/dist/esm/components/Alert/Alert.d.ts +15 -0
- package/dist/esm/components/Alert/Alert.js +59 -0
- package/dist/esm/components/Alert/Alert.stories.d.ts +8 -0
- package/dist/esm/components/Alert/Alert.stories.js +50 -0
- package/dist/esm/components/Button/ActionButton.d.ts +30 -0
- package/dist/esm/components/Button/ActionButton.js +68 -0
- package/dist/esm/components/Button/ActionButton.stories.d.ts +15 -0
- package/dist/esm/components/Button/ActionButton.stories.js +110 -0
- package/dist/esm/components/Button/Button.d.ts +54 -0
- package/dist/esm/components/Button/Button.js +232 -0
- package/dist/esm/components/Button/Button.stories.d.ts +17 -0
- package/dist/esm/components/Button/Button.stories.js +132 -0
- package/dist/esm/components/Button/Button.test.d.ts +1 -0
- package/dist/esm/components/Button/Button.test.js +44 -0
- package/dist/esm/components/ImageAdapter/ImageAdapter.d.ts +23 -0
- package/dist/esm/components/ImageAdapter/ImageAdapter.js +27 -0
- package/dist/esm/components/Input/Input.d.ts +116 -0
- package/dist/esm/components/Input/Input.js +232 -0
- package/dist/esm/components/Input/Input.stories.d.ts +19 -0
- package/dist/esm/components/Input/Input.stories.js +132 -0
- package/dist/esm/components/Input/Input.test.d.ts +1 -0
- package/dist/esm/components/Input/Input.test.js +30 -0
- package/dist/esm/components/LinkAdapter/LinkAdapter.d.ts +23 -0
- package/dist/esm/components/LinkAdapter/LinkAdapter.js +31 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.d.ts +19 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.js +56 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.stories.js +40 -0
- package/dist/esm/components/ScrollSnap/useScrollSnap.d.ts +6 -0
- package/dist/esm/components/ScrollSnap/useScrollSnap.js +33 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.js +40 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.js +41 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.js +60 -0
- package/dist/esm/components/TabButtons/TabButtonList.d.ts +25 -0
- package/dist/esm/components/TabButtons/TabButtonList.js +92 -0
- package/dist/esm/components/TabButtons/TabButtonList.stories.d.ts +24 -0
- package/dist/esm/components/TabButtons/TabButtonList.stories.js +136 -0
- package/dist/esm/components/TextField/TextField.d.ts +29 -0
- package/dist/esm/components/TextField/TextField.js +30 -0
- package/dist/esm/components/TextField/TextField.stories.d.ts +10 -0
- package/dist/esm/components/TextField/TextField.stories.js +133 -0
- package/dist/esm/components/TextField/TextField.test.d.ts +1 -0
- package/dist/esm/components/TextField/TextField.test.js +75 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.d.ts +21 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.js +82 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.stories.d.ts +63 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.stories.js +99 -0
- package/dist/esm/components/ThemeProvider/Typography.stories.d.ts +39 -0
- package/dist/esm/components/ThemeProvider/Typography.stories.js +62 -0
- package/dist/esm/components/ThemeProvider/breakpoints.d.ts +4 -0
- package/dist/esm/components/ThemeProvider/breakpoints.js +15 -0
- package/dist/esm/components/ThemeProvider/buttons.d.ts +7 -0
- package/dist/esm/components/ThemeProvider/buttons.js +17 -0
- package/dist/esm/components/ThemeProvider/chips.d.ts +3 -0
- package/dist/esm/components/ThemeProvider/chips.js +151 -0
- package/dist/esm/components/ThemeProvider/colors.d.ts +32 -0
- package/dist/esm/components/ThemeProvider/colors.js +32 -0
- package/dist/esm/components/ThemeProvider/typography.d.ts +18 -0
- package/dist/esm/components/ThemeProvider/typography.js +167 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +30 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.js +10 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.js +73 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.test.js +91 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/jest-setup.d.ts +1 -0
- package/dist/esm/jest-setup.js +16 -0
- package/dist/esm/jsdom-extended.d.ts +6 -0
- package/dist/esm/jsdom-extended.js +12 -0
- package/dist/esm/story-utils/index.d.ts +6 -0
- package/dist/esm/story-utils/index.js +13 -0
- package/dist/esm/utils/composeRefs.d.ts +7 -0
- package/dist/esm/utils/composeRefs.js +17 -0
- package/dist/esm/utils/composeRefs.test.d.ts +1 -0
- package/dist/esm/utils/composeRefs.test.js +17 -0
- package/dist/esm/utils/useDevCheckStable.d.ts +8 -0
- package/dist/esm/utils/useDevCheckStable.js +26 -0
- package/dist/esm/utils/useInterval.d.ts +7 -0
- package/dist/esm/utils/useInterval.js +22 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/type-augmentation/TypescriptDocs.mdx +17 -0
- package/dist/type-augmentation/imports.d.ts +3 -0
- package/dist/type-augmentation/index.d.ts +3 -0
- package/dist/type-augmentation/theme.d.ts +105 -0
- package/dist/type-augmentation/typography.d.ts +54 -0
- package/package.json +155 -0
|
@@ -0,0 +1,240 @@
|
|
|
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 === "secondary" && {
|
|
103
|
+
color: colors.red,
|
|
104
|
+
backgroundColor: "transparent",
|
|
105
|
+
borderColor: "currentcolor",
|
|
106
|
+
borderStyle: "solid",
|
|
107
|
+
":hover:not(:disabled)": {
|
|
108
|
+
// brightRed at 0.06 alpha
|
|
109
|
+
backgroundColor: "rgba(255, 20, 35, 0.06)",
|
|
110
|
+
},
|
|
111
|
+
":disabled": {
|
|
112
|
+
color: colors.silverGray,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
variant === "text" && {
|
|
116
|
+
backgroundColor: "transparent",
|
|
117
|
+
borderStyle: "none",
|
|
118
|
+
color: colors.darkGray2,
|
|
119
|
+
":hover:not(:disabled)": {
|
|
120
|
+
// darkGray1 at 6% alpha
|
|
121
|
+
backgroundColor: "rgba(64, 70, 76, 0.06)",
|
|
122
|
+
},
|
|
123
|
+
":disabled": {
|
|
124
|
+
color: colors.silverGray,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
variant === "bordered" && {
|
|
128
|
+
backgroundColor: colors.white,
|
|
129
|
+
color: colors.silverGrayDark,
|
|
130
|
+
border: `1px solid ${colors.silverGrayLight}`,
|
|
131
|
+
":hover:not(:disabled)": {
|
|
132
|
+
backgroundColor: colors.lightGray1,
|
|
133
|
+
color: colors.darkGray2,
|
|
134
|
+
},
|
|
135
|
+
":disabled": {
|
|
136
|
+
backgroundColor: colors.lightGray2,
|
|
137
|
+
border: `1px solid ${colors.lightGray2}`,
|
|
138
|
+
color: colors.silverGrayDark,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
variant === "tertiary" && {
|
|
142
|
+
color: colors.darkGray2,
|
|
143
|
+
border: "none",
|
|
144
|
+
backgroundColor: colors.lightGray2,
|
|
145
|
+
":hover:not(:disabled)": {
|
|
146
|
+
backgroundColor: colors.white,
|
|
147
|
+
},
|
|
148
|
+
":disabled": {
|
|
149
|
+
backgroundColor: colors.lightGray2,
|
|
150
|
+
color: colors.silverGrayLight,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
// edge
|
|
154
|
+
edge === "rounded" && {
|
|
155
|
+
borderRadius: "4px",
|
|
156
|
+
},
|
|
157
|
+
edge === "circular" && {
|
|
158
|
+
// Pill-shaped buttons... Overlapping border radius get clipped to pill.
|
|
159
|
+
borderRadius: "100vh",
|
|
160
|
+
},
|
|
161
|
+
// color
|
|
162
|
+
color === "secondary" && {
|
|
163
|
+
color: theme.custom.colors.silverGray,
|
|
164
|
+
borderColor: theme.custom.colors.silverGray,
|
|
165
|
+
":hover:not(:disabled)": {
|
|
166
|
+
backgroundColor: theme.custom.colors.lightGray1,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
]);
|
|
170
|
+
};
|
|
171
|
+
const ButtonRoot = (0, styled_1.default)("button", {
|
|
172
|
+
shouldForwardProp: shouldForwardButtonProp,
|
|
173
|
+
})(buttonStyles);
|
|
174
|
+
exports.ButtonRoot = ButtonRoot;
|
|
175
|
+
const ButtonLinkRoot = (0, styled_1.default)(LinkAdapter_1.LinkAdapter, {
|
|
176
|
+
shouldForwardProp: shouldForwardButtonProp,
|
|
177
|
+
})(buttonStyles);
|
|
178
|
+
exports.ButtonLinkRoot = ButtonLinkRoot;
|
|
179
|
+
const IconContainer = styled_1.default.span(({ size, side }) => [
|
|
180
|
+
{
|
|
181
|
+
height: "1em",
|
|
182
|
+
display: "flex",
|
|
183
|
+
alignItems: "center",
|
|
184
|
+
},
|
|
185
|
+
side === "start" && {
|
|
186
|
+
/**
|
|
187
|
+
* The negative margin is to counteract the padding on the button itself.
|
|
188
|
+
* Without icons, the left space is 24/16/12 px.
|
|
189
|
+
* With icons, the left space is 20/12/8 px.
|
|
190
|
+
*/
|
|
191
|
+
marginLeft: "-4px",
|
|
192
|
+
marginRight: "8px",
|
|
193
|
+
},
|
|
194
|
+
side === "end" && {
|
|
195
|
+
marginLeft: "8px",
|
|
196
|
+
marginRight: "-4px",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"& svg, & .MuiSvgIcon-root": {
|
|
200
|
+
width: "1em",
|
|
201
|
+
height: "1em",
|
|
202
|
+
fontSize: (0, typography_1.pxToRem)({
|
|
203
|
+
small: 16,
|
|
204
|
+
medium: 20,
|
|
205
|
+
large: 24,
|
|
206
|
+
}[size]),
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
]);
|
|
210
|
+
const ButtonInner = (props) => {
|
|
211
|
+
const { children, size = DEFAULT_PROPS.size } = props;
|
|
212
|
+
return (React.createElement(React.Fragment, null,
|
|
213
|
+
props.startIcon ? (React.createElement(IconContainer, { size: size, side: "start" }, props.startIcon)) : null,
|
|
214
|
+
children,
|
|
215
|
+
props.endIcon ? (React.createElement(IconContainer, { size: size, side: "end" }, props.endIcon)) : null));
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Our standard button component. See [Button Docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs).
|
|
219
|
+
*
|
|
220
|
+
* See also:
|
|
221
|
+
* - [ButtonLink](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs#links)
|
|
222
|
+
* - [ActionButton](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs) for icon-only uses
|
|
223
|
+
*/
|
|
224
|
+
const Button = React.forwardRef((_a, ref) => {
|
|
225
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
226
|
+
return (React.createElement(ButtonRoot, Object.assign({ ref: ref, type: "button" }, props),
|
|
227
|
+
React.createElement(ButtonInner, Object.assign({}, props), children)));
|
|
228
|
+
});
|
|
229
|
+
exports.Button = Button;
|
|
230
|
+
Button.displayName = "Button";
|
|
231
|
+
/**
|
|
232
|
+
* See [ButtonLink docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs#links)
|
|
233
|
+
*/
|
|
234
|
+
const ButtonLink = React.forwardRef((_a, ref) => {
|
|
235
|
+
var { children, Component } = _a, props = __rest(_a, ["children", "Component"]);
|
|
236
|
+
return (React.createElement(ButtonLinkRoot, Object.assign({ Component: Component, ref: ref }, props),
|
|
237
|
+
React.createElement(ButtonInner, Object.assign({}, props), children)));
|
|
238
|
+
});
|
|
239
|
+
exports.ButtonLink = ButtonLink;
|
|
240
|
+
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;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Showcase = exports.Links = exports.WithIcons = exports.Sizes = exports.VariantsAndEdge = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const Button_1 = require("./Button");
|
|
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
|
+
});
|
|
24
|
+
const STABLE_VARIANTS = VARIANTS.filter((v) => !v.startsWith("unstable"));
|
|
25
|
+
const SIZES = (0, story_utils_1.enumValues)({
|
|
26
|
+
small: true,
|
|
27
|
+
medium: true,
|
|
28
|
+
large: true,
|
|
29
|
+
});
|
|
30
|
+
const EDGES = (0, story_utils_1.enumValues)({
|
|
31
|
+
circular: true,
|
|
32
|
+
rounded: true,
|
|
33
|
+
none: true,
|
|
34
|
+
});
|
|
35
|
+
const meta = {
|
|
36
|
+
title: "smoot-design/Button",
|
|
37
|
+
component: Button_1.Button,
|
|
38
|
+
argTypes: {
|
|
39
|
+
startIcon: {
|
|
40
|
+
options: Object.keys(ICONS),
|
|
41
|
+
mapping: ICONS,
|
|
42
|
+
},
|
|
43
|
+
endIcon: {
|
|
44
|
+
options: Object.keys(ICONS),
|
|
45
|
+
mapping: ICONS,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
args: {
|
|
49
|
+
onClick: (0, test_1.fn)(),
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
exports.default = meta;
|
|
53
|
+
exports.VariantsAndEdge = {
|
|
54
|
+
render: (args) => (React.createElement(React.Fragment, null,
|
|
55
|
+
React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
56
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "none", variant: "primary" }, args), "Primary"),
|
|
57
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "none", variant: "secondary" }, args), "Secondary"),
|
|
58
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "none", variant: "tertiary" }, args), "Tertiary"),
|
|
59
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "none", variant: "bordered" }, args), "Bordered"),
|
|
60
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "none", variant: "text" }, args), "Text")),
|
|
61
|
+
React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
62
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "rounded", variant: "primary" }, args), "Primary"),
|
|
63
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "rounded", variant: "secondary" }, args), "Secondary"),
|
|
64
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "rounded", variant: "tertiary" }, args), "Tertiary"),
|
|
65
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "rounded", variant: "bordered" }, args), "Bordered"),
|
|
66
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "rounded", variant: "text" }, args), "Text")),
|
|
67
|
+
React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
68
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "circular", variant: "primary" }, args), "Primary"),
|
|
69
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "circular", variant: "secondary" }, args), "Secondary"),
|
|
70
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "circular", variant: "tertiary" }, args), "Tertiary"),
|
|
71
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "circular", variant: "bordered" }, args), "Bordered"),
|
|
72
|
+
React.createElement(Button_1.Button, Object.assign({ edge: "circular", variant: "text" }, args), "Text")))),
|
|
73
|
+
tags: ["main"],
|
|
74
|
+
};
|
|
75
|
+
const RESPONSIVE = [true, false];
|
|
76
|
+
exports.Sizes = {
|
|
77
|
+
argTypes: {
|
|
78
|
+
size: { table: { disable: true } },
|
|
79
|
+
},
|
|
80
|
+
render: (args) => (React.createElement(Grid2_1.default, { container: true, sx: { my: 2, maxWidth: "600px" }, alignItems: "center" }, RESPONSIVE.flatMap((responsive) => {
|
|
81
|
+
return (React.createElement(React.Fragment, { key: String(responsive) },
|
|
82
|
+
React.createElement(Grid2_1.default, { size: { xs: 12 } },
|
|
83
|
+
React.createElement("code", null, `responsive={${responsive.toString()}}`)),
|
|
84
|
+
SIZES.map((size) => (React.createElement(Grid2_1.default, { size: { xs: 4 }, gap: 2, display: "flex", alignItems: "center", key: size },
|
|
85
|
+
React.createElement(Button_1.Button, Object.assign({}, args, { size: size, responsive: responsive }), size))))));
|
|
86
|
+
}))),
|
|
87
|
+
};
|
|
88
|
+
exports.WithIcons = {
|
|
89
|
+
render: (args) => (React.createElement(Stack_1.default, { direction: "column", alignItems: "start", gap: 2, sx: { my: 2 } }, Object.entries(ICONS).map(([key, icon]) => (React.createElement(Button_1.Button, Object.assign({}, args, { startIcon: icon, key: key }), key))))),
|
|
90
|
+
};
|
|
91
|
+
const EXTRA_PROPS = [
|
|
92
|
+
{},
|
|
93
|
+
/**
|
|
94
|
+
* Show RiTestTubeLine because it is a fairly thin icon
|
|
95
|
+
*/
|
|
96
|
+
{ startIcon: React.createElement(react_1.RiTestTubeLine, null) },
|
|
97
|
+
/**
|
|
98
|
+
* Show RiTestTubeLine because it is a fairly thick icon
|
|
99
|
+
*/
|
|
100
|
+
{ startIcon: React.createElement(react_1.RiMailLine, null) },
|
|
101
|
+
{ endIcon: React.createElement(react_1.RiTestTubeLine, null) },
|
|
102
|
+
{ endIcon: React.createElement(react_1.RiMailLine, null) },
|
|
103
|
+
];
|
|
104
|
+
/**
|
|
105
|
+
* `ButtonLink` is a styled `Button` that renders an anchor tag.
|
|
106
|
+
*
|
|
107
|
+
* To use a custom link component (E.g. `Link` from `react-router` or `next/link`),
|
|
108
|
+
* pass it as the `Component` prop. Alternatively, customize the project-wide
|
|
109
|
+
* default link adapter via [Theme's LinkAdapter](../?path=/docs/smoot-design-themeprovider--docs)
|
|
110
|
+
*/
|
|
111
|
+
exports.Links = {
|
|
112
|
+
render: () => (React.createElement(Stack_1.default, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
113
|
+
React.createElement(Button_1.ButtonLink, { href: "#fake", variant: "primary" }, "Link"),
|
|
114
|
+
React.createElement(Button_1.ButtonLink, { href: "#fake", variant: "secondary" }, "Link"),
|
|
115
|
+
React.createElement(Button_1.ButtonLink, { href: "#fake", variant: "tertiary" }, "Link"),
|
|
116
|
+
React.createElement(Button_1.ButtonLink, { href: "#fake", variant: "bordered" }, "Link"),
|
|
117
|
+
React.createElement(Button_1.ButtonLink, { href: "#fake", variant: "text" }, "Link"))),
|
|
118
|
+
};
|
|
119
|
+
exports.Showcase = {
|
|
120
|
+
render: (args) => (React.createElement(Grid2_1.default, { container: true, rowGap: 2, sx: { maxWidth: "600px" } }, STABLE_VARIANTS.flatMap((variant) => EDGES.flatMap((edge) => EXTRA_PROPS.map((extraProps, i) => {
|
|
121
|
+
return (React.createElement(React.Fragment, { key: `${variant}-${edge}-${i}` },
|
|
122
|
+
React.createElement(Grid2_1.default, { size: { xs: 3 } },
|
|
123
|
+
React.createElement("pre", null,
|
|
124
|
+
"variant=",
|
|
125
|
+
variant,
|
|
126
|
+
React.createElement("br", null),
|
|
127
|
+
"edge=",
|
|
128
|
+
edge)),
|
|
129
|
+
SIZES.map((size) => (React.createElement(Grid2_1.default, { size: { xs: 3 }, display: "flex", alignItems: "center", key: `${size}` },
|
|
130
|
+
React.createElement(Button_1.Button, Object.assign({}, args, { variant: variant, edge: edge, size: size }, extraProps), args.children))))));
|
|
131
|
+
}))))),
|
|
132
|
+
args: {
|
|
133
|
+
children: "Click me",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const react_1 = require("@testing-library/react");
|
|
5
|
+
const ThemeProvider_1 = require("../ThemeProvider/ThemeProvider");
|
|
6
|
+
const Button_1 = require("./Button");
|
|
7
|
+
const ActionButton_1 = require("./ActionButton");
|
|
8
|
+
const withLinkOverride = (0, ThemeProvider_1.createTheme)({
|
|
9
|
+
custom: {
|
|
10
|
+
LinkAdapter: React.forwardRef(function LinkAdapter(props, ref) {
|
|
11
|
+
return (
|
|
12
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
13
|
+
React.createElement("a", Object.assign({ ref: ref, "data-custom": "theme-default" }, props)));
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
describe.each([
|
|
18
|
+
//
|
|
19
|
+
{ ButtonComponent: Button_1.ButtonLink },
|
|
20
|
+
{ ButtonComponent: ActionButton_1.ActionButtonLink },
|
|
21
|
+
])("$ButtonComponent.displayName overrides", ({ ButtonComponent }) => {
|
|
22
|
+
test("Uses anchor by default", () => {
|
|
23
|
+
(0, react_1.render)(React.createElement(ButtonComponent, { href: "/test" }, "Link text here"), {
|
|
24
|
+
wrapper: ThemeProvider_1.ThemeProvider,
|
|
25
|
+
});
|
|
26
|
+
const link = react_1.screen.getByRole("link");
|
|
27
|
+
expect(link.dataset.custom).toBe(undefined);
|
|
28
|
+
});
|
|
29
|
+
test("Uses theme's override if supplied", () => {
|
|
30
|
+
(0, react_1.render)(React.createElement(ButtonComponent, { href: "/test" }, "Link text here"), {
|
|
31
|
+
wrapper: (props) => React.createElement(ThemeProvider_1.ThemeProvider, Object.assign({ theme: withLinkOverride }, props)),
|
|
32
|
+
});
|
|
33
|
+
const link = react_1.screen.getByRole("link");
|
|
34
|
+
expect(link.dataset.custom).toBe("theme-default");
|
|
35
|
+
});
|
|
36
|
+
test("Uses component's override if supplied", () => {
|
|
37
|
+
const LinkImplementation = (props) => (
|
|
38
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
39
|
+
React.createElement("a", Object.assign({ "data-custom": "anchor-override" }, props)));
|
|
40
|
+
(0, react_1.render)(React.createElement(ButtonComponent, { Component: LinkImplementation, href: "/test" }, "Link text here"), {
|
|
41
|
+
wrapper: (props) => (React.createElement(ThemeProvider_1.ThemeProvider, Object.assign({ theme: withLinkOverride }, props))),
|
|
42
|
+
});
|
|
43
|
+
const link = react_1.screen.getByRole("link");
|
|
44
|
+
expect(link.dataset.custom).toBe("anchor-override");
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* ImageAdapterPropsOverrides can be used with module augmentation to provide
|
|
4
|
+
* extra props to ButtonLink.
|
|
5
|
+
*
|
|
6
|
+
* For example, in a NextJS App, you might set `next/image` as your default
|
|
7
|
+
* image implementation, and use ImageAdapterPropsOverrides to provide
|
|
8
|
+
* `next/image`-specific props.
|
|
9
|
+
*/
|
|
10
|
+
interface ImageAdapterPropsOverrides {
|
|
11
|
+
}
|
|
12
|
+
type ImageAdapterProps = React.ComponentProps<"img"> & {
|
|
13
|
+
Component?: React.ElementType;
|
|
14
|
+
} & ImageAdapterPropsOverrides;
|
|
15
|
+
/**
|
|
16
|
+
* Overridable Image component.
|
|
17
|
+
* - If `Component` is provided, renders as `Component`
|
|
18
|
+
* - else, if `theme.custom.ImageAdapter` is provided, renders as `theme.custom.ImageAdapter`
|
|
19
|
+
* - else, renders as `img` tag
|
|
20
|
+
*/
|
|
21
|
+
declare const ImageAdapter: React.ForwardRefExoticComponent<Omit<ImageAdapterProps, "ref"> & React.RefAttributes<HTMLImageElement>>;
|
|
22
|
+
export { ImageAdapter };
|
|
23
|
+
export type { ImageAdapterPropsOverrides, ImageAdapterProps };
|
|
@@ -0,0 +1,30 @@
|
|
|
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.ImageAdapter = void 0;
|
|
15
|
+
const React = require("react");
|
|
16
|
+
const react_1 = require("@emotion/react");
|
|
17
|
+
/**
|
|
18
|
+
* Overridable Image component.
|
|
19
|
+
* - If `Component` is provided, renders as `Component`
|
|
20
|
+
* - else, if `theme.custom.ImageAdapter` is provided, renders as `theme.custom.ImageAdapter`
|
|
21
|
+
* - else, renders as `img` tag
|
|
22
|
+
*/
|
|
23
|
+
const ImageAdapter = React.forwardRef(function ImageAdapter(_a, ref) {
|
|
24
|
+
var _b;
|
|
25
|
+
var { Component } = _a, props = __rest(_a, ["Component"]);
|
|
26
|
+
const theme = (0, react_1.useTheme)();
|
|
27
|
+
const ImgComponent = (_b = Component !== null && Component !== void 0 ? Component : theme.custom.ImgAdapter) !== null && _b !== void 0 ? _b : "img";
|
|
28
|
+
return React.createElement(ImgComponent, Object.assign({ ref: ref }, props));
|
|
29
|
+
});
|
|
30
|
+
exports.ImageAdapter = ImageAdapter;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { InputBaseProps } from "@mui/material/InputBase";
|
|
3
|
+
import type { Theme } from "@mui/material/styles";
|
|
4
|
+
type Size = "small" | "medium" | "large" | "chat" | "hero";
|
|
5
|
+
type CustomInputProps = {
|
|
6
|
+
/**
|
|
7
|
+
* If true, the input will display one size smaller at mobile breakpoint.
|
|
8
|
+
*/
|
|
9
|
+
responsive?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type MuiDocOverride = {
|
|
12
|
+
size?: Size;
|
|
13
|
+
/**
|
|
14
|
+
* Slot for icon adornments.
|
|
15
|
+
*
|
|
16
|
+
* If the icon is a button, use `AdornmentButton` component.
|
|
17
|
+
*/
|
|
18
|
+
startAdornment?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Slot for icon adornments.
|
|
21
|
+
*
|
|
22
|
+
* If the icon is a button, use `AdornmentButton` component.
|
|
23
|
+
*/
|
|
24
|
+
endAdornment?: React.ReactNode;
|
|
25
|
+
};
|
|
26
|
+
type InputProps = CustomInputProps & MuiDocOverride & Omit<InputBaseProps, "color" | keyof MuiDocOverride>;
|
|
27
|
+
/**
|
|
28
|
+
* Base styles for Input and Select components. Includes border, color, hover effects.
|
|
29
|
+
*/
|
|
30
|
+
declare const baseInputStyles: (theme: Theme) => {
|
|
31
|
+
backgroundColor: string;
|
|
32
|
+
color: string;
|
|
33
|
+
borderColor: string;
|
|
34
|
+
borderWidth: string;
|
|
35
|
+
borderStyle: string;
|
|
36
|
+
borderRadius: string;
|
|
37
|
+
overflow: string;
|
|
38
|
+
"&.Mui-disabled": {
|
|
39
|
+
backgroundColor: string;
|
|
40
|
+
};
|
|
41
|
+
"&:hover:not(.Mui-disabled):not(.Mui-focused)": {
|
|
42
|
+
borderColor: string;
|
|
43
|
+
};
|
|
44
|
+
"&.Mui-focused": {
|
|
45
|
+
/**
|
|
46
|
+
* When change border width, it affects either the elements outside of it or
|
|
47
|
+
* inside based on the border-box setting.
|
|
48
|
+
*
|
|
49
|
+
* Instead of changing the border width, we hide the border and change width
|
|
50
|
+
* using outline.
|
|
51
|
+
*/
|
|
52
|
+
borderColor: string;
|
|
53
|
+
outline: string;
|
|
54
|
+
outlineOffset: string;
|
|
55
|
+
};
|
|
56
|
+
"&.Mui-error": {
|
|
57
|
+
borderColor: string;
|
|
58
|
+
outlineColor: string;
|
|
59
|
+
};
|
|
60
|
+
"& input::placeholder, textarea::placeholder": {
|
|
61
|
+
color: string;
|
|
62
|
+
opacity: number;
|
|
63
|
+
};
|
|
64
|
+
"& input:placeholder-shown, textarea:placeholder-shown": {
|
|
65
|
+
textOverflow: string;
|
|
66
|
+
};
|
|
67
|
+
"& textarea": {
|
|
68
|
+
paddingTop: string;
|
|
69
|
+
paddingBottom: string;
|
|
70
|
+
};
|
|
71
|
+
"&.MuiInputBase-adornedStart": {
|
|
72
|
+
paddingLeft: string;
|
|
73
|
+
input: {
|
|
74
|
+
paddingLeft: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
"&.MuiInputBase-adornedEnd": {
|
|
78
|
+
paddingRight: string;
|
|
79
|
+
input: {
|
|
80
|
+
paddingRight: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Use `Input` for a visually unlabelled input field. If used, it should still
|
|
86
|
+
* have an accessible label, e.g., provided via `aria-label`.
|
|
87
|
+
* For a labeled input field, use `TextField`. instead.
|
|
88
|
+
*
|
|
89
|
+
* **Note:** This component is a styled version of MUI's `InputBase`. See
|
|
90
|
+
* MUI's documentation for full info.
|
|
91
|
+
*
|
|
92
|
+
* - [Smoot Design Input Documentation](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-input--docs)
|
|
93
|
+
* - [InputBase Documentation](https://mui.com/api/input-base/)
|
|
94
|
+
*/
|
|
95
|
+
declare const Input: React.FC<InputProps>;
|
|
96
|
+
declare const AdornmentButtonStyled: import("@emotion/styled").StyledComponent<{
|
|
97
|
+
theme?: import("@emotion/react").Theme;
|
|
98
|
+
as?: React.ElementType;
|
|
99
|
+
}, React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
|
|
100
|
+
type AdornmentButtonProps = React.ComponentProps<typeof AdornmentButtonStyled>;
|
|
101
|
+
/**
|
|
102
|
+
* Button to be used with `startAdornment` and `endAdornment` props on Input and
|
|
103
|
+
* TextField components. AdornmentButton takes care of positioning and other
|
|
104
|
+
* styling concerns.
|
|
105
|
+
*
|
|
106
|
+
* NOTES:
|
|
107
|
+
* - It is generally expected that the content of the AdornmentButton is a
|
|
108
|
+
* Remix Icon component. https://remixicon.com/
|
|
109
|
+
* - By default, the AdornmentButton calls `preventDefault` on `mouseDown`
|
|
110
|
+
* events. This prevents the button from stealing focus from the input on
|
|
111
|
+
* click. The button is still focusable via keyboard events. You can override
|
|
112
|
+
* this behavior by passing your own `onMouseDown` handler.
|
|
113
|
+
*/
|
|
114
|
+
declare const AdornmentButton: React.FC<AdornmentButtonProps>;
|
|
115
|
+
export { AdornmentButton, Input, baseInputStyles };
|
|
116
|
+
export type { InputProps, AdornmentButtonProps };
|