Skip to content

Commit

Permalink
Tooltip2: Make the text prop required (#3925)
Browse files Browse the repository at this point in the history
* Tooltip: make text prop required

* changeset
  • Loading branch information
broccolinisoup authored Nov 9, 2023
1 parent 9be6c90 commit 6b362b2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-trees-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Tooltip2: make the text prop required
1 change: 1 addition & 0 deletions src/drafts/Tooltip/Tooltip.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
{
"name": "text",
"required": true,
"type": "string",
"description": "The text to be displayed in the tooltip"
},
Expand Down
4 changes: 2 additions & 2 deletions src/drafts/Tooltip/Tooltip.playground.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export default {
export const Playground: StoryFn = args => {
// this is a hack to remove the `type` prop from the args because for this example type label is not a valid choice and violates accessibility
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {type, ...rest} = args
const {text, type, ...rest} = args
return (
<Box sx={{p: 6}}>
<Tooltip type="description" {...rest}>
<Tooltip text={text} type="description" {...rest}>
<Button>Delete</Button>
</Tooltip>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/drafts/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type TooltipDirection = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
export type TooltipProps = React.PropsWithChildren<
{
direction?: TooltipDirection
text?: string
text: string
type?: 'label' | 'description'
} & SxProp &
ComponentProps<typeof StyledTooltip>
Expand Down
2 changes: 1 addition & 1 deletion src/drafts/Tooltip/__tests__/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {render as HTMLRender} from '@testing-library/react'
import theme from '../../../theme'
import {Button, ActionMenu, ActionList, ThemeProvider, SSRProvider, BaseStyles} from '../../../'

const TooltipComponent = (props: TooltipProps) => (
const TooltipComponent = (props: Omit<TooltipProps, 'text'> & {text?: string}) => (
<Tooltip text="Tooltip text" {...props}>
<Button>Button Text</Button>
</Tooltip>
Expand Down

0 comments on commit 6b362b2

Please sign in to comment.