@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,122 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { http, HttpResponse, delay } from "msw";
|
|
11
|
+
const SAMPLE_RESPONSES = [
|
|
12
|
+
`For exploring AI applications in business, I recommend the following course from MIT:
|
|
13
|
+
|
|
14
|
+
1. **[Machine Learning, Modeling, and Simulation Principles](https://xpro.mit.edu/courses/course-v1:xPRO+MLx1/)**: Offered by MIT xPRO, this course is part of the program "Machine Learning, Modeling, and Simulation: Engineering Problem-Solving in the Age of AI." It focuses on the principles of machine learning and how they can be applied to solve engineering problems, which is highly relevant for business applications of AI.
|
|
15
|
+
|
|
16
|
+
This course is not free, but it provides a certification upon completion, which can be valuable for professionals looking to apply AI in business contexts. It covers essential concepts that can help you understand how AI can be leveraged to improve business processes and decision-making.
|
|
17
|
+
<!-- Comment! -->
|
|
18
|
+
`,
|
|
19
|
+
`
|
|
20
|
+
To understand global warming, I recommend the following resources from MIT:
|
|
21
|
+
|
|
22
|
+
1. **[Global Warming Science](https://www.edx.org/learn/global-warming/massachusetts-institute-of-technology-global-warming-science)**: This course offered by MITx covers the physics, chemistry, biology, and geology of the earth’s climate system. It's a comprehensive introduction to the scientific principles underlying global warming.
|
|
23
|
+
|
|
24
|
+
2. **[Global Warming Science](https://openlearninglibrary.mit.edu/courses/course-v1:MITx+12.340x+1T2020/about)**: Another offering of the same course by MITx, available through the Open Learning Library. It provides the same in-depth exploration of the earth's climate system.
|
|
25
|
+
|
|
26
|
+
These courses are free and provide a solid foundation in understanding the scientific aspects of global warming. They are suitable for anyone interested in the topic, regardless of prior knowledge.
|
|
27
|
+
<!-- Comment! -->
|
|
28
|
+
`,
|
|
29
|
+
`
|
|
30
|
+
Here are some courses on linear algebra that you can explore:
|
|
31
|
+
|
|
32
|
+
1. **[Linear Algebra (MIT OpenCourseWare)](https://openlearninglibrary.mit.edu/courses/course-v1:OCW+18.06SC+2T2019/about)**: This course covers matrix theory and linear algebra, emphasizing topics useful in various disciplines such as physics, economics, social sciences, natural sciences, and engineering. It parallels the combination of theory and applications in Professor Strang's textbook "Introduction to Linear Algebra." This course is free and available through MIT OpenCourseWare.
|
|
33
|
+
|
|
34
|
+
2. **[Mathematical Methods for Quantitative Finance (MITx)](https://www.edx.org/learn/finance/massachusetts-institute-of-technology-mathematical-methods-for-quantitative-finance)**: This course covers the mathematical foundations essential for financial engineering and quantitative finance, including linear algebra, optimization, probability, stochastic processes, statistics, and applied computational techniques in R. It is free and offers certification upon completion.
|
|
35
|
+
|
|
36
|
+
3. **[Quantum Information Science I, Part 1 (MITx)](https://openlearninglibrary.mit.edu/courses/course-v1:MITx+8.370.1x+1T2018/about)**: While primarily focused on quantum information science, this course requires some knowledge of linear algebra and is suitable for those interested in quantum mechanics. It is free and available through MITx.
|
|
37
|
+
|
|
38
|
+
These courses provide a comprehensive introduction to linear algebra and its applications across various fields.
|
|
39
|
+
<!-- Comment! -->
|
|
40
|
+
`,
|
|
41
|
+
`Here are some courses on quantum computing that offer certificates:
|
|
42
|
+
|
|
43
|
+
1. [Introduction to Quantum Computing](https://xpro.mit.edu/courses/course-v1:xPRO+QCFx1/)
|
|
44
|
+
- **Description**: This is the first course in the Quantum Computing Fundamentals professional certificate program. You can earn a Professional Certificate and CEUs by completing both courses in the program. Alternatively, you can take this course individually for a certificate of completion and CEUs.
|
|
45
|
+
- **Offered by**: MIT xPRO
|
|
46
|
+
- **Instructors**: Isaac Chuang, William Oliver, Peter Shor, Aram Harrow
|
|
47
|
+
|
|
48
|
+
2. [Practical Realities of Quantum Computation and Quantum Communication](https://xpro.mit.edu/courses/course-v1:xPRO+QCRx1/)
|
|
49
|
+
- **Description**: This course is part of the Quantum Computing Realities professional certificate program. Completing both courses in the program will earn you a Professional Certificate and CEUs. You can also take this course individually for a certificate of completion and CEUs.
|
|
50
|
+
- **Offered by**: MIT xPRO
|
|
51
|
+
- **Instructors**: Isaac Chuang, William Oliver, Peter Shor, Aram Harrow
|
|
52
|
+
|
|
53
|
+
These courses are part of professional certificate programs, and you can choose to complete the entire program or take individual courses for certification.`,
|
|
54
|
+
];
|
|
55
|
+
const rand = (min, max) => {
|
|
56
|
+
// min and max included
|
|
57
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
58
|
+
};
|
|
59
|
+
const getReadableStream = () => {
|
|
60
|
+
let timerId;
|
|
61
|
+
const response = SAMPLE_RESPONSES[rand(0, SAMPLE_RESPONSES.length - 1)];
|
|
62
|
+
const chunks = response.split(" ").reduce((acc, word) => {
|
|
63
|
+
const last = acc[acc.length - 1];
|
|
64
|
+
if (acc.length === 0) {
|
|
65
|
+
acc.push(word);
|
|
66
|
+
}
|
|
67
|
+
else if (Math.random() < 0.75) {
|
|
68
|
+
acc[acc.length - 1] = `${last} ${word}`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
acc.push(` ${word}`);
|
|
72
|
+
}
|
|
73
|
+
return acc;
|
|
74
|
+
}, []);
|
|
75
|
+
const num = chunks.length;
|
|
76
|
+
let i = 0;
|
|
77
|
+
return new ReadableStream({
|
|
78
|
+
start(controller) {
|
|
79
|
+
timerId = setInterval(() => {
|
|
80
|
+
const msg = new TextEncoder().encode(chunks[i]);
|
|
81
|
+
controller.enqueue(msg);
|
|
82
|
+
i++;
|
|
83
|
+
if (i === num) {
|
|
84
|
+
controller.close();
|
|
85
|
+
clearInterval(timerId);
|
|
86
|
+
}
|
|
87
|
+
}, 100);
|
|
88
|
+
},
|
|
89
|
+
cancel() {
|
|
90
|
+
if (timerId) {
|
|
91
|
+
clearInterval(timerId);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
const handlers = [
|
|
97
|
+
http.post("http://localhost:4567/streaming", (_a) => __awaiter(void 0, [_a], void 0, function* ({ request }) {
|
|
98
|
+
yield delay(600);
|
|
99
|
+
const body = getReadableStream();
|
|
100
|
+
const requestBody = yield request.json();
|
|
101
|
+
if (Array.isArray(requestBody)) {
|
|
102
|
+
const last = requestBody[requestBody.length - 1];
|
|
103
|
+
const { content } = last;
|
|
104
|
+
if (content === "error") {
|
|
105
|
+
return new HttpResponse("Internal Server Error", {
|
|
106
|
+
status: 500,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return new HttpResponse(body, {
|
|
111
|
+
headers: {
|
|
112
|
+
"Content-Type": "text/plain",
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
})),
|
|
116
|
+
http.post("http://localhost:4567/json", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
const message = SAMPLE_RESPONSES[rand(0, SAMPLE_RESPONSES.length - 1)];
|
|
118
|
+
yield delay(800);
|
|
119
|
+
return HttpResponse.json({ message });
|
|
120
|
+
})),
|
|
121
|
+
];
|
|
122
|
+
export { handlers };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { RefAttributes } from "react";
|
|
2
|
+
type Role = "assistant" | "user";
|
|
3
|
+
type AiChatMessage = {
|
|
4
|
+
id: string;
|
|
5
|
+
content: string;
|
|
6
|
+
role: Role;
|
|
7
|
+
};
|
|
8
|
+
type RequestOpts = {
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* Transforms array of chat messages into request body. Messages
|
|
12
|
+
* are ordered oldest to newest.
|
|
13
|
+
*
|
|
14
|
+
* JSON.stringify is applied to the return value.
|
|
15
|
+
*/
|
|
16
|
+
transformBody?: (messages: AiChatMessage[]) => unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Extra options to pass to fetch.
|
|
19
|
+
*/
|
|
20
|
+
fetchOpts?: RequestInit;
|
|
21
|
+
onFinish?: (message: AiChatMessage) => void;
|
|
22
|
+
};
|
|
23
|
+
type AiChatProps = {
|
|
24
|
+
/**
|
|
25
|
+
* Changing the `chatId` will reset the chat. Changing the `chatId` to a
|
|
26
|
+
* previously used value will restore the session state.
|
|
27
|
+
*/
|
|
28
|
+
chatId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* If provided, renders the "AskTIM" title motif followed by the text.
|
|
31
|
+
*/
|
|
32
|
+
askTimTitle?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Placeholder message for chat input.
|
|
35
|
+
*/
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
className?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Set to false to disable the entry screen and load the chat immediately.
|
|
40
|
+
* Defaults to true.
|
|
41
|
+
*/
|
|
42
|
+
entryScreenEnabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Title to display on the entry screen, also the initial assistant message if not overridden by `initialMessages`.
|
|
45
|
+
*/
|
|
46
|
+
entryScreenTitle?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Initial messages to display on the chat. If not provided, the entry screen title will be used as the initial message.
|
|
49
|
+
*/
|
|
50
|
+
initialMessages?: Omit<AiChatMessage, "id">[];
|
|
51
|
+
/**
|
|
52
|
+
* Prompt suggestions for the user, clickable on the entry screen or in the chat if the entry screen is not enabled.
|
|
53
|
+
*/
|
|
54
|
+
conversationStarters?: {
|
|
55
|
+
content: string;
|
|
56
|
+
}[];
|
|
57
|
+
/**
|
|
58
|
+
* Options for making requests to the AI service.
|
|
59
|
+
*/
|
|
60
|
+
requestOpts: RequestOpts;
|
|
61
|
+
parseContent?: (content: unknown) => string;
|
|
62
|
+
/**
|
|
63
|
+
* A message to display while the component is in a loading state.
|
|
64
|
+
*
|
|
65
|
+
* Identical consecutive messages may not be read on some screen readers.
|
|
66
|
+
*/
|
|
67
|
+
srLoadingMessages?: {
|
|
68
|
+
delay: number;
|
|
69
|
+
text: string;
|
|
70
|
+
}[];
|
|
71
|
+
/**
|
|
72
|
+
* If provided, element to use for rendering avatar images.
|
|
73
|
+
* By default, the theme's ImageAdater is used.
|
|
74
|
+
*/
|
|
75
|
+
ImgComponent?: React.ElementType;
|
|
76
|
+
/**
|
|
77
|
+
* Where the scroll container is provided by the component,
|
|
78
|
+
* the AiChat will scroll to the bottom as chat messages are added.
|
|
79
|
+
*/
|
|
80
|
+
scrollElement?: HTMLElement | null;
|
|
81
|
+
} & RefAttributes<HTMLDivElement>;
|
|
82
|
+
export type { RequestOpts, AiChatProps, AiChatMessage };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UseChatOptions } from "ai/react";
|
|
2
|
+
import type { RequestOpts } from "./types";
|
|
3
|
+
declare const useAiChat: (requestOpts: RequestOpts, opts: UseChatOptions) => import("@ai-sdk/react").UseChatHelpers & {
|
|
4
|
+
addToolResult: ({ toolCallId, result, }: {
|
|
5
|
+
toolCallId: string;
|
|
6
|
+
result: any;
|
|
7
|
+
}) => void;
|
|
8
|
+
};
|
|
9
|
+
export { useAiChat };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { useChat } from "ai/react";
|
|
11
|
+
import { useMemo } from "react";
|
|
12
|
+
const identity = (x) => x;
|
|
13
|
+
const getFetcher = (requestOpts) => (url, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
if (typeof (opts === null || opts === void 0 ? void 0 : opts.body) !== "string") {
|
|
16
|
+
console.error("Unexpected body type.");
|
|
17
|
+
return window.fetch(url, opts);
|
|
18
|
+
}
|
|
19
|
+
const messages = JSON.parse(opts === null || opts === void 0 ? void 0 : opts.body).messages;
|
|
20
|
+
const transformBody = (_a = requestOpts.transformBody) !== null && _a !== void 0 ? _a : identity;
|
|
21
|
+
const options = Object.assign(Object.assign(Object.assign(Object.assign({}, opts), { body: JSON.stringify(transformBody(messages)) }), requestOpts.fetchOpts), { headers: Object.assign(Object.assign(Object.assign({}, opts === null || opts === void 0 ? void 0 : opts.headers), { "Content-Type": "application/json" }), (_b = requestOpts.fetchOpts) === null || _b === void 0 ? void 0 : _b.headers) });
|
|
22
|
+
return fetch(url, options);
|
|
23
|
+
});
|
|
24
|
+
const useAiChat = (requestOpts, opts) => {
|
|
25
|
+
const fetcher = useMemo(() => getFetcher(requestOpts), [requestOpts]);
|
|
26
|
+
return useChat(Object.assign({ api: requestOpts.apiUrl, streamProtocol: "text", fetch: fetcher, onFinish: (message) => {
|
|
27
|
+
var _a;
|
|
28
|
+
if (!requestOpts.onFinish)
|
|
29
|
+
return;
|
|
30
|
+
if (message.role === "assistant" || message.role === "user") {
|
|
31
|
+
(_a = requestOpts.onFinish) === null || _a === void 0 ? void 0 : _a.call(requestOpts, message);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.info("Unexpected message role.", message);
|
|
35
|
+
}
|
|
36
|
+
} }, opts));
|
|
37
|
+
};
|
|
38
|
+
export { useAiChat };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { AlertColor } from "@mui/material/Alert";
|
|
3
|
+
type AlertProps = {
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
closable?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
severity?: AlertColor;
|
|
8
|
+
/**
|
|
9
|
+
* Alert Content
|
|
10
|
+
*/
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
declare const Alert: React.FC<AlertProps>;
|
|
14
|
+
export { Alert };
|
|
15
|
+
export type { AlertProps };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { default as MuiAlert } from "@mui/material/Alert";
|
|
5
|
+
const getColor = (theme, severity) => {
|
|
6
|
+
return {
|
|
7
|
+
info: theme.custom.colors.blue,
|
|
8
|
+
success: theme.custom.colors.green,
|
|
9
|
+
warning: theme.custom.colors.orange,
|
|
10
|
+
error: theme.custom.colors.lightRed,
|
|
11
|
+
}[severity];
|
|
12
|
+
};
|
|
13
|
+
const AlertStyled = styled(MuiAlert)(({ theme, severity }) => ({
|
|
14
|
+
padding: "11px 16px",
|
|
15
|
+
borderRadius: 4,
|
|
16
|
+
borderWidth: 2,
|
|
17
|
+
borderStyle: "solid",
|
|
18
|
+
borderColor: getColor(theme, severity),
|
|
19
|
+
background: "#FFF",
|
|
20
|
+
".MuiAlert-message": Object.assign(Object.assign({}, theme.typography.body2), { color: theme.custom.colors.darkGray2, alignSelf: "center" }),
|
|
21
|
+
"> div": {
|
|
22
|
+
paddingTop: 0,
|
|
23
|
+
paddingBottom: 0,
|
|
24
|
+
},
|
|
25
|
+
".MuiAlert-icon": {
|
|
26
|
+
marginRight: 8,
|
|
27
|
+
svg: {
|
|
28
|
+
width: 16,
|
|
29
|
+
fill: getColor(theme, severity),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
button: {
|
|
33
|
+
padding: 0,
|
|
34
|
+
":hover": {
|
|
35
|
+
margin: 0,
|
|
36
|
+
background: "none",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
const Hidden = styled.span({ display: "none" });
|
|
41
|
+
const Alert = ({ visible = true, severity = "info", closable, children, className, }) => {
|
|
42
|
+
const [_visible, setVisible] = React.useState(visible);
|
|
43
|
+
const id = React.useId();
|
|
44
|
+
const onCloseClick = () => {
|
|
45
|
+
setVisible(false);
|
|
46
|
+
};
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
setVisible(visible);
|
|
49
|
+
}, [visible]);
|
|
50
|
+
if (!_visible) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return (React.createElement(AlertStyled, { severity: severity, onClose: closable ? onCloseClick : undefined, role: "alert", "aria-describedby": id, className: className },
|
|
54
|
+
children,
|
|
55
|
+
React.createElement(Hidden, { id: id },
|
|
56
|
+
severity,
|
|
57
|
+
" message")));
|
|
58
|
+
};
|
|
59
|
+
export { Alert };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Alert } from "./Alert";
|
|
3
|
+
declare const meta: Meta<typeof Alert>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Alert>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const Closable: Story;
|
|
8
|
+
export declare const Variants: Story;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Alert } from "./Alert";
|
|
3
|
+
import Stack from "@mui/material/Stack";
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "smoot-design/Alert",
|
|
6
|
+
component: Alert,
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export const Basic = {
|
|
10
|
+
args: {
|
|
11
|
+
severity: "info",
|
|
12
|
+
},
|
|
13
|
+
render: (args) => (React.createElement(Alert, Object.assign({}, args),
|
|
14
|
+
"Alert with severity \"",
|
|
15
|
+
args.severity,
|
|
16
|
+
"\"")),
|
|
17
|
+
};
|
|
18
|
+
export const Closable = {
|
|
19
|
+
args: {
|
|
20
|
+
severity: "warning",
|
|
21
|
+
closable: true,
|
|
22
|
+
},
|
|
23
|
+
render: (args) => (React.createElement(Alert, Object.assign({}, args),
|
|
24
|
+
"Closable alert with severity \"",
|
|
25
|
+
args.severity,
|
|
26
|
+
"\"")),
|
|
27
|
+
};
|
|
28
|
+
export const Variants = {
|
|
29
|
+
argTypes: {
|
|
30
|
+
severity: {
|
|
31
|
+
table: {
|
|
32
|
+
disable: true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
closable: {
|
|
36
|
+
table: {
|
|
37
|
+
disable: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
render: (args) => (React.createElement(Stack, { direction: "column", gap: 2, sx: { my: 2 } },
|
|
42
|
+
React.createElement(Alert, Object.assign({}, args, { severity: "info" }), "Alert with severity \"info\""),
|
|
43
|
+
React.createElement(Alert, Object.assign({}, args, { closable: true, severity: "info" }), "Closable alert with severity \"info\""),
|
|
44
|
+
React.createElement(Alert, Object.assign({}, args, { severity: "success" }), "Alert with severity \"success\""),
|
|
45
|
+
React.createElement(Alert, Object.assign({}, args, { closable: true, severity: "success" }), "Closable alert with severity \"success\""),
|
|
46
|
+
React.createElement(Alert, Object.assign({}, args, { severity: "warning" }), "Alert with severity \"warning\""),
|
|
47
|
+
React.createElement(Alert, Object.assign({}, args, { closable: true, severity: "warning" }), "Closable alert with severity \"warning\""),
|
|
48
|
+
React.createElement(Alert, Object.assign({}, args, { severity: "error" }), "Alert with severity \"error\""),
|
|
49
|
+
React.createElement(Alert, Object.assign({}, args, { closable: true, severity: "error" }), "Closable alert with severity \"error\""))),
|
|
50
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DEFAULT_PROPS } from "./Button";
|
|
3
|
+
import type { ButtonStyleProps } from "./Button";
|
|
4
|
+
import type { LinkAdapterPropsOverrides } from "../LinkAdapter/LinkAdapter";
|
|
5
|
+
type ActionButtonStyleProps = Omit<ButtonStyleProps, "startIcon" | "endIcon">;
|
|
6
|
+
type ActionButtonProps = ActionButtonStyleProps & React.ComponentProps<"button">;
|
|
7
|
+
/**
|
|
8
|
+
* A button that should contain a remixicon icon and nothing else.
|
|
9
|
+
* See [ActionButton docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs).
|
|
10
|
+
*
|
|
11
|
+
* See also:
|
|
12
|
+
* - [ActionButtonLink](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs#links)
|
|
13
|
+
* - [Button](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs) for text buttons
|
|
14
|
+
*/
|
|
15
|
+
declare const ActionButton: import("@emotion/styled").StyledComponent<Omit<ActionButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement> & {
|
|
16
|
+
theme?: import("@emotion/react").Theme;
|
|
17
|
+
}, {}, {}>;
|
|
18
|
+
type ActionButtonLinkProps = ActionButtonStyleProps & React.ComponentProps<"a"> & {
|
|
19
|
+
Component?: React.ElementType;
|
|
20
|
+
} & LinkAdapterPropsOverrides;
|
|
21
|
+
/**
|
|
22
|
+
* See [ActionButtonLink docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs#links)
|
|
23
|
+
*/
|
|
24
|
+
declare const ActionButtonLink: import("@emotion/styled").StyledComponent<Omit<ActionButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement> & {
|
|
25
|
+
theme?: import("@emotion/react").Theme;
|
|
26
|
+
} & ActionButtonStyleProps & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
27
|
+
Component?: React.ElementType;
|
|
28
|
+
} & LinkAdapterPropsOverrides, {}, {}>;
|
|
29
|
+
export { ActionButton, ActionButtonLink, DEFAULT_PROPS };
|
|
30
|
+
export type { ActionButtonProps, ActionButtonLinkProps };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import styled from "@emotion/styled";
|
|
14
|
+
import { pxToRem } from "../ThemeProvider/typography";
|
|
15
|
+
import { ButtonRoot, ButtonLinkRoot, RESPONSIVE_SIZES, DEFAULT_PROPS, } from "./Button";
|
|
16
|
+
const actionStyles = (size) => {
|
|
17
|
+
return {
|
|
18
|
+
minWidth: "auto",
|
|
19
|
+
padding: 0,
|
|
20
|
+
height: {
|
|
21
|
+
small: "32px",
|
|
22
|
+
medium: "40px",
|
|
23
|
+
large: "48px",
|
|
24
|
+
}[size],
|
|
25
|
+
width: {
|
|
26
|
+
small: "32px",
|
|
27
|
+
medium: "40px",
|
|
28
|
+
large: "48px",
|
|
29
|
+
}[size],
|
|
30
|
+
"& svg, & .MuiSvgIcon-root": {
|
|
31
|
+
width: "1em",
|
|
32
|
+
height: "1em",
|
|
33
|
+
fontSize: pxToRem({
|
|
34
|
+
small: 20,
|
|
35
|
+
medium: 24,
|
|
36
|
+
large: 32,
|
|
37
|
+
}[size]),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A button that should contain a remixicon icon and nothing else.
|
|
43
|
+
* See [ActionButton docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs).
|
|
44
|
+
*
|
|
45
|
+
* See also:
|
|
46
|
+
* - [ActionButtonLink](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs#links)
|
|
47
|
+
* - [Button](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-button--docs) for text buttons
|
|
48
|
+
*/
|
|
49
|
+
const ActionButton = styled(React.forwardRef(function Root(props, ref) {
|
|
50
|
+
return React.createElement(ButtonRoot, Object.assign({ ref: ref, type: "button" }, props));
|
|
51
|
+
}))(({ size = DEFAULT_PROPS.size, responsive, theme }) => {
|
|
52
|
+
return [
|
|
53
|
+
actionStyles(size),
|
|
54
|
+
responsive && {
|
|
55
|
+
[theme.breakpoints.down("sm")]: actionStyles(RESPONSIVE_SIZES[size]),
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
});
|
|
59
|
+
ActionButton.displayName = "ActionButton";
|
|
60
|
+
/**
|
|
61
|
+
* See [ActionButtonLink docs](https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-actionbutton--docs#links)
|
|
62
|
+
*/
|
|
63
|
+
const ActionButtonLink = ActionButton.withComponent((_a) => {
|
|
64
|
+
var { Component } = _a, props = __rest(_a, ["Component"]);
|
|
65
|
+
return React.createElement(ButtonLinkRoot, Object.assign({ Component: Component }, props));
|
|
66
|
+
});
|
|
67
|
+
ActionButtonLink.displayName = "ActionButtonLink";
|
|
68
|
+
export { ActionButton, ActionButtonLink, DEFAULT_PROPS };
|
|
@@ -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,110 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ActionButton, ActionButtonLink, DEFAULT_PROPS } from "./ActionButton";
|
|
3
|
+
import Grid from "@mui/material/Grid2";
|
|
4
|
+
import Stack from "@mui/material/Stack";
|
|
5
|
+
import { RiArrowLeftLine, RiDeleteBinLine, RiTestTubeLine, } from "@remixicon/react";
|
|
6
|
+
import { fn } from "@storybook/test";
|
|
7
|
+
import { enumValues } from "../../story-utils";
|
|
8
|
+
const ICONS = {
|
|
9
|
+
None: undefined,
|
|
10
|
+
ArrowBackIcon: React.createElement(RiArrowLeftLine, null),
|
|
11
|
+
DeleteIcon: React.createElement(RiDeleteBinLine, null),
|
|
12
|
+
TestTubeIcon: React.createElement(RiTestTubeLine, null),
|
|
13
|
+
};
|
|
14
|
+
const VARIANTS = enumValues({
|
|
15
|
+
primary: true,
|
|
16
|
+
secondary: true,
|
|
17
|
+
tertiary: true,
|
|
18
|
+
bordered: true,
|
|
19
|
+
text: true,
|
|
20
|
+
});
|
|
21
|
+
const STABLE_VARIANTS = VARIANTS.filter((v) => !v.startsWith("unstable"));
|
|
22
|
+
const SIZES = enumValues({
|
|
23
|
+
small: true,
|
|
24
|
+
medium: true,
|
|
25
|
+
large: true,
|
|
26
|
+
});
|
|
27
|
+
const EDGES = enumValues({
|
|
28
|
+
circular: true,
|
|
29
|
+
rounded: true,
|
|
30
|
+
none: true,
|
|
31
|
+
});
|
|
32
|
+
const meta = {
|
|
33
|
+
title: "smoot-design/ActionButton",
|
|
34
|
+
component: ActionButton,
|
|
35
|
+
argTypes: {
|
|
36
|
+
variant: {
|
|
37
|
+
control: { type: "select" },
|
|
38
|
+
table: {
|
|
39
|
+
defaultValue: { summary: DEFAULT_PROPS.variant },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
size: {
|
|
43
|
+
control: { type: "select" },
|
|
44
|
+
table: {
|
|
45
|
+
defaultValue: { summary: DEFAULT_PROPS.size },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
edge: {
|
|
49
|
+
control: { type: "select" },
|
|
50
|
+
table: {
|
|
51
|
+
defaultValue: { summary: DEFAULT_PROPS.edge },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
args: {
|
|
56
|
+
onClick: fn(),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export default meta;
|
|
60
|
+
export const VariantsAndEdge = {
|
|
61
|
+
render: (args) => (React.createElement(React.Fragment, null,
|
|
62
|
+
React.createElement(Stack, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
63
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "none", variant: "primary" }), ICONS.DeleteIcon),
|
|
64
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "none", variant: "secondary" }), ICONS.DeleteIcon),
|
|
65
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "none", variant: "tertiary" }), ICONS.DeleteIcon),
|
|
66
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "none", variant: "bordered" }), ICONS.DeleteIcon),
|
|
67
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "none", variant: "text" }), ICONS.DeleteIcon)),
|
|
68
|
+
React.createElement(Stack, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
69
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "rounded", variant: "primary" }), ICONS.DeleteIcon),
|
|
70
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "rounded", variant: "secondary" }), ICONS.DeleteIcon),
|
|
71
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "rounded", variant: "tertiary" }), ICONS.DeleteIcon),
|
|
72
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "rounded", variant: "bordered" }), ICONS.DeleteIcon),
|
|
73
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "rounded", variant: "text" }), ICONS.DeleteIcon)),
|
|
74
|
+
React.createElement(Stack, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
75
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "circular", variant: "primary" }), ICONS.DeleteIcon),
|
|
76
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "circular", variant: "secondary" }), ICONS.DeleteIcon),
|
|
77
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "circular", variant: "tertiary" }), ICONS.DeleteIcon),
|
|
78
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "circular", variant: "bordered" }), ICONS.DeleteIcon),
|
|
79
|
+
React.createElement(ActionButton, Object.assign({}, args, { edge: "circular", variant: "text" }), ICONS.DeleteIcon)))),
|
|
80
|
+
tags: ["main"],
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* `ActionButtonLink` is styled as a `ActionButton` that renders an anchor tag.
|
|
84
|
+
*
|
|
85
|
+
* To use a custom link component (E.g. `Link` from `react-router` or `next/link`),
|
|
86
|
+
* pass it as the `Component` prop. Alternatively, customize the project-wide
|
|
87
|
+
* default link adapter via [Theme's LinkAdapter](../?path=/docs/smoot-design-themeprovider--docs)
|
|
88
|
+
*/
|
|
89
|
+
export const Links = {
|
|
90
|
+
render: () => (React.createElement(Stack, { direction: "row", gap: 2, sx: { my: 2 } },
|
|
91
|
+
React.createElement(ActionButtonLink, { href: "#fake", variant: "primary" }, ICONS.DeleteIcon),
|
|
92
|
+
React.createElement(ActionButtonLink, { href: "#fake", variant: "secondary" }, ICONS.DeleteIcon),
|
|
93
|
+
React.createElement(ActionButtonLink, { href: "#fake", variant: "tertiary" }, ICONS.DeleteIcon),
|
|
94
|
+
React.createElement(ActionButtonLink, { href: "#fake", variant: "bordered" }, ICONS.DeleteIcon),
|
|
95
|
+
React.createElement(ActionButtonLink, { href: "#fake", variant: "text" }, ICONS.DeleteIcon))),
|
|
96
|
+
};
|
|
97
|
+
export const Showcase = {
|
|
98
|
+
render: (args) => (React.createElement(Grid, { container: true, sx: { maxWidth: "750px" }, rowGap: 2 }, STABLE_VARIANTS.flatMap((variant) => EDGES.flatMap((edge) => (React.createElement(React.Fragment, { key: `${variant}-${edge}` },
|
|
99
|
+
React.createElement(Grid, { size: { xs: 12, sm: 3 }, alignItems: "center" },
|
|
100
|
+
React.createElement("code", null,
|
|
101
|
+
"variant=",
|
|
102
|
+
variant,
|
|
103
|
+
React.createElement("br", null),
|
|
104
|
+
"edge=",
|
|
105
|
+
edge)),
|
|
106
|
+
SIZES.flatMap((size) => Object.entries(ICONS)
|
|
107
|
+
.filter(([_key, icon]) => icon)
|
|
108
|
+
.map(([iconKey, icon]) => (React.createElement(Grid, { size: { xs: 4, sm: 1 }, key: `${size}-${iconKey}` },
|
|
109
|
+
React.createElement(ActionButton, Object.assign({ variant: variant, edge: edge, size: size }, args), icon))))))))))),
|
|
110
|
+
};
|