@ndlib/component-library 1.0.21 → 1.0.23

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 (259) hide show
  1. package/README.md +26 -8
  2. package/dist/assets/index-3cfb730f.js +1 -0
  3. package/dist/components/composites/Card/Card.stories.js +2 -0
  4. package/dist/components/composites/Card/index.js +4 -3
  5. package/dist/components/composites/CardV2/CardV2.module.css +74 -0
  6. package/dist/components/composites/CardV2/CardV2.stories.d.ts +19 -0
  7. package/dist/components/composites/CardV2/CardV2.stories.js +187 -0
  8. package/dist/components/composites/CardV2/CardV2.test.js +67 -0
  9. package/dist/components/composites/CardV2/index.d.ts +43 -0
  10. package/dist/components/composites/CardV2/index.js +99 -0
  11. package/dist/components/composites/DragDropList/DragDropList.stories.js +3 -1
  12. package/dist/components/composites/DropdownLinks/DropdownLinks.stories.js +2 -0
  13. package/dist/components/composites/DropdownLinks/index.d.ts +1 -1
  14. package/dist/components/composites/EmptyState/EmptyState.stories.js +2 -0
  15. package/dist/components/composites/EmptyState/index.js +1 -1
  16. package/dist/components/composites/Modal/Modal.stories.js +5 -2
  17. package/dist/components/composites/Modal/index.js +3 -2
  18. package/dist/components/composites/ModalV2/ModalV2.stories.d.ts +6 -0
  19. package/dist/components/composites/ModalV2/ModalV2.stories.js +41 -0
  20. package/dist/components/composites/ModalV2/ModalV2.test.js +37 -0
  21. package/dist/components/composites/ModalV2/index.d.ts +20 -0
  22. package/dist/components/composites/ModalV2/index.js +65 -0
  23. package/dist/components/composites/NavMenu/NavMenu.stories.js +2 -0
  24. package/dist/components/composites/NavMenu/index.js +1 -1
  25. package/dist/components/composites/Seo/seo.stories.js +2 -0
  26. package/dist/components/composites/SnackBar/SnackBar.stories.js +2 -0
  27. package/dist/components/composites/StructuredData/StructuredData.stories.js +2 -0
  28. package/dist/components/elements/Alerts/Alert.stories.js +2 -0
  29. package/dist/components/elements/Alerts/Alerts.stories.js +2 -0
  30. package/dist/components/elements/Alerts/index.js +2 -1
  31. package/dist/components/elements/ArrowLink/ArrowLink.stories.js +2 -0
  32. package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.stories.js +6 -4
  33. package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.test.js +1 -1
  34. package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/index.js +3 -3
  35. package/dist/components/elements/BrandingBar/BrandingBar.stories.js +2 -0
  36. package/dist/components/elements/Button/Button.stories.js +4 -2
  37. package/dist/components/elements/ButtonV2/ButtonV2.module.css +25 -0
  38. package/dist/components/elements/ButtonV2/ButtonV2.stories.d.ts +15 -0
  39. package/dist/components/elements/ButtonV2/ButtonV2.stories.js +90 -0
  40. package/dist/components/elements/ButtonV2/ButtonV2.test.js +45 -0
  41. package/dist/components/elements/ButtonV2/index.d.ts +51 -0
  42. package/dist/components/elements/ButtonV2/index.js +137 -0
  43. package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.stories.js +3 -1
  44. package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.test.js +1 -1
  45. package/dist/components/elements/{Fields/Checkbox → Checkbox}/index.d.ts +1 -1
  46. package/dist/components/elements/{Fields/Checkbox → Checkbox}/index.js +2 -2
  47. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.stories.js +3 -1
  48. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.test.js +1 -1
  49. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/index.d.ts +1 -1
  50. package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/index.js +7 -7
  51. package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.stories.d.ts +8 -0
  52. package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.stories.js +31 -0
  53. package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.test.js +34 -0
  54. package/dist/components/elements/CheckboxGroupV2/index.d.ts +17 -0
  55. package/dist/components/elements/CheckboxGroupV2/index.js +50 -0
  56. package/dist/components/elements/CheckboxV2/CheckboxV2.module.css +5 -0
  57. package/dist/components/elements/CheckboxV2/CheckboxV2.stories.d.ts +6 -0
  58. package/dist/components/elements/CheckboxV2/CheckboxV2.stories.js +19 -0
  59. package/dist/components/elements/CheckboxV2/CheckboxV2.test.js +35 -0
  60. package/dist/components/elements/CheckboxV2/index.d.ts +10 -0
  61. package/dist/components/elements/CheckboxV2/index.js +23 -0
  62. package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.stories.js +3 -1
  63. package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.test.js +1 -1
  64. package/dist/components/elements/{Fields/DatePicker → DatePicker}/index.d.ts +1 -1
  65. package/dist/components/elements/{Fields/DatePicker → DatePicker}/index.js +2 -2
  66. package/dist/components/elements/Dropdown/Dropdown.stories.js +3 -1
  67. package/dist/components/elements/Dropdown/index.js +1 -1
  68. package/dist/components/elements/GroupV2/index.d.ts +22 -0
  69. package/dist/components/elements/GroupV2/index.js +71 -0
  70. package/dist/components/elements/{text/Heading → Heading}/Heading.stories.js +5 -3
  71. package/dist/components/elements/{text/Heading → Heading}/Heading.test.js +3 -3
  72. package/dist/components/elements/{text/Heading → Heading}/index.d.ts +3 -3
  73. package/dist/components/elements/{text/Heading → Heading}/index.js +10 -9
  74. package/dist/components/elements/HeadingV2/HeadingV2.module.css +8 -0
  75. package/dist/components/elements/HeadingV2/HeadingV2.stories.d.ts +8 -0
  76. package/dist/components/elements/HeadingV2/HeadingV2.stories.js +37 -0
  77. package/dist/components/elements/HeadingV2/HeadingV2.test.js +51 -0
  78. package/dist/components/elements/HeadingV2/index.d.ts +23 -0
  79. package/dist/components/elements/HeadingV2/index.js +101 -0
  80. package/dist/components/elements/Icon/Icon.stories.js +3 -1
  81. package/dist/components/elements/IconV2/IconV2.module.css +10 -0
  82. package/dist/components/elements/IconV2/IconV2.stories.d.ts +7 -0
  83. package/dist/components/elements/IconV2/IconV2.stories.js +31 -0
  84. package/dist/components/elements/IconV2/IconV2.test.js +62 -0
  85. package/dist/components/elements/IconV2/index.d.ts +11 -0
  86. package/dist/components/elements/IconV2/index.js +34 -0
  87. package/dist/components/elements/{text/Inline → Inline}/Inline.stories.js +2 -0
  88. package/dist/components/elements/{text/Inline → Inline}/index.d.ts +1 -1
  89. package/dist/components/elements/{text/Inline → Inline}/index.js +1 -1
  90. package/dist/components/elements/{text/Label → Label}/Label.stories.js +4 -2
  91. package/dist/components/elements/Label/Label.test.d.ts +1 -0
  92. package/dist/components/elements/{text/Label → Label}/Label.test.js +3 -3
  93. package/dist/components/elements/{text/Label → Label}/index.d.ts +2 -2
  94. package/dist/components/elements/{text/Label → Label}/index.js +3 -3
  95. package/dist/components/elements/LabelV2/LabelV2.stories.d.ts +6 -0
  96. package/dist/components/elements/LabelV2/LabelV2.stories.js +22 -0
  97. package/dist/components/elements/LabelV2/LabelV2.test.d.ts +1 -0
  98. package/dist/components/elements/LabelV2/LabelV2.test.js +56 -0
  99. package/dist/components/elements/LabelV2/index.d.ts +20 -0
  100. package/dist/components/elements/LabelV2/index.js +41 -0
  101. package/dist/components/elements/Link/Link.stories.js +3 -1
  102. package/dist/components/elements/List/List.stories.js +3 -1
  103. package/dist/components/elements/List/index.js +1 -1
  104. package/dist/components/elements/ListBox/Listbox.stories.js +2 -0
  105. package/dist/components/elements/ListBox/index.d.ts +1 -1
  106. package/dist/components/elements/ListBox/index.js +1 -1
  107. package/dist/components/elements/ListBoxV2/ListBoxV2.module.css +33 -0
  108. package/dist/components/elements/ListBoxV2/ListBoxV2.stories.d.ts +6 -0
  109. package/dist/components/elements/ListBoxV2/ListBoxV2.stories.js +19 -0
  110. package/dist/components/elements/ListBoxV2/index.d.ts +35 -0
  111. package/dist/components/elements/ListBoxV2/index.js +36 -0
  112. package/dist/components/elements/Markdown/Markdown.stories.js +2 -0
  113. package/dist/components/elements/Markdown/index.js +4 -4
  114. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.stories.js +3 -1
  115. package/dist/components/elements/MonthPicker/MonthPicker.test.d.ts +1 -0
  116. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.test.js +1 -1
  117. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/index.d.ts +1 -1
  118. package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/index.js +2 -2
  119. package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.stories.js +5 -3
  120. package/dist/components/elements/Paragraph/Paragraph.test.d.ts +1 -0
  121. package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.test.js +1 -1
  122. package/dist/components/elements/{text/Paragraph → Paragraph}/index.d.ts +2 -2
  123. package/dist/components/elements/{text/Paragraph → Paragraph}/index.js +6 -5
  124. package/dist/components/elements/ParagraphV2/ParagraphV2.stories.d.ts +7 -0
  125. package/dist/components/elements/ParagraphV2/ParagraphV2.stories.js +33 -0
  126. package/dist/components/elements/ParagraphV2/ParagraphV2.test.d.ts +1 -0
  127. package/dist/components/elements/ParagraphV2/ParagraphV2.test.js +9 -0
  128. package/dist/components/elements/ParagraphV2/index.d.ts +15 -0
  129. package/dist/components/elements/ParagraphV2/index.js +39 -0
  130. package/dist/components/elements/Pill/Pill.stories.js +3 -1
  131. package/dist/components/elements/Pill/index.js +2 -1
  132. package/dist/components/elements/{Fields/Radio → Radio}/Radio.stories.js +3 -1
  133. package/dist/components/elements/Radio/Radio.test.d.ts +1 -0
  134. package/dist/components/elements/{Fields/Radio → Radio}/Radio.test.js +3 -3
  135. package/dist/components/elements/{Fields/Radio → Radio}/index.d.ts +1 -1
  136. package/dist/components/elements/{Fields/Radio → Radio}/index.js +1 -1
  137. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.stories.js +3 -1
  138. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.test.js +1 -1
  139. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/index.d.ts +1 -1
  140. package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/index.js +6 -6
  141. package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.stories.js +5 -3
  142. package/dist/components/elements/ReadMore/ReadMore.test.d.ts +1 -0
  143. package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.test.js +4 -9
  144. package/dist/components/elements/{text/ReadMore → ReadMore}/index.d.ts +2 -2
  145. package/dist/components/elements/{text/ReadMore → ReadMore}/index.js +10 -9
  146. package/dist/components/elements/ReadMoreV2/ReadMoreV2.module.css +19 -0
  147. package/dist/components/elements/ReadMoreV2/ReadMoreV2.stories.d.ts +8 -0
  148. package/dist/components/elements/ReadMoreV2/ReadMoreV2.stories.js +28 -0
  149. package/dist/components/elements/ReadMoreV2/ReadMoreV2.test.d.ts +1 -0
  150. package/dist/components/elements/ReadMoreV2/ReadMoreV2.test.js +30 -0
  151. package/dist/components/elements/ReadMoreV2/index.d.ts +13 -0
  152. package/dist/components/elements/ReadMoreV2/index.js +82 -0
  153. package/dist/components/elements/{Fields/Select → Select}/Select.stories.js +6 -4
  154. package/dist/components/elements/Select/Select.test.d.ts +1 -0
  155. package/dist/components/elements/{Fields/Select → Select}/Select.test.js +1 -1
  156. package/dist/components/elements/{Fields/Select → Select}/index.d.ts +1 -1
  157. package/dist/components/elements/{Fields/Select → Select}/index.js +9 -9
  158. package/dist/components/elements/SelectV2/SelectV2.module.css +27 -0
  159. package/dist/components/elements/SelectV2/SelectV2.stories.d.ts +8 -0
  160. package/dist/components/elements/SelectV2/SelectV2.stories.js +41 -0
  161. package/dist/components/elements/SelectV2/SelectV2.test.d.ts +1 -0
  162. package/dist/components/elements/SelectV2/SelectV2.test.js +52 -0
  163. package/dist/components/elements/SelectV2/index.d.ts +19 -0
  164. package/dist/components/elements/SelectV2/index.js +164 -0
  165. package/dist/components/elements/Spinner/Spinner.stories.js +2 -0
  166. package/dist/components/elements/Spinner/index.js +1 -1
  167. package/dist/components/elements/SpinnerV2/SpinnerV2.module.css +12 -0
  168. package/dist/components/elements/SpinnerV2/SpinnerV2.stories.d.ts +7 -0
  169. package/dist/components/elements/SpinnerV2/SpinnerV2.stories.js +29 -0
  170. package/dist/components/elements/SpinnerV2/SpinnerV2.test.d.ts +1 -0
  171. package/dist/components/elements/SpinnerV2/SpinnerV2.test.js +9 -0
  172. package/dist/components/elements/SpinnerV2/index.d.ts +15 -0
  173. package/dist/components/elements/SpinnerV2/index.js +36 -0
  174. package/dist/components/elements/TabList/TabList.stories.js +2 -0
  175. package/dist/components/elements/Table/Table.stories.js +2 -0
  176. package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.stories.js +6 -4
  177. package/dist/components/elements/TextInput/TextInput.test.d.ts +1 -0
  178. package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.test.js +2 -2
  179. package/dist/components/elements/{Fields/TextInput → TextInput}/index.d.ts +3 -3
  180. package/dist/components/elements/{Fields/TextInput → TextInput}/index.js +9 -8
  181. package/dist/components/elements/TextInputV2/TextInputV2.module.css +71 -0
  182. package/dist/components/elements/TextInputV2/TextInputV2.stories.d.ts +9 -0
  183. package/dist/components/elements/TextInputV2/TextInputV2.stories.js +37 -0
  184. package/dist/components/elements/TextInputV2/TextInputV2.test.d.ts +1 -0
  185. package/dist/components/elements/TextInputV2/TextInputV2.test.js +59 -0
  186. package/dist/components/elements/TextInputV2/index.d.ts +47 -0
  187. package/dist/components/elements/TextInputV2/index.js +98 -0
  188. package/dist/components/elements/layout/Box.stories.js +2 -0
  189. package/dist/components/elements/layout/Flex.stories.js +3 -1
  190. package/dist/components/elements/layoutV2/BoxV2.d.ts +9 -0
  191. package/dist/components/elements/layoutV2/BoxV2.js +19 -0
  192. package/dist/components/elements/layoutV2/BoxV2.stories.d.ts +6 -0
  193. package/dist/components/elements/layoutV2/BoxV2.stories.js +14 -0
  194. package/dist/components/elements/layoutV2/ColumnV2.d.ts +8 -0
  195. package/dist/components/elements/layoutV2/ColumnV2.js +21 -0
  196. package/dist/components/elements/layoutV2/RowV2.d.ts +19 -0
  197. package/dist/components/elements/layoutV2/RowV2.js +54 -0
  198. package/dist/components/providers/alerts.js +0 -1
  199. package/dist/components/providers/alerts.test.d.ts +1 -0
  200. package/dist/components/providers/alerts.test.js +115 -0
  201. package/dist/components/providers/componentConfigV2.d.ts +25 -0
  202. package/dist/components/providers/componentConfigV2.js +37 -0
  203. package/dist/components/providers/media.js +1 -1
  204. package/dist/components/providers/mediaV2.d.ts +11 -0
  205. package/dist/components/providers/mediaV2.js +48 -0
  206. package/dist/components/providers/uiV2.d.ts +20 -0
  207. package/dist/components/providers/uiV2.js +16 -0
  208. package/dist/index.d.ts +34 -14
  209. package/dist/index.html +14 -0
  210. package/dist/index.js +33 -13
  211. package/dist/theme/Color.stories.js +3 -1
  212. package/dist/theme/GlobalStylesV2.d.ts +2 -0
  213. package/dist/theme/GlobalStylesV2.js +212 -0
  214. package/dist/theme/Typography.stories.js +3 -1
  215. package/dist/theme/css-variables.css +57 -0
  216. package/dist/theme/index.d.ts +127 -1
  217. package/dist/theme/index.js +14 -0
  218. package/dist/theme/typography.js +2 -2
  219. package/dist/utils/decorators/UIVersion1.d.ts +2 -0
  220. package/dist/utils/decorators/UIVersion1.js +7 -0
  221. package/dist/utils/decorators/UIVersion2.d.ts +2 -0
  222. package/dist/utils/decorators/UIVersion2.js +7 -0
  223. package/dist/utils/hooks/useFocus.d.ts +7 -0
  224. package/dist/utils/hooks/useFocus.js +12 -0
  225. package/dist/utils/processSx.d.ts +3 -0
  226. package/dist/utils/processSx.js +135 -0
  227. package/package.json +8 -4
  228. /package/dist/components/{elements/Fields/Checkbox/Checkbox.test.d.ts → composites/CardV2/CardV2.test.d.ts} +0 -0
  229. /package/dist/components/{elements/Fields/CheckboxGroup/CheckboxGroup.test.d.ts → composites/ModalV2/ModalV2.test.d.ts} +0 -0
  230. /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.stories.d.ts +0 -0
  231. /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.test.d.ts +0 -0
  232. /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/index.d.ts +0 -0
  233. /package/dist/components/elements/{Fields/DatePicker/DatePicker.test.d.ts → ButtonV2/ButtonV2.test.d.ts} +0 -0
  234. /package/dist/components/elements/{text/Caption → Caption}/index.d.ts +0 -0
  235. /package/dist/components/elements/{text/Caption → Caption}/index.js +0 -0
  236. /package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.stories.d.ts +0 -0
  237. /package/dist/components/elements/{Fields/MonthPicker/MonthPicker.test.d.ts → Checkbox/Checkbox.test.d.ts} +0 -0
  238. /package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.stories.d.ts +0 -0
  239. /package/dist/components/elements/{Fields/Radio/Radio.test.d.ts → CheckboxGroup/CheckboxGroup.test.d.ts} +0 -0
  240. /package/dist/components/elements/{Fields/Select/Select.test.d.ts → CheckboxGroupV2/CheckboxGroupV2.test.d.ts} +0 -0
  241. /package/dist/components/elements/{text/Heading/Heading.test.d.ts → CheckboxV2/CheckboxV2.test.d.ts} +0 -0
  242. /package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.stories.d.ts +0 -0
  243. /package/dist/components/elements/{text/Label/Label.test.d.ts → DatePicker/DatePicker.test.d.ts} +0 -0
  244. /package/dist/components/elements/{text/Heading → Heading}/Heading.stories.d.ts +0 -0
  245. /package/dist/components/elements/{text/Paragraph/Paragraph.test.d.ts → Heading/Heading.test.d.ts} +0 -0
  246. /package/dist/components/elements/{text/ReadMore/ReadMore.test.d.ts → HeadingV2/HeadingV2.test.d.ts} +0 -0
  247. /package/dist/components/elements/{Fields/RadioGroup/RadioGroup.test.d.ts → IconV2/IconV2.test.d.ts} +0 -0
  248. /package/dist/components/elements/{text/Inline → Inline}/Inline.stories.d.ts +0 -0
  249. /package/dist/components/elements/{text/Label → Label}/Label.stories.d.ts +0 -0
  250. /package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.stories.d.ts +0 -0
  251. /package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.stories.d.ts +0 -0
  252. /package/dist/components/elements/{Fields/Radio → Radio}/Radio.stories.d.ts +0 -0
  253. /package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.stories.d.ts +0 -0
  254. /package/dist/components/elements/{Fields/TextInput/TextInput.test.d.ts → RadioGroup/RadioGroup.test.d.ts} +0 -0
  255. /package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.stories.d.ts +0 -0
  256. /package/dist/components/elements/{Fields/Select → Select}/Select.stories.d.ts +0 -0
  257. /package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.stories.d.ts +0 -0
  258. /package/dist/components/elements/{Fields/option.d.ts → option.d.ts} +0 -0
  259. /package/dist/components/elements/{Fields/option.js → option.js} +0 -0
package/README.md CHANGED
@@ -1,18 +1,22 @@
1
1
  # Hesburgh Component Library
2
2
 
3
- This is the repo for The Hesburgh Component Library, a set of React components that escapsulate the
3
+ This is the repo for The Hesburgh Component Library, a set of React components that escapsulate the
4
4
  design patterns used by the Hesburgh Library IT department.
5
5
 
6
6
  ## Using the library
7
+
7
8
  ### Installation
9
+
8
10
  To install the library in your project, run
11
+
9
12
  ```
10
13
  yarn install @ndlib/component-library
11
14
  ```
12
15
 
13
- ### Setup
16
+ ### Setup
14
17
 
15
18
  #### UiProvider
19
+
16
20
  In order for styles to be applied correctly, the `UiProvider` component must be included at the top of your project.
17
21
 
18
22
  ```tsx
@@ -21,20 +25,27 @@ In order for styles to be applied correctly, the `UiProvider` component must be
21
25
  </UiProvider>
22
26
  ```
23
27
 
24
- For frameworks that split application code by pages, it is recommended to add this provider at the root level rather than
28
+ #### UiProviderV2
29
+
30
+ If you are using Version 2 components, you must use the `UiProviderV2` component at the top of your project as it compiles styles differently.
31
+
32
+ ```tsx
33
+ <UIProviderV2>
34
+ <App>
35
+ </UiProviderV2>
36
+ ```
37
+
38
+ For frameworks that split application code by pages, it is recommended to add this provider at the root level rather than
25
39
  at the page level. In Gatsby, this can be done using the [wrapRootElement](https://www.gatsbyjs.com/docs/reference/config-files/gatsby-browser/#wrapRootElement) browser API.
26
40
 
27
41
  ```tsx
28
42
  exports.wrapRootElement = ({ element }) => {
29
- return (
30
- <UiProvider>
31
- {element}
32
- </UiProvider>
33
- )
43
+ return <UiProvider>{element}</UiProvider>
34
44
  }
35
45
  ```
36
46
 
37
47
  #### Configuring Link
48
+
38
49
  By default, the `Link` component in this library will use a native HTML `<a>` component in its implementation. This behavior can be overriden
39
50
  by setting the `link.internalLink` and/or `link.externalLink` property on the `components` prop of the `UiProvider` component. If a custom component
40
51
  is provided, the custom component will be rendered by when the <Link /> component is used. It will receive the same props the <Link> receives, as well as an
@@ -62,28 +73,34 @@ const WrappedApp = () => {
62
73
  ```
63
74
 
64
75
  ## Running locally
76
+
65
77
  Dependencies must be installed before storybook can be started. Dependencies can be installed with: `yarn install`.
66
78
 
67
79
  To build and deploy your storybook locally for development, run `yarn start`
68
80
 
69
81
  ## Deploying Storybook
82
+
70
83
  Whenever a commit is added to the main branch, the contents of the `/docs` folder will be deployed to our Github pages site.
71
84
 
72
85
  To build a new version of the storybook to be deployed, run `yarn build-storybook`. Our storybook build uses [vite](https://vitejs.dev/).
73
86
 
74
87
  ## Running tests
88
+
75
89
  Tests are run using [vitest](https://vitest.dev/), a test-runner built for vite that is similar to jest. Test suite can be run with: `yarn test`
76
90
 
77
91
  ## Linting
92
+
78
93
  Changes should be linted before commits. Run our linter with `yarn lint`. Failed linting will block builds and deploys. Our lint process uses `eslint` and `prettier`.
79
94
  Running `yarn lint:fix` will fix any issues that can be automatically fixed.
80
95
 
81
96
  ## Building for npm
97
+
82
98
  The build process for the npm module for this library uses `tsc`. ESM exports are used to better support tree-shaking. When adding new code to this library,
83
99
  be careful to ensure than importing the module do not cause side-effects. In other words, don't execute any process or do any state management outside
84
100
  of exported properties or functions because this code might be removed by tree-shaker. See examples below:
85
101
 
86
102
  ### Wrong
103
+
87
104
  ```jsx
88
105
  // This code may get removed by tree-shaker
89
106
  setTimeout(() => {
@@ -92,6 +109,7 @@ setTimeout(() => {
92
109
  ```
93
110
 
94
111
  ### Right
112
+
95
113
  ```jsx
96
114
  export const myFunction = () => {
97
115
  setTimeout(() => {
@@ -0,0 +1 @@
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))i(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function s(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(e){if(e.ep)return;e.ep=!0;const r=s(e);fetch(e.href,r)}})();
@@ -7,10 +7,12 @@ import { CARD_LAYOUT, CARD_SIZE, Card } from '.';
7
7
  import { COLOR, Column, LABEL_SIZE, Label, Paragraph, ReadMore, TYPOGRAPHY_TYPE, } from '../../..';
8
8
  import { Icon } from '../../elements/Icon';
9
9
  import { BUTTON_TYPE, Button } from '../../elements/Button';
10
+ import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
10
11
  const meta = {
11
12
  title: 'Composites/Card',
12
13
  component: Card,
13
14
  tags: ['autodocs'],
15
+ decorators: [UIVersion1],
14
16
  };
15
17
  export default meta;
16
18
  const headlinedCards = [
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useEffect, useState } from 'react';
3
- import { HEADING_SIZE, Heading } from '../../elements/text/Heading';
4
- import { ReadMore } from '../../elements/text/ReadMore';
3
+ import { HEADING_SIZE, Heading } from '../../elements/Heading';
4
+ import { ReadMore } from '../../elements/ReadMore';
5
5
  import { useTheme } from '../../../theme';
6
6
  import { GROUP_TYPE, Group } from '../../elements/Group';
7
7
  import { Box } from '../../elements/layout/Box';
@@ -53,6 +53,7 @@ const DateDisplay = ({ date: dateString }) => {
53
53
  } }, { children: MONTH_LABELS[date.getMonth()] }))] })));
54
54
  };
55
55
  export const Card = ({ size, displayDate, headline, image, alt, layout, onClick, raised, truncateHeadlineAfter, heading, headlineStyles, headingStyles, headingIcon, headingAction, backgroundColor, sx, imageHeight: imageHeightProp, imageWidth: imageWidthProp, containImage, containerWidth, containerHeight, children, }) => {
56
+ var _a;
56
57
  const theme = useTheme();
57
58
  const contentPaddingX = size === CARD_SIZE.SM ? 3 : 4;
58
59
  const isVertical = !layout || layout === CARD_LAYOUT.VERTICAL;
@@ -86,7 +87,7 @@ export const Card = ({ size, displayDate, headline, image, alt, layout, onClick,
86
87
  if (onClick && e.key === KEY_CODES.ENTER) {
87
88
  onClick();
88
89
  }
89
- }, tabIndex: onClick ? 0 : undefined, sx: Object.assign({ boxShadow: raised || heading ? theme.boxShadow.NORMAL : undefined, width: !isVertical && '100%', backgroundColor: backgroundColor ? backgroundColor : COLOR.WHITE, borderBottom: 'solid 2px', borderColor: COLOR.TRANSPARENT, cursor: onClick ? 'pointer' : undefined, display: 'flex', flexDirection: layout === CARD_LAYOUT.HORIZONTAL ? 'row' : 'column', alignItems: 'flex-start', ':hover,:focus': onClick
90
+ }, tabIndex: onClick ? 0 : undefined, sx: Object.assign({ boxShadow: raised || heading ? (_a = theme.boxShadow) === null || _a === void 0 ? void 0 : _a.NORMAL : undefined, width: !isVertical && '100%', backgroundColor: backgroundColor ? backgroundColor : COLOR.WHITE, borderBottom: 'solid 2px', borderColor: COLOR.TRANSPARENT, cursor: onClick ? 'pointer' : undefined, display: 'flex', flexDirection: layout === CARD_LAYOUT.HORIZONTAL ? 'row' : 'column', alignItems: 'flex-start', ':hover,:focus': onClick
90
91
  ? {
91
92
  transform: 'scale(1.01)',
92
93
  borderColor: COLOR.ND_SKY_BLUE_DARK,
@@ -0,0 +1,74 @@
1
+ .groupCardWrapper {
2
+ position: relative;
3
+ display: flex;
4
+ align-items: flex-start;
5
+ background-color: var(--white);
6
+ border-bottom: 2px solid;
7
+ border-color: transparent;
8
+ }
9
+
10
+ .groupCardWrapperWithHover {
11
+ position: relative;
12
+ display: flex;
13
+ align-items: flex-start;
14
+ border-bottom: 2px solid;
15
+ border-color: transparent;
16
+ transition: all 0.15s ease-in-out;
17
+ }
18
+
19
+ .groupCardWrapperWithHover:hover, .groupCardWrapperWithHover:focus {
20
+ transform: scale(1.01);
21
+ border-color: var(--ndSkyBlueDark);
22
+ background-color: var(--ndSkyBlue);
23
+ cursor: pointer;
24
+ }
25
+
26
+ .leftBadge {
27
+ position: absolute;
28
+ left: -1rem;
29
+ top: 20px;
30
+ z-index: 1;
31
+ }
32
+
33
+ .rightBadge {
34
+ position: absolute;
35
+ right: -1rem;
36
+ top: 20px;
37
+ z-index: 1;
38
+ }
39
+
40
+ .containImageContainer {
41
+ width: 500px;
42
+ height: 280px;
43
+ background-color: var(--extraExtraLightGray);
44
+ border: 1px solid var(--extraLightGray);
45
+ display: flex;
46
+ justify-content: center;
47
+ align-items: center;
48
+ }
49
+
50
+ .headingOuterWrapper {
51
+ background-color: var(--primary);
52
+ color: var(--white);
53
+ width: 100%;
54
+ padding-top: 0.75rem;
55
+ padding-bottom: 0.75rem;
56
+ justify-content: space-between;
57
+ align-items: center;
58
+ }
59
+
60
+ .icon {
61
+ margin-right: 0.5rem;
62
+ }
63
+
64
+ .heading {
65
+ color: var(--white);
66
+ white-space: nowrap;
67
+ }
68
+
69
+ .dateWrapper {
70
+ align-items: center;
71
+ justify-content: center;
72
+ padding: 0.75rem;
73
+ background-color: var(--ndGoldLight);
74
+ }
@@ -0,0 +1,19 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { CardV2 } from '.';
3
+ declare const meta: Meta<typeof CardV2>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof CardV2>;
6
+ export declare const Default: Story;
7
+ export declare const ContainedImage: Story;
8
+ export declare const TruncateHeadline: Story;
9
+ export declare const Horizontal: Story;
10
+ export declare const CustomBackgroundColor: Story;
11
+ export declare const DateCards: Story;
12
+ export declare const Clickable: Story;
13
+ export declare const ShouldShowHoverStyle: Story;
14
+ export declare const Raised: Story;
15
+ export declare const Heading: Story;
16
+ export declare const CustomImageHeading: Story;
17
+ export declare const LeftBadge: Story;
18
+ export declare const RightBadge: Story;
19
+ export declare const LeftAndRightBadges: Story;
@@ -0,0 +1,187 @@
1
+ import { createElement as _createElement } from "react";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import AccessTime from '@mui/icons-material/AccessTimeFilled';
4
+ import CalendarIcon from '@mui/icons-material/CalendarMonth';
5
+ import BookmarkIcon from '@mui/icons-material/Bookmark';
6
+ import { CollectionsBookmark } from '@mui/icons-material';
7
+ import { Bookmark } from '@mui/icons-material';
8
+ import { CARDV2_LAYOUT, CARDV2_SIZE, CardV2 } from '.';
9
+ import { COLOR, FONT_SIZE, ColumnV2, LABELV2_SIZE, LabelV2, ParagraphV2, ReadMoreV2, TYPOGRAPHY_TYPE, BoxV2, } from '../../..';
10
+ import { IconV2 } from '../../elements/IconV2';
11
+ import { BUTTONV2_TYPE, ButtonV2 } from '../../elements/ButtonV2';
12
+ import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
13
+ const meta = {
14
+ title: 'Composites/CardV2',
15
+ component: CardV2,
16
+ tags: ['autodocs'],
17
+ decorators: [UIVersion2],
18
+ };
19
+ export default meta;
20
+ const headlinedCards = [
21
+ {
22
+ headline: 'Exhibit — Printing the Nation: A Century of Irish Book Arts',
23
+ image: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.us-east-1.amazonaws.com/14_15_I_Ten_American_Diaries_29a3788848.jpg',
24
+ size: CARDV2_SIZE.SM,
25
+ inlineStyles: {
26
+ width: '500px',
27
+ },
28
+ },
29
+ {
30
+ headline: 'Paws, Hooves, Fins & Feathers',
31
+ image: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.us-east-1.amazonaws.com/RBSC_Spring2020_Rep_2_a88660826b.jpg',
32
+ size: CARDV2_SIZE.SM,
33
+ inlineStyles: {
34
+ width: '500px',
35
+ },
36
+ },
37
+ {
38
+ headline: 'Tracy C. Bergstrom, director of the Specialized Collection Services Program',
39
+ image: 'https://strapi-prod-library-website-contentbucket52d4b12c-1whgwwl6746tz.s3.us-east-1.amazonaws.com/Tracy_News_218x275_1dd180dc80.jpg',
40
+ size: CARDV2_SIZE.SM,
41
+ inlineStyles: {
42
+ width: '500px',
43
+ },
44
+ },
45
+ {
46
+ headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer. Other text to make this longer than the other card.',
47
+ image: 'https://images.ctfassets.net/cfblb1f7i85j/2sGpdDbNkl6MPnlem6wq1R/995c786624613b5ff07228e481996385/One.Book.2023-Rep.png',
48
+ size: CARDV2_SIZE.SM,
49
+ inlineStyles: {
50
+ width: '500px',
51
+ },
52
+ },
53
+ ];
54
+ const basicCards = [
55
+ {
56
+ children: _jsx(ParagraphV2, { children: "Basic card 1" }),
57
+ size: CARDV2_SIZE.SM,
58
+ inlineStyles: {
59
+ width: '500px',
60
+ },
61
+ },
62
+ {
63
+ children: _jsx(ParagraphV2, { children: "Basic card 2" }),
64
+ size: CARDV2_SIZE.SM,
65
+ inlineStyles: {
66
+ width: '500px',
67
+ },
68
+ },
69
+ ];
70
+ const dateCards = [
71
+ {
72
+ displayDate: new Date().toISOString(),
73
+ headline: 'Exhibit — Printing the Nation: A Century of Irish Book Arts',
74
+ size: CARDV2_SIZE.SM,
75
+ },
76
+ {
77
+ displayDate: new Date().toISOString(),
78
+ headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer',
79
+ size: CARDV2_SIZE.SM,
80
+ },
81
+ ];
82
+ const horizontalCards = [
83
+ {
84
+ headline: 'Exhibit — Printing the Nation: A Century of Irish Book Arts',
85
+ image: 'https://images.ctfassets.net/cfblb1f7i85j/7aCd5Sm86JdtQepGBKDUfy/dcb4d97dd3a1d3ee810e8bcaa82dc715/Spring_Exhibit_2023-Rep.jpg?w=296',
86
+ size: CARDV2_SIZE.SM,
87
+ children: (_jsxs(_Fragment, { children: [_jsxs(LabelV2, Object.assign({ color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
88
+ display: 'flex',
89
+ } }, { children: [_jsx(IconV2, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] })), _jsxs(LabelV2, Object.assign({ color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
90
+ display: 'flex',
91
+ } }, { children: [_jsx(IconV2, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] })), _jsx(ParagraphV2, { children: "This exhibit demonstrates the art and craft of the Irish book since 1900." })] })),
92
+ },
93
+ {
94
+ headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer',
95
+ image: 'https://images.ctfassets.net/cfblb1f7i85j/2sGpdDbNkl6MPnlem6wq1R/995c786624613b5ff07228e481996385/One.Book.2023-Rep.png?w=296',
96
+ size: CARDV2_SIZE.SM,
97
+ children: (_jsxs(_Fragment, { children: [_jsxs(LabelV2, Object.assign({ color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
98
+ display: 'flex',
99
+ } }, { children: [_jsx(IconV2, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] })), _jsxs(LabelV2, Object.assign({ color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
100
+ display: 'flex',
101
+ } }, { children: [_jsx(IconV2, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] })), _jsx(ReadMoreV2, Object.assign({ typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM, lines: 2 }, { children: "This online exhibition displays rare materials from Hesburgh Libraries collections that place Mike Curato\u2019s teen graphic novel into a historical and social context." }))] })),
102
+ },
103
+ ];
104
+ const leftBadge = (_jsx(BoxV2, Object.assign({ sx: {
105
+ width: '40px',
106
+ height: '40px',
107
+ borderRadius: '50%',
108
+ display: 'flex',
109
+ alignItems: 'center',
110
+ justifyContent: 'center',
111
+ bg: COLOR.ND_BLUE,
112
+ } }, { children: _jsx(IconV2, { icon: CollectionsBookmark, size: FONT_SIZE.MD, color: COLOR.WHITE }) })));
113
+ const rightBadge = (_jsx(BoxV2, Object.assign({ sx: {
114
+ width: '40px',
115
+ height: '40px',
116
+ borderRadius: '4px',
117
+ display: 'flex',
118
+ alignItems: 'center',
119
+ justifyContent: 'center',
120
+ bg: COLOR.WHITE,
121
+ borderColor: COLOR.ND_BLUE,
122
+ borderWidth: '1px',
123
+ borderStyle: 'solid',
124
+ } }, { children: _jsx(IconV2, { icon: Bookmark, size: FONT_SIZE.MD, color: COLOR.ND_BLUE }) })));
125
+ export const Default = {
126
+ render: () => (_jsx(ColumnV2, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i })))) })),
127
+ args: {},
128
+ };
129
+ export const ContainedImage = {
130
+ render: () => (_jsx(ColumnV2, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({ containImage: true, containerHeight: '280px' }, props, { key: i })))) })),
131
+ args: {},
132
+ };
133
+ export const TruncateHeadline = {
134
+ render: () => (_jsx(ColumnV2, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, truncateHeadlineAfter: 2, shouldShowHoverStyle: true })))) })),
135
+ args: {},
136
+ };
137
+ export const Horizontal = {
138
+ render: () => (_jsx(ColumnV2, { children: horizontalCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, layout: CARDV2_LAYOUT.HORIZONTAL })))) })),
139
+ args: {},
140
+ };
141
+ export const CustomBackgroundColor = {
142
+ render: () => (_jsx(ColumnV2, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, backgroundColor: COLOR.ND_SKY_BLUE })))) })),
143
+ args: {},
144
+ };
145
+ export const DateCards = {
146
+ render: () => (_jsx(ColumnV2, { children: dateCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, layout: CARDV2_LAYOUT.HORIZONTAL, inlineStyles: { height: '120px' }, backgroundColor: COLOR.TRANSPARENT })))) })),
147
+ args: {},
148
+ };
149
+ export const Clickable = {
150
+ render: () => (_jsx(ColumnV2, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { onClick: () => {
151
+ alert('Card clicked');
152
+ }, key: i })))) })),
153
+ args: {},
154
+ };
155
+ export const ShouldShowHoverStyle = {
156
+ render: () => (_jsx(ColumnV2, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { shouldShowHoverStyle: true, key: i })))) })),
157
+ args: {},
158
+ };
159
+ export const Raised = {
160
+ render: () => (_jsx(ColumnV2, { children: basicCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { raised: true, key: i })))) })),
161
+ args: {},
162
+ };
163
+ export const Heading = {
164
+ render: () => (_jsx(ColumnV2, { children: basicCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, heading: "Heading", headingIcon: BookmarkIcon, headingAction: _jsx(ButtonV2, Object.assign({ type: BUTTONV2_TYPE.TEXT, color: COLOR.WHITE, onClick: () => { } }, { children: "Click Me" })) })))) })),
165
+ args: {},
166
+ };
167
+ export const CustomImageHeading = {
168
+ render: () => (_jsx(ColumnV2, { children: basicCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, heading: "Heading", headingStyles: {
169
+ backgroundImage: `url(https://library.nd.edu/static/media/jesus.2.4a2b137e.png)`,
170
+ backgroundRepeat: 'no-repeat',
171
+ backgroundPositionX: 'right',
172
+ backgroundPositionY: '-15px',
173
+ } })))) })),
174
+ args: {},
175
+ };
176
+ export const LeftBadge = {
177
+ render: () => (_jsx(ColumnV2, Object.assign({ sx: { ml: '1.5rem' } }, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({ containImage: true, containerHeight: '280px', leftBadge: leftBadge }, props, { key: i })))) }))),
178
+ args: {},
179
+ };
180
+ export const RightBadge = {
181
+ render: () => (_jsx(ColumnV2, Object.assign({ sx: { ml: '1.5rem' } }, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({ containImage: true, containerHeight: '280px', rightBadge: rightBadge }, props, { key: i })))) }))),
182
+ args: {},
183
+ };
184
+ export const LeftAndRightBadges = {
185
+ render: () => (_jsx(ColumnV2, Object.assign({ sx: { ml: '1.5rem' } }, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({ containImage: true, containerHeight: '280px', leftBadge: leftBadge, rightBadge: rightBadge }, props, { key: i })))) }))),
186
+ args: {},
187
+ };
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { fireEvent, screen } from '@testing-library/react';
3
+ import { vi } from 'vitest';
4
+ import { render } from '../../../utils/test';
5
+ import { CardV2 } from '.';
6
+ import { KEY_CODES } from '../../../utils/misc';
7
+ const MOCK_HEADLINE = 'MOCK HEADLINE';
8
+ const MOCK_BODY = 'MOCK BODY';
9
+ describe('CardV2', () => {
10
+ const mockClickHandler = vi.fn();
11
+ afterEach(() => {
12
+ vi.resetAllMocks();
13
+ });
14
+ it('renders contents', () => {
15
+ const { getByText } = render(_jsx(CardV2, Object.assign({ headline: MOCK_HEADLINE }, { children: MOCK_BODY })));
16
+ expect(getByText(MOCK_HEADLINE)).toBeDefined();
17
+ expect(getByText(MOCK_BODY)).toBeDefined();
18
+ });
19
+ it('fires handler when clicked', () => {
20
+ const { getByRole } = render(_jsx(CardV2, { headline: MOCK_HEADLINE, onClick: mockClickHandler }));
21
+ const card = getByRole('button');
22
+ fireEvent.click(card);
23
+ expect(mockClickHandler).toBeCalledTimes(1);
24
+ fireEvent.keyDown(card, {
25
+ key: KEY_CODES.ENTER,
26
+ });
27
+ expect(mockClickHandler).toBeCalledTimes(2);
28
+ });
29
+ it('labels card with headline when passed', () => {
30
+ const { getByText } = render(_jsx(CardV2, { headline: MOCK_HEADLINE }));
31
+ expect(getByText(MOCK_HEADLINE)).toBeDefined();
32
+ });
33
+ it('labels card with heading when passed', () => {
34
+ const { getByText } = render(_jsx(CardV2, { heading: MOCK_HEADLINE }));
35
+ expect(getByText(MOCK_HEADLINE)).toBeDefined();
36
+ });
37
+ it('renders the image with containImage prop', () => {
38
+ const imageSrc = 'https://via.placeholder.com/150';
39
+ const altText = 'Test Image';
40
+ const containerWidth = '500px';
41
+ const containerHeight = '280px';
42
+ render(_jsx(CardV2, { image: imageSrc, alt: altText, containImage: true, containerWidth: containerWidth, containerHeight: containerHeight }));
43
+ const imageElement = screen.getByAltText(altText);
44
+ expect(imageElement).toBeInTheDocument();
45
+ expect(imageElement).toHaveStyle({
46
+ width: '100%',
47
+ height: 'auto',
48
+ objectFit: 'scale-down',
49
+ });
50
+ const containerElement = imageElement.closest('div');
51
+ expect(containerElement).toHaveStyle({
52
+ width: containerWidth,
53
+ height: containerHeight,
54
+ });
55
+ });
56
+ it('renders the image without containImage prop', () => {
57
+ const imageSrc = 'https://via.placeholder.com/150';
58
+ const altText = 'Test Image';
59
+ render(_jsx(CardV2, { image: imageSrc, alt: altText }));
60
+ const imageElement = screen.getByAltText(altText);
61
+ expect(imageElement).toBeInTheDocument();
62
+ expect(imageElement).toHaveStyle({
63
+ width: '100%',
64
+ height: 'auto',
65
+ });
66
+ });
67
+ });
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { StyledElementPropsV2, StylesPropV2 } from '../../../theme';
3
+ import { COLOR } from '../../../theme/colors';
4
+ export declare enum CARDV2_LAYOUT {
5
+ VERTICAL = "vertical",
6
+ HORIZONTAL = "horizontal"
7
+ }
8
+ export declare enum CARDV2_SIZE {
9
+ SM = "SM",
10
+ MD = "MD",
11
+ LG = "LG"
12
+ }
13
+ type CardChildren = React.ReactNode;
14
+ export type CardV2Props = StyledElementPropsV2<HTMLDivElement, {
15
+ headline?: string;
16
+ heading?: string;
17
+ headlineStyles?: StylesPropV2;
18
+ headingStyles?: StylesPropV2;
19
+ headingIcon?: React.FC;
20
+ headingAction?: React.ReactNode;
21
+ truncateHeadlineAfter?: number;
22
+ body?: React.ReactNode;
23
+ image?: string;
24
+ alt?: string;
25
+ layout?: CARDV2_LAYOUT;
26
+ size?: CARDV2_SIZE;
27
+ displayDate?: string;
28
+ onClick?: () => void;
29
+ raised?: boolean;
30
+ imageHeight?: string;
31
+ imageWidth?: string;
32
+ containerWidth?: string;
33
+ containerHeight?: string;
34
+ inlineStyles?: any;
35
+ containImage?: boolean;
36
+ backgroundColor?: COLOR;
37
+ shouldShowHoverStyle?: boolean;
38
+ className?: string;
39
+ leftBadge?: React.ReactNode;
40
+ rightBadge?: React.ReactNode;
41
+ }, CardChildren>;
42
+ export declare const CardV2: React.FC<CardV2Props>;
43
+ export {};
@@ -0,0 +1,99 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useEffect, useState } from 'react';
3
+ import { HEADINGV2_SIZE, HeadingV2 } from '../../elements/HeadingV2';
4
+ import { BOX_SHADOW } from '../../../theme';
5
+ import { GROUPV2_TYPE, GroupV2 } from '../../elements/GroupV2';
6
+ import { BoxV2 } from '../../elements/layoutV2/BoxV2';
7
+ import { IconV2 } from '../../elements/IconV2';
8
+ import { ColumnV2, FONT, FONT_SIZE, RowV2, TYPOGRAPHY_TYPE } from '../../..';
9
+ import { COLOR } from '../../../theme/colors';
10
+ import { KEY_CODES } from '../../../utils/misc';
11
+ import * as styles from './CardV2.module.css';
12
+ import clsx from 'clsx';
13
+ export var CARDV2_LAYOUT;
14
+ (function (CARDV2_LAYOUT) {
15
+ CARDV2_LAYOUT["VERTICAL"] = "vertical";
16
+ CARDV2_LAYOUT["HORIZONTAL"] = "horizontal";
17
+ })(CARDV2_LAYOUT || (CARDV2_LAYOUT = {}));
18
+ export var CARDV2_SIZE;
19
+ (function (CARDV2_SIZE) {
20
+ CARDV2_SIZE["SM"] = "SM";
21
+ CARDV2_SIZE["MD"] = "MD";
22
+ CARDV2_SIZE["LG"] = "LG";
23
+ })(CARDV2_SIZE || (CARDV2_SIZE = {}));
24
+ const MONTH_LABELS = [
25
+ 'JAN',
26
+ 'FEB',
27
+ 'MAR',
28
+ 'APR',
29
+ 'MAY',
30
+ 'JUN',
31
+ 'JUL',
32
+ 'AUG',
33
+ 'SEP',
34
+ 'OCT',
35
+ 'NOV',
36
+ 'DEC',
37
+ ];
38
+ const typeSafeStyles = styles;
39
+ const DateDisplay = ({ date: dateString }) => {
40
+ const date = React.useMemo(() => {
41
+ return new Date(dateString);
42
+ }, [dateString]);
43
+ return (_jsxs(ColumnV2, Object.assign({ className: typeSafeStyles.dateWrapper, sx: {
44
+ fontFamily: FONT.BRANDED2,
45
+ boxShadow: BOX_SHADOW.EMPHASIZED,
46
+ } }, { children: [_jsx(BoxV2, Object.assign({ sx: {
47
+ fontSize: FONT_SIZE.LG,
48
+ } }, { children: date.getDate() })), _jsx(BoxV2, Object.assign({ sx: {
49
+ fontSize: FONT_SIZE.MD,
50
+ marginTop: '0.25rem',
51
+ } }, { children: MONTH_LABELS[date.getMonth()] }))] })));
52
+ };
53
+ export const CardV2 = ({ size, displayDate, headline, image, alt, layout, onClick, raised, truncateHeadlineAfter, heading, headlineStyles, headingStyles, headingIcon, headingAction, backgroundColor, leftBadge, rightBadge, className, shouldShowHoverStyle, imageHeight: imageHeightProp, imageWidth: imageWidthProp, containImage, containerWidth, containerHeight, inlineStyles, children, }) => {
54
+ const contentPaddingX = size === CARDV2_SIZE.SM ? 3 : 4;
55
+ const isVertical = !layout || layout === CARDV2_LAYOUT.VERTICAL;
56
+ const [objectFit, setObjectFit] = useState('scale-down');
57
+ useEffect(() => {
58
+ if (image) {
59
+ const img = new Image();
60
+ img.onload = () => {
61
+ if (img.width > img.height) {
62
+ setObjectFit('contain');
63
+ }
64
+ else {
65
+ setObjectFit('scale-down');
66
+ }
67
+ };
68
+ img.src = image;
69
+ }
70
+ }, [image]);
71
+ const imageHeight = imageHeightProp || (isVertical ? 'auto' : '100%');
72
+ const imageWidth = imageWidthProp || (isVertical ? '100%' : 'auto');
73
+ const contentPaddingY = isVertical ? contentPaddingX : 2;
74
+ const typography = size === CARDV2_SIZE.SM
75
+ ? TYPOGRAPHY_TYPE.HEADLINE_SMALL
76
+ : TYPOGRAPHY_TYPE.HEADLINE_MEDIUM;
77
+ const baseCardClass = onClick || shouldShowHoverStyle
78
+ ? typeSafeStyles.groupCardWrapperWithHover
79
+ : typeSafeStyles.groupCardWrapper;
80
+ return (_jsxs(GroupV2, Object.assign({ type: headline || heading ? GROUPV2_TYPE.REGION : GROUPV2_TYPE.GROUP, role: onClick ? 'button' : 'group', onClick: onClick, onKeyDown: (e) => {
81
+ if (onClick && e.key === KEY_CODES.ENTER) {
82
+ onClick();
83
+ }
84
+ }, tabIndex: onClick ? 0 : undefined, className: clsx(baseCardClass, className), sx: Object.assign({ boxShadow: raised || heading ? BOX_SHADOW.NORMAL : undefined, width: !isVertical && '100%', backgroundColor: backgroundColor ? backgroundColor : '', flexDirection: layout === CARDV2_LAYOUT.HORIZONTAL ? 'row' : 'column' }, inlineStyles) }, { children: [leftBadge && (_jsx(BoxV2, Object.assign({ className: typeSafeStyles.leftBadge }, { children: leftBadge }))), rightBadge && (_jsx(BoxV2, Object.assign({ className: typeSafeStyles.rightBadge }, { children: rightBadge }))), image && !containImage && (_jsx("img", { src: image, alt: alt, style: {
85
+ width: imageWidth,
86
+ height: imageHeight,
87
+ } })), image && containImage && (_jsx(BoxV2, Object.assign({ className: typeSafeStyles.containImageContainer, sx: {
88
+ width: containerWidth ? containerWidth : '',
89
+ height: containerHeight ? containerHeight : '',
90
+ } }, { children: _jsx("img", { src: image, alt: alt, style: {
91
+ width: imageWidth,
92
+ height: imageHeight,
93
+ objectFit: objectFit,
94
+ } }) }))), displayDate && _jsx(DateDisplay, { date: displayDate }), heading && (_jsxs(RowV2, Object.assign({ className: typeSafeStyles.headingOuterWrapper, sx: Object.assign({}, headingStyles) }, { children: [_jsxs(RowV2, Object.assign({ align: "center", sx: { px: contentPaddingX } }, { children: [headingIcon && (_jsx(IconV2, { icon: headingIcon, size: FONT_SIZE.LG, color: COLOR.WHITE, className: typeSafeStyles.icon })), _jsx(HeadingV2, Object.assign({ size: HEADINGV2_SIZE.SM, className: typeSafeStyles.heading, sx: {
95
+ mt: 0,
96
+ } }, { children: heading }))] })), _jsx(RowV2, Object.assign({ align: "center", sx: { px: contentPaddingX } }, { children: headingAction && headingAction }))] }))), _jsx(RowV2, Object.assign({ sx: { px: contentPaddingX, py: contentPaddingY } }, { children: _jsxs(ColumnV2, Object.assign({ justify: "center" }, { children: [headline && (_jsx(HeadingV2, Object.assign({ typography: typography, sx: Object.assign({ mt: 0, display: '-webkit-box', WebkitBoxOrient: 'vertical', overflow: 'hidden', WebkitLineClamp: truncateHeadlineAfter
97
+ ? truncateHeadlineAfter
98
+ : 0 }, headlineStyles) }, { children: headline }))), children && (_jsx(BoxV2, Object.assign({ sx: { mt: headline && !heading ? 2 : 0 } }, { children: children })))] })) }))] })));
99
+ };
@@ -1,11 +1,13 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { DragDropList, DragHandle } from './index';
3
3
  import React from 'react';
4
- import { Paragraph } from '../../elements/text/Paragraph';
4
+ import { Paragraph } from '../../elements/Paragraph';
5
+ import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
5
6
  const meta = {
6
7
  title: 'Composites/DragDropList',
7
8
  component: DragDropList,
8
9
  tags: ['autodocs'],
10
+ decorators: [UIVersion1],
9
11
  };
10
12
  export default meta;
11
13
  const _items = [