@workday/canvas-kit-docs 15.0.0-alpha.0010-next.0 → 15.0.0-alpha.0023-next.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 (22) hide show
  1. package/dist/es6/lib/docs.js +180337 -181060
  2. package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
  3. package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
  4. package/dist/mdx/15.0-UPGRADE-GUIDE.mdx +197 -1
  5. package/dist/mdx/react/_examples/mdx/examples/Density.tsx +1 -1
  6. package/dist/mdx/react/_examples/mdx/examples/layout/ResponsiveColumns.tsx +1 -1
  7. package/dist/mdx/react/action-bar/examples/OverflowActionBar.tsx +1 -1
  8. package/dist/mdx/react/breadcrumbs/examples/Overflow.tsx +1 -1
  9. package/dist/mdx/react/segmented-control/SegmentedControl.mdx +119 -26
  10. package/dist/mdx/react/segmented-control/examples/Basic.tsx +32 -28
  11. package/dist/mdx/{preview-react → react}/segmented-control/examples/Disabled.tsx +1 -1
  12. package/dist/mdx/{preview-react → react}/segmented-control/examples/Dynamic.tsx +1 -1
  13. package/dist/mdx/{preview-react → react}/segmented-control/examples/RTL.tsx +1 -1
  14. package/dist/mdx/{preview-react → react}/segmented-control/examples/Sizes.tsx +1 -1
  15. package/dist/mdx/{preview-react → react}/segmented-control/examples/TextAndIcon.tsx +1 -1
  16. package/dist/mdx/{preview-react → react}/segmented-control/examples/TextOnly.tsx +1 -1
  17. package/dist/mdx/{preview-react → react}/segmented-control/examples/Vertical.tsx +1 -1
  18. package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +1 -1
  19. package/package.json +6 -6
  20. package/dist/mdx/preview-react/segmented-control/SegmentedControl.mdx +0 -139
  21. package/dist/mdx/preview-react/segmented-control/examples/Basic.tsx +0 -42
  22. package/dist/mdx/react/_examples/mdx/examples/SegmentControlWithText.tsx +0 -119
@@ -1,139 +0,0 @@
1
- import {ExampleCodeBlock, SymbolDoc, Specifications} from '@workday/canvas-kit-docs';
2
- import Basic from './examples/Basic';
3
- import Disabled from './examples/Disabled';
4
- import TextAndIcon from './examples/TextAndIcon';
5
- import TextOnly from './examples/TextOnly';
6
- import Sizes from './examples/Sizes';
7
- import Vertical from './examples/Vertical';
8
- import RTL from './examples/RTL';
9
- import Dynamic from './examples/Dynamic';
10
-
11
-
12
- # Canvas Kit Segmented Control
13
-
14
- Segmented Control is a
15
- [compound component](/getting-started/for-developers/resources/compound-components/) that represents
16
- a linear group of multiple buttons allowing the selection of a specific value.
17
-
18
- [> Workday Design Reference](https://design.workday.com/components/buttons/segmented-control)
19
-
20
- ## Installation
21
-
22
- ```sh
23
- yarn add @workday/canvas-kit-preview-react
24
- ```
25
-
26
- ## Usage
27
-
28
- ### Basic Example
29
-
30
- `SegmentedControl` includes a container `SegmentedControl` component and the following
31
- subcomponents: `SegmentedControl.List` and `SegmentedControl.Item`.
32
-
33
- The example below contains a `SegmentedControl` with four icon-only buttons. Each button is rendered
34
- using a `SegmentedControl.Item` and is paired with a tooltip describing the button's function. Only
35
- one button can be active at a time.
36
-
37
- <ExampleCodeBlock code={Basic} />
38
-
39
- We **strongly** discourage including more than four buttons in a single `SegmentedControl`.
40
-
41
- ### Accessibility
42
-
43
- Our `SegmentedControl` component renders semantic HTML `<button>` elements to the browser DOM,
44
- wrapped inside of a `<div>` with an explicit ARIA `role="group"`. This is equivalent to an HTML
45
- `<fieldset>` element, and useful for screen readers to describe the relationship between the
46
- buttons.
47
-
48
- - Each button is a 2-state toggle button with `aria-pressed={true | false}` to indicate the current
49
- state to screen readers.
50
- - Providing your own `aria-label`string to `SegmentedControl.List` is recommended for describing the
51
- purpose of the component.
52
-
53
- #### Screen Reader Experience
54
-
55
- When users interact with a `SegmentedControl` using screen readers:
56
-
57
- - The group context is announced (e.g., "View options, group" when using
58
- `aria-label="View options"`)
59
- - Each button announces its text/label, "toggle button" role, and pressed/unpressed state (e.g.,
60
- "List view, toggle button, pressed" or "Grid view, toggle button, not pressed")
61
- - For icon-only buttons with tooltips, the tooltip text is announced along with the button role and
62
- state
63
- - When a button is activated, screen readers should announce the new state
64
-
65
- Refer to [Button](?path=/docs/components-buttons--docs#accessibility) for more information about
66
- accessibility of these components.
67
-
68
- ### Variations
69
-
70
- `SegmentedControl` supports three variations based on whether or not its `SegmentedControl.Item`
71
- components have an `icon` prop and/or text content: icon-only, text-only, and text-and-icon.
72
-
73
- All `SegmentedControl.Item` components within a given `SegmentedControl` must be of the same
74
- variation.
75
-
76
- #### Icon-Only
77
-
78
- To render an icon-only `SegmentedControl`, apply the `icon` prop to `SegmentedControl.Item` and do
79
- not provide it with text content. Refer to the [basic example](#basic-example) above for an instance
80
- of an icon-only `SegmentedControl`.
81
-
82
- The icon-only variation is the only variation which supports a vertical orientation in addition to
83
- the default horizontal orientation. Set the `orientation` prop of `SegmentedControl` to `vertical`
84
- to configure the component to render vertically.
85
-
86
- <ExampleCodeBlock code={Vertical} />
87
-
88
- #### Text-Only
89
-
90
- To render a text-only `SegmentedControl`, omit the `icon` prop from `SegmentedControl.Item` and
91
- provide it with text content.
92
-
93
- <ExampleCodeBlock code={TextOnly} />
94
-
95
- #### Text-and-Icon
96
-
97
- To render a text-and-icon `SegmentedControl`, apply the `icon` prop to `SegmentedControl.Item` and
98
- provide it with text content.
99
-
100
- <ExampleCodeBlock code={TextAndIcon} />
101
-
102
- ### Sizes
103
-
104
- `SegmentedControl` accepts a `size` prop which supports the following values:
105
-
106
- - `small`
107
- - `medium` (Default)
108
- - `large`
109
-
110
- <ExampleCodeBlock code={Sizes} />
111
-
112
- ### Disabled
113
-
114
- Set the `disabled` prop of `SegmentedControl` to disable the entire component including its buttons.
115
-
116
- <ExampleCodeBlock code={Disabled} />
117
-
118
- ### Right-to-Left (RTL)
119
-
120
- `SegmentedControl` supports right-to-left languages when specified in the `CanvasProvider` `theme`.
121
-
122
- <ExampleCodeBlock code={RTL} />
123
-
124
- ### Dynamic Items
125
-
126
- `SegmentedControl` supports a
127
- [dynamic API](/getting-started/for-developers/resources/collection-api/#dynamic-items) where instead
128
- of statically providing the JSX for each `SegmentedControl.Item`, you pass an array of `items` in
129
- the `model` state and provide a render function to display the items.
130
-
131
- <ExampleCodeBlock code={Dynamic} />
132
-
133
- ## Component API
134
-
135
- <SymbolDoc name="SegmentedControl" fileName="/preview-react/" />
136
-
137
- ## Specifications
138
-
139
- <Specifications file="SegmentedControl.spec.ts" name="SegmentedControl" />
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
-
3
- import {SegmentedControl} from '@workday/canvas-kit-preview-react/segmented-control';
4
- import {BodyText} from '@workday/canvas-kit-react/text';
5
- import {
6
- gridIcon,
7
- listViewIcon,
8
- listDetailIcon,
9
- pieChartIcon,
10
- } from '@workday/canvas-system-icons-web';
11
-
12
- export default () => {
13
- const [viewType, setViewType] = React.useState('table');
14
-
15
- return (
16
- <>
17
- <SegmentedControl initialValue={viewType} onSelect={data => setViewType(data.id)}>
18
- <SegmentedControl.List aria-label="View type">
19
- <SegmentedControl.Item data-id="table" icon={gridIcon} tooltipProps={{title: 'Table'}} />
20
- <SegmentedControl.Item
21
- data-id="list-view"
22
- icon={listViewIcon}
23
- tooltipProps={{title: 'List'}}
24
- />
25
- <SegmentedControl.Item
26
- data-id="list-detail"
27
- icon={listDetailIcon}
28
- tooltipProps={{title: 'Detail'}}
29
- />
30
- <SegmentedControl.Item
31
- data-id="diagrams"
32
- icon={pieChartIcon}
33
- tooltipProps={{title: 'Diagram'}}
34
- />
35
- </SegmentedControl.List>
36
- </SegmentedControl>
37
- <BodyText size="small" marginTop="s">
38
- Selected: {viewType}
39
- </BodyText>
40
- </>
41
- );
42
- };
@@ -1,119 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import {SegmentedControl} from '@workday/canvas-kit-react/segmented-control';
4
- import {
5
- styled,
6
- StyledType,
7
- ExtractProps,
8
- mouseFocusBehavior,
9
- } from '@workday/canvas-kit-react/common';
10
- import {colors, borderRadius, space} from '@workday/canvas-kit-react/tokens';
11
- import {BaseButton, ButtonColors} from '@workday/canvas-kit-react/button';
12
- import {CanvasIconTypes, CanvasSystemIcon} from '@workday/design-assets-types';
13
- const placeholderIcon: CanvasSystemIcon = {
14
- name: '',
15
- svg: '',
16
- filename: '',
17
- type: CanvasIconTypes.System,
18
- };
19
-
20
- const getIconButtonColors = (toggled?: boolean): ButtonColors => {
21
- return {
22
- default: {
23
- background: toggled ? colors.blueberry400 : colors.soap200,
24
- icon: toggled ? colors.frenchVanilla100 : colors.licorice200,
25
- label: toggled ? colors.frenchVanilla100 : colors.licorice200,
26
- },
27
- hover: {
28
- background: toggled ? colors.blueberry400 : colors.soap300,
29
- icon: toggled ? colors.frenchVanilla100 : colors.licorice500,
30
- label: toggled ? colors.frenchVanilla100 : colors.licorice500,
31
- },
32
- active: {
33
- background: toggled ? colors.blueberry400 : colors.soap500,
34
- icon: toggled ? colors.frenchVanilla100 : colors.licorice500,
35
- label: toggled ? colors.frenchVanilla100 : colors.licorice500,
36
- },
37
- focus: {
38
- background: toggled ? colors.blueberry400 : undefined,
39
- icon: toggled ? colors.frenchVanilla100 : colors.licorice500,
40
- label: toggled ? colors.frenchVanilla100 : colors.licorice500,
41
- },
42
- disabled: {
43
- background: toggled ? colors.soap100 : colors.soap100,
44
- icon: colors.soap600,
45
- label: colors.soap600,
46
- opacity: '1',
47
- },
48
- };
49
- };
50
-
51
- const StyledBaseButton = styled(BaseButton)<
52
- ExtractProps<typeof SegmentedControl.Button> & StyledType
53
- >({
54
- borderRadius: borderRadius.zero,
55
- border: `1px solid ${colors.soap500}`,
56
- borderLeft: 'none',
57
- minWidth: space.xxxl,
58
- '&:first-of-type': {
59
- borderRadius: `${borderRadius.m} 0 0 ${borderRadius.m}`,
60
- borderLeft: `1px solid ${colors.soap500}`,
61
- },
62
- '&:last-of-type': {
63
- borderRadius: `0 ${borderRadius.m} ${borderRadius.m} 0`,
64
- },
65
- '&[aria-pressed="true"]': {
66
- borderColor: `${colors.blueberry400} !important`,
67
- '&:hover, &:focus:hover': {
68
- background: colors.blueberry400,
69
- },
70
- },
71
- '&:focus': {
72
- borderRadius: borderRadius.m,
73
- zIndex: 1,
74
- animation: 'none', // reset focusRing animation
75
- transition: 'all 120ms, border-radius 1ms',
76
- ...mouseFocusBehavior({
77
- '&': {
78
- borderRadius: borderRadius.zero,
79
- '&:first-of-type': {
80
- borderRadius: `${borderRadius.m} 0 0 ${borderRadius.m}`,
81
- },
82
- '&:last-of-type': {
83
- borderRadius: `0 ${borderRadius.m} ${borderRadius.m} 0`,
84
- },
85
- },
86
- }),
87
- },
88
- });
89
-
90
- export default () => {
91
- const [value, setValue] = React.useState<string | number>('day');
92
- const handleToggle = (selectedValue: string | number) => {
93
- setValue(selectedValue);
94
- };
95
-
96
- const isDayToggled = value === 'day';
97
- const isWeekToggled = value === 'week';
98
-
99
- return (
100
- <SegmentedControl value={value} onChange={handleToggle}>
101
- <StyledBaseButton
102
- icon={{...placeholderIcon}}
103
- colors={getIconButtonColors(isDayToggled)}
104
- value="day"
105
- onClick={() => setValue('day')}
106
- >
107
- Day
108
- </StyledBaseButton>
109
- <StyledBaseButton
110
- icon={placeholderIcon}
111
- colors={getIconButtonColors(isWeekToggled)}
112
- value="week"
113
- onClick={() => setValue('week')}
114
- >
115
- Week
116
- </StyledBaseButton>
117
- </SegmentedControl>
118
- );
119
- };