@workday/canvas-kit-docs 11.1.7 → 11.1.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Value.d.ts","sourceRoot":"","sources":["../../../lib/Value.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAC;AAQ5C,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,EACrD,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EACd,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAC9B,IAAI,CAGN;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,KAAK,CAAC,KAAK;IAChE,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,eAAO,MAAM,KAAK;UAAqB,MAAM;qDAW5C,CAAC;AAEF,eAAO,MAAM,gBAAgB;gBAA+B,MAAM,cAAc,EAAE;iBA+CjF,CAAC;AAgEF,eAAO,MAAM,eAAe;gBAKd,MAAM,cAAc,EAAE;;;iBAyBnC,CAAC"}
1
+ {"version":3,"file":"Value.d.ts","sourceRoot":"","sources":["../../../lib/Value.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAC;AAS5C,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,EACrD,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EACd,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAC9B,IAAI,CAGN;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,KAAK,CAAC,KAAK;IAChE,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,eAAO,MAAM,KAAK;UAAqB,MAAM;qDAW5C,CAAC;AAEF,eAAO,MAAM,gBAAgB;gBAA+B,MAAM,cAAc,EAAE;iBAgDjF,CAAC;AAgEF,eAAO,MAAM,eAAe;gBAKd,MAAM,cAAc,EAAE;;;iBAyBnC,CAAC"}
@@ -5,6 +5,7 @@ import { MdxJSToJSX } from './MDXElements';
5
5
  import { Table } from './Table';
6
6
  import { capitalize, IndentLevelContext, RenderContext, indent } from './widgetUtils';
7
7
  import { DescriptionTooltip } from './DescriptionTooltip';
8
+ import { colors } from '@workday/canvas-kit-react/tokens';
8
9
  const widgets = {};
9
10
  export function registerWidget(key, widget) {
10
11
  widget.displayName = `${capitalize(key)}Widget`;
@@ -30,11 +31,12 @@ export const PropertiesInline = ({ properties }) => {
30
31
  return (React.createElement(React.Fragment, { key: index },
31
32
  React.createElement("br", null),
32
33
  indent(level + 1),
33
- p.description ? (React.createElement(DescriptionTooltip, { type: "describe", style: { maxWidth: '50em' }, title: React.createElement(MdxJSToJSX, null, p.description) },
34
+ p.description || p.tags.deprecated ? (React.createElement(DescriptionTooltip, { type: "describe", style: { maxWidth: '50em' }, title: React.createElement(MdxJSToJSX, null, p.description || p.tags.deprecated) },
34
35
  React.createElement("span", { className: "token property", style: {
35
36
  cursor: 'pointer',
36
- textDecoration: 'underline',
37
+ textDecoration: p.tags.deprecated ? 'line-through' : 'underline',
37
38
  textDecorationStyle: 'dotted',
39
+ color: p.tags.deprecated ? colors.cinnamon600 : colors.plum600,
38
40
  } }, p.name))) : (React.createElement("span", { className: "token property" }, p.name)),
39
41
  React.createElement("span", { className: "token punctuation" }, ":"),
40
42
  "\u00A0",
@@ -62000,6 +62000,42 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
62000
62000
  "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/button/lib/types.ts"
62001
62001
  }
62002
62002
  ],
62003
+ "tags": {
62004
+ "deprecated": "This option is no longer supported at run time and will be removed from the type interface in a v12. If you want to customize the focus ring, use `boxShadowInner` and `boxShadowOuter` to update the inner and outer colors of the focus ring. Use with caution."
62005
+ }
62006
+ },
62007
+ {
62008
+ "kind": "property",
62009
+ "name": "boxShadowInner",
62010
+ "required": false,
62011
+ "type": {
62012
+ "kind": "primitive",
62013
+ "value": "string"
62014
+ },
62015
+ "description": "Updates the color of the inner `box-shadow` within a focus ring.",
62016
+ "declarations": [
62017
+ {
62018
+ "name": "boxShadowInner",
62019
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/button/lib/types.ts"
62020
+ }
62021
+ ],
62022
+ "tags": {}
62023
+ },
62024
+ {
62025
+ "kind": "property",
62026
+ "name": "boxShadowOuter",
62027
+ "required": false,
62028
+ "type": {
62029
+ "kind": "primitive",
62030
+ "value": "string"
62031
+ },
62032
+ "description": "Updates the color of the outer `box-shadow` within a focus ring.",
62033
+ "declarations": [
62034
+ {
62035
+ "name": "boxShadowOuter",
62036
+ "filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/button/lib/types.ts"
62037
+ }
62038
+ ],
62003
62039
  "tags": {}
62004
62040
  }
62005
62041
  ]
@@ -42,10 +42,20 @@ messages on their first day back.
42
42
 
43
43
  ### Notification Badge
44
44
 
45
- Notifications are a major use case for `CountBadge`. Remember that any `CountBadge` with a
46
- live-updating value should be announced to screen readers with an `aria-live` region and an
47
- `aria-label` on the button to provide additional context, as in the example below. Please also read
48
- the Accessibility guidance below this example for aditional information.
45
+ Notifications are a major use case for `CountBadge`. When the `CountBadge` value is updated in
46
+ real-time, screen readers must be supported with an `AriaLiveRegion` that will automatically
47
+ describe the change in the number of notifications. If the web app only updates `CountBadge` as part
48
+ of another screen update, then this use of `AriaLiveRegion` is unnecessary and not recommended.
49
+
50
+ #### Notes on accessibility for the example below
51
+
52
+ - `Tooltip` is set on the `SecondaryButton` automatically applying the `aria-label` to the button.
53
+ - `aria-describedby` property is conditionally set on the `SecondaryButton` when greater than zero
54
+ referencing a unique `id` for the `CountBadge` value .
55
+ - `AriaLiveRegion` is used around the `CountBadge`, enabling screen readers to monitor changes in
56
+ value.
57
+ - `aria-label` string is conditionally set on `AriaLiveRegion` when greater than zero, describing
58
+ "New notification"
49
59
 
50
60
  <ExampleCodeBlock code={NotificationBadge} />
51
61
 
@@ -54,17 +64,6 @@ the Accessibility guidance below this example for aditional information.
54
64
  Count Badge supports custom styling via the `cs` prop. For more information, check our
55
65
  ["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-how-to-customize-styles--page).
56
66
 
57
- ## Accessibility
58
-
59
- A common use case for `CountBadge` is displaying notifications, but there are other situations where
60
- they will have live-updated values. There are several accessibility concerns you'll want to keep in
61
- mind:
62
-
63
- - The button should have an aria-label that updates with the count
64
- - The elements inside the button should have `aria-hidden`
65
- - The live region should be outside the button
66
- - The live region should be visually hidden and only contain text
67
-
68
67
  ## Component API
69
68
 
70
69
  <SymbolDoc name="CountBadge" fileName="/react/" />
@@ -1,10 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import {CountBadge} from '@workday/canvas-kit-react/badge';
3
3
  import {SecondaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
4
- import {accessibleHide} from '@workday/canvas-kit-react/common';
4
+ import {AriaLiveRegion, useUniqueId} from '@workday/canvas-kit-react/common';
5
5
  import {createStyles, cssVar} from '@workday/canvas-kit-styling';
6
6
  import {notificationsIcon} from '@workday/canvas-system-icons-web';
7
7
  import {base, system} from '@workday/canvas-tokens-web';
8
+ import {Tooltip} from '@workday/canvas-kit-react/tooltip';
9
+ import {Flex} from '@workday/canvas-kit-react/layout';
8
10
 
9
11
  function negate(value: string, fallback?: string) {
10
12
  return `calc(${cssVar(value, fallback)} * -1)`;
@@ -12,16 +14,13 @@ function negate(value: string, fallback?: string) {
12
14
 
13
15
  const container = createStyles({
14
16
  boxSizing: 'border-box',
15
- display: 'flex',
16
17
  flexDirection: 'column',
17
18
  gap: system.space.x4,
18
19
  });
19
20
 
20
21
  const controls = createStyles({
21
22
  boxSizing: 'border-box',
22
- borderBottom: `solid 1px ${cssVar(base.soap400)}`,
23
- display: 'flex',
24
- gap: system.space.x1,
23
+ gap: system.space.x2,
25
24
  padding: system.space.x1,
26
25
  });
27
26
 
@@ -33,40 +32,46 @@ const notificationContainerStyles = createStyles({
33
32
  const countBadgeStyles = createStyles({
34
33
  boxSizing: 'border-box',
35
34
  position: 'absolute',
36
- top: negate(system.space.x4),
35
+ top: negate(system.space.x1),
37
36
  insetInlineEnd: negate(system.space.x1),
38
37
  });
39
38
 
40
- const accessibleHideStyles = createStyles(accessibleHide);
41
-
39
+ // Testing notes (Aug. 30, 2024):
40
+ // Windows 11
41
+ // JAWS 2024 + Chrome / Edge: "New notifications" once, then only the count change "2"
42
+ // JAWS 2024 + FF: "New notifications" once, then describes nothing
43
+ // NVDA + Chrome / Edge: Consistently describes "{X} New notifications"
44
+ // NVDA + FF: Consistently describes count value only "{X}"
45
+ // macOS v14.6.1
46
+ // VoiceOver + Chrome / Safari: Consistently describes "New notifications {X}"
42
47
  export function NotificationBadge() {
43
48
  const [count, setCount] = React.useState(4);
49
+ const badgeID = useUniqueId();
44
50
 
45
51
  return (
46
- <div className={container}>
47
- <div className={controls}>
52
+ <Flex cs={container}>
53
+ <Flex cs={controls}>
48
54
  <TertiaryButton size="small" onClick={() => setCount(count + 1)}>
49
55
  Add Notification
50
56
  </TertiaryButton>
51
57
  <TertiaryButton size="small" onClick={() => setCount(0)}>
52
58
  Clear
53
59
  </TertiaryButton>
54
- </div>
55
- <div>
60
+ </Flex>
61
+ <Flex>
56
62
  <span className={notificationContainerStyles}>
57
- <SecondaryButton
58
- aria-label={`Alerts ${count} new notifications`}
59
- size="medium"
60
- icon={notificationsIcon}
61
- />
62
- {!!count && (
63
- <CountBadge count={count} limit={100} aria-hidden="true" cs={countBadgeStyles} />
64
- )}
65
- <div className={accessibleHideStyles} role="status" aria-live="polite" aria-atomic="true">
66
- New notifications
67
- </div>
63
+ <Tooltip title="Notifications">
64
+ <SecondaryButton
65
+ size="medium"
66
+ icon={notificationsIcon}
67
+ aria-describedby={!!count ? badgeID : undefined}
68
+ />
69
+ </Tooltip>
70
+ <AriaLiveRegion aria-label={!!count ? 'New notifications' : undefined}>
71
+ {!!count && <CountBadge id={badgeID} count={count} limit={100} cs={countBadgeStyles} />}
72
+ </AriaLiveRegion>
68
73
  </span>
69
- </div>
70
- </div>
74
+ </Flex>
75
+ </Flex>
71
76
  );
72
77
  }
@@ -15,6 +15,11 @@ const myButtonStencil = createStencil({
15
15
  [systemIconStencil.vars.color]: system.color.static.green.strong,
16
16
  [buttonStencil.vars.borderRadius]: system.shape.half,
17
17
  border: `${px2rem(3)} solid transparent`,
18
+ '&:focus-visible': {
19
+ [buttonStencil.vars.background]: system.color.static.green.strong,
20
+ [buttonStencil.vars.boxShadowInner]: system.color.static.green.soft,
21
+ [buttonStencil.vars.boxShadowOuter]: system.color.static.green.strong,
22
+ },
18
23
  '&:hover': {
19
24
  [buttonStencil.vars.background]: system.color.static.green.default,
20
25
  border: `${px2rem(3)} dotted ${system.color.static.green.strong}`,
@@ -29,8 +34,8 @@ const myButtonStencil = createStencil({
29
34
  });
30
35
 
31
36
  const MyCustomButton = createComponent('button')({
32
- Component: ({children, size, ...elemProps}: PrimaryButtonProps, ref, Element) => (
33
- <PrimaryButton ref={ref} {...handleCsProp(elemProps, myButtonStencil({size}))}>
37
+ Component: ({children, ...elemProps}: PrimaryButtonProps, ref, Element) => (
38
+ <PrimaryButton as={Element} ref={ref} {...handleCsProp(elemProps, myButtonStencil())}>
34
39
  {children}
35
40
  </PrimaryButton>
36
41
  ),
@@ -43,14 +48,23 @@ const myCustomStyles = createStyles({
43
48
 
44
49
  const customColors = {
45
50
  default: {
46
- background: system.color.static.green.soft,
47
- icon: system.color.static.green.strong,
48
- label: system.color.static.green.strong,
51
+ background: system.color.static.orange.soft,
52
+ icon: system.color.static.orange.strong,
53
+ label: system.color.static.orange.strong,
49
54
  },
50
55
  hover: {
51
- background: system.color.static.green.default,
52
- icon: system.color.static.green.strong,
56
+ background: system.color.static.orange.default,
57
+ icon: system.color.static.orange.strong,
58
+ },
59
+ active: {
60
+ background: system.color.static.orange.strong,
61
+ },
62
+ focus: {
63
+ background: system.color.static.orange.strong,
64
+ boxShadowInner: system.color.static.orange.soft,
65
+ boxShadowOuter: system.color.static.orange.strong,
53
66
  },
67
+ disabled: {},
54
68
  };
55
69
 
56
70
  export default () => (
package/lib/Value.tsx CHANGED
@@ -8,6 +8,7 @@ import {MdxJSToJSX} from './MDXElements';
8
8
  import {Table} from './Table';
9
9
  import {capitalize, IndentLevelContext, RenderContext, indent} from './widgetUtils';
10
10
  import {DescriptionTooltip} from './DescriptionTooltip';
11
+ import {colors} from '@workday/canvas-kit-react/tokens';
11
12
 
12
13
  const widgets: Record<string, React.FC<ValueProps>> = {};
13
14
 
@@ -52,18 +53,19 @@ export const PropertiesInline = ({properties}: {properties: types.ObjectProperty
52
53
  <React.Fragment key={index}>
53
54
  <br />
54
55
  {indent(level + 1)}
55
- {p.description ? (
56
+ {p.description || p.tags.deprecated ? (
56
57
  <DescriptionTooltip
57
58
  type="describe"
58
59
  style={{maxWidth: '50em'}}
59
- title={<MdxJSToJSX>{p.description}</MdxJSToJSX>}
60
+ title={<MdxJSToJSX>{p.description || p.tags.deprecated}</MdxJSToJSX>}
60
61
  >
61
62
  <span
62
63
  className="token property"
63
64
  style={{
64
65
  cursor: 'pointer',
65
- textDecoration: 'underline',
66
+ textDecoration: p.tags.deprecated ? 'line-through' : 'underline',
66
67
  textDecorationStyle: 'dotted',
68
+ color: p.tags.deprecated ? colors.cinnamon600 : colors.plum600,
67
69
  }}
68
70
  >
69
71
  {p.name}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "11.1.7",
3
+ "version": "11.1.9",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -44,10 +44,10 @@
44
44
  "dependencies": {
45
45
  "@emotion/styled": "^11.6.0",
46
46
  "@storybook/csf": "0.0.1",
47
- "@workday/canvas-kit-labs-react": "^11.1.7",
48
- "@workday/canvas-kit-preview-react": "^11.1.7",
49
- "@workday/canvas-kit-react": "^11.1.7",
50
- "@workday/canvas-kit-styling": "^11.1.7",
47
+ "@workday/canvas-kit-labs-react": "^11.1.9",
48
+ "@workday/canvas-kit-preview-react": "^11.1.9",
49
+ "@workday/canvas-kit-react": "^11.1.9",
50
+ "@workday/canvas-kit-styling": "^11.1.9",
51
51
  "@workday/canvas-system-icons-web": "^3.0.0",
52
52
  "@workday/canvas-tokens-web": "^2.0.0",
53
53
  "markdown-to-jsx": "^7.2.0",
@@ -59,5 +59,5 @@
59
59
  "mkdirp": "^1.0.3",
60
60
  "typescript": "4.2"
61
61
  },
62
- "gitHead": "f2f16c84455ece760c07e75631480f0ec65b9ada"
62
+ "gitHead": "c81e8e0bef16f336966043e58a3c119dbab19617"
63
63
  }
@@ -1,98 +0,0 @@
1
- import React, {useState} from 'react';
2
- import {AccessibleHide, AriaLiveRegion, useUniqueId} from '@workday/canvas-kit-react/common';
3
- import {notificationsIcon, inboxIcon, assistantIcon} from '@workday/canvas-system-icons-web';
4
- import {space} from '@workday/canvas-kit-react/tokens';
5
- import {SecondaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
6
- import {Flex} from '@workday/canvas-kit-react/layout';
7
- import {Tooltip} from '@workday/canvas-kit-react/tooltip';
8
- import {CountBadge} from '@workday/canvas-kit-react/badge';
9
-
10
- const MyTasksLiveBadge = ({cnt}) => {
11
- // use tooltip to assign name,
12
- // use AriaLiveRegion inside button,
13
- // assign name to live region referencing the button,
14
- // use BadgeCount inside live region,
15
- // use AccessibleHide to create invisible word "new" after badge
16
- // use aria-describedby on button, referencing live region container to set description
17
- // Safari + VO => not working at all
18
- // JAWS 2024 + Chrome / Edge => works as expected :)
19
- // NVDA + Chrome / Edge => works as expected :)
20
- // Firefox => isn't announcing description on focus, only announces "X New" live (missing button name)
21
- const badgeID = useUniqueId();
22
- const myTasksID = useUniqueId();
23
-
24
- return (
25
- <Tooltip title="My Tasks">
26
- <TertiaryButton icon={inboxIcon} id={myTasksID} aria-describedby={badgeID}>
27
- <AriaLiveRegion id={badgeID} aria-labelledby={myTasksID}>
28
- <CountBadge count={cnt} />
29
- <AccessibleHide>New</AccessibleHide>
30
- </AriaLiveRegion>
31
- </TertiaryButton>
32
- </Tooltip>
33
- );
34
- };
35
-
36
- // use AriaLiveRegion around the button,
37
- // use Tooltip to assign the name of the button,
38
- // make sure Tooltip title string includes count value
39
- // Chrome + VO => Announces name "notifications X new" and innerText 'X'
40
- // Safari + VO => Works as expected :)
41
- // JAWS 2024 => Announces full button name twice (previous state, then new state)
42
- // JAWS 2024 + Firefox => Works as expected :)
43
- // NVDA (All Browsers) => Atomic property isn't working, only announcing number change, announces twice
44
- const NotificationsLiveBadge = ({cnt}) => (
45
- <AriaLiveRegion>
46
- <Tooltip title={`Notifications ${cnt} new`}>
47
- <TertiaryButton icon={notificationsIcon}>
48
- <CountBadge count={cnt} />
49
- </TertiaryButton>
50
- </Tooltip>
51
- </AriaLiveRegion>
52
- );
53
-
54
- const AssistantLiveBadge = ({cnt}) => {
55
- // use AriaLiveRegion around the button
56
- // use muted type Tooltip (avoid using aria-label to name button)
57
- // use AccessibleHide inside of button to compose name
58
- // Chrome + VO => announces twice
59
- // Safari + VO => works as expected :)
60
- const lbl = 'Workday Assistant';
61
-
62
- return (
63
- <AriaLiveRegion>
64
- <Tooltip title={lbl} type="muted">
65
- <TertiaryButton icon={assistantIcon}>
66
- <AccessibleHide>{lbl}</AccessibleHide>
67
- <CountBadge count={cnt} />
68
- <AccessibleHide>New</AccessibleHide>
69
- </TertiaryButton>
70
- </Tooltip>
71
- </AriaLiveRegion>
72
- );
73
- };
74
-
75
- export default () => {
76
- const [counter, setCounter] = useState(0);
77
- const [notifications, setNotifications] = useState(0);
78
- const [assistant, setAssistant] = useState(0);
79
-
80
- const handleAddTask = () => setCounter(prev => prev + 1);
81
- const handleAddNotification = () => setNotifications(prev => prev + 1);
82
- const handleAssistant = () => setAssistant(prev => prev + 1);
83
-
84
- return (
85
- <>
86
- <Flex padding={space.s} gap={space.s} as="header">
87
- <AssistantLiveBadge cnt={assistant} />
88
- <NotificationsLiveBadge cnt={notifications} />
89
- <MyTasksLiveBadge cnt={counter} />
90
- </Flex>
91
- <Flex padding={space.s} gap={space.s} as="main">
92
- <SecondaryButton onClick={handleAssistant}>Add a Message</SecondaryButton>
93
- <SecondaryButton onClick={handleAddNotification}>Add a Notification</SecondaryButton>
94
- <SecondaryButton onClick={handleAddTask}>Add an item to My Tasks</SecondaryButton>
95
- </Flex>
96
- </>
97
- );
98
- };