@kaizen/components 1.57.1 → 1.58.0

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 (226) hide show
  1. package/bin/codemod.sh +39 -0
  2. package/codemods/README.md +31 -0
  3. package/codemods/__tests__/utils/index.ts +1 -0
  4. package/codemods/__tests__/utils/parseJsx.ts +11 -0
  5. package/codemods/migrateBrandMomentMoodToVariant/index.ts +21 -0
  6. package/codemods/migrateBrandMomentMoodToVariant/transformBrandMomentMoodToVariant.spec.ts +44 -0
  7. package/codemods/migrateBrandMomentMoodToVariant/transformBrandMomentMoodToVariant.ts +24 -0
  8. package/codemods/migrateCardVariantToColor/index.ts +15 -0
  9. package/codemods/migrateCardVariantToColor/transformCardVariantToColor.spec.ts +91 -0
  10. package/codemods/migrateCardVariantToColor/transformCardVariantToColor.ts +32 -0
  11. package/codemods/migrateConfirmationModalMoodsToVariant/index.ts +19 -0
  12. package/codemods/migrateConfirmationModalMoodsToVariant/transformConfirmationModalMoodsToVariant.spec.ts +110 -0
  13. package/codemods/migrateConfirmationModalMoodsToVariant/transformConfirmationModalMoodsToVariant.ts +59 -0
  14. package/codemods/migrateEmptyStateIllustrationTypeToVariant/index.ts +21 -0
  15. package/codemods/migrateEmptyStateIllustrationTypeToVariant/transformEmptyStateIllustrationTypeToVariant.spec.ts +74 -0
  16. package/codemods/migrateEmptyStateIllustrationTypeToVariant/transformEmptyStateIllustrationTypeToVariant.ts +28 -0
  17. package/codemods/migrateGlobalNotificationTypeToVariant/index.ts +19 -0
  18. package/codemods/migrateInformationTileMoodToVariant/index.ts +21 -0
  19. package/codemods/migrateInformationTileMoodToVariant/transformInformationTileMoodToVariant.spec.ts +84 -0
  20. package/codemods/migrateInformationTileMoodToVariant/transformInformationTileMoodToVariant.ts +22 -0
  21. package/codemods/migrateInlineNotificationTypeToVariant/index.ts +19 -0
  22. package/codemods/migrateMultiActionTileMoodToVariant/index.ts +21 -0
  23. package/codemods/migrateMultiActionTileMoodToVariant/transformMultiActionTileMoodToVariant.spec.ts +84 -0
  24. package/codemods/migrateMultiActionTileMoodToVariant/transformMultiActionTileMoodToVariant.ts +22 -0
  25. package/codemods/migrateNotificationTypeToVariant/index.ts +1 -0
  26. package/codemods/migrateNotificationTypeToVariant/migrateNotificationTypeToVariant.spec.ts +107 -0
  27. package/codemods/migrateNotificationTypeToVariant/migrateNotificationTypeToVariant.ts +28 -0
  28. package/codemods/migrateProgressBarMoodToColor/index.ts +21 -0
  29. package/codemods/migrateProgressBarMoodToColor/transformProgressBarMoodToColor.spec.ts +54 -0
  30. package/codemods/migrateProgressBarMoodToColor/transformProgressBarMoodToColor.ts +26 -0
  31. package/codemods/migrateToastNotificationTypeToVariant/index.ts +19 -0
  32. package/codemods/migrateWellVariantToColor/index.ts +15 -0
  33. package/codemods/migrateWellVariantToColor/transformWellVariantToColor.spec.ts +192 -0
  34. package/codemods/migrateWellVariantToColor/transformWellVariantToColor.ts +75 -0
  35. package/codemods/removeInputEditModalMood/index.ts +19 -0
  36. package/codemods/removeInputEditModalMood/removeInputEditModalMood.spec.ts +80 -0
  37. package/codemods/removeInputEditModalMood/removeInputEditModalMood.ts +40 -0
  38. package/codemods/updateGuidanceBlockVariantProp/transformGuidanceBlockVariantProp.spec.ts +118 -0
  39. package/codemods/updateGuidanceBlockVariantProp/transformGuidanceBlockVariantProp.ts +64 -0
  40. package/codemods/utils/__fixtures__/KaioComponent.tsx +6 -0
  41. package/codemods/utils/__snapshots__/transformSource.spec.ts.snap +11 -0
  42. package/codemods/utils/getPropValueText.spec.ts +75 -0
  43. package/codemods/utils/getPropValueText.ts +21 -0
  44. package/codemods/utils/getTagName.spec.ts +24 -0
  45. package/codemods/utils/getTagName.ts +32 -0
  46. package/codemods/utils/index.ts +7 -0
  47. package/codemods/utils/migrateStringProp.spec.ts +129 -0
  48. package/codemods/utils/migrateStringProp.ts +43 -0
  49. package/codemods/utils/printAst.ts +6 -0
  50. package/codemods/utils/transformComponentsInDir.ts +42 -0
  51. package/codemods/utils/transformSource.spec.ts +56 -0
  52. package/codemods/utils/transformSource.ts +25 -0
  53. package/codemods/utils/updateJsxElementWithNewProps.spec.ts +67 -0
  54. package/codemods/utils/updateJsxElementWithNewProps.ts +24 -0
  55. package/dist/cjs/BrandMoment/BrandMoment.cjs +3 -2
  56. package/dist/cjs/BrandMoment/BrandMoment.module.scss.cjs +3 -1
  57. package/dist/cjs/Card/Card.cjs +7 -6
  58. package/dist/cjs/Card/Card.module.scss.cjs +10 -2
  59. package/dist/cjs/EmptyState/EmptyState.cjs +14 -6
  60. package/dist/cjs/EmptyState/EmptyState.module.scss.cjs +3 -0
  61. package/dist/cjs/ErrorPage/ErrorPage.cjs +1 -1
  62. package/dist/cjs/Modal/ConfirmationModal/ConfirmationModal.cjs +9 -5
  63. package/dist/cjs/Modal/ConfirmationModal/ConfirmationModal.module.scss.cjs +6 -2
  64. package/dist/cjs/Notification/ToastNotification/ToastNotification/ToastNotification.cjs +1 -3
  65. package/dist/cjs/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.cjs +1 -3
  66. package/dist/cjs/Notification/subcomponents/GenericNotification/GenericNotification.cjs +6 -3
  67. package/dist/cjs/Notification/subcomponents/GenericNotification/GenericNotification.module.scss.cjs +5 -3
  68. package/dist/cjs/Notification/subcomponents/NotificationIcon/NotificationIcon.cjs +35 -3
  69. package/dist/cjs/ProgressBar/ProgressBar.cjs +3 -2
  70. package/dist/cjs/ProgressBar/ProgressBar.module.scss.cjs +8 -4
  71. package/dist/cjs/Tile/subcomponents/GenericTile/GenericTile.cjs +7 -5
  72. package/dist/cjs/Tile/subcomponents/GenericTile/GenericTile.module.scss.cjs +8 -6
  73. package/dist/cjs/Well/Well.cjs +5 -4
  74. package/dist/cjs/Well/Well.module.scss.cjs +9 -1
  75. package/dist/cjs/{GuidanceBlock → __containers__/GuidanceBlock/v1}/GuidanceBlock.cjs +6 -6
  76. package/dist/cjs/__containers__/GuidanceBlock/v1/GuidanceBlock.module.scss.cjs +33 -0
  77. package/dist/cjs/__containers__/GuidanceBlock/v2/GuidanceBlock.cjs +160 -0
  78. package/dist/cjs/__containers__/GuidanceBlock/v2/GuidanceBlock.module.scss.cjs +28 -0
  79. package/dist/cjs/containersV1.cjs +4 -0
  80. package/dist/cjs/containersV2.cjs +4 -0
  81. package/dist/cjs/index.cjs +2 -2
  82. package/dist/esm/BrandMoment/BrandMoment.mjs +3 -2
  83. package/dist/esm/BrandMoment/BrandMoment.module.scss.mjs +3 -1
  84. package/dist/esm/Card/Card.mjs +7 -6
  85. package/dist/esm/Card/Card.module.scss.mjs +10 -2
  86. package/dist/esm/EmptyState/EmptyState.mjs +15 -7
  87. package/dist/esm/EmptyState/EmptyState.module.scss.mjs +3 -0
  88. package/dist/esm/ErrorPage/ErrorPage.mjs +1 -1
  89. package/dist/esm/Modal/ConfirmationModal/ConfirmationModal.mjs +9 -5
  90. package/dist/esm/Modal/ConfirmationModal/ConfirmationModal.module.scss.mjs +6 -2
  91. package/dist/esm/Notification/ToastNotification/ToastNotification/ToastNotification.mjs +1 -3
  92. package/dist/esm/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.mjs +1 -3
  93. package/dist/esm/Notification/subcomponents/GenericNotification/GenericNotification.mjs +8 -5
  94. package/dist/esm/Notification/subcomponents/GenericNotification/GenericNotification.module.scss.mjs +5 -3
  95. package/dist/esm/Notification/subcomponents/NotificationIcon/NotificationIcon.mjs +39 -5
  96. package/dist/esm/ProgressBar/ProgressBar.mjs +3 -2
  97. package/dist/esm/ProgressBar/ProgressBar.module.scss.mjs +8 -4
  98. package/dist/esm/Tile/subcomponents/GenericTile/GenericTile.mjs +7 -5
  99. package/dist/esm/Tile/subcomponents/GenericTile/GenericTile.module.scss.mjs +8 -6
  100. package/dist/esm/Well/Well.mjs +5 -4
  101. package/dist/esm/Well/Well.module.scss.mjs +9 -1
  102. package/dist/esm/{GuidanceBlock → __containers__/GuidanceBlock/v1}/GuidanceBlock.mjs +6 -6
  103. package/dist/esm/__containers__/GuidanceBlock/v1/GuidanceBlock.module.scss.mjs +31 -0
  104. package/dist/esm/__containers__/GuidanceBlock/v2/GuidanceBlock.mjs +153 -0
  105. package/dist/esm/__containers__/GuidanceBlock/v2/GuidanceBlock.module.scss.mjs +26 -0
  106. package/dist/esm/containersV1.mjs +1 -0
  107. package/dist/esm/containersV2.mjs +1 -0
  108. package/dist/esm/index.mjs +1 -1
  109. package/dist/styles.css +13 -12
  110. package/dist/types/BrandMoment/BrandMoment.d.ts +19 -3
  111. package/dist/types/Card/Card.d.ts +20 -7
  112. package/dist/types/EmptyState/EmptyState.d.ts +14 -6
  113. package/dist/types/Modal/ConfirmationModal/ConfirmationModal.d.ts +25 -7
  114. package/dist/types/Modal/GenericModal/subcomponents/ModalFooter/ModalFooter.d.ts +3 -0
  115. package/dist/types/Modal/InputEditModal/InputEditModal.d.ts +4 -1
  116. package/dist/types/Notification/GlobalNotification/GlobalNotification.d.ts +3 -3
  117. package/dist/types/Notification/InlineNotification/InlineNotification.d.ts +3 -3
  118. package/dist/types/Notification/ToastNotification/ToastNotification/ToastNotification.d.ts +5 -4
  119. package/dist/types/Notification/ToastNotification/context/ToastNotificationContext.d.ts +4 -3
  120. package/dist/types/Notification/ToastNotification/types.d.ts +3 -3
  121. package/dist/types/Notification/subcomponents/GenericNotification/GenericNotification.d.ts +24 -4
  122. package/dist/types/Notification/subcomponents/NotificationIcon/NotificationIcon.d.ts +11 -4
  123. package/dist/types/Notification/types.d.ts +2 -1
  124. package/dist/types/ProgressBar/ProgressBar.d.ts +25 -6
  125. package/dist/types/Tile/subcomponents/GenericTile/GenericTile.d.ts +10 -3
  126. package/dist/types/Well/Well.d.ts +6 -2
  127. package/dist/types/Well/types.d.ts +4 -0
  128. package/dist/types/{GuidanceBlock → __containers__/GuidanceBlock/v1}/GuidanceBlock.d.ts +4 -4
  129. package/dist/types/__containers__/GuidanceBlock/v2/GuidanceBlock.d.ts +59 -0
  130. package/dist/types/__containers__/GuidanceBlock/v2/index.d.ts +1 -0
  131. package/dist/types/__containers__/v1.d.ts +1 -0
  132. package/dist/types/__containers__/v2.d.ts +1 -0
  133. package/dist/types/index.d.ts +1 -1
  134. package/package.json +19 -5
  135. package/src/BrandMoment/BrandMoment.module.scss +20 -9
  136. package/src/BrandMoment/BrandMoment.tsx +26 -3
  137. package/src/BrandMoment/_docs/BrandMoment.mdx +13 -13
  138. package/src/BrandMoment/_docs/BrandMoment.stickersheet.stories.tsx +102 -0
  139. package/src/BrandMoment/_docs/BrandMoment.stories.tsx +17 -99
  140. package/src/Card/Card.module.scss +56 -7
  141. package/src/Card/Card.tsx +35 -11
  142. package/src/Card/_docs/Card.mdx +6 -3
  143. package/src/Card/_docs/Card.stickersheet.stories.tsx +44 -39
  144. package/src/Card/_docs/Card.stories.tsx +23 -23
  145. package/src/EmptyState/EmptyState.module.scss +32 -14
  146. package/src/EmptyState/EmptyState.tsx +32 -18
  147. package/src/EmptyState/_docs/EmptyState.stickersheet.stories.tsx +69 -121
  148. package/src/EmptyState/_docs/EmptyState.stories.tsx +6 -8
  149. package/src/ErrorPage/ErrorPage.tsx +1 -1
  150. package/src/Modal/ConfirmationModal/ConfirmationModal.module.scss +100 -78
  151. package/src/Modal/ConfirmationModal/ConfirmationModal.spec.tsx +5 -5
  152. package/src/Modal/ConfirmationModal/ConfirmationModal.tsx +41 -10
  153. package/src/Modal/ConfirmationModal/_docs/ConfirmationModal.mdx +3 -3
  154. package/src/Modal/ConfirmationModal/_docs/ConfirmationModal.stories.tsx +11 -4
  155. package/src/Modal/ContextModal/_docs/ContextModal.stories.tsx +3 -1
  156. package/src/Modal/GenericModal/subcomponents/ModalFooter/ModalFooter.tsx +3 -0
  157. package/src/Modal/InputEditModal/InputEditModal.tsx +4 -1
  158. package/src/Modal/InputEditModal/_docs/InputEditModal.mdx +0 -13
  159. package/src/Modal/InputEditModal/_docs/InputEditModal.stories.tsx +9 -10
  160. package/src/Notification/GlobalNotification/GlobalNotification.tsx +9 -4
  161. package/src/Notification/GlobalNotification/_docs/GlobalNotification.stickersheet.stories.tsx +68 -58
  162. package/src/Notification/GlobalNotification/_docs/GlobalNotification.stories.tsx +10 -13
  163. package/src/Notification/InlineNotification/InlineNotification.tsx +9 -4
  164. package/src/Notification/InlineNotification/_docs/InlineNotification.stickersheet.stories.tsx +79 -44
  165. package/src/Notification/InlineNotification/_docs/InlineNotification.stories.tsx +17 -17
  166. package/src/Notification/ToastNotification/ToastNotification/ToastNotification.tsx +7 -5
  167. package/src/Notification/ToastNotification/ToastNotificationsList/subcomponents/ToastNotificationsMap/ToastNotificationsMap.tsx +1 -2
  168. package/src/Notification/ToastNotification/_docs/ToastNotification.stickersheet.stories.tsx +12 -7
  169. package/src/Notification/ToastNotification/_docs/ToastNotification.stories.tsx +6 -1
  170. package/src/Notification/ToastNotification/context/ToastNotificationContext.tsx +7 -3
  171. package/src/Notification/ToastNotification/types.ts +8 -3
  172. package/src/Notification/subcomponents/GenericNotification/GenericNotification.module.scss +42 -5
  173. package/src/Notification/subcomponents/GenericNotification/GenericNotification.tsx +40 -6
  174. package/src/Notification/subcomponents/GenericNotification/_mixins.scss +2 -1
  175. package/src/Notification/subcomponents/NotificationIcon/NotificationIcon.tsx +31 -5
  176. package/src/Notification/types.ts +9 -2
  177. package/src/ProgressBar/ProgressBar.module.scss +37 -25
  178. package/src/ProgressBar/ProgressBar.tsx +30 -5
  179. package/src/ProgressBar/_docs/ProgressBar.mdx +2 -3
  180. package/src/ProgressBar/_docs/ProgressBar.stickersheet.stories.tsx +95 -51
  181. package/src/ProgressBar/_docs/ProgressBar.stories.tsx +56 -25
  182. package/src/Tile/InformationTile/_docs/InformationTile.mdx +3 -2
  183. package/src/Tile/InformationTile/_docs/InformationTile.stickersheet.stories.tsx +57 -19
  184. package/src/Tile/InformationTile/_docs/InformationTile.stories.tsx +19 -7
  185. package/src/Tile/MultiActionTile/_docs/MultiActionTile.mdx +3 -2
  186. package/src/Tile/MultiActionTile/_docs/MultiActionTile.stickersheet.stories.tsx +62 -24
  187. package/src/Tile/MultiActionTile/_docs/MultiActionTile.stories.tsx +19 -7
  188. package/src/Tile/subcomponents/GenericTile/GenericTile.module.scss +34 -22
  189. package/src/Tile/subcomponents/GenericTile/GenericTile.tsx +17 -8
  190. package/src/Tile/subcomponents/GenericTile/_docs/GenericTile.stickersheet.stories.tsx +57 -19
  191. package/src/Well/Well.module.scss +70 -33
  192. package/src/Well/Well.tsx +9 -3
  193. package/src/Well/_docs/Well.mdx +9 -2
  194. package/src/Well/_docs/Well.stickersheet.stories.tsx +10 -1
  195. package/src/Well/_docs/Well.stories.tsx +54 -29
  196. package/src/Well/types.ts +15 -0
  197. package/src/__actions__/Button/v3/_docs/ApiSpecification.mdx +1 -1
  198. package/src/__actions__/Menu/v3/MenuItem.module.scss +1 -0
  199. package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/GuidanceBlock.module.scss +2 -2
  200. package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/_docs/GuidanceBlock.mdx +2 -2
  201. package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/_docs/GuidanceBlock.stickersheet.stories.tsx +1 -1
  202. package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/_docs/GuidanceBlock.stories.tsx +1 -1
  203. package/src/__containers__/GuidanceBlock/v2/GuidanceBlock.module.scss +356 -0
  204. package/src/__containers__/GuidanceBlock/v2/GuidanceBlock.spec.tsx +82 -0
  205. package/src/__containers__/GuidanceBlock/v2/GuidanceBlock.tsx +262 -0
  206. package/src/__containers__/GuidanceBlock/v2/_docs/GuidanceBlock.mdx +38 -0
  207. package/src/__containers__/GuidanceBlock/v2/_docs/GuidanceBlock.stickersheet.stories.tsx +118 -0
  208. package/src/__containers__/GuidanceBlock/v2/_docs/GuidanceBlock.stories.tsx +152 -0
  209. package/src/__containers__/GuidanceBlock/v2/index.ts +1 -0
  210. package/src/__containers__/v1.ts +1 -0
  211. package/src/__containers__/v2.ts +1 -0
  212. package/src/index.ts +2 -1
  213. package/v1/containers/package.json +5 -0
  214. package/v2/containers/package.json +5 -0
  215. package/dist/cjs/GuidanceBlock/GuidanceBlock.module.scss.cjs +0 -33
  216. package/dist/esm/GuidanceBlock/GuidanceBlock.module.scss.mjs +0 -31
  217. package/dist/types/Tile/subcomponents/GenericTile/types.d.ts +0 -2
  218. package/src/EmptyState/_docs/EmptyState.stories.module.scss +0 -15
  219. package/src/Notification/ToastNotification/ToastNotification/ToastNotification.spec.tsx +0 -33
  220. package/src/Tile/subcomponents/GenericTile/types.ts +0 -10
  221. /package/dist/types/{GuidanceBlock → __containers__/GuidanceBlock/v1}/index.d.ts +0 -0
  222. /package/dist/types/{GuidanceBlock → __containers__/GuidanceBlock/v1}/types.d.ts +0 -0
  223. /package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/GuidanceBlock.spec.tsx +0 -0
  224. /package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/GuidanceBlock.tsx +0 -0
  225. /package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/index.ts +0 -0
  226. /package/src/{GuidanceBlock → __containers__/GuidanceBlock/v1}/types.ts +0 -0
@@ -0,0 +1,262 @@
1
+ import React, { useEffect, useState } from "react"
2
+ import classNames from "classnames"
3
+ import Media from "react-media"
4
+ import { Heading, HeadingProps } from "~components/Heading"
5
+ import { ArrowForwardIcon } from "~components/Icon"
6
+ import { SceneProps, SpotProps } from "~components/Illustration"
7
+ import { Text } from "~components/Text"
8
+ import { Button, ButtonProps } from "~components/__actions__/v2"
9
+ import { Tooltip, TooltipProps } from "~components/__overlays__/Tooltip/v1"
10
+ import styles from "./GuidanceBlock.module.scss"
11
+
12
+ export type ActionProps = ButtonProps & {
13
+ tooltip?: TooltipProps
14
+ }
15
+
16
+ type LayoutType = "default" | "inline" | "stacked"
17
+
18
+ type IllustrationType = "spot" | "scene"
19
+
20
+ type TextAlignment = "center" | "left"
21
+
22
+ type GuidanceBlockActions = {
23
+ primary: ActionProps
24
+ secondary?: ActionProps
25
+ dismiss?: {
26
+ onClick: () => void
27
+ }
28
+ }
29
+
30
+ type BaseGuidanceBlockProps = {
31
+ layout?: LayoutType
32
+ illustration: React.ReactElement<SpotProps | SceneProps>
33
+ /*
34
+ * Sets how the width and aspect ratio will respond to the Illustration passed in.
35
+ */
36
+ illustrationType?: IllustrationType
37
+
38
+ smallScreenTextAlignment?: TextAlignment
39
+ actions?: GuidanceBlockActions
40
+ /*
41
+ * This will still require the secondary object to be passed into the actions ie: {secondary: { label: "Dismiss action" }}`
42
+ */
43
+ secondaryDismiss?: boolean
44
+ /**
45
+ * If you are migrating from the KAIO v1:
46
+ * - `prominent` is now `expert-advice`
47
+ * - All other variants are removed in favour of `default`
48
+ */
49
+ variant?: "default" | "expert-advice"
50
+ withActionButtonArrow?: boolean
51
+ noMaxWidth?: boolean
52
+ }
53
+
54
+ type GuidanceBlockWithText = {
55
+ text: {
56
+ title: string
57
+ titleTag?: HeadingProps["tag"]
58
+ description: string | React.ReactNode
59
+ }
60
+ } & BaseGuidanceBlockProps
61
+
62
+ type GuidanceBlockPropsWithContent = {
63
+ content: React.ReactElement
64
+ } & BaseGuidanceBlockProps
65
+
66
+ export type GuidanceBlockProps =
67
+ | GuidanceBlockWithText
68
+ | GuidanceBlockPropsWithContent
69
+
70
+ export type GuidanceBlockState = {
71
+ hidden: boolean
72
+ removed: boolean
73
+ mediaQueryLayout: string
74
+ }
75
+
76
+ type WithTooltipProps = {
77
+ children: React.ReactNode
78
+ tooltipProps?: TooltipProps
79
+ }
80
+
81
+ const WithTooltip = ({
82
+ tooltipProps,
83
+ children,
84
+ }: WithTooltipProps): JSX.Element =>
85
+ !!tooltipProps ? (
86
+ <Tooltip {...tooltipProps}>{children}</Tooltip>
87
+ ) : (
88
+ <>{children}</>
89
+ )
90
+
91
+ /**
92
+ * {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082093807/Guidance+Block Guidance} |
93
+ * {@link https://cultureamp.design/?path=/docs/components-guidanceblock--docs Storybook}
94
+ */
95
+ export const GuidanceBlock = ({
96
+ layout = "default",
97
+ variant = "default",
98
+ withActionButtonArrow = true,
99
+ noMaxWidth = false,
100
+ illustrationType = "spot",
101
+ smallScreenTextAlignment = "center",
102
+ actions,
103
+ illustration,
104
+ secondaryDismiss,
105
+ ...restProps
106
+ }: GuidanceBlockProps): JSX.Element => {
107
+ const [hidden, setHidden] = useState<boolean>(false)
108
+ const [removed, setRemoved] = useState<boolean>(false)
109
+ const [mediaQueryLayout, setMediaQueryLayout] = useState<string>("")
110
+
111
+ const containerRef = React.createRef<HTMLDivElement>()
112
+
113
+ useEffect(() => {
114
+ if (layout === "inline" || layout === "stacked") {
115
+ containerQuery()
116
+ }
117
+ }, [])
118
+
119
+ const handleDismissBanner = (): void => {
120
+ setHidden(true)
121
+ actions?.dismiss?.onClick()
122
+ }
123
+
124
+ const onTransitionEnd = (e: React.TransitionEvent<HTMLDivElement>): void => {
125
+ // Be careful: this assumes the final CSS property to be animated is "margin-top".
126
+ if (hidden && e.propertyName === "margin-top") {
127
+ setRemoved(true)
128
+ }
129
+ }
130
+
131
+ const containerQuery = (): void => {
132
+ const resizeObserver = new ResizeObserver(entries => {
133
+ if (entries.length === 1) {
134
+ handleMediaQueryLayout(entries[0].contentRect.width)
135
+ }
136
+ })
137
+
138
+ resizeObserver.observe(containerRef.current as HTMLElement)
139
+ }
140
+
141
+ const handleMediaQueryLayout = (width: number): void => {
142
+ if (width <= 320) {
143
+ setMediaQueryLayout("centerContent")
144
+ } else {
145
+ setMediaQueryLayout("")
146
+ }
147
+ }
148
+
149
+ const marginTop = (): string => {
150
+ if (hidden && containerRef.current) {
151
+ return -containerRef.current.clientHeight + "px"
152
+ }
153
+
154
+ return "0"
155
+ }
156
+
157
+ if (removed) {
158
+ return <></>
159
+ }
160
+
161
+ const componentIsMobile = mediaQueryLayout.includes("centerContent")
162
+
163
+ return (
164
+ <div
165
+ className={classNames(
166
+ styles.banner,
167
+ variant && styles[variant],
168
+ layout && styles[layout],
169
+ hidden && styles.hidden,
170
+ mediaQueryLayout === "centerContent" && styles.centerContent,
171
+ noMaxWidth && styles.noMaxWidth,
172
+ illustrationType === "scene" && styles.hasSceneIllustration,
173
+ smallScreenTextAlignment === "left" && styles.smallScreenTextAlignment
174
+ )}
175
+ style={{
176
+ marginTop: marginTop(),
177
+ }}
178
+ ref={containerRef}
179
+ onTransitionEnd={onTransitionEnd}
180
+ >
181
+ <div className={styles.illustrationWrapper}>
182
+ <div className={styles.illustration}>
183
+ {illustrationType === "scene"
184
+ ? React.cloneElement(illustration, { enableAspectRatio: true })
185
+ : illustration}
186
+ </div>
187
+ </div>
188
+ <div className={styles.descriptionAndActions}>
189
+ <div className={styles.descriptionContainer}>
190
+ {"content" in restProps && restProps.content}
191
+ {"text" in restProps && (
192
+ <>
193
+ <div className={styles.headingWrapper}>
194
+ <Heading
195
+ tag={restProps?.text?.titleTag ?? "h3"}
196
+ variant="heading-3"
197
+ >
198
+ {restProps?.text?.title}
199
+ </Heading>
200
+ </div>
201
+ <Text tag="p" variant="body">
202
+ {restProps?.text?.description}
203
+ </Text>
204
+ </>
205
+ )}
206
+ </div>
207
+ {actions?.primary && (
208
+ <Media query="(max-width: 767px)">
209
+ {(isMobile: boolean): JSX.Element => (
210
+ <div
211
+ className={classNames({
212
+ noRightMargin: isMobile || componentIsMobile,
213
+ rightMargin:
214
+ !(isMobile || componentIsMobile) && layout === "default",
215
+ })}
216
+ >
217
+ <div
218
+ className={classNames(
219
+ styles.buttonContainer,
220
+ actions?.secondary && styles.secondaryAction
221
+ )}
222
+ >
223
+ <WithTooltip tooltipProps={actions.primary.tooltip}>
224
+ <Button
225
+ icon={
226
+ withActionButtonArrow ? (
227
+ <ArrowForwardIcon role="presentation" />
228
+ ) : undefined
229
+ }
230
+ iconPosition="end"
231
+ {...actions.primary}
232
+ fullWidth={isMobile || componentIsMobile}
233
+ />
234
+ </WithTooltip>
235
+
236
+ {actions?.secondary && (
237
+ <WithTooltip tooltipProps={actions.secondary.tooltip}>
238
+ <div className={styles.secondaryAction}>
239
+ <Button
240
+ secondary
241
+ {...actions.secondary}
242
+ onClick={
243
+ secondaryDismiss
244
+ ? (): void => handleDismissBanner()
245
+ : actions?.secondary?.onClick
246
+ }
247
+ fullWidth={isMobile || componentIsMobile}
248
+ />
249
+ </div>
250
+ </WithTooltip>
251
+ )}
252
+ </div>
253
+ </div>
254
+ )}
255
+ </Media>
256
+ )}
257
+ </div>
258
+ </div>
259
+ )
260
+ }
261
+
262
+ GuidanceBlock.displayName = "GuidanceBlock"
@@ -0,0 +1,38 @@
1
+ import { Canvas, Controls, DocsStory, Meta } from "@storybook/blocks"
2
+ import { ResourceLinks, KAIOInstallation } from "~storybook/components"
3
+ import * as GuidanceBlockStories from "./GuidanceBlock.stories"
4
+
5
+ <Meta of={GuidanceBlockStories} />
6
+
7
+ # GuidanceBlock (V2)
8
+
9
+ <ResourceLinks
10
+ sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/GuidanceBlock"
11
+ figma="https://www.figma.com/file/ZRfnoNUXbGZv4eVWLbF4Az/%EF%B8%8F%F0%9F%96%BC%EF%B8%8F-Component-Gallery?node-id=622%3A149926&t=P1w10jr2cpPuaayw-1"
12
+ designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3082093807/Guidance+Block"
13
+
14
+ />
15
+
16
+ <KAIOInstallation exportNames="GuidanceBlock" version="2" family="containers" />
17
+
18
+ ## Overview
19
+
20
+ A Guidance Block provides a familiar layout that is visually prominent to draw attention to related content.
21
+ It guides people to new actions they haven't done before or connects them to relevant content they can view on another page.
22
+
23
+ <Canvas of={GuidanceBlockStories.Playground} />
24
+ <Controls of={GuidanceBlockStories.Playground} />
25
+
26
+ ## API
27
+
28
+ <DocsStory of={GuidanceBlockStories.Actions} />
29
+
30
+ <DocsStory of={GuidanceBlockStories.Tooltip} />
31
+
32
+ <DocsStory of={GuidanceBlockStories.CustomContent} />
33
+
34
+ <DocsStory of={GuidanceBlockStories.Stacked} />
35
+
36
+ <DocsStory of={GuidanceBlockStories.SceneExample} />
37
+
38
+ <DocsStory of={GuidanceBlockStories.Variants} />
@@ -0,0 +1,118 @@
1
+ import React from "react"
2
+ import { Meta } from "@storybook/react"
3
+ import { Heading } from "~components/Heading"
4
+ import { EmptyStatesPositive, Informative } from "~components/Illustration"
5
+ import { Tag } from "~components/Tag"
6
+ import { Text } from "~components/Text"
7
+ import {
8
+ StickerSheet,
9
+ StickerSheetStory,
10
+ } from "~storybook/components/StickerSheet"
11
+ import { GuidanceBlock, GuidanceBlockProps } from "../index"
12
+
13
+ export default {
14
+ title: "Containers/GuidanceBlock/v2",
15
+ parameters: {
16
+ chromatic: { disable: false },
17
+ controls: { disable: true },
18
+ },
19
+ } satisfies Meta
20
+
21
+ const GENERIC_PROPS = {
22
+ persistent: true,
23
+ illustration: <Informative alt="" />,
24
+ actions: {
25
+ primary: {
26
+ label: "Action",
27
+ onClick: () => {
28
+ alert("tada: 🎉")
29
+ },
30
+ },
31
+ secondary: {
32
+ label: "Pass",
33
+ onClick: () => {
34
+ alert("tada: 🎉")
35
+ },
36
+ },
37
+ },
38
+ }
39
+
40
+ const TEXT_PROPS: GuidanceBlockProps = {
41
+ ...GENERIC_PROPS,
42
+ text: {
43
+ title: "This is the Guidance block title",
44
+ description:
45
+ "Mussum Ipsum, cacilds vidis litro abertis. Suco de cevadiss, é um leite divinis, " +
46
+ "qui tem lupuliz, matis, aguis e fermentis. Mé faiz elementum girarzis, nisi eros vermeio.",
47
+ },
48
+ }
49
+
50
+ const CONTENT_PROPS: GuidanceBlockProps = {
51
+ ...GENERIC_PROPS,
52
+ content: (
53
+ <>
54
+ <Tag>Early Access</Tag>
55
+ <Heading variant="heading-3">{TEXT_PROPS.text.title}</Heading>
56
+ <Text variant="body">{TEXT_PROPS.text.description}</Text>
57
+ </>
58
+ ),
59
+ }
60
+
61
+ const StickerSheetTemplate: StickerSheetStory = {
62
+ render: ({ isReversed }) => (
63
+ <StickerSheet isReversed={isReversed}>
64
+ <StickerSheet.Body>
65
+ <StickerSheet.Row rowTitle="Default">
66
+ <GuidanceBlock {...TEXT_PROPS} />
67
+ </StickerSheet.Row>
68
+ <StickerSheet.Row rowTitle="Expert advice">
69
+ <GuidanceBlock variant="expert-advice" {...TEXT_PROPS} />
70
+ </StickerSheet.Row>
71
+ <StickerSheet.Row rowTitle="No arrow">
72
+ <GuidanceBlock withActionButtonArrow={false} {...TEXT_PROPS} />
73
+ </StickerSheet.Row>
74
+ <StickerSheet.Row rowTitle="Custom Content">
75
+ <GuidanceBlock {...CONTENT_PROPS} />
76
+ </StickerSheet.Row>
77
+ <StickerSheet.Row rowTitle="Tooltip">
78
+ <GuidanceBlock
79
+ {...TEXT_PROPS}
80
+ actions={{
81
+ primary: {
82
+ ...GENERIC_PROPS.actions.primary,
83
+ tooltip: {
84
+ text: "Opens in a new tab",
85
+ mood: "cautionary",
86
+ isInitiallyVisible: true,
87
+ },
88
+ },
89
+ }}
90
+ />
91
+ </StickerSheet.Row>
92
+ <StickerSheet.Row rowTitle="Scene Illustration">
93
+ <GuidanceBlock
94
+ {...TEXT_PROPS}
95
+ illustration={<EmptyStatesPositive alt="" />}
96
+ illustrationType="scene"
97
+ />
98
+ </StickerSheet.Row>
99
+ <StickerSheet.Row rowTitle="No Max Width">
100
+ <GuidanceBlock {...TEXT_PROPS} noMaxWidth />
101
+ </StickerSheet.Row>
102
+ </StickerSheet.Body>
103
+ </StickerSheet>
104
+ ),
105
+ }
106
+
107
+ export const StickerSheetDefault: StickerSheetStory = {
108
+ ...StickerSheetTemplate,
109
+ name: "Sticker Sheet (Default)",
110
+ }
111
+
112
+ export const StickerSheetRTL: StickerSheetStory = {
113
+ ...StickerSheetTemplate,
114
+ name: "Sticker Sheet (RTL)",
115
+ parameters: {
116
+ textDirection: "rtl",
117
+ },
118
+ }
@@ -0,0 +1,152 @@
1
+ import React from "react"
2
+ import { Meta, StoryObj } from "@storybook/react"
3
+ import { Heading } from "~components/Heading"
4
+ import {
5
+ BrandMomentPositiveOutro,
6
+ Informative,
7
+ SkillsCoachEssentialFeedback,
8
+ } from "~components/Illustration"
9
+ import { Text } from "~components/Text"
10
+ import { GuidanceBlock } from "../index"
11
+
12
+ const ContentComponent = (): JSX.Element => (
13
+ <>
14
+ <Heading tag="h3" variant="heading-3">
15
+ This is the Guidance block title
16
+ </Heading>
17
+ <Text variant="body">
18
+ Mussum Ipsum, cacilds vidis litro abertis. Suco de cevadiss, é um leite
19
+ divinis,
20
+ </Text>
21
+ </>
22
+ )
23
+
24
+ const defaultText = {
25
+ description:
26
+ "Mussum Ipsum, cacilds vidis litro abertis. Suco de cevadiss, é um leite divinis, qui tem lupuliz, matis, aguis e fermentis. Mé faiz elementum girarzis, nisi eros vermeio.",
27
+ title: "This is the Guidance block title",
28
+ }
29
+
30
+ const meta = {
31
+ title: "Containers/GuidanceBlock/v2",
32
+ component: GuidanceBlock,
33
+ args: {
34
+ layout: "default",
35
+ illustration: <Informative alt="" />,
36
+ },
37
+ argTypes: {
38
+ actions: {
39
+ control: false,
40
+ },
41
+ illustrationType: {
42
+ description:
43
+ "Sets the how the width and aspect ratio will respond to the Illustration passed in.",
44
+ },
45
+ illustration: {
46
+ control: { type: "radio" },
47
+ options: ["spot", "scene"],
48
+ mapping: {
49
+ spot: <Informative alt="" />,
50
+ scene: <BrandMomentPositiveOutro alt="" />,
51
+ },
52
+ description:
53
+ "This takes a scene scene or spot element, ie: `<Informative />`. This radio button implementation is a storybook only representation to toggle between the two illustration styles.",
54
+ },
55
+ content: {
56
+ description:
57
+ "If you need to render custom content inside of the `GuidanceBlock` that is more than just a title and description use this prop instead of the default `text` option.",
58
+ },
59
+ },
60
+ } satisfies Meta<typeof GuidanceBlock>
61
+
62
+ export default meta
63
+
64
+ type Story = StoryObj<typeof meta>
65
+
66
+ export const Playground: Story = {
67
+ args: {
68
+ text: defaultText,
69
+ },
70
+ parameters: {
71
+ docs: {
72
+ canvas: {
73
+ sourceState: "shown",
74
+ },
75
+ },
76
+ },
77
+ }
78
+
79
+ export const Actions: Story = {
80
+ args: {
81
+ content: <ContentComponent />,
82
+ actions: {
83
+ primary: {
84
+ label: "Learn more",
85
+ onClick: () => alert("tada: 🎉"),
86
+ },
87
+ secondary: {
88
+ label: "Dismiss",
89
+ href: "#",
90
+ },
91
+ },
92
+ },
93
+ }
94
+
95
+ export const Tooltip: Story = {
96
+ args: {
97
+ content: <ContentComponent />,
98
+ actions: {
99
+ primary: {
100
+ label: "Hover me for a tooltip",
101
+ onClick: () => alert("tada: 🎉"),
102
+ tooltip: {
103
+ text: "Opens in a new tab",
104
+ mood: "cautionary",
105
+ },
106
+ },
107
+ secondary: {
108
+ label: "Dismiss",
109
+ href: "#",
110
+ },
111
+ },
112
+ },
113
+ }
114
+
115
+ export const CustomContent: Story = {
116
+ args: {
117
+ content: <ContentComponent />,
118
+ },
119
+ }
120
+
121
+ export const Stacked: Story = {
122
+ render: args => (
123
+ <div style={{ display: "flex", gap: "36px" }}>
124
+ <GuidanceBlock {...args} />
125
+ <GuidanceBlock {...args} />
126
+ </div>
127
+ ),
128
+ args: {
129
+ layout: "stacked",
130
+ content: <ContentComponent />,
131
+ },
132
+ }
133
+
134
+ export const SceneExample: Story = {
135
+ args: {
136
+ illustration: <SkillsCoachEssentialFeedback alt="" />,
137
+ illustrationType: "scene",
138
+ text: defaultText,
139
+ },
140
+ }
141
+
142
+ export const Variants: Story = {
143
+ render: args => (
144
+ <div className="flex flex-col gap-16">
145
+ <GuidanceBlock {...args} />
146
+ <GuidanceBlock variant="expert-advice" {...args} />
147
+ </div>
148
+ ),
149
+ args: {
150
+ text: defaultText,
151
+ },
152
+ }
@@ -0,0 +1 @@
1
+ export * from "./GuidanceBlock"
@@ -0,0 +1 @@
1
+ export * from "./GuidanceBlock/v1"
@@ -0,0 +1 @@
1
+ export * from "./GuidanceBlock/v2"
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@ export * from "./ErrorPage"
20
20
  export * from "./FieldGroup"
21
21
  export * from "./FieldMessage"
22
22
  export * from "./Filter"
23
- export * from "./GuidanceBlock"
23
+
24
24
  export * from "./Heading"
25
25
  export * from "./Icon"
26
26
  export * from "./Illustration"
@@ -61,3 +61,4 @@ export * from "./Workflow"
61
61
  export * from "./__overlays__/Tooltip/v1"
62
62
  export * from "./__actions__/Menu/v1"
63
63
  export * from "./__actions__/Button/v1"
64
+ export * from "./__containers__/GuidanceBlock/v1"
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../dist/cjs/containersV1.cjs",
3
+ "module": "../../dist/esm/containersV1.mjs",
4
+ "types": "../../dist/types/__containers__/v1.d.ts"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../dist/cjs/containersV2.cjs",
3
+ "module": "../../dist/esm/containersV2.mjs",
4
+ "types": "../../dist/types/__containers__/v2.d.ts"
5
+ }
@@ -1,33 +0,0 @@
1
- 'use strict';
2
-
3
- var styles = {
4
- "rightMargin": "GuidanceBlock-module_rightMargin__-iEFa",
5
- "noRightMargin": "GuidanceBlock-module_noRightMargin__4Uy9N",
6
- "banner": "GuidanceBlock-module_banner__FxKcd",
7
- "noMaxWidth": "GuidanceBlock-module_noMaxWidth__UzHP1",
8
- "illustrationWrapper": "GuidanceBlock-module_illustrationWrapper__AEljX",
9
- "illustration": "GuidanceBlock-module_illustration__sU1Vu",
10
- "hasSceneIllustration": "GuidanceBlock-module_hasSceneIllustration__tvFRD",
11
- "descriptionContainer": "GuidanceBlock-module_descriptionContainer__aywtY",
12
- "descriptionAndActions": "GuidanceBlock-module_descriptionAndActions__E5BcL",
13
- "buttonContainer": "GuidanceBlock-module_buttonContainer__U2Hxn",
14
- "hidden": "GuidanceBlock-module_hidden__CbgXn",
15
- "headingWrapper": "GuidanceBlock-module_headingWrapper__zgVmA",
16
- "cancel": "GuidanceBlock-module_cancel__UaIA-",
17
- "icon": "GuidanceBlock-module_icon__y2xz8",
18
- "disabled": "GuidanceBlock-module_disabled__Uhgsr",
19
- "hover": "GuidanceBlock-module_hover__7V9x1",
20
- "active": "GuidanceBlock-module_active__YJaZt",
21
- "default": "GuidanceBlock-module_default__Ffblg",
22
- "positive": "GuidanceBlock-module_positive__yENlT",
23
- "negative": "GuidanceBlock-module_negative__E-Jvh",
24
- "assertive": "GuidanceBlock-module_assertive__6PZlM",
25
- "informative": "GuidanceBlock-module_informative__ZUH4j",
26
- "cautionary": "GuidanceBlock-module_cautionary__sJ1CE",
27
- "prominent": "GuidanceBlock-module_prominent__nn-r4",
28
- "inline": "GuidanceBlock-module_inline__GwOWR",
29
- "stacked": "GuidanceBlock-module_stacked__rDupX",
30
- "centerContent": "GuidanceBlock-module_centerContent__m3IhB",
31
- "smallScreenTextAlignment": "GuidanceBlock-module_smallScreenTextAlignment__oWufj"
32
- };
33
- module.exports = styles;
@@ -1,31 +0,0 @@
1
- var styles = {
2
- "rightMargin": "GuidanceBlock-module_rightMargin__-iEFa",
3
- "noRightMargin": "GuidanceBlock-module_noRightMargin__4Uy9N",
4
- "banner": "GuidanceBlock-module_banner__FxKcd",
5
- "noMaxWidth": "GuidanceBlock-module_noMaxWidth__UzHP1",
6
- "illustrationWrapper": "GuidanceBlock-module_illustrationWrapper__AEljX",
7
- "illustration": "GuidanceBlock-module_illustration__sU1Vu",
8
- "hasSceneIllustration": "GuidanceBlock-module_hasSceneIllustration__tvFRD",
9
- "descriptionContainer": "GuidanceBlock-module_descriptionContainer__aywtY",
10
- "descriptionAndActions": "GuidanceBlock-module_descriptionAndActions__E5BcL",
11
- "buttonContainer": "GuidanceBlock-module_buttonContainer__U2Hxn",
12
- "hidden": "GuidanceBlock-module_hidden__CbgXn",
13
- "headingWrapper": "GuidanceBlock-module_headingWrapper__zgVmA",
14
- "cancel": "GuidanceBlock-module_cancel__UaIA-",
15
- "icon": "GuidanceBlock-module_icon__y2xz8",
16
- "disabled": "GuidanceBlock-module_disabled__Uhgsr",
17
- "hover": "GuidanceBlock-module_hover__7V9x1",
18
- "active": "GuidanceBlock-module_active__YJaZt",
19
- "default": "GuidanceBlock-module_default__Ffblg",
20
- "positive": "GuidanceBlock-module_positive__yENlT",
21
- "negative": "GuidanceBlock-module_negative__E-Jvh",
22
- "assertive": "GuidanceBlock-module_assertive__6PZlM",
23
- "informative": "GuidanceBlock-module_informative__ZUH4j",
24
- "cautionary": "GuidanceBlock-module_cautionary__sJ1CE",
25
- "prominent": "GuidanceBlock-module_prominent__nn-r4",
26
- "inline": "GuidanceBlock-module_inline__GwOWR",
27
- "stacked": "GuidanceBlock-module_stacked__rDupX",
28
- "centerContent": "GuidanceBlock-module_centerContent__m3IhB",
29
- "smallScreenTextAlignment": "GuidanceBlock-module_smallScreenTextAlignment__oWufj"
30
- };
31
- export { styles as default };
@@ -1,2 +0,0 @@
1
- export declare const moodsList: readonly ["positive", "informative", "cautionary", "assertive", "negative", "prominent"];
2
- export type Moods = (typeof moodsList)[number];