Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4efc95d
Refactor tooltip markup without styled components and apply a11y reme…
broccolinisoup Mar 15, 2023
e2b140b
experiment tooltip
broccolinisoup Mar 15, 2023
84d93eb
checking interactive elements and clean the code a bit
broccolinisoup Mar 16, 2023
842f50e
add another story
broccolinisoup Mar 16, 2023
f052247
style fixes and more stories
broccolinisoup Mar 20, 2023
5f25911
Merge branch 'main' into tooltip-experiments
broccolinisoup Mar 20, 2023
fff246f
refactor it to use internal open state and make css presudo classes r…
broccolinisoup Mar 20, 2023
16a8258
apply code review feedback
broccolinisoup Mar 21, 2023
b6ea709
Merge branch 'main' into tooltip-experiments
broccolinisoup Mar 22, 2023
8be4e6c
Refactor the styles to use data-attr and styled-components
broccolinisoup Mar 22, 2023
03a081a
update events
broccolinisoup Mar 22, 2023
55d5f0f
align and wrap styles with data attr
broccolinisoup Mar 23, 2023
2096001
remove unused var
broccolinisoup Mar 24, 2023
a1f908f
restructure markup and make tooltip hoverable
broccolinisoup Mar 27, 2023
2587269
wrap up, clean up, interactive children
broccolinisoup Mar 28, 2023
dff06a9
Apply suggestions from code review
broccolinisoup Mar 29, 2023
2e9e18c
code review feedback
broccolinisoup Mar 29, 2023
407398c
Merge branch 'main' into tooltip-experiments
broccolinisoup Apr 3, 2023
da1bc70
add outline for force-color media
broccolinisoup Apr 3, 2023
f3116bb
Add unit tests
broccolinisoup Apr 3, 2023
ec8e0ea
Merge branch 'main' into tooltip-experiments
broccolinisoup Apr 4, 2023
8e83bb6
check the trigger element's content for label
broccolinisoup Apr 5, 2023
d5077cb
useOnEscapePress hook to close the tooltip when mouse is hovering ove…
broccolinisoup Apr 5, 2023
d2400d4
fix tests
broccolinisoup Apr 5, 2023
dd7da3b
docs and move tooltip into folder
broccolinisoup Apr 5, 2023
87df7b5
Update generated/components.json
broccolinisoup Apr 5, 2023
1a3a456
add changeset
broccolinisoup Apr 5, 2023
16fc7b1
fix imports
broccolinisoup Apr 5, 2023
c7dd301
update snapshot
broccolinisoup Apr 5, 2023
3f1917f
update snapshot
broccolinisoup Apr 5, 2023
7863594
Merge branch 'main' into tooltip-experiments
broccolinisoup Apr 5, 2023
c5597f8
Merge branch 'main' into tooltip-experiments
broccolinisoup Apr 10, 2023
a7797a9
Merge branch 'main' into tooltip-experiments
broccolinisoup Apr 11, 2023
5861cac
default value to the docs
broccolinisoup Apr 11, 2023
ca9c135
Update generated/components.json
broccolinisoup Apr 11, 2023
2042dd7
snaps
broccolinisoup Apr 11, 2023
e60a1ca
Merge branch 'main' into tooltip-experiments
broccolinisoup Apr 11, 2023
7a816fb
remove snapshot tests
broccolinisoup Apr 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-drinks-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Tooltip: Address accessibility remediations and refactor styles towards more static styling
83 changes: 79 additions & 4 deletions docs/content/Tooltip.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Tooltip
status: Alpha
---

import data from '../../src/Tooltip.docs.json'
import data from '../../src/Tooltip/Tooltip.docs.json'

The Tooltip component adds a tooltip to add context to interactive elements on the page.

Expand All @@ -20,10 +20,85 @@ A tooltip may only be used on an element that is interactive such as a button or

## Examples

### Default (As a label type)

```jsx live
<Tooltip aria-label="Search on the documentation">
<Button>
<SearchIcon />
</Button>
</Tooltip>
```

### As a description type

```jsx live
<Tooltip text="This is a supplementary text for the save button" type="description">
<Button>Save</Button>
</Tooltip>
```

### With direction

```jsx live
<Box borderWidth="1px" borderStyle="solid" borderColor="border.default" borderRadius={2} p={3}>
<Tooltip aria-label="Hello, Tooltip!">
<Button>Hover me</Button>
<Box sx={{padding: 5, display: 'flex', gap: '8px'}}>
<Tooltip direction="n" text="Supplementary text" type="description">
<Button>North</Button>
</Tooltip>
<Tooltip direction="s" text="Supplementary text" type="description">
<Button>South</Button>
</Tooltip>
<Tooltip direction="e" text="Supplementary text" type="description">
<Button>East</Button>
</Tooltip>
<Tooltip direction="w" text="Supplementary text" type="description">
<Button>West</Button>
</Tooltip>
<Tooltip direction="ne" text="Supplementary text" type="description">
<Button>North East</Button>
</Tooltip>
<Tooltip direction="nw" text="Supplementary text" type="description">
<Button>North West</Button>
</Tooltip>
<Tooltip direction="se" text="Supplementary text" type="description">
<Button>Southeast</Button>
</Tooltip>
<Tooltip direction="sw" text="Supplementary text" type="description">
<Button>Southwest</Button>
</Tooltip>
</Box>
```

### With wrap

```jsx live
<Tooltip
direction="n"
wrap
text="Random long text that needs to be wrapped and be multipline and have some paddings around"
type="description"
>
<Button>Multiline</Button>
</Tooltip>
```

### With no delay

```jsx live
<Tooltip noDelay text="Supplemetary text" type="description" direction="se">
<Button>Button</Button>
</Tooltip>
```

### With align

```jsx live
<Box sx={{padding: 5, display: 'flex', gap: '8px'}}>
<Tooltip align="left" text="Supplemetary text" type="description">
<Button>Align Left</Button>
</Tooltip>
<Tooltip align="right" text="Supplemetary text" type="description">
<Button>Align Right</Button>
</Tooltip>
</Box>
```
Expand Down
93 changes: 55 additions & 38 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,44 +295,6 @@
],
"subcomponents": []
},
"tooltip": {
"id": "tooltip",
"name": "Tooltip",
"status": "alpha",
"a11yReviewed": false,
"stories": [],
"props": [
{
"name": "align",
"type": "'left' | 'right'"
},
{
"name": "direction",
"type": "'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw'",
"description": "Sets where the tooltip renders in relation to the target."
},
{
"name": "noDelay",
"type": "boolean",
"description": "When set to `true`, tooltip appears without any delay."
},
{
"name": "aria-label",
"type": "string",
"description": "Text used in `aria-label` (for accessibility)"
},
{
"name": "wrap",
"type": "boolean",
"description": "Use `true` to allow text within tooltip to wrap."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"truncate": {
"id": "truncate",
"name": "Truncate",
Expand Down Expand Up @@ -4677,6 +4639,61 @@
}
]
},
"tooltip": {
"id": "tooltip",
"name": "Tooltip",
"status": "alpha",
"a11yReviewed": false,
"stories": [
{
"id": "components-tooltip--default",
"code": "() => (\n <Box\n sx={{\n p: 5,\n }}\n >\n <Tooltip aria-label=\"Filter vegetarian options\" direction=\"e\">\n <Button>🥦</Button>\n </Tooltip>\n </Box>\n)"
}
],
"props": [
{
"name": "align",
"type": "'left' | 'right'"
},
{
"name": "aria-label",
"type": "string",
"description": "Should be utilised for label type tooltips and it is going to be used to label the tooltip trigger."
},
{
"name": "direction",
"type": "'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw'",
"defaultValue": "n",
"description": "Sets where the tooltip renders in relation to the target."
},
{
"name": "noDelay",
"type": "boolean",
"description": "When set to `true`, tooltip appears without any delay."
},
{
"name": "text",
"type": "string",
"description": "Should be utilised for description type tooltips and it is going to be used to describe the tooltip trigger."
},
{
"name": "type",
"type": "'label' | 'description'",
"defaultValue": "label",
"description": "The type of tooltip. `label` is used for labelling the element that triggers tooltip. `description` is used for describing or adding a suplementary information to the element that triggers the tooltip."
},
{
"name": "wrap",
"type": "boolean",
"description": "Use `true` to allow text within tooltip to wrap."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"tree_view": {
"id": "tree_view",
"name": "TreeView",
Expand Down
Loading