-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new
description
variant to Tooltip and deprecate `describ…
…e` variant for better accessibility. (#2814) Fixes: #2797 [category:Components] Release Note: - We've added a new `description` variant and **deprecated** the `describe` variant. The `describe` variant of the tool tip relies on `aria-describedby` attribute to assign the tool tip text to the accessible description of the target element. This only works when the tool tip is visible and present in the DOM, which only occurs when the element has focus. Screen readers can access web page elements without necessarily using keyboard focus, therefore, this variant didn't appear to always work reliably for screen reader users. The preferred type to use is `description` to provide better accessible support. Co-authored-by: manuel.carrera <[email protected]> Co-authored-by: @mannycarrera4 <[email protected]>
- Loading branch information
1 parent
36cb5e3
commit d2351f7
Showing
10 changed files
with
184 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Tooltip} from '@workday/canvas-kit-react/tooltip'; | ||
import {ListOfUploadedFiles} from './examples/Tooltips/ListOfUploadedFiles'; | ||
|
||
<Meta title="Examples/Tooltips" component={Tooltip} /> | ||
|
||
# Accessible Tooltip Examples | ||
|
||
## Using descriptive tooltips for repeated text buttons | ||
|
||
In this example, the "Delete" buttons are used repeatedly to reference the multiple files that have | ||
been uploaded to the web app. The text buttons already have an accessible name (a.k.a. label) | ||
derived from the button's inner text. The `describe` tooltip can be useful for providing more | ||
in-context description for both low vision sighted users and screen reader users without overriding | ||
the button name "Delete". | ||
|
||
<ExampleCodeBlock code={ListOfUploadedFiles} /> |
38 changes: 38 additions & 0 deletions
38
modules/react/_examples/stories/examples/Tooltips/ListOfUploadedFiles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
|
||
import {DeleteButton} from '@workday/canvas-kit-react/button'; | ||
import {Flex} from '@workday/canvas-kit-react/layout'; | ||
import {Heading, Text} from '@workday/canvas-kit-react/text'; | ||
import {Tooltip} from '@workday/canvas-kit-react/tooltip'; | ||
import {trashIcon} from '@workday/canvas-system-icons-web'; | ||
|
||
const files = ['Cover Letter.docx', 'Resume.docx', 'Portfolio.pptx', 'Portrait.png']; | ||
|
||
const listStyles = { | ||
alignItems: 'center', | ||
width: '35rem', | ||
}; | ||
|
||
const deleteBtnStyle = { | ||
marginLeft: 'auto', | ||
}; | ||
|
||
export const ListOfUploadedFiles = () => { | ||
return ( | ||
<> | ||
<Heading size="medium">Uploaded Files:</Heading> | ||
<Flex as="ul" gap="1rem" flexDirection="column"> | ||
{files.map(i => ( | ||
<Flex as="li" style={listStyles}> | ||
<Text>{i}</Text> | ||
<Tooltip type="description" title={i}> | ||
<DeleteButton icon={trashIcon} style={deleteBtnStyle}> | ||
Delete | ||
</DeleteButton> | ||
</Tooltip> | ||
</Flex> | ||
))} | ||
</Flex> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
modules/react/tooltip/stories/examples/DescriptionType.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
|
||
import {DeleteButton, SecondaryButton, TertiaryButton} from '@workday/canvas-kit-react/button'; | ||
import {Tooltip} from '@workday/canvas-kit-react/tooltip'; | ||
import {Flex} from '@workday/canvas-kit-react/layout'; | ||
import {chartConfigIcon} from '@workday/canvas-system-icons-web'; | ||
|
||
export const DescriptionType = () => { | ||
return ( | ||
<Flex gap="s"> | ||
<Tooltip type="description" title="Search using additional criteria"> | ||
<TertiaryButton icon={chartConfigIcon}>Advanced Search</TertiaryButton> | ||
</Tooltip> | ||
<Tooltip type="description" title="Create saved search"> | ||
<SecondaryButton>Save</SecondaryButton> | ||
</Tooltip> | ||
<Tooltip type="description" title="The service will restart after this action"> | ||
<DeleteButton>Delete</DeleteButton> | ||
</Tooltip> | ||
</Flex> | ||
); | ||
}; |