@workday/canvas-kit-docs 13.1.4 → 13.1.6

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.
@@ -338465,6 +338465,186 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
338465
338465
  ]
338466
338466
  }
338467
338467
  },
338468
+ {
338469
+ "name": "useTabOverflowScroll",
338470
+ "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx",
338471
+ "description": "",
338472
+ "declarations": [
338473
+ {
338474
+ "name": "useTabOverflowScroll",
338475
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx"
338476
+ }
338477
+ ],
338478
+ "tags": {},
338479
+ "type": {
338480
+ "kind": "function",
338481
+ "name": {
338482
+ "kind": "symbol",
338483
+ "name": "createElemPropsHook"
338484
+ },
338485
+ "parameters": [
338486
+ {
338487
+ "kind": "parameter",
338488
+ "name": "model",
338489
+ "description": "",
338490
+ "tags": {},
338491
+ "declarations": [],
338492
+ "type": {
338493
+ "kind": "symbol",
338494
+ "name": "TabsModel"
338495
+ },
338496
+ "required": true
338497
+ },
338498
+ {
338499
+ "kind": "parameter",
338500
+ "name": "elemProps",
338501
+ "description": "",
338502
+ "tags": {},
338503
+ "declarations": [],
338504
+ "type": {
338505
+ "kind": "object",
338506
+ "properties": [
338507
+ {
338508
+ "kind": "property",
338509
+ "name": "aria-orientation",
338510
+ "required": false,
338511
+ "type": {
338512
+ "kind": "union",
338513
+ "value": [
338514
+ {
338515
+ "kind": "string",
338516
+ "value": "vertical"
338517
+ },
338518
+ {
338519
+ "kind": "string",
338520
+ "value": "horizontal"
338521
+ }
338522
+ ]
338523
+ },
338524
+ "description": "",
338525
+ "declarations": [
338526
+ {
338527
+ "name": "aria-orientation",
338528
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx"
338529
+ }
338530
+ ],
338531
+ "tags": {}
338532
+ }
338533
+ ]
338534
+ },
338535
+ "required": false
338536
+ },
338537
+ {
338538
+ "kind": "parameter",
338539
+ "name": "ref",
338540
+ "description": "",
338541
+ "tags": {},
338542
+ "declarations": [],
338543
+ "type": {
338544
+ "kind": "external",
338545
+ "name": "React.Ref",
338546
+ "url": "https://reactjs.org/docs/refs-and-the-dom.html"
338547
+ },
338548
+ "required": false
338549
+ }
338550
+ ],
338551
+ "returnType": {
338552
+ "kind": "object",
338553
+ "properties": [
338554
+ {
338555
+ "kind": "property",
338556
+ "name": "ref",
338557
+ "required": true,
338558
+ "type": {
338559
+ "kind": "function",
338560
+ "parameters": [
338561
+ {
338562
+ "kind": "parameter",
338563
+ "name": "instance",
338564
+ "type": {
338565
+ "kind": "union",
338566
+ "value": [
338567
+ {
338568
+ "kind": "symbol",
338569
+ "name": "T",
338570
+ "value": "T"
338571
+ },
338572
+ {
338573
+ "kind": "primitive",
338574
+ "value": "null"
338575
+ }
338576
+ ]
338577
+ },
338578
+ "required": true,
338579
+ "rest": false,
338580
+ "description": "",
338581
+ "declarations": [
338582
+ {
338583
+ "name": "instance",
338584
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/node_modules/@types/react/ts5.0/index.d.ts"
338585
+ }
338586
+ ],
338587
+ "tags": {}
338588
+ }
338589
+ ],
338590
+ "members": [],
338591
+ "returnType": {
338592
+ "kind": "primitive",
338593
+ "value": "void"
338594
+ }
338595
+ },
338596
+ "description": "",
338597
+ "tags": {},
338598
+ "declarations": []
338599
+ },
338600
+ {
338601
+ "kind": "property",
338602
+ "name": "onScroll",
338603
+ "required": true,
338604
+ "type": {
338605
+ "kind": "function",
338606
+ "parameters": [
338607
+ {
338608
+ "kind": "parameter",
338609
+ "name": "event",
338610
+ "type": {
338611
+ "kind": "symbol",
338612
+ "name": "React.UIEvent",
338613
+ "typeParameters": [
338614
+ {
338615
+ "kind": "symbol",
338616
+ "name": "HTMLDivElement",
338617
+ "value": "HTMLDivElement"
338618
+ }
338619
+ ],
338620
+ "value": "UIEvent<T, E>"
338621
+ },
338622
+ "required": true,
338623
+ "rest": false,
338624
+ "description": "",
338625
+ "declarations": [
338626
+ {
338627
+ "name": "event",
338628
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx"
338629
+ }
338630
+ ],
338631
+ "tags": {}
338632
+ }
338633
+ ],
338634
+ "members": [],
338635
+ "returnType": {
338636
+ "kind": "primitive",
338637
+ "value": "void"
338638
+ }
338639
+ },
338640
+ "description": "",
338641
+ "tags": {},
338642
+ "declarations": []
338643
+ }
338644
+ ]
338645
+ }
338646
+ }
338647
+ },
338468
338648
  {
338469
338649
  "name": "useTabsList",
338470
338650
  "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx",
@@ -338483,6 +338663,12 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
338483
338663
  "name": "composeHooks"
338484
338664
  },
338485
338665
  "parameters": [
338666
+ {
338667
+ "kind": "symbol",
338668
+ "name": "useTabOverflowScroll",
338669
+ "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx",
338670
+ "value": "useTabOverflowScroll"
338671
+ },
338486
338672
  {
338487
338673
  "kind": "function",
338488
338674
  "name": {
@@ -338545,20 +338731,12 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
338545
338731
  },
338546
338732
  {
338547
338733
  "kind": "property",
338548
- "name": "overflowX",
338734
+ "name": "aria-orientation",
338549
338735
  "required": true,
338550
338736
  "type": {
338551
- "kind": "union",
338552
- "value": [
338553
- {
338554
- "kind": "string",
338555
- "value": "auto"
338556
- },
338557
- {
338558
- "kind": "primitive",
338559
- "value": "undefined"
338560
- }
338561
- ]
338737
+ "kind": "symbol",
338738
+ "name": "Orientation",
338739
+ "value": "any"
338562
338740
  },
338563
338741
  "description": "",
338564
338742
  "tags": {},
@@ -339503,85 +339681,6 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
339503
339681
  "model": "TabsModel"
339504
339682
  }
339505
339683
  },
339506
- {
339507
- "name": "useTouchDirection",
339508
- "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx",
339509
- "description": "",
339510
- "declarations": [
339511
- {
339512
- "name": "useTouchDirection",
339513
- "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx"
339514
- }
339515
- ],
339516
- "tags": {},
339517
- "type": {
339518
- "kind": "function",
339519
- "parameters": [],
339520
- "members": [],
339521
- "returnType": {
339522
- "kind": "object",
339523
- "properties": [
339524
- {
339525
- "kind": "property",
339526
- "name": "direction",
339527
- "defaultValue": {
339528
- "kind": "unknown",
339529
- "value": "unknown",
339530
- "text": "touchDir"
339531
- },
339532
- "type": {
339533
- "kind": "union",
339534
- "value": [
339535
- {
339536
- "kind": "string",
339537
- "value": "left"
339538
- },
339539
- {
339540
- "kind": "string",
339541
- "value": "right"
339542
- },
339543
- {
339544
- "kind": "primitive",
339545
- "value": "undefined"
339546
- }
339547
- ]
339548
- },
339549
- "required": false,
339550
- "description": "",
339551
- "declarations": [
339552
- {
339553
- "name": "direction",
339554
- "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx"
339555
- }
339556
- ],
339557
- "tags": {}
339558
- },
339559
- {
339560
- "kind": "property",
339561
- "name": "isDragging",
339562
- "defaultValue": {
339563
- "kind": "unknown",
339564
- "value": "unknown",
339565
- "text": "isDragging"
339566
- },
339567
- "type": {
339568
- "kind": "primitive",
339569
- "value": "boolean"
339570
- },
339571
- "required": true,
339572
- "description": "",
339573
- "declarations": [
339574
- {
339575
- "name": "isDragging",
339576
- "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsList.tsx"
339577
- }
339578
- ],
339579
- "tags": {}
339580
- }
339581
- ]
339582
- }
339583
- }
339584
- },
339585
339684
  {
339586
339685
  "name": "MenuPopperProps",
339587
339686
  "fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/tabs/lib/TabsMenuPopper.tsx",
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "13.1.4",
22
- "@workday/canvas-kit-preview-react": "13.1.4",
23
- "@workday/canvas-kit-react": "13.1.4",
24
- "@workday/canvas-kit-react-fonts": "^13.1.4",
25
- "@workday/canvas-kit-styling": "13.1.4",
21
+ "@workday/canvas-kit-labs-react": "13.1.6",
22
+ "@workday/canvas-kit-preview-react": "13.1.6",
23
+ "@workday/canvas-kit-react": "13.1.6",
24
+ "@workday/canvas-kit-react-fonts": "^13.1.6",
25
+ "@workday/canvas-kit-styling": "13.1.6",
26
26
  "@workday/canvas-system-icons-web": "3.0.22",
27
27
  "@workday/canvas-tokens-web": "2.0.0"
28
28
  },
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "13.1.4",
22
- "@workday/canvas-kit-preview-react": "13.1.4",
23
- "@workday/canvas-kit-react": "13.1.4",
24
- "@workday/canvas-kit-react-fonts": "^13.1.4",
25
- "@workday/canvas-kit-styling": "13.1.4",
21
+ "@workday/canvas-kit-labs-react": "13.1.6",
22
+ "@workday/canvas-kit-preview-react": "13.1.6",
23
+ "@workday/canvas-kit-react": "13.1.6",
24
+ "@workday/canvas-kit-react-fonts": "^13.1.6",
25
+ "@workday/canvas-kit-styling": "13.1.6",
26
26
  "@workday/canvas-system-icons-web": "3.0.22",
27
27
  "@workday/canvas-tokens-web": "2.0.0"
28
28
  },
@@ -0,0 +1,111 @@
1
+ import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
2
+ import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight';
3
+ import {system} from '@workday/canvas-tokens-web'
4
+
5
+ import CreateStyles from './examples/CreateStyles';
6
+
7
+
8
+ # Create Styles
9
+
10
+ The primary utility function is the `createStyles` function. It makes a call to the `css` function
11
+ from `@emotion/css`. Emotion still does most of the heavy lifting by handling the serialization,
12
+ hashing, caching, and style injection.
13
+
14
+ ## Basic Example
15
+
16
+ In this example, the HTML will look like:
17
+
18
+ ```html
19
+ <div class="css-m39zwu"></div>
20
+ ```
21
+
22
+ The CSS will look like this:
23
+
24
+ ```css
25
+ .css-m39zwu {
26
+ background: var(--cnvs-sys-color-bg-primary-default);
27
+ color: var(--cnvs-sys-color-text-inverse);
28
+ }
29
+ ```
30
+ <InformationHighlight className="sb-unstyled" cs={{marginBlock: system.space.x4,}}>
31
+ <InformationHighlight.Icon />
32
+ <InformationHighlight.Heading> Note</InformationHighlight.Heading>
33
+ <InformationHighlight.Body>
34
+ The `createStyles` function handles wrapping our Tokens in `var(--${token})`.
35
+ </InformationHighlight.Body>
36
+ </InformationHighlight>
37
+
38
+ We're using `className` for simplicity here.
39
+
40
+ <ExampleCodeBlock code={CreateStyles} />
41
+
42
+ <InformationHighlight className="sb-unstyled" variant="caution" cs={{marginBlock: system.space.x4,}}>
43
+ <InformationHighlight.Icon />
44
+ <InformationHighlight.Heading> Caution: Performance Hit</InformationHighlight.Heading>
45
+ <InformationHighlight.Body>
46
+ Do not inline the call to `createStyles` in the render function of a component. This will cause performance issues as a new style is inserted into the browser on every render.
47
+ </InformationHighlight.Body>
48
+ </InformationHighlight>
49
+
50
+ ```tsx
51
+ // Bad example (inside render function)
52
+ import {system} from '@workday/canvas-tokens-webs';
53
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
54
+
55
+ function MyComponent() {
56
+ const styles = createStyles({color: system.color.static.red.default}); // Don't do this
57
+ return <PrimaryButton className={createStyles({color: system.color.static.red.default})}>Text</PrimaryButton>;
58
+ }
59
+ ```
60
+
61
+ ## When to Use `createStyles`
62
+
63
+ `createStyles` is a great way to generate static styles when styling our components that don't rely
64
+ on dynamic styles. Use `createStyles` if you want to create re useable styles or need to apply
65
+ simple style overrides to our components.
66
+
67
+ ## When to Use Something Else
68
+
69
+ You should use [stencils](/docs/styling-getting-started-stencils--docs) when styling our components
70
+ that have complex styles and dynamic properties.
71
+
72
+ ## Proper Usage
73
+
74
+ ```tsx
75
+ // Bad example (inside render function)
76
+ import {system} from '@workday/canvas-tokens-webs';
77
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
78
+
79
+ function MyComponent() {
80
+ const styles = createStyles({color: system.color.static.red.default}); // Don't do this
81
+ return <PrimaryButton cs={styles}>Text</PrimaryButton>;
82
+ }
83
+
84
+ // Good example (outside render function)
85
+ import {system} from '@workday/canvas-tokens-webs';
86
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
87
+
88
+ const styles = createStyles({color: system.color.static.red.default});
89
+
90
+ function MyComponent() {
91
+ return <PrimaryButton cs={styles}>Text</PrimaryButton>;
92
+ }
93
+ ```
94
+
95
+ <InformationHighlight className="sb-unstyled" cs={{marginBlock: system.space.x4,}}>
96
+ <InformationHighlight.Icon />
97
+ <InformationHighlight.Heading>Note</InformationHighlight.Heading>
98
+ <InformationHighlight.Body>
99
+ Most of our components support using the `cs` prop to apply the static styles. It merges everything together and applies `className` and `style` attributes to a React element
100
+ </InformationHighlight.Body>
101
+ </InformationHighlight>
102
+
103
+
104
+
105
+ ## Performance Benefits
106
+
107
+ `createStyles` is performant because:
108
+
109
+ - Styles are statically evaluated when styles are defined outside the render function
110
+ - No new StyleSheets are injected during render
111
+ - It works well with the browser's selector cache
@@ -0,0 +1,179 @@
1
+ # How To Customize Styles
2
+
3
+ There are multiple ways to customize styles for components within Canvas Kit. The approach you
4
+ choose will depend on your use case. Ranging from some simple overrides to fully custom solutions,
5
+ here are the following options:
6
+
7
+ - [Create Styles](#createstyles)
8
+ - [Stencils](#stencils)
9
+
10
+ ## Create Styles
11
+
12
+ ### Using `createStyles` with `cs` prop
13
+
14
+ Use `createStyles` in tandem with `cs` prop when you're overriding static styles and making small modifications to an
15
+ existing Canvas Kit component like padding, color and flex properties. Take our `Text` component as
16
+ an example.
17
+
18
+ ```tsx
19
+ import {createStyles} from '@Workday/canvas-kit-styling';
20
+ import {system} from '@Workday/canvas-tokens-web';
21
+ import {Text} from '@Workday/canvas-kit-react/text';
22
+
23
+ const uppercaseTextStyles = createStyles({
24
+ textTransform: 'uppercase',
25
+ margin: system.space.x4
26
+ })
27
+ //...
28
+ <Text cs={uppercaseTextStyles}>My uppercased text</Text>;
29
+ ```
30
+
31
+ > **Note:** `createStyles` handles wrapping our token variables in `var(--${token})`
32
+
33
+ You can also apply styles created via `createStyles` via `className`.
34
+
35
+ ```tsx
36
+ import {createStyles} from '@Workday/canvas-kit-styling';
37
+ import {system} from '@Workday/canvas-tokens-web';
38
+ import {Text} from '@Workday/canvas-kit-react/text';
39
+
40
+ const uppercaseTextStyles = createStyles({
41
+ textTransform: 'uppercase',
42
+ margin: system.space.x4
43
+ })
44
+ //...
45
+ <Text className={uppercaseTextStyles}>My uppercased text</Text>;
46
+ ```
47
+
48
+ If you need to dynamically apply styles based on some state or prop, use [Stencils](#stencils) instead.
49
+
50
+
51
+ ## Stencils
52
+
53
+ Stencils can be useful when applying dynamic styles or building your own reusable component.
54
+
55
+ ### Extending Stencils
56
+
57
+ [Stencils](https://workday.github.io/canvas-kit/?path=/docs/styling-basics--create-stencil) help you
58
+ organize the styling of reusable components into base styles, modifiers, and variables. The
59
+ organization makes it more natural to produce static and clean CSS with optional extraction into CSS
60
+ files.
61
+
62
+ Stencils that define variables, modifiers and base styles can be extended to create your own
63
+ reusable component using Canvas Kit styles.
64
+
65
+ If we take `SystemIcon` component as an example, it defines `systemIconStencil` which defines styles
66
+ for an icon. This stencil can be extended to build a custom icon component for your use case.
67
+
68
+ **Before v11** you'd have to use `systemIconStyles` function to overwrite styles for an icon:
69
+
70
+ ```tsx
71
+ // Before v11
72
+ import {systemIconStyles} from '@workday/canvas-kit-react';
73
+ import {space} from '@workday/canvas-kit-react/tokens'; // old tokens
74
+
75
+ // old way of styling with Emotion styled
76
+ const StyledNavIcon = styled('span')(({size, iconStyles}){
77
+ display: 'inline-flex',
78
+ pointerEvents: 'unset',
79
+ margin: `${space.xxxs} ${space.xxxs} 0 0`,
80
+ padding: '0',
81
+ 'svg': {
82
+ ...iconStyles,
83
+ width: size,
84
+ height: size,
85
+ }
86
+ });
87
+
88
+ const NavIcon = ({iconColor, iconHover, iconBackground, iconBackgroundHover, icon, size}) => {
89
+ // old way of styling with systemIconStyles function
90
+ // systemIconStyles is deprecated in v11
91
+ const iconStyles = systemIconStyles({
92
+ fill: iconColor,
93
+ fillHover: iconHover,
94
+ background: iconBackground,
95
+ backgroundHover: iconBackgroundHover,
96
+ });
97
+
98
+ // insert icon function used by platform or any other functionality here
99
+
100
+ return (
101
+ <StyledNavIcon
102
+ icon={icon}
103
+ size={size}
104
+ iconStyles={iconStyles}
105
+ />
106
+ );
107
+ };
108
+ ```
109
+
110
+ **In v11** you'd extend `systemIconStencil` to reuse its styles:
111
+
112
+ ```tsx
113
+ // v11
114
+ import {createStencil} from '@workday/canvas-kit-styling';
115
+ import {system} from '@workday/canvas-tokens-web';
116
+ import {systemIconStencil} from '@workday/canvas-kit-react/icon';
117
+
118
+ const navIconStencil = createStencil({
119
+ // We extend `systemIconStencil` to inherit it's base styles, modifiers and variables so that we can customize it
120
+ extends: systemIconStencil,
121
+ vars: {
122
+ // These variables support our styling iconHover and iconBackgroundHover
123
+ // they can be removed later and overwritten by `cs`.
124
+ // Also note the variables have no value. This allows for cascading styles.
125
+ fillHover: '',
126
+ backgroundHover: '',
127
+ },
128
+ base: ({fillHover, backgroundHover}) => ({
129
+ display: 'inline-flex',
130
+ pointerEvents: 'unset',
131
+ // instead of using our old tokens it's better to use our new system tokens
132
+ margin: `${system.space.x1} ${system.space.x1} 0 0`,
133
+ padding: '0',
134
+ '&:hover, &.hover': {
135
+ // systemIconStencil doesn't have hover specific variables
136
+ // so we reassigned color and backgroundColor variables using pseudo-selector
137
+ [systemIconStencil.vars.color]: fillHover,
138
+ [systemIconStencil.vars.backgroundColor]: backgroundHover,
139
+ },
140
+ }),
141
+ });
142
+
143
+ // Your reusable NavIcon component using Stencils
144
+ const NavIcon = ({
145
+ iconColor,
146
+ iconHover,
147
+ iconBackground,
148
+ iconBackgroundHover,
149
+ icon,
150
+ size,
151
+ ...elemProps
152
+ }) => {
153
+ // insert icon function used by platform or any other functionality here
154
+
155
+ return (
156
+ <span
157
+ icon={icon}
158
+ {...handleCsProp(
159
+ elemProps,
160
+ navIconStencil({
161
+ // Because we're extending systemIconStencil, it already has a size prop and applies size to the svg's width and height
162
+ // so we don't need to set these variables in our navIconStencil
163
+ size,
164
+ // systemIconStencil already has color (for icon fill) and backgroundColor variables
165
+ // so we assigned them to our prop values
166
+ color: iconColor,
167
+ backgroundColor: iconBackground,
168
+ fillHover: iconHover,
169
+ backgroundHover: iconBackgroundHover,
170
+ })
171
+ )}
172
+ />
173
+ );
174
+ };
175
+ ```
176
+
177
+ Another example of Stencil extension and customization is our
178
+ [CustomButton](https://workday.github.io/canvas-kit/?path=/story/components-buttons--custom-styles)
179
+ example. This example highlights the power of inheritance that you get from extending stencils.