Skip to content

Commit 36afe56

Browse files
siddharthkpPrinceSumberia
authored andcommitted
Revert accessible Tooltip + IconButton (primer#2092)
* Revert "Fix ActionMenu with IconButton (primer#2084)" This reverts commit 3204599. * Revert 2069 + 2006 + 2084
1 parent 9ba988a commit 36afe56

28 files changed

+1052
-1347
lines changed

.changeset/iconbutton-default-tooltip.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/improved-tooltip.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/content/IconButton.mdx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ A separate component called `IconButton` is used if the action shows only an ico
3535
</>
3636
```
3737

38-
### Customize description / tooltip text
39-
40-
To add description for the button, wrap `IconButton` in a `Tooltip`. Make sure you pass `aria-label` to the button as well.
41-
42-
```jsx live
43-
<Tooltip text="You have no unread notifications">
44-
<IconButton icon={BellIcon} aria-label="Notifications" />
45-
</Tooltip>
46-
```
47-
4838
## API reference
4939

5040
Native `<button>` HTML attributes are forwarded to the underlying React `button` component and are not listed below.

docs/content/Tooltip.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
componentId: tooltip
3+
title: Tooltip
4+
status: Alpha
5+
---
6+
7+
The Tooltip component adds a tooltip to add context to elements on the page.
8+
9+
**_⚠️ Usage warning! ⚠️_**
10+
11+
Tooltips as a UI pattern should be our last resort for conveying information because it is hidden by default and often with zero or little visual indicator of its existence.
12+
13+
Before adding a tooltip, please consider: Is this information essential and necessary? Can the UI be made clearer? Can the information be shown on the page by default?
14+
15+
**Attention:** we use aria-label for tooltip contents, because it is crucial that they are accessible to screen reader users. However, aria-label replaces the text content of an element in screen readers, so only use Tooltip on elements with no existing text content, or consider using `title` for supplemental information.
16+
17+
## Default example
18+
19+
```jsx live
20+
<Box borderWidth="1px" borderStyle="solid" borderColor="border.default" borderRadius={2} p={3}>
21+
<Tooltip aria-label="Hello, Tooltip!">Text with a tooltip</Tooltip>
22+
</Box>
23+
```
24+
25+
## Component props
26+
27+
| Name | Type | Default | Description |
28+
| :--------- | :---------------- | :-----: | :------------------------------------------------------------------------------------------------------------------ |
29+
| align | String | | Can be either `left` or `right`. |
30+
| direction | String | | Can be one of `n`, `ne`, `e`, `se`, `s`, `sw`, `w`, `nw`. Sets where the tooltip renders in relation to the target. |
31+
| noDelay | Boolean | | When set to `true`, tooltip appears without any delay |
32+
| aria-label | String | | Text used in `aria-label` (for accessibility). |
33+
| wrap | Boolean | | Use `true` to allow text within tooltip to wrap. |
34+
| sx | SystemStyleObject | {} | Style to be applied to the component |

docs/content/Tooltip.mdx

Lines changed: 0 additions & 194 deletions
This file was deleted.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"npm": ">=7"
7979
},
8080
"dependencies": {
81-
"@primer/behaviors": "^1.1.3",
81+
"@primer/behaviors": "1.1.1",
8282
"@primer/octicons-react": "16.1.1",
8383
"@primer/primitives": "7.6.0",
8484
"@radix-ui/react-polymorphic": "0.0.14",

src/Button/Button.stories.tsx

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import {BellIcon, EyeClosedIcon, EyeIcon, SearchIcon, TriangleDownIcon, XIcon} from '@primer/octicons-react'
1+
import {EyeClosedIcon, EyeIcon, SearchIcon, TriangleDownIcon, XIcon} from '@primer/octicons-react'
22
import {Meta} from '@storybook/react'
33
import React, {useState} from 'react'
44
import {Button, ButtonProps, IconButton} from '.'
55
import {BaseStyles, ThemeProvider} from '..'
66
import Box from '../Box'
7-
import {Tooltip} from '../Tooltip'
87

98
export default {
109
title: 'Composite components/Button',
@@ -94,35 +93,6 @@ export const iconButton = ({...args}: ButtonProps) => {
9493
)
9594
}
9695

97-
export const iconButtonWithTooltip = ({...args}: ButtonProps) => {
98-
return (
99-
<>
100-
<Box sx={{mt: 4, display: 'grid', gridTemplateColumns: '1fr 1fr', rowGap: 2}}>
101-
Default tooltip
102-
<span>
103-
<IconButton icon={BellIcon} aria-label="Notifications" {...args} />
104-
</span>
105-
Custom tooltip text
106-
<span>
107-
<Tooltip text="You have no unread notifications">
108-
<IconButton icon={BellIcon} aria-label="Notifications" {...args} />
109-
</Tooltip>
110-
</span>
111-
Custom tooltip direction
112-
<span>
113-
<Tooltip text="Notifications" direction="e">
114-
<IconButton icon={BellIcon} aria-label="Notifications" {...args} />
115-
</Tooltip>
116-
</span>
117-
Disable tooltip
118-
<span>
119-
<IconButton icon={BellIcon} aria-label="Notifications" disableTooltip {...args} />
120-
</span>
121-
</Box>
122-
</>
123-
)
124-
}
125-
12696
export const WatchCounterButton = ({...args}: ButtonProps) => {
12797
const [count, setCount] = useState(0)
12898
return (

0 commit comments

Comments
 (0)