@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.
Files changed (243) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +31 -0
  3. package/dist/bundles/remoteTutorDrawer.es.js +38347 -0
  4. package/dist/bundles/remoteTutorDrawer.umd.js +207 -0
  5. package/dist/cjs/ai.d.ts +3 -0
  6. package/dist/cjs/ai.js +5 -0
  7. package/dist/cjs/bundles/RemoteTutorDrawer/FlashcardsScreen.d.ts +9 -0
  8. package/dist/cjs/bundles/RemoteTutorDrawer/FlashcardsScreen.js +87 -0
  9. package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.d.ts +57 -0
  10. package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.js +276 -0
  11. package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts +16 -0
  12. package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.js +283 -0
  13. package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts +1 -0
  14. package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.js +241 -0
  15. package/dist/cjs/bundles/remoteTutorDrawer.d.ts +7 -0
  16. package/dist/cjs/bundles/remoteTutorDrawer.js +40 -0
  17. package/dist/cjs/components/AiChat/AiChat.d.ts +5 -0
  18. package/dist/cjs/components/AiChat/AiChat.js +247 -0
  19. package/dist/cjs/components/AiChat/AiChat.stories.d.ts +21 -0
  20. package/dist/cjs/components/AiChat/AiChat.stories.js +243 -0
  21. package/dist/cjs/components/AiChat/AiChat.test.d.ts +1 -0
  22. package/dist/cjs/components/AiChat/AiChat.test.js +211 -0
  23. package/dist/cjs/components/AiChat/ChatTitle.d.ts +8 -0
  24. package/dist/cjs/components/AiChat/ChatTitle.js +43 -0
  25. package/dist/cjs/components/AiChat/EntryScreen.d.ts +11 -0
  26. package/dist/cjs/components/AiChat/EntryScreen.js +123 -0
  27. package/dist/cjs/components/AiChat/TimLogo.d.ts +5 -0
  28. package/dist/cjs/components/AiChat/TimLogo.js +15 -0
  29. package/dist/cjs/components/AiChat/test-utils/api.d.ts +2 -0
  30. package/dist/cjs/components/AiChat/test-utils/api.js +125 -0
  31. package/dist/cjs/components/AiChat/types.d.ts +82 -0
  32. package/dist/cjs/components/AiChat/types.js +3 -0
  33. package/dist/cjs/components/AiChat/utils.d.ts +9 -0
  34. package/dist/cjs/components/AiChat/utils.js +41 -0
  35. package/dist/cjs/components/Alert/Alert.d.ts +15 -0
  36. package/dist/cjs/components/Alert/Alert.js +62 -0
  37. package/dist/cjs/components/Alert/Alert.stories.d.ts +8 -0
  38. package/dist/cjs/components/Alert/Alert.stories.js +53 -0
  39. package/dist/cjs/components/Button/ActionButton.d.ts +30 -0
  40. package/dist/cjs/components/Button/ActionButton.js +73 -0
  41. package/dist/cjs/components/Button/ActionButton.stories.d.ts +15 -0
  42. package/dist/cjs/components/Button/ActionButton.stories.js +113 -0
  43. package/dist/cjs/components/Button/Button.d.ts +54 -0
  44. package/dist/cjs/components/Button/Button.js +240 -0
  45. package/dist/cjs/components/Button/Button.stories.d.ts +17 -0
  46. package/dist/cjs/components/Button/Button.stories.js +135 -0
  47. package/dist/cjs/components/Button/Button.test.d.ts +1 -0
  48. package/dist/cjs/components/Button/Button.test.js +46 -0
  49. package/dist/cjs/components/ImageAdapter/ImageAdapter.d.ts +23 -0
  50. package/dist/cjs/components/ImageAdapter/ImageAdapter.js +30 -0
  51. package/dist/cjs/components/Input/Input.d.ts +116 -0
  52. package/dist/cjs/components/Input/Input.js +237 -0
  53. package/dist/cjs/components/Input/Input.stories.d.ts +19 -0
  54. package/dist/cjs/components/Input/Input.stories.js +135 -0
  55. package/dist/cjs/components/Input/Input.test.d.ts +1 -0
  56. package/dist/cjs/components/Input/Input.test.js +32 -0
  57. package/dist/cjs/components/LinkAdapter/LinkAdapter.d.ts +23 -0
  58. package/dist/cjs/components/LinkAdapter/LinkAdapter.js +34 -0
  59. package/dist/cjs/components/ScrollSnap/ScrollSnap.d.ts +19 -0
  60. package/dist/cjs/components/ScrollSnap/ScrollSnap.js +59 -0
  61. package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
  62. package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.js +43 -0
  63. package/dist/cjs/components/ScrollSnap/useScrollSnap.d.ts +6 -0
  64. package/dist/cjs/components/ScrollSnap/useScrollSnap.js +36 -0
  65. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
  66. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.js +43 -0
  67. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
  68. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.js +44 -0
  69. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
  70. package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.js +62 -0
  71. package/dist/cjs/components/TabButtons/TabButtonList.d.ts +25 -0
  72. package/dist/cjs/components/TabButtons/TabButtonList.js +97 -0
  73. package/dist/cjs/components/TabButtons/TabButtonList.stories.d.ts +24 -0
  74. package/dist/cjs/components/TabButtons/TabButtonList.stories.js +139 -0
  75. package/dist/cjs/components/TextField/TextField.d.ts +29 -0
  76. package/dist/cjs/components/TextField/TextField.js +33 -0
  77. package/dist/cjs/components/TextField/TextField.stories.d.ts +10 -0
  78. package/dist/cjs/components/TextField/TextField.stories.js +136 -0
  79. package/dist/cjs/components/TextField/TextField.test.d.ts +1 -0
  80. package/dist/cjs/components/TextField/TextField.test.js +77 -0
  81. package/dist/cjs/components/ThemeProvider/ThemeProvider.d.ts +21 -0
  82. package/dist/cjs/components/ThemeProvider/ThemeProvider.js +86 -0
  83. package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.d.ts +63 -0
  84. package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.js +102 -0
  85. package/dist/cjs/components/ThemeProvider/Typography.stories.d.ts +39 -0
  86. package/dist/cjs/components/ThemeProvider/Typography.stories.js +65 -0
  87. package/dist/cjs/components/ThemeProvider/breakpoints.d.ts +4 -0
  88. package/dist/cjs/components/ThemeProvider/breakpoints.js +19 -0
  89. package/dist/cjs/components/ThemeProvider/buttons.d.ts +7 -0
  90. package/dist/cjs/components/ThemeProvider/buttons.js +20 -0
  91. package/dist/cjs/components/ThemeProvider/chips.d.ts +3 -0
  92. package/dist/cjs/components/ThemeProvider/chips.js +154 -0
  93. package/dist/cjs/components/ThemeProvider/colors.d.ts +32 -0
  94. package/dist/cjs/components/ThemeProvider/colors.js +35 -0
  95. package/dist/cjs/components/ThemeProvider/typography.d.ts +18 -0
  96. package/dist/cjs/components/ThemeProvider/typography.js +173 -0
  97. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
  98. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.js +33 -0
  99. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
  100. package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.js +13 -0
  101. package/dist/cjs/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
  102. package/dist/cjs/components/internal/FormHelpers/FormHelpers.js +78 -0
  103. package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
  104. package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.js +93 -0
  105. package/dist/cjs/index.d.ts +16 -0
  106. package/dist/cjs/index.js +30 -0
  107. package/dist/cjs/jest-setup.d.ts +1 -0
  108. package/dist/cjs/jest-setup.js +18 -0
  109. package/dist/cjs/jsdom-extended.d.ts +6 -0
  110. package/dist/cjs/jsdom-extended.js +14 -0
  111. package/dist/cjs/story-utils/index.d.ts +6 -0
  112. package/dist/cjs/story-utils/index.js +17 -0
  113. package/dist/cjs/utils/composeRefs.d.ts +7 -0
  114. package/dist/cjs/utils/composeRefs.js +20 -0
  115. package/dist/cjs/utils/composeRefs.test.d.ts +1 -0
  116. package/dist/cjs/utils/composeRefs.test.js +19 -0
  117. package/dist/cjs/utils/useDevCheckStable.d.ts +8 -0
  118. package/dist/cjs/utils/useDevCheckStable.js +29 -0
  119. package/dist/cjs/utils/useInterval.d.ts +7 -0
  120. package/dist/cjs/utils/useInterval.js +25 -0
  121. package/dist/esm/ai.d.ts +3 -0
  122. package/dist/esm/ai.js +1 -0
  123. package/dist/esm/bundles/RemoteTutorDrawer/FlashcardsScreen.d.ts +9 -0
  124. package/dist/esm/bundles/RemoteTutorDrawer/FlashcardsScreen.js +83 -0
  125. package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.d.ts +57 -0
  126. package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.js +273 -0
  127. package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts +16 -0
  128. package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.js +280 -0
  129. package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts +1 -0
  130. package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.js +239 -0
  131. package/dist/esm/bundles/remoteTutorDrawer.d.ts +7 -0
  132. package/dist/esm/bundles/remoteTutorDrawer.js +37 -0
  133. package/dist/esm/components/AiChat/AiChat.d.ts +5 -0
  134. package/dist/esm/components/AiChat/AiChat.js +244 -0
  135. package/dist/esm/components/AiChat/AiChat.stories.d.ts +21 -0
  136. package/dist/esm/components/AiChat/AiChat.stories.js +240 -0
  137. package/dist/esm/components/AiChat/AiChat.test.d.ts +1 -0
  138. package/dist/esm/components/AiChat/AiChat.test.js +209 -0
  139. package/dist/esm/components/AiChat/ChatTitle.d.ts +8 -0
  140. package/dist/esm/components/AiChat/ChatTitle.js +40 -0
  141. package/dist/esm/components/AiChat/EntryScreen.d.ts +11 -0
  142. package/dist/esm/components/AiChat/EntryScreen.js +120 -0
  143. package/dist/esm/components/AiChat/TimLogo.d.ts +5 -0
  144. package/dist/esm/components/AiChat/TimLogo.js +13 -0
  145. package/dist/esm/components/AiChat/test-utils/api.d.ts +2 -0
  146. package/dist/esm/components/AiChat/test-utils/api.js +122 -0
  147. package/dist/esm/components/AiChat/types.d.ts +82 -0
  148. package/dist/esm/components/AiChat/types.js +2 -0
  149. package/dist/esm/components/AiChat/utils.d.ts +9 -0
  150. package/dist/esm/components/AiChat/utils.js +38 -0
  151. package/dist/esm/components/Alert/Alert.d.ts +15 -0
  152. package/dist/esm/components/Alert/Alert.js +59 -0
  153. package/dist/esm/components/Alert/Alert.stories.d.ts +8 -0
  154. package/dist/esm/components/Alert/Alert.stories.js +50 -0
  155. package/dist/esm/components/Button/ActionButton.d.ts +30 -0
  156. package/dist/esm/components/Button/ActionButton.js +68 -0
  157. package/dist/esm/components/Button/ActionButton.stories.d.ts +15 -0
  158. package/dist/esm/components/Button/ActionButton.stories.js +110 -0
  159. package/dist/esm/components/Button/Button.d.ts +54 -0
  160. package/dist/esm/components/Button/Button.js +232 -0
  161. package/dist/esm/components/Button/Button.stories.d.ts +17 -0
  162. package/dist/esm/components/Button/Button.stories.js +132 -0
  163. package/dist/esm/components/Button/Button.test.d.ts +1 -0
  164. package/dist/esm/components/Button/Button.test.js +44 -0
  165. package/dist/esm/components/ImageAdapter/ImageAdapter.d.ts +23 -0
  166. package/dist/esm/components/ImageAdapter/ImageAdapter.js +27 -0
  167. package/dist/esm/components/Input/Input.d.ts +116 -0
  168. package/dist/esm/components/Input/Input.js +232 -0
  169. package/dist/esm/components/Input/Input.stories.d.ts +19 -0
  170. package/dist/esm/components/Input/Input.stories.js +132 -0
  171. package/dist/esm/components/Input/Input.test.d.ts +1 -0
  172. package/dist/esm/components/Input/Input.test.js +30 -0
  173. package/dist/esm/components/LinkAdapter/LinkAdapter.d.ts +23 -0
  174. package/dist/esm/components/LinkAdapter/LinkAdapter.js +31 -0
  175. package/dist/esm/components/ScrollSnap/ScrollSnap.d.ts +19 -0
  176. package/dist/esm/components/ScrollSnap/ScrollSnap.js +56 -0
  177. package/dist/esm/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
  178. package/dist/esm/components/ScrollSnap/ScrollSnap.stories.js +40 -0
  179. package/dist/esm/components/ScrollSnap/useScrollSnap.d.ts +6 -0
  180. package/dist/esm/components/ScrollSnap/useScrollSnap.js +33 -0
  181. package/dist/esm/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
  182. package/dist/esm/components/SrAnnouncer/SrAnnouncer.js +40 -0
  183. package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
  184. package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.js +41 -0
  185. package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
  186. package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.js +60 -0
  187. package/dist/esm/components/TabButtons/TabButtonList.d.ts +25 -0
  188. package/dist/esm/components/TabButtons/TabButtonList.js +92 -0
  189. package/dist/esm/components/TabButtons/TabButtonList.stories.d.ts +24 -0
  190. package/dist/esm/components/TabButtons/TabButtonList.stories.js +136 -0
  191. package/dist/esm/components/TextField/TextField.d.ts +29 -0
  192. package/dist/esm/components/TextField/TextField.js +30 -0
  193. package/dist/esm/components/TextField/TextField.stories.d.ts +10 -0
  194. package/dist/esm/components/TextField/TextField.stories.js +133 -0
  195. package/dist/esm/components/TextField/TextField.test.d.ts +1 -0
  196. package/dist/esm/components/TextField/TextField.test.js +75 -0
  197. package/dist/esm/components/ThemeProvider/ThemeProvider.d.ts +21 -0
  198. package/dist/esm/components/ThemeProvider/ThemeProvider.js +82 -0
  199. package/dist/esm/components/ThemeProvider/ThemeProvider.stories.d.ts +63 -0
  200. package/dist/esm/components/ThemeProvider/ThemeProvider.stories.js +99 -0
  201. package/dist/esm/components/ThemeProvider/Typography.stories.d.ts +39 -0
  202. package/dist/esm/components/ThemeProvider/Typography.stories.js +62 -0
  203. package/dist/esm/components/ThemeProvider/breakpoints.d.ts +4 -0
  204. package/dist/esm/components/ThemeProvider/breakpoints.js +15 -0
  205. package/dist/esm/components/ThemeProvider/buttons.d.ts +7 -0
  206. package/dist/esm/components/ThemeProvider/buttons.js +17 -0
  207. package/dist/esm/components/ThemeProvider/chips.d.ts +3 -0
  208. package/dist/esm/components/ThemeProvider/chips.js +151 -0
  209. package/dist/esm/components/ThemeProvider/colors.d.ts +32 -0
  210. package/dist/esm/components/ThemeProvider/colors.js +32 -0
  211. package/dist/esm/components/ThemeProvider/typography.d.ts +18 -0
  212. package/dist/esm/components/ThemeProvider/typography.js +167 -0
  213. package/dist/esm/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
  214. package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +30 -0
  215. package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
  216. package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.js +10 -0
  217. package/dist/esm/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
  218. package/dist/esm/components/internal/FormHelpers/FormHelpers.js +73 -0
  219. package/dist/esm/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
  220. package/dist/esm/components/internal/FormHelpers/FormHelpers.test.js +91 -0
  221. package/dist/esm/index.d.ts +16 -0
  222. package/dist/esm/index.js +11 -0
  223. package/dist/esm/jest-setup.d.ts +1 -0
  224. package/dist/esm/jest-setup.js +16 -0
  225. package/dist/esm/jsdom-extended.d.ts +6 -0
  226. package/dist/esm/jsdom-extended.js +12 -0
  227. package/dist/esm/story-utils/index.d.ts +6 -0
  228. package/dist/esm/story-utils/index.js +13 -0
  229. package/dist/esm/utils/composeRefs.d.ts +7 -0
  230. package/dist/esm/utils/composeRefs.js +17 -0
  231. package/dist/esm/utils/composeRefs.test.d.ts +1 -0
  232. package/dist/esm/utils/composeRefs.test.js +17 -0
  233. package/dist/esm/utils/useDevCheckStable.d.ts +8 -0
  234. package/dist/esm/utils/useDevCheckStable.js +26 -0
  235. package/dist/esm/utils/useInterval.d.ts +7 -0
  236. package/dist/esm/utils/useInterval.js +22 -0
  237. package/dist/tsconfig.tsbuildinfo +1 -0
  238. package/dist/type-augmentation/TypescriptDocs.mdx +17 -0
  239. package/dist/type-augmentation/imports.d.ts +3 -0
  240. package/dist/type-augmentation/index.d.ts +3 -0
  241. package/dist/type-augmentation/theme.d.ts +105 -0
  242. package/dist/type-augmentation/typography.d.ts +54 -0
  243. package/package.json +155 -0
@@ -0,0 +1,32 @@
1
+ const colors = {
2
+ mitRed: "#750014",
3
+ brightRed: "#FF1423",
4
+ black: "#000000",
5
+ white: "#FFFFFF",
6
+ darkGray2: "#212326",
7
+ darkGray1: "#40464C",
8
+ silverGrayDark: "#626A73",
9
+ silverGray: "#8B959E",
10
+ silverGrayLight: "#B8C2CC",
11
+ lightGray2: "#DDE1E6",
12
+ lightGray1: "#F3F4F8",
13
+ navGray: "#303337",
14
+ darkPink: "#750062",
15
+ pink: "#FF14F0",
16
+ lightPink: "#FFB3FF",
17
+ darkPurple: "#3E006B",
18
+ purple: "#93F",
19
+ lightPurple: "#BFB3FF",
20
+ darkBlue: "#002896",
21
+ blue: "#1966FF",
22
+ lightBlue: "#99EBFF",
23
+ darkGreen: "#004D1A",
24
+ green: "#00AD00",
25
+ lightGreen: "#AF3",
26
+ darkRed: "#83192A",
27
+ red: "#A31F34",
28
+ lightRed: "#D02E44",
29
+ orange: "#FAB005",
30
+ yellow: "#FFEB00",
31
+ };
32
+ export { colors };
@@ -0,0 +1,18 @@
1
+ import type { ThemeOptions } from "@mui/material/styles";
2
+ /**
3
+ * This function converts from pixels to rems, assuming a base font size of 16px
4
+ * (which is the default for most modern browsers).
5
+ *
6
+ * Using this function, we can:
7
+ * - match desgins that are in pixels for default font size
8
+ * - allow users to scale the font size up or down by chaning base font size.
9
+ *
10
+ * For example, a Chrome user might specify a base font size of 20px ("large")
11
+ * in their browser settings. Then, `pxToRem(32)` would actually be 40px for
12
+ * that user.
13
+ */
14
+ declare const pxToRem: (px: number) => string;
15
+ declare const globalSettings: ThemeOptions["typography"];
16
+ declare const component: NonNullable<ThemeOptions["components"]>["MuiTypography"];
17
+ declare const typography: import("@mui/material/styles").TypographyVariants;
18
+ export { globalSettings, component, pxToRem, typography };
@@ -0,0 +1,167 @@
1
+ import { createTheme } from "@mui/material/styles";
2
+ const fontWeights = {
3
+ text: {
4
+ roman: 400,
5
+ medium: 500,
6
+ bold: 700,
7
+ },
8
+ };
9
+ /**
10
+ * This function converts from pixels to rems, assuming a base font size of 16px
11
+ * (which is the default for most modern browsers).
12
+ *
13
+ * Using this function, we can:
14
+ * - match desgins that are in pixels for default font size
15
+ * - allow users to scale the font size up or down by chaning base font size.
16
+ *
17
+ * For example, a Chrome user might specify a base font size of 20px ("large")
18
+ * in their browser settings. Then, `pxToRem(32)` would actually be 40px for
19
+ * that user.
20
+ */
21
+ const pxToRem = (px) => `${px / 16}rem`;
22
+ const globalSettings = {
23
+ // Note: Figma calls this "Neue Haas Grotesk Text", but that is incorrect based on Adobe's font family.
24
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
25
+ fontWeightLight: fontWeights.text.roman,
26
+ fontWeightRegular: fontWeights.text.roman,
27
+ fontWeightMedium: fontWeights.text.medium,
28
+ fontWeightBold: fontWeights.text.bold,
29
+ h1: {
30
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
31
+ fontWeight: fontWeights.text.bold,
32
+ fontStyle: "normal",
33
+ fontSize: pxToRem(52),
34
+ lineHeight: pxToRem(60),
35
+ },
36
+ h2: {
37
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
38
+ fontWeight: fontWeights.text.bold,
39
+ fontStyle: "normal",
40
+ fontSize: pxToRem(34),
41
+ lineHeight: pxToRem(40),
42
+ },
43
+ h3: {
44
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
45
+ fontWeight: fontWeights.text.bold,
46
+ fontStyle: "normal",
47
+ fontSize: pxToRem(28),
48
+ lineHeight: pxToRem(36),
49
+ },
50
+ h4: {
51
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
52
+ fontWeight: fontWeights.text.bold,
53
+ fontStyle: "normal",
54
+ fontSize: pxToRem(24),
55
+ lineHeight: pxToRem(30),
56
+ },
57
+ h5: {
58
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
59
+ fontWeight: fontWeights.text.medium,
60
+ fontStyle: "normal",
61
+ fontSize: pxToRem(18),
62
+ lineHeight: pxToRem(22),
63
+ },
64
+ subtitle1: {
65
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
66
+ fontWeight: fontWeights.text.medium,
67
+ fontStyle: "normal",
68
+ fontSize: pxToRem(16),
69
+ lineHeight: pxToRem(20),
70
+ },
71
+ subtitle2: {
72
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
73
+ fontWeight: fontWeights.text.medium,
74
+ fontStyle: "normal",
75
+ fontSize: pxToRem(14),
76
+ lineHeight: pxToRem(18),
77
+ },
78
+ subtitle3: {
79
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
80
+ fontWeight: fontWeights.text.medium,
81
+ fontStyle: "normal",
82
+ fontSize: pxToRem(12),
83
+ lineHeight: pxToRem(16),
84
+ },
85
+ subtitle4: {
86
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
87
+ fontWeight: fontWeights.text.medium,
88
+ fontStyle: "normal",
89
+ fontSize: pxToRem(10),
90
+ lineHeight: pxToRem(14),
91
+ },
92
+ body1: {
93
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
94
+ fontWeight: fontWeights.text.roman,
95
+ fontStyle: "normal",
96
+ fontSize: pxToRem(16),
97
+ lineHeight: pxToRem(20),
98
+ },
99
+ body2: {
100
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
101
+ fontWeight: fontWeights.text.roman,
102
+ fontStyle: "normal",
103
+ fontSize: pxToRem(14),
104
+ lineHeight: pxToRem(18),
105
+ },
106
+ body3: {
107
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
108
+ fontWeight: fontWeights.text.roman,
109
+ fontStyle: "normal",
110
+ fontSize: pxToRem(12),
111
+ lineHeight: pxToRem(16),
112
+ },
113
+ body4: {
114
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
115
+ fontWeight: fontWeights.text.roman,
116
+ fontStyle: "normal",
117
+ fontSize: pxToRem(10),
118
+ lineHeight: pxToRem(14),
119
+ },
120
+ buttonLarge: {
121
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
122
+ fontWeight: fontWeights.text.medium,
123
+ fontStyle: "normal",
124
+ fontSize: pxToRem(16),
125
+ lineHeight: pxToRem(20),
126
+ },
127
+ button: {
128
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
129
+ fontWeight: fontWeights.text.medium,
130
+ fontStyle: "normal",
131
+ fontSize: pxToRem(14),
132
+ lineHeight: pxToRem(18),
133
+ textTransform: "none",
134
+ },
135
+ buttonSmall: {
136
+ fontFamily: "neue-haas-grotesk-text, sans-serif",
137
+ fontWeight: fontWeights.text.medium,
138
+ fontStyle: "normal",
139
+ fontSize: pxToRem(12),
140
+ lineHeight: pxToRem(16),
141
+ },
142
+ };
143
+ const component = {
144
+ defaultProps: {
145
+ variantMapping: {
146
+ h1: "span",
147
+ h2: "span",
148
+ h3: "span",
149
+ h4: "span",
150
+ h5: "span",
151
+ body1: "p",
152
+ body2: "p",
153
+ body3: "p",
154
+ body4: "p",
155
+ subtitle1: "p",
156
+ subtitle2: "p",
157
+ subtitle3: "p",
158
+ subtitle4: "p",
159
+ button: "span",
160
+ },
161
+ },
162
+ };
163
+ const { typography } = createTheme({
164
+ typography: globalSettings,
165
+ custom: {},
166
+ });
167
+ export { globalSettings, component, pxToRem, typography };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * VisuallyHidden is a utility component that hides its children from sighted
3
+ * users, but keeps them accessible to screen readers.
4
+ *
5
+ * Often, screenreader-only content can be handled with an `aria-label`. However,
6
+ * occasionally we need actual elements.
7
+ *
8
+ * Example:
9
+ * - a visually hidden aria-live section that reads announcements that
10
+ * isual users can ascertain in some other way.
11
+ * - a visually hidden Heading for a section whose purpose is clear for sighted users
12
+ * - a visually hidden description used for aria-describeddby
13
+ * - There is an aria-description attribute that can be used to provide a
14
+ * without an actual element on the page. However, it is introduced in
15
+ * ARIA 1.3 (working draft), not compatible with some screen readers, and
16
+ * flagged problematic by our linting.
17
+ *
18
+ * The CSS here is based on https://inclusive-components.design/tooltips-toggletips/
19
+ */
20
+ declare const VisuallyHidden: import("@emotion/styled").StyledComponent<{
21
+ theme?: import("@emotion/react").Theme;
22
+ as?: React.ElementType;
23
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
24
+ export { VisuallyHidden };
@@ -0,0 +1,30 @@
1
+ import styled from "@emotion/styled";
2
+ /**
3
+ * VisuallyHidden is a utility component that hides its children from sighted
4
+ * users, but keeps them accessible to screen readers.
5
+ *
6
+ * Often, screenreader-only content can be handled with an `aria-label`. However,
7
+ * occasionally we need actual elements.
8
+ *
9
+ * Example:
10
+ * - a visually hidden aria-live section that reads announcements that
11
+ * isual users can ascertain in some other way.
12
+ * - a visually hidden Heading for a section whose purpose is clear for sighted users
13
+ * - a visually hidden description used for aria-describeddby
14
+ * - There is an aria-description attribute that can be used to provide a
15
+ * without an actual element on the page. However, it is introduced in
16
+ * ARIA 1.3 (working draft), not compatible with some screen readers, and
17
+ * flagged problematic by our linting.
18
+ *
19
+ * The CSS here is based on https://inclusive-components.design/tooltips-toggletips/
20
+ */
21
+ const VisuallyHidden = styled.span({
22
+ clipPath: "inset(100%)",
23
+ clip: "rect(1px, 1px, 1px, 1px)",
24
+ height: "1px",
25
+ overflow: "hidden",
26
+ position: "absolute",
27
+ whiteSpace: "nowrap",
28
+ width: "1px",
29
+ });
30
+ export { VisuallyHidden };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { VisuallyHidden } from "./VisuallyHidden";
3
+ declare const meta: Meta<typeof VisuallyHidden>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof VisuallyHidden>;
6
+ export declare const ScreenreaderOnly: Story;
@@ -0,0 +1,10 @@
1
+ import { VisuallyHidden } from "./VisuallyHidden";
2
+ const meta = {
3
+ title: "smoot-design/VisuallyHidden",
4
+ component: VisuallyHidden,
5
+ args: {
6
+ children: "Not visible, but screen readers can still read this text.",
7
+ },
8
+ };
9
+ export default meta;
10
+ export const ScreenreaderOnly = {};
@@ -0,0 +1,39 @@
1
+ import * as React from "react";
2
+ declare const Description: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme;
4
+ as?: React.ElementType;
5
+ } & {
6
+ error?: boolean;
7
+ }, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
8
+ type ControlLabelProps = {
9
+ htmlFor: string;
10
+ label: React.ReactNode;
11
+ required?: boolean;
12
+ id?: string;
13
+ fullWidth?: boolean;
14
+ };
15
+ declare const ControlLabel: React.FC<ControlLabelProps>;
16
+ type FormFieldWrapperProps = {
17
+ label: React.ReactNode;
18
+ required?: boolean;
19
+ helpText?: string;
20
+ error?: boolean;
21
+ errorText?: string;
22
+ className?: string;
23
+ fullWidth?: boolean;
24
+ /**
25
+ * The id of the input element. If not provided, a unique id will be generated.
26
+ */
27
+ id?: string;
28
+ children: (childProps: {
29
+ id: string;
30
+ required?: boolean;
31
+ error?: boolean;
32
+ fullWidth?: boolean;
33
+ labelId: string;
34
+ "aria-describedby"?: string;
35
+ }) => React.ReactNode;
36
+ };
37
+ declare const FormFieldWrapper: React.FC<FormFieldWrapperProps>;
38
+ export { FormFieldWrapper, ControlLabel, Description };
39
+ export type { FormFieldWrapperProps, ControlLabelProps };
@@ -0,0 +1,73 @@
1
+ import * as React from "react";
2
+ import styled from "@emotion/styled";
3
+ import { RiErrorWarningLine } from "@remixicon/react";
4
+ import Typography from "@mui/material/Typography";
5
+ const Required = styled.span(({ theme }) => ({
6
+ color: theme.custom.colors.lightRed,
7
+ marginLeft: "4px",
8
+ }));
9
+ const Description = styled.div(({ theme, error }) => [
10
+ Object.assign(Object.assign({}, theme.typography.body2), { color: error
11
+ ? theme.custom.colors.lightRed
12
+ : theme.custom.colors.silverGrayDark }),
13
+ error && {
14
+ textIndent: "-24px",
15
+ paddingLeft: "24px",
16
+ "> svg:first-of-type": {
17
+ marginRight: "4px",
18
+ transform: "translateY(2px)",
19
+ width: "18px",
20
+ height: "18px",
21
+ position: "relative",
22
+ top: "2px",
23
+ },
24
+ },
25
+ ]);
26
+ const Container = styled.div(({ fullWidth }) => [
27
+ {
28
+ display: "inline-flex",
29
+ flexDirection: "column",
30
+ alignItems: "start",
31
+ "> *:not(:last-child)": {
32
+ marginBottom: "4px",
33
+ },
34
+ },
35
+ fullWidth && {
36
+ width: "100%",
37
+ },
38
+ ]);
39
+ const ControlLabel = ({ htmlFor, label, required, id, fullWidth, }) => {
40
+ return (React.createElement(Typography, { id: id, component: "label", htmlFor: htmlFor, variant: "subtitle2", sx: { marginBottom: "4px", width: fullWidth ? "100%" : "auto" } },
41
+ label,
42
+ required ? React.createElement(Required, { "aria-hidden": "true" }, "*") : null));
43
+ };
44
+ const FormFieldWrapper = ({ label, required, helpText, error, errorText, className, fullWidth, id, children, }) => {
45
+ const fallbackInputId = React.useId();
46
+ const inputId = id || fallbackInputId;
47
+ const helpId = React.useId();
48
+ const errorId = React.useId();
49
+ const labelId = React.useId();
50
+ /**
51
+ * aria-errormessage would be more semantic for the error message but has
52
+ * somewhat limited support. See https://github.com/w3c/aria/issues/2048 for
53
+ * some related information.
54
+ */
55
+ const describedBy = [helpText && helpId, error && errorText && errorId]
56
+ .filter(Boolean)
57
+ .join(" ") || undefined;
58
+ return (React.createElement(Container, { className: className, fullWidth: fullWidth },
59
+ React.createElement(ControlLabel, { htmlFor: inputId, id: labelId, label: label, required: required, fullWidth: fullWidth }),
60
+ children({
61
+ id: inputId,
62
+ error,
63
+ required,
64
+ labelId,
65
+ fullWidth,
66
+ "aria-describedby": describedBy,
67
+ }),
68
+ helpText && React.createElement(Description, { id: helpId }, helpText),
69
+ error && errorText && (React.createElement(Description, { id: errorId, error: true },
70
+ React.createElement(RiErrorWarningLine, { fontSize: "inherit" }),
71
+ errorText))));
72
+ };
73
+ export { FormFieldWrapper, ControlLabel, Description };
@@ -0,0 +1,91 @@
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 { render, screen } from "@testing-library/react";
14
+ import { FormFieldWrapper } from "./FormHelpers";
15
+ import { ThemeProvider } from "../../../components/ThemeProvider/ThemeProvider";
16
+ import { faker } from "@faker-js/faker/locale/en";
17
+ const assertDescription = ({ text, total, exists, }) => {
18
+ var _a;
19
+ const input = screen.getByRole("textbox");
20
+ const describedBy = input.getAttribute("aria-describedby");
21
+ const descriptionIds = (_a = describedBy === null || describedBy === void 0 ? void 0 : describedBy.split(" ")) !== null && _a !== void 0 ? _a : [];
22
+ if (total === 0) {
23
+ expect(describedBy).toBe(null);
24
+ }
25
+ expect(descriptionIds.length).toBe(total);
26
+ const description = screen.queryByText(text);
27
+ expect(!!description).toBe(exists);
28
+ if (exists) {
29
+ expect(description).toBeInTheDocument();
30
+ expect(descriptionIds).toContain(description === null || description === void 0 ? void 0 : description.id);
31
+ }
32
+ };
33
+ describe("FormFieldWrapper", () => {
34
+ const setup = (props) => {
35
+ const defaults = {
36
+ name: "test-name",
37
+ value: "test-value",
38
+ label: "test-label",
39
+ };
40
+ const { rerender: _rerender } = render(React.createElement(FormFieldWrapper, Object.assign({}, defaults, props), (_a) => {
41
+ var { error, labelId, fullWidth } = _a, childProps = __rest(_a, ["error", "labelId", "fullWidth"]);
42
+ return (React.createElement("input", Object.assign({}, childProps)));
43
+ }), {
44
+ wrapper: ThemeProvider,
45
+ });
46
+ const rerender = (newProps) => {
47
+ _rerender(React.createElement(FormFieldWrapper, Object.assign({}, defaults, newProps), (_a) => {
48
+ var { error, labelId, fullWidth } = _a, childProps = __rest(_a, ["error", "labelId", "fullWidth"]);
49
+ return (React.createElement("input", Object.assign({}, childProps)));
50
+ }));
51
+ };
52
+ return { rerender };
53
+ };
54
+ it("Labels the input", () => {
55
+ const label = faker.lorem.words();
56
+ setup({ label });
57
+ const input = screen.getByRole("textbox", { name: label });
58
+ expect(input).toBeInstanceOf(HTMLInputElement);
59
+ });
60
+ it("Has a description only if description provided", () => {
61
+ const label = faker.lorem.words();
62
+ const helpText = faker.lorem.words();
63
+ const { rerender } = setup({ label, helpText });
64
+ assertDescription({ text: helpText, total: 1, exists: true });
65
+ rerender({ label });
66
+ assertDescription({ text: helpText, total: 0, exists: false });
67
+ });
68
+ it("Has an error message only if errorText provided AND error=true", () => {
69
+ const label = faker.lorem.words();
70
+ const errorText = faker.lorem.words();
71
+ const { rerender } = setup({ label, errorText, error: true });
72
+ assertDescription({ text: errorText, total: 1, exists: true });
73
+ rerender({ label, errorText });
74
+ assertDescription({ text: errorText, total: 0, exists: false });
75
+ rerender({ label, error: true });
76
+ assertDescription({ text: errorText, total: 0, exists: false });
77
+ rerender({ label, errorText, error: true });
78
+ assertDescription({ text: errorText, total: 1, exists: true });
79
+ });
80
+ it("Shows both description and errormessage if both provided and error", () => {
81
+ const label = faker.lorem.words();
82
+ const errorText = faker.lorem.words();
83
+ const helpText = faker.lorem.words();
84
+ const { rerender } = setup({ label, errorText, helpText });
85
+ assertDescription({ text: helpText, total: 1, exists: true });
86
+ assertDescription({ text: errorText, total: 1, exists: false });
87
+ rerender({ label, errorText, helpText, error: true });
88
+ assertDescription({ text: helpText, total: 2, exists: true });
89
+ assertDescription({ text: errorText, total: 2, exists: true });
90
+ });
91
+ });
@@ -0,0 +1,16 @@
1
+ export { default as styled } from "@emotion/styled";
2
+ export { css, Global } from "@emotion/react";
3
+ export { ThemeProvider, createTheme, } from "./components/ThemeProvider/ThemeProvider";
4
+ export { Button, ButtonLink } from "./components/Button/Button";
5
+ export type { ButtonProps, ButtonLinkProps } from "./components/Button/Button";
6
+ export { ActionButton, ActionButtonLink, } from "./components/Button/ActionButton";
7
+ export type { ActionButtonProps, ActionButtonLinkProps, } from "./components/Button/ActionButton";
8
+ export type { LinkAdapterPropsOverrides } from "./components/LinkAdapter/LinkAdapter";
9
+ export { Input } from "./components/Input/Input";
10
+ export type { InputProps } from "./components/Input/Input";
11
+ export { TextField } from "./components/TextField/TextField";
12
+ export type { TextFieldProps } from "./components/TextField/TextField";
13
+ export { SrAnnouncer } from "./components/SrAnnouncer/SrAnnouncer";
14
+ export type { SrAnnouncerProps } from "./components/SrAnnouncer/SrAnnouncer";
15
+ export { TabButton, TabButtonLink, TabButtonList, } from "./components/TabButtons/TabButtonList";
16
+ export { VisuallyHidden } from "./components/VisuallyHidden/VisuallyHidden";
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ export { default as styled } from "@emotion/styled";
3
+ export { css, Global } from "@emotion/react";
4
+ export { ThemeProvider, createTheme, } from "./components/ThemeProvider/ThemeProvider";
5
+ export { Button, ButtonLink } from "./components/Button/Button";
6
+ export { ActionButton, ActionButtonLink, } from "./components/Button/ActionButton";
7
+ export { Input } from "./components/Input/Input";
8
+ export { TextField } from "./components/TextField/TextField";
9
+ export { SrAnnouncer } from "./components/SrAnnouncer/SrAnnouncer";
10
+ export { TabButton, TabButtonLink, TabButtonList, } from "./components/TabButtons/TabButtonList";
11
+ export { VisuallyHidden } from "./components/VisuallyHidden/VisuallyHidden";
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom";
@@ -0,0 +1,16 @@
1
+ import "@testing-library/jest-dom";
2
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
3
+ const failOnConsole = require("jest-fail-on-console");
4
+ failOnConsole();
5
+ beforeAll(() => {
6
+ const scrollBy = jest.fn();
7
+ HTMLElement.prototype.scrollBy = scrollBy;
8
+ });
9
+ afterEach(() => {
10
+ /**
11
+ * Clear all mock call counts between tests.
12
+ * This does NOT clear mock implementations.
13
+ * Mock implementations are always cleared between test files.
14
+ */
15
+ jest.clearAllMocks();
16
+ });
@@ -0,0 +1,6 @@
1
+ import { TestEnvironment } from "jest-environment-jsdom";
2
+ import { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
3
+ declare class JSDOMEnvironmentExtended extends TestEnvironment {
4
+ constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
5
+ }
6
+ export default JSDOMEnvironmentExtended;
@@ -0,0 +1,12 @@
1
+ // Jest environment extended with Web APIs para tranbajar con MSW
2
+ import { TestEnvironment } from "jest-environment-jsdom";
3
+ class JSDOMEnvironmentExtended extends TestEnvironment {
4
+ constructor(config, context) {
5
+ super(config, context);
6
+ this.global.TransformStream = TransformStream;
7
+ this.global.ReadableStream = ReadableStream;
8
+ this.global.Response = Response;
9
+ this.global.TextDecoderStream = TextDecoderStream;
10
+ }
11
+ }
12
+ export default JSDOMEnvironmentExtended;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A type helper just to make sure an array contains union values.
3
+ */
4
+ declare const enumValues: <T extends string | undefined>(obj: Record<NonNullable<T>, unknown>) => NonNullable<T>[];
5
+ declare const gitLink: (filepath: string) => string;
6
+ export { enumValues, gitLink };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A type helper just to make sure an array contains union values.
3
+ */
4
+ const enumValues = (obj) => {
5
+ return Object.keys(obj);
6
+ };
7
+ const gitLink = (filepath) => {
8
+ if (!filepath.startsWith("src/")) {
9
+ throw new Error(`Invalid filepath: ${filepath}\nShould start with "src/"`);
10
+ }
11
+ return `https://github.com/mitodl/smoot-design/blob/${process.env.STORYBOOK_GIT_SHA}/${filepath}`;
12
+ };
13
+ export { enumValues, gitLink };
@@ -0,0 +1,7 @@
1
+ import type { MutableRefObject, ForwardedRef, RefCallback } from "react";
2
+ /**
3
+ * Compose 2+ refs. Useful when a reusable component needs a ref itself, but
4
+ * consumers may also need the ref.
5
+ */
6
+ declare const composeRefs: <T>(...refs: (ForwardedRef<T> | MutableRefObject<T | undefined> | RefCallback<T>)[]) => RefCallback<T>;
7
+ export { composeRefs };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Compose 2+ refs. Useful when a reusable component needs a ref itself, but
3
+ * consumers may also need the ref.
4
+ */
5
+ const composeRefs = (...refs) => {
6
+ return (value) => {
7
+ refs.forEach((ref) => {
8
+ if (typeof ref === "function") {
9
+ ref(value);
10
+ }
11
+ else if (ref) {
12
+ ref.current = value;
13
+ }
14
+ });
15
+ };
16
+ };
17
+ export { composeRefs };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { composeRefs } from "./composeRefs";
3
+ import { render, screen } from "@testing-library/react";
4
+ describe("composeRefs", () => {
5
+ test("Composing object + fn ref", () => {
6
+ const objRef1 = React.createRef();
7
+ const objRef2 = React.createRef();
8
+ const fnRef1 = jest.fn();
9
+ const fnRef2 = jest.fn();
10
+ render(React.createElement("div", { "data-testid": "my-div", ref: composeRefs(objRef1, objRef2, fnRef1, fnRef2) }));
11
+ const el = screen.getByTestId("my-div");
12
+ expect(objRef1.current).toBe(el);
13
+ expect(objRef2.current).toBe(el);
14
+ expect(fnRef1).toHaveBeenCalledWith(el);
15
+ expect(fnRef2).toHaveBeenCalledWith(el);
16
+ });
17
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Emits `console.error` if two subsequent values of `jsonSerializable` serialize
3
+ * to the same thing but are different references.
4
+ *
5
+ * This hook does NOT run in production.
6
+ */
7
+ declare const useDevCheckStable: (jsonSerializable: unknown, msg?: string) => void;
8
+ export { useDevCheckStable };