@kaizen/components 3.3.15 → 3.3.16

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.
@@ -16,6 +16,11 @@ import { type NavigationTabProps } from './subcomponents/NavigationTabs';
16
16
  export type TitleBlockProps = {
17
17
  children?: React.ReactNode;
18
18
  title: string;
19
+ /**
20
+ * `light` is the recommended variant for new implementations. Leaving `variant`
21
+ * unset falls back to the default purple background.
22
+ *
23
+ */
19
24
  variant?: TitleBlockVariant;
20
25
  breadcrumb?: TitleBlockBreadcrumbType;
21
26
  avatar?: JSX.Element | TitleBlockAvatarProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "3.3.15",
3
+ "version": "3.3.16",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -103,7 +103,7 @@
103
103
  "lodash.debounce": "^4.0.8",
104
104
  "nanobus": "^4.5.0",
105
105
  "prosemirror-commands": "^1.7.2",
106
- "prosemirror-history": "^1.5.0",
106
+ "prosemirror-history": "^1.5.1",
107
107
  "prosemirror-inputrules": "^1.5.1",
108
108
  "prosemirror-keymap": "^1.2.3",
109
109
  "prosemirror-model": "^1.25.12",
@@ -130,7 +130,7 @@
130
130
  },
131
131
  "devDependencies": {
132
132
  "@cultureamp/frontend-apis": "13.3.0",
133
- "@cultureamp/i18n-react-intl": "^4.6.5",
133
+ "@cultureamp/i18n-react-intl": "^4.6.6",
134
134
  "@cultureamp/package-bundler": "^4.1.1",
135
135
  "@svgr/rollup": "^8.1.0",
136
136
  "@testing-library/dom": "^10.4.2",
@@ -149,21 +149,21 @@
149
149
  "postcss": "^8.5.28",
150
150
  "postcss-cli": "^11.0.1",
151
151
  "postcss-import": "^16.2.0",
152
- "postcss-preset-env": "^11.5.4",
152
+ "postcss-preset-env": "^11.6.0",
153
153
  "postcss-scss": "^4.0.9",
154
154
  "query-string": "^9.5.1",
155
155
  "react": "19.2.8",
156
156
  "react-dom": "19.2.8",
157
157
  "react-highlight": "^0.15.0",
158
158
  "react-intl": "^10.2.2",
159
- "rollup": "^4.63.5",
159
+ "rollup": "^4.64.0",
160
160
  "sass": "1.79.6",
161
161
  "serialize-query-params": "^2.0.4",
162
162
  "svgo": "^4.1.0",
163
163
  "ts-patch": "^3.3.0",
164
164
  "tslib": "^2.8.1",
165
165
  "tsx": "^4.23.15",
166
- "@kaizen/design-tokens": "11.0.19"
166
+ "@kaizen/design-tokens": "11.0.20"
167
167
  },
168
168
  "devDependenciesComments": {
169
169
  "sass": "Prevent deprecation warnings introduced in 1.80 as we plan to move away from sass",
@@ -17,14 +17,15 @@ import * as TitleBlockStories from './TitleBlock.stories'
17
17
 
18
18
  `TitleBlock` A consistent pattern to allow users to navigate and complete tasks easily.
19
19
 
20
- <Canvas of={TitleBlockStories.Playground} />
20
+ <Canvas of={TitleBlockStories.LightVariant} />
21
21
 
22
22
  ## Props
23
23
 
24
24
  <Controls
25
- of={TitleBlockStories.Playground}
25
+ of={TitleBlockStories.LightVariant}
26
26
  include={[
27
27
  'avatar',
28
+ //TODO: note as depreication per https://cultureamp.atlassian.net/browse/KZN-4538
28
29
  'breadcrumb',
29
30
  'defaultAction',
30
31
  'handleHamburgerClick',
@@ -32,13 +33,30 @@ import * as TitleBlockStories from './TitleBlock.stories'
32
33
  'primaryAction',
33
34
  'secondaryActions',
34
35
  'secondaryOverflowMenuItems',
36
+ 'sticky',
35
37
  'surveyStatus',
36
38
  'title',
39
+ 'variant',
37
40
  ]}
38
41
  />
39
42
 
40
43
  ## Options
41
44
 
45
+ ### variant
46
+
47
+ ```
48
+ variant?: 'light' | 'admin' | 'education'
49
+ ```
50
+
51
+ Controls the TitleBlock's background and text colour. `light`
52
+ is the recommended value. Without passing it, the UI renders as the default
53
+ purple variant. See
54
+ [Usage Guidelines](/docs/components-titleblock-usage-guidelines--docs)
55
+ for the full guidance.
56
+
57
+ If you're rendering `NavigationTab`s alongside the TitleBlock, set the same
58
+ `variant` on each tab. Tabs don't inherit from the TitleBlock.
59
+
42
60
  ### primaryAction
43
61
 
44
62
  The primary action (the "main" button in the top right) can either be a Button,
@@ -66,6 +84,18 @@ If you want it to be a Menu, pass in this object of type `MenuGroup`:
66
84
  Using the `label`, the Title Block will render a Button with a chevron icon and your `menuItems` will appear
67
85
  in the dropdown menu when you click it. (`MenuItemProps` is a type imported from the `Menu` component.)
68
86
 
87
+ ### defaultAction
88
+
89
+ ```
90
+ type DefaultActionProps = TitleBlockButtonProps | TitleBlockCustomButtonProps
91
+ ```
92
+
93
+ Renders a Button immediately to the left of `primaryAction`, in the same top
94
+ row. Pass the Button's props as an object, same as `primaryAction`.
95
+
96
+ Unlike `primaryAction`, `defaultAction` **can't be a menu group** There's no
97
+ dropdown variant of the default action, so passing `menuItems` is invalid. It can take a `badge`, but the badge only renders on the full-width button: at tablet and ≤360px widths the default action collapses into a menu item and the badge isn't shown.
98
+
69
99
  ### secondaryActions & secondaryOverflowMenuItems
70
100
 
71
101
  Secondary Actions sit below the Primary Actions, and consist of
@@ -1,5 +1,6 @@
1
- import { Canvas, DocsStory, Meta, Controls } from '@storybook/blocks'
2
- import { ResourceLinks, KAIOInstallation, DosAndDonts, DoOrDont } from '~storybook/components'
1
+ import { Canvas, DocsStory, Meta, Controls, Unstyled } from '@storybook/blocks'
2
+ import { ResourceLinks, KAIOInstallation } from '~storybook/components'
3
+ import { InlineNotification } from '~components/Notification'
3
4
  import * as TitleBlockStories from './TitleBlock.stories'
4
5
 
5
6
  <Meta title="Components/TitleBlock/Usage Guidelines" />
@@ -18,31 +19,106 @@ import * as TitleBlockStories from './TitleBlock.stories'
18
19
 
19
20
  A consistent pattern to allow users to navigate and complete tasks easily.
20
21
 
21
- <Canvas of={TitleBlockStories.Playground} />
22
+ <Canvas of={TitleBlockStories.LightVariant} sourceState="hidden" />
22
23
 
23
24
  <Controls
24
- of={TitleBlockStories.Playground}
25
- include={['avatar', 'defaultAction', 'navigationTabs', 'primaryAction', 'title']}
25
+ of={TitleBlockStories.LightVariant}
26
+ include={[
27
+ 'avatar',
28
+ 'defaultAction',
29
+ 'navigationTabs',
30
+ 'primaryAction',
31
+ 'sticky',
32
+ 'title',
33
+ 'variant',
34
+ ]}
26
35
  />
27
36
 
28
- ## Examples
37
+ ## Variants
38
+
39
+ <Unstyled>
40
+ <InlineNotification persistent variant="cautionary">
41
+ {
42
+ <>
43
+ <strong>
44
+ Passing <code>variant="light"</code> is the ongoing recommendation.
45
+ </strong>{' '}
46
+ When a variant isn't passed, TitleBlock falls back to the default purple variant.
47
+ </>
48
+ }
49
+ </InlineNotification>
50
+ </Unstyled>
51
+
52
+ ### Light (recommended)
53
+
54
+ <Canvas of={TitleBlockStories.LightVariant} sourceState="hidden" />
55
+
56
+ **If you're using navigation tabs, set `variant="light"` on each
57
+ `NavigationTab`** Tabs don't inherit the variant from the TitleBlock. set
58
+ it in both places, or the tabs keep their purple background.
59
+
60
+ ```tsx
61
+ <TitleBlock
62
+ variant="light"
63
+ title="Page title"
64
+ navigationTabs={[
65
+ <NavigationTab key="1" variant="light" text="Label" href="#" active />,
66
+ <NavigationTab key="2" variant="light" text="Label" href="#" />,
67
+ ]}
68
+ />
69
+ ```
29
70
 
30
- ### Viewports
71
+ ### Default (purple)
31
72
 
32
- <Canvas of={TitleBlockStories.Viewports} />
73
+ Shown for recognition only. Don't reach for this on new surfaces.
33
74
 
34
- ### Long titles
75
+ <Canvas of={TitleBlockStories.Playground} sourceState="hidden" />
76
+
77
+ ## Sticky behavior
78
+
79
+ Setting `sticky` pins the TitleBlock's top strip to the top of its scroll
80
+ container as the page scrolls, instead of letting it scroll away. Full
81
+ mechanism, structure, and code for reserving space above the strip (for
82
+ example, a banner) are covered in the
83
+ [Sticky Banner guide](/docs/components-titleblock-sticky-banner--docs).
84
+
85
+ **If your surface is adding Coach, turn `sticky` on.** A pinned top strip is a
86
+ requirement when the header carries a Coach button.
87
+
88
+ ### Coach button placement
35
89
 
36
- <Canvas of={TitleBlockStories.HasLongTitle} />
90
+ For teams adding Coach to a surface that already has a primary Call to action CTA:
37
91
 
38
- ### Light Variant
92
+ - **Coach is the primary action.** Pass it as `primaryAction`.
93
+ - **Demote the existing primary CTA to `defaultAction`.** This is the slot
94
+ that renders immediately to the left of `primaryAction`, in the same top
95
+ row. Don't use `secondaryActions` or `secondaryOverflowMenuItems` for this.
96
+ Those render in a separate row below, alongside the navigation tabs, not
97
+ next to the primary and default actions.
98
+
99
+ TitleBlock predates current naming conventions, so `defaultAction` is
100
+ its term for what a modern component would call a secondary action: a
101
+ non-primary button rendered next to the primary one.
102
+
103
+ - **Coach sits furthest right**, closest to the side panel. TitleBlock is
104
+ props-based and its action slots aren't reorderable, so passing Coach as
105
+ `primaryAction` gives you this placement automatically.
106
+
107
+ ## Examples
108
+
109
+ ### Long titles
39
110
 
40
- <Canvas of={TitleBlockStories.LightVariant} />
111
+ <Canvas of={TitleBlockStories.HasLongTitleLightVariant} sourceState="hidden" />
41
112
 
42
- ### Admin Variant
113
+ ### Default action limitations
43
114
 
44
- <Canvas of={TitleBlockStories.AdminVariant} />
115
+ `primaryAction` and `defaultAction` both render in the top row, but they don't
116
+ accept the same props:
45
117
 
46
- ### Education Variant
118
+ - **`defaultAction` accepts a `badge`.** Pass `badge: { text: '3' }` alongside
119
+ the label. It reaches the underlying button, so you also get its optional
120
+ `variant` and `reversed` fields.
121
+ - **`defaultAction` can't be a dropdown.** Only `primaryAction` accepts a menu
122
+ group (`{ label, menuItems }`) and renders a button that opens a menu.
47
123
 
48
- <Canvas of={TitleBlockStories.EducationVariant} />
124
+ <Canvas of={TitleBlockStories.WithDefaultActionBadge} sourceState="hidden" />
@@ -30,6 +30,15 @@ const SECONDARY_ACTIONS = [
30
30
  },
31
31
  ]
32
32
 
33
+ const LIGHT_NAVIGATION_TABS = [
34
+ <NavigationTab key="1" variant="light" text="Label" href="#" active />,
35
+ <NavigationTab key="2" variant="light" text="Label" href="#" />,
36
+ <NavigationTab key="3" variant="light" text="Label" href="#" />,
37
+ <NavigationTab key="4" variant="light" text="Label" href="#" />,
38
+ <NavigationTab key="5" variant="light" text="Label" href="#" />,
39
+ <NavigationTab key="6" variant="light" text="Label" href="#" />,
40
+ ]
41
+
33
42
  const viewports = {
34
43
  viewports: {
35
44
  default: {
@@ -181,12 +190,6 @@ export const Playground: Story = {
181
190
  },
182
191
  }
183
192
 
184
- export const Viewports: Story = {
185
- parameters: {
186
- viewport: viewports,
187
- chromatic: chromaticViewports,
188
- },
189
- }
190
193
  export const WithTabNavigation: Story = {
191
194
  parameters: {
192
195
  viewport: viewports,
@@ -222,6 +225,18 @@ export const HasLongTitle: Story = {
222
225
  args: { title: 'A long title with over thirty characters' },
223
226
  }
224
227
 
228
+ export const HasLongTitleLightVariant: Story = {
229
+ parameters: {
230
+ viewport: viewports,
231
+ chromatic: { disable: true },
232
+ },
233
+ args: {
234
+ variant: 'light',
235
+ title: 'A long title with over thirty characters',
236
+ navigationTabs: LIGHT_NAVIGATION_TABS,
237
+ },
238
+ }
239
+
225
240
  export const LightVariant: Story = {
226
241
  parameters: {
227
242
  docs: {
@@ -235,14 +250,7 @@ export const LightVariant: Story = {
235
250
  args: {
236
251
  variant: 'light',
237
252
  title: 'Light TitleBlock',
238
- navigationTabs: [
239
- <NavigationTab key="1" variant="light" text="Label" href="#" active />,
240
- <NavigationTab key="2" variant="light" text="Label" href="#" />,
241
- <NavigationTab key="3" variant="light" text="Label" href="#" />,
242
- <NavigationTab key="4" variant="light" text="Label" href="#" />,
243
- <NavigationTab key="5" variant="light" text="Label" href="#" />,
244
- <NavigationTab key="6" variant="light" text="Label" href="#" />,
245
- ],
253
+ navigationTabs: LIGHT_NAVIGATION_TABS,
246
254
  },
247
255
  }
248
256
 
@@ -725,6 +733,34 @@ export const WithOnlySecondaryActions: Story = {
725
733
  },
726
734
  }
727
735
 
736
+ export const WithDefaultActionBadge: Story = {
737
+ parameters: {
738
+ viewport: viewports,
739
+ chromatic: { disable: true },
740
+ },
741
+ args: {
742
+ variant: 'light',
743
+ title: 'Goals',
744
+ surveyStatus: undefined,
745
+ avatar: undefined,
746
+ breadcrumb: undefined,
747
+ secondaryActions: undefined,
748
+ secondaryOverflowMenuItems: undefined,
749
+ // Badge is supported: it passes through to the underlying button.
750
+ defaultAction: {
751
+ label: 'View drafts',
752
+ href: '#',
753
+ badge: { text: '3' },
754
+ },
755
+ // Only the primary action can be a menu group (label + menuItems).
756
+ primaryAction: {
757
+ label: 'Create goal',
758
+ menuItems: [{ label: 'Create a single goal' }, { label: 'Bulk create goals' }],
759
+ },
760
+ navigationTabs: LIGHT_NAVIGATION_TABS,
761
+ },
762
+ }
763
+
728
764
  export const StickyTopStripInScrollableContainer: Story = {
729
765
  name: 'Sticker Sheet (Sticky Top Strip In Scrollable Container)',
730
766
  parameters: {
@@ -17,6 +17,11 @@ import { type NavigationTabProps } from './subcomponents/NavigationTabs'
17
17
  export type TitleBlockProps = {
18
18
  children?: React.ReactNode
19
19
  title: string
20
+ /**
21
+ * `light` is the recommended variant for new implementations. Leaving `variant`
22
+ * unset falls back to the default purple background.
23
+ *
24
+ */
20
25
  variant?: TitleBlockVariant
21
26
  breadcrumb?: TitleBlockBreadcrumbType
22
27
  avatar?: JSX.Element | TitleBlockAvatarProps