Skip to content

Commit

Permalink
Merge branch 'main' into KZN-2846/codemod--upgrade-button
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwinter07 committed Feb 14, 2025
2 parents 1789eaa + 1758a85 commit b00705b
Show file tree
Hide file tree
Showing 20 changed files with 527 additions and 56 deletions.
28 changes: 28 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Change Log

## 1.70.23

### Patch Changes

- [#5527](https://github.com/cultureamp/kaizen-design-system/pull/5527) [`4bb3858`](https://github.com/cultureamp/kaizen-design-system/commit/4bb38586b576d3f56d3510b3e49f5659d32cb95b) - Export react-aria Selection type

## 1.70.22

### Patch Changes

- [#5524](https://github.com/cultureamp/kaizen-design-system/pull/5524) [`3d0aca6`](https://github.com/cultureamp/kaizen-design-system/commit/3d0aca6ea5c1fc6f95e519ca13fc4a43363fd230) - Export RTE mockRangeForBoundingRect helper function

## 1.70.21

### Patch Changes

- [#5523](https://github.com/cultureamp/kaizen-design-system/pull/5523) [`d66876a`](https://github.com/cultureamp/kaizen-design-system/commit/d66876a3b46d0c396974c056ba83b38079eae9fe) - Expose the FilterButtonBase primitive for tier 3 usages

## 1.70.20

### Patch Changes

- [#5520](https://github.com/cultureamp/kaizen-design-system/pull/5520) [`389e332`](https://github.com/cultureamp/kaizen-design-system/commit/389e3320ab84ec85e4e548e574d798ca959465e6) - Add missing v3 utilites export field

- [#5517](https://github.com/cultureamp/kaizen-design-system/pull/5517) [`1ad7d14`](https://github.com/cultureamp/kaizen-design-system/commit/1ad7d1461f11f80399d85616074ea2e4b28abcda) - Adds Share icon to default set

- [#5509](https://github.com/cultureamp/kaizen-design-system/pull/5509) [`544e59e`](https://github.com/cultureamp/kaizen-design-system/commit/544e59e0612d7cd534f1ff733f4013881c63a23c) - Tabs: small style changes in line with button

## 1.70.19

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const transformProp = (
case 'onMouseDown':
return createProp('onPressStart', propValue)
case 'disableTabFocusAndIUnderstandTheAccessibilityImplications':
return createProp('onPressEnd', propValue)
return createProp('excludeFromTabOrder', propValue)
case 'newTabAndIUnderstandTheAccessibilityImplications':
return null
case 'disabled':
Expand Down
7 changes: 6 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kaizen/components",
"version": "1.70.19",
"version": "1.70.23",
"description": "Kaizen component library",
"author": "Geoffrey Chong <[email protected]>",
"homepage": "https://cultureamp.design",
Expand Down Expand Up @@ -81,6 +81,11 @@
"require": "./dist/cjs/reactAriaComponentsV3.cjs",
"types": "./dist/types/__react-aria-components__/index.d.ts"
},
"./v3/utilities": {
"import": "./dist/esm/utilitiesV3.mjs",
"require": "./dist/cjs/utilitiesV3.cjs",
"types": "./dist/types/__utilities__/v3.d.ts"
},
"./dist/styles.css": {
"import": "./dist/styles.css",
"require": "./dist/styles.css",
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/Filter/FilterButton/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './subcomponents/FilterButtonBase'
export * from './FilterButton'
export * from './FilterButtonRemovable'
4 changes: 3 additions & 1 deletion packages/components/src/Filter/FilterMultiSelect/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Key, type Node } from '@react-types/shared'
import { type Key, type Node, type Selection as ReactAriaSelection } from '@react-types/shared'

export type ItemType = {
label: string
Expand All @@ -8,3 +8,5 @@ export type ItemType = {
}

export type MultiSelectItem = Node<ItemType>

export type Selection = ReactAriaSelection
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { findByText, waitFor } from '@testing-library/dom'
import { vi } from 'vitest'
import { createRichTextEditor } from '../core'
import { addMark } from './addMark'
import {
mockRangeForBoundingRect,
simulateSelectionByText,
simulateTextInsert,
} from './fixtures/helpers'
import { mockRangeForBoundingRect, simulateSelectionByText, simulateTextInsert } from './fixtures/'
import { testEditorState, testSchema } from './fixtures/test-state'
describe('addMark()', () => {
const onChange = vi.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,7 @@ import {
type Transaction,
} from 'prosemirror-state'
import { findChildrenByType } from 'prosemirror-utils'
// eslint-disable-next-line import/no-extraneous-dependencies
import { vi } from 'vitest'
import { type ProseMirrorModel } from '../../prosemirror'
/*
** This is used handle the JSDom type error issue you may encounter in testing
** See https://github.com/jsdom/jsdom/issues/3002
*/
export const mockRangeForBoundingRect = (): void => {
vi.spyOn(document, 'createRange').mockImplementation(() => {
const range = new Range()

range.getBoundingClientRect = () => ({
x: 0,
y: 0,
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0,
toJSON: () => undefined,
})

range.getClientRects = () => ({
item: () => null,
length: 0,
[Symbol.iterator]: vi.fn(),
})

return range
})
}

/*
** Prosemirror cannot intuit a real `Selection` of content injected into the base test.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './mockRangeForBoundingRect'
export * from './helpers'
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { vi } from 'vitest'

/*
** This is used handle the JSDom type error issue you may encounter in testing
** See https://github.com/jsdom/jsdom/issues/3002
*/
export const mockRangeForBoundingRect = (): void => {
vi.spyOn(document, 'createRange').mockImplementation(() => {
const range = new Range()

range.getBoundingClientRect = () => ({
x: 0,
y: 0,
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0,
toJSON: () => undefined,
})

range.getClientRects = () => ({
item: () => null,
length: 0,
[Symbol.iterator]: vi.fn(),
})

return range
})
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './fixtures/mockRangeForBoundingRect'
export * from './addMark'
export * from './getMarkAttrs'
export * from './getMarkRange'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Canvas, Meta, Controls } from '@storybook/blocks'
import { ResourceLinks, KAIOInstallation } from '~storybook/components'
import { ResourceLinks, KAIOInstallation, DosAndDonts, DoOrDont } from '~storybook/components'
import * as Button from './Button.docs.stories'
import ButtonIconOnlySpec from './assets/button_icon_only_spec.png'
import ButtonIconSpec from './assets/button_icon_spec.png'
import ButtonSpec from './assets/button_spec.png'
import ButtonAnatomy from './assets/button_anatomy.png'

<Meta title="Components/Button/Button (v3)/Usage Guidelines" />

Expand All @@ -27,3 +31,168 @@ Buttons allow users to perform an action. They have multiple styles for various
include={['children', 'variant', 'size', 'isDisabled', 'icon', 'iconPosition']}
className="mb-64"
/>

## Anatomy

<img
src={ButtonAnatomy}
alt="Indicates the anatomy of an Button component with text"
className="my-auto"
/>

### When to use

Use buttons to communicate actions users can take. Each page should have only one primary button, and any remaining calls to action should use lower emphasis buttons.

### When not to use

Do not use buttons as navigational elements. Instead, use links when the desired action is to take the user to a new page.

## Specs

<img
src={ButtonSpec}
alt="Indicates the spacing specifications of a Button component with text"
className="my-auto"
/>

<img
src={ButtonIconSpec}
alt="Indicates the spacing specifications of a Button component with text and an icon"
className="my-auto"
/>

<img
src={ButtonIconOnlySpec}
alt="Indicates the spacing specifications of an icon-only Button"
className="my-auto"
/>

### Dos and don'ts

#### Use primary buttons to highlight a single, important action

Reserve the primary button for actions that are essential to an experience. Usually, use only one primary button on a page or section. These buttons give extra prominence and help establish a clear hierarchy.

<DosAndDonts>
<DoOrDont story={Button.DoExamplePrimaryAndSecondary} />
<DoOrDont story={Button.DontExamplePrimaryAndSecondary} isDont />
</DosAndDonts>

#### Use secondary buttons for medium emphasis actions

Use secondary buttons when the action requires less prominence, or if there are multiple actions with the same importance on a page or section.

#### Use tertiary buttons to communicate action hierarchy

Use tertiary buttons for less important actions within a group or section to help establish a clear hierarchy. Don't use tertiary buttons in isolation.

#### Use large buttons for high emphasis

Use large buttons sparingly within pages or sections where you need a high emphasis and prominent button to provide balance with other large elements. This might be on a landing page or a CTA in proximity to large headings.

<DosAndDonts>
<DoOrDont story={Button.DoExampleCta} />
</DosAndDonts>

#### Use medium buttons most of the time

Medium buttons are appropriate in most common contexts such as pairing with input fields.

<DosAndDonts>
<DoOrDont story={Button.DoExampleDefaultToMediumSize} />
<DoOrDont story={Button.DontExampleDefaultToMediumSize} isDont />
</DosAndDonts>

#### Use small buttons in information rich contexts

Use small buttons when space is limited, such as inside or adjacent to lists, tables, or data visualizations.

Ensure clarity by prioritizing the most important actions. Think about how many buttons you use and where you put them. Don't overload your interface with too many buttons, as clustering buttons can confuse people.

#### Use icons in Primary and Secondary buttons sparingly and consistently

Overusing icons can create visual clutter and overwhelm users. Use them sparingly to highlight common and recognizable actions.

<DosAndDonts>
<DoOrDont story={Button.DoExampleUseIconsSparingly} />
<DoOrDont story={Button.DontExampleUseIconsSparingly} isDont />
</DosAndDonts>

#### Always use icons in Tertiary buttons

Without icons, tertiary buttons can look like plain text. Tertiary buttons must always use icons to support a button affordance and meet accessibility standards.

<DosAndDonts>
<DoOrDont story={Button.DoExampleTertiaryButtonWithIcons} />
<DoOrDont story={Button.DontExampleTertiaryButtonWithIcons} isDont />
</DosAndDonts>

#### Use tooltips when the label is hidden

When a button label is hidden and only an icon is used, show a tooltip on hover that displays the label text.

<DosAndDonts>
<DoOrDont story={Button.DoExampleUseTooltips} />
<DoOrDont story={Button.DontExampleUseTooltips} isDont />
</DosAndDonts>

#### Use a menu button when all actions are equally important

Group related actions in a menu. The action options should be closely related and make sense as a group. You can use any type or size of button based on the context.

<DosAndDonts>
<DoOrDont story={Button.DoExampleMenuButton} />
</DosAndDonts>

#### Use a button and an overflow button when there is a most common or distinct action

Highlight the most important, common, or a distinct action by using a button with text. Group related, less important actions in an overflow button. The action options should be closely related and make sense as a group. You can use any type or size of button based on the context. This pattern replaces Split Buttons.

<DosAndDonts>
<DoOrDont story={Button.DoExampleKebabMenuButton} />
</DosAndDonts>

#### Write clear, action-oriented button labels

Write button labels as concise verbs that clearly state the action and its outcome. Always align the button label with the language used elsewhere in the Platform to maintain consistency and clarity.
Make sure that all your buttons begin with a strong verb (something that elicits an action from the user). Verbs indicate to a user what they’re about to see or do next.

<DosAndDonts>
<DoOrDont story={Button.DoExampleClearAndConciseLabels} />
<DoOrDont story={Button.DontExampleClearAndConciseLabels} isDont />
</DosAndDonts>

A verb and noun combination gives users more context and can help guide them when the action they’re about to perform isn’t commonplace.

<DosAndDonts>
<DoOrDont story={Button.DoExampleDeclareContext} />
<DoOrDont story={Button.DontExampleDeclareContext} isDont />
</DosAndDonts>

#### Write in sentence case with minimal punctuation

All buttons should be in sentence case i.e. the first letter of the first word is capitalized and everything else is in lower case unless it’s a proper noun or feature name. Always err on the side of minimal punctuation, so leave out full stops and commas where possible.

<DosAndDonts>
<DoOrDont story={Button.DoExampleMinimalPunctuation} />
<DoOrDont story={Button.DontExampleMinimalPunctuation} isDont />
</DosAndDonts>

#### Use second person

Any buttons that include a personal pronoun should be written in the second person. Keep in mind that you shouldn’t use personal pronouns unless you’re asking the user to filter something. For example, “View your reports” vs “View all reports.”

<DosAndDonts>
<DoOrDont story={Button.DoExampleSecondPerson} />
<DoOrDont story={Button.DontExampleSecondPerson} isDont />
</DosAndDonts>

#### Button labels should make sense in isolation

If buttons on a page have the same label repeated multiple times, they should have distinct, accessible names that add context for users. This ensures better accessibility for screen reader users, who rely on descriptive labels to distinguish between actions.

<DosAndDonts>
<DoOrDont story={Button.DoExampleFunctionalLabels} />
<DoOrDont story={Button.DontExampleFunctionalLabels} isDont />
</DosAndDonts>
Loading

0 comments on commit b00705b

Please sign in to comment.