-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tooltip] Component and Hook #264
Merged
Merged
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
e9af242
Fix lockfile
atomiks 66b64a3
[Tooltip] Component and Hook
atomiks 775bc92
Docs
atomiks df2b267
Update APIs to trigger
atomiks 4e3212c
Fix lockfile
atomiks 5d0f55f
Sync style with Popover
atomiks 20bc7ee
Rewrite docs to new template
atomiks 389b1ed
Fix wording
atomiks cf6bf0c
Wait for microtasks when rendering
atomiks 32ad0b5
Feedback
atomiks d2bdfb2
Fix codegen
atomiks c365955
Rename Content to Popup
atomiks 93fbc1a
Update docs
atomiks dcd4965
Docgen
atomiks 4793dca
Rename contentEl to popupEl
atomiks 50204cf
Import useEnhancedEffect from utils
atomiks 5d56633
Refactor popup hook logic
atomiks 2eb69ff
Codegen
atomiks a2555bb
Update TransitionStatus
atomiks aeffa72
Refactor use Root API
atomiks 8b4d70f
Refactor to use Root API
atomiks d112305
Pass delay params
atomiks d2bc9ec
Refactor Arrow API
atomiks b25e9b8
Refactor animation API
atomiks e35a7e8
Refactor animations
atomiks 51ea374
Unmount animation hook
atomiks 6463842
Add animated prop
atomiks cd88970
Remove useAnimationUnmount directory
atomiks 6109db4
Update tests
atomiks 3b4dc5e
Pass animated logic, codegen
atomiks 3d28ca4
Adopt useComponentRenderer
atomiks adf35bc
Use non-breaking space
atomiks 36d8d3b
Add TooltipPopupRoot component
atomiks 6050a25
Update
atomiks 1b4d3ed
Use main APIs
atomiks debef29
Fix lockfile
atomiks ae9ae10
Fix Group delay
atomiks 3640f34
Codegen
atomiks d6a6b38
Feedback
atomiks 2861154
Update useTransitionStatus
atomiks 7b1925a
Omit hook params from component
atomiks ae6820f
Split types
atomiks af22269
Improve JSDocs
atomiks c14b7cd
Remove propGetter
atomiks 8e47fdd
Update JSDocs
atomiks 2f59183
Refactor animations hooks
atomiks 16d8fef
Remove async
atomiks 918e2eb
Update docs
atomiks 5a5e47e
Update corejs
atomiks a229163
Allow Tooltip.Root to override Tooltip.Provider delays
atomiks 62a2520
Refactor to TooltipPositioner API
atomiks 9f6b247
Fix tests
atomiks a053fbc
Fix tests
atomiks 9e4a5d7
Fix italic demo
atomiks 61c658e
Update JSDocs
atomiks 73c23bc
Update docs
atomiks bf5f50f
Fix prop-types and docs
atomiks 9c66bd1
Update docs
atomiks 1a7588d
Update docs
atomiks e9511b9
Update docs
atomiks fe09b08
Apply aria-hidden to arrow
atomiks 74e8d17
Update docs
atomiks a1d9bcf
Improve docs consistency
atomiks e31058a
Refactor
atomiks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
60 changes: 60 additions & 0 deletions
60
docs/data/base/components/tooltip/UnstyledTooltipDelayGroup.js
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,60 @@ | ||
import * as React from 'react'; | ||
import * as Tooltip from '@base_ui/react/Tooltip'; | ||
import { styled } from '@mui/system'; | ||
|
||
export default function UnstyledTooltipDelayGroup() { | ||
return ( | ||
<div style={{ display: 'flex', gap: 12 }}> | ||
<Tooltip.Provider delay={500} closeDelay={500}> | ||
<Tooltip.Root> | ||
<AnchorButton>Anchor A</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip A</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
<Tooltip.Root> | ||
<AnchorButton>Anchor B</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip B</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
</Tooltip.Provider> | ||
</div> | ||
); | ||
} | ||
|
||
const blue = { | ||
400: '#3399FF', | ||
600: '#0072E6', | ||
800: '#004C99', | ||
}; | ||
|
||
export const TooltipPopup = styled(Tooltip.Popup)` | ||
${({ theme }) => ` | ||
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'}; | ||
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'}; | ||
padding: 4px 6px; | ||
border-radius: 4px; | ||
font-size: 95%; | ||
cursor: default; | ||
`} | ||
`; | ||
|
||
export const AnchorButton = styled(Tooltip.Trigger)` | ||
border: none; | ||
background: ${blue[600]}; | ||
color: white; | ||
padding: 8px 16px; | ||
border-radius: 4px; | ||
font-size: 16px; | ||
|
||
&:focus-visible { | ||
outline: 2px solid ${blue[400]}; | ||
outline-offset: 2px; | ||
} | ||
|
||
&:hover, | ||
&[data-state='open'] { | ||
background: ${blue[800]}; | ||
} | ||
`; |
60 changes: 60 additions & 0 deletions
60
docs/data/base/components/tooltip/UnstyledTooltipDelayGroup.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,60 @@ | ||
import * as React from 'react'; | ||
import * as Tooltip from '@base_ui/react/Tooltip'; | ||
import { styled } from '@mui/system'; | ||
|
||
export default function UnstyledTooltipDelayGroup() { | ||
return ( | ||
<div style={{ display: 'flex', gap: 12 }}> | ||
<Tooltip.Provider delay={500} closeDelay={500}> | ||
<Tooltip.Root> | ||
<AnchorButton>Anchor A</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip A</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
<Tooltip.Root> | ||
<AnchorButton>Anchor B</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip B</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
</Tooltip.Provider> | ||
</div> | ||
); | ||
} | ||
|
||
const blue = { | ||
400: '#3399FF', | ||
600: '#0072E6', | ||
800: '#004C99', | ||
}; | ||
|
||
export const TooltipPopup = styled(Tooltip.Popup)` | ||
${({ theme }) => ` | ||
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'}; | ||
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'}; | ||
padding: 4px 6px; | ||
border-radius: 4px; | ||
font-size: 95%; | ||
cursor: default; | ||
`} | ||
`; | ||
|
||
export const AnchorButton = styled(Tooltip.Trigger)` | ||
border: none; | ||
background: ${blue[600]}; | ||
color: white; | ||
padding: 8px 16px; | ||
border-radius: 4px; | ||
font-size: 16px; | ||
|
||
&:focus-visible { | ||
outline: 2px solid ${blue[400]}; | ||
outline-offset: 2px; | ||
} | ||
|
||
&:hover, | ||
&[data-state='open'] { | ||
background: ${blue[800]}; | ||
} | ||
`; |
14 changes: 14 additions & 0 deletions
14
docs/data/base/components/tooltip/UnstyledTooltipDelayGroup.tsx.preview
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,14 @@ | ||
<Tooltip.Provider delay={500} closeDelay={500}> | ||
<Tooltip.Root> | ||
<AnchorButton>Anchor A</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip A</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
<Tooltip.Root> | ||
<AnchorButton>Anchor B</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip B</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
</Tooltip.Provider> |
52 changes: 52 additions & 0 deletions
52
docs/data/base/components/tooltip/UnstyledTooltipFollowCursor.js
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,52 @@ | ||
import * as React from 'react'; | ||
import * as Tooltip from '@base_ui/react/Tooltip'; | ||
import { styled } from '@mui/system'; | ||
|
||
export default function UnstyledTooltipFollowCursor() { | ||
return ( | ||
<div style={{ display: 'flex', gap: 12 }}> | ||
<Tooltip.Root followCursorAxis="both"> | ||
<AnchorButton>Anchor</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
</div> | ||
); | ||
} | ||
|
||
const blue = { | ||
400: '#3399FF', | ||
600: '#0072E6', | ||
800: '#004C99', | ||
}; | ||
|
||
export const TooltipPopup = styled(Tooltip.Popup)` | ||
${({ theme }) => ` | ||
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'}; | ||
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'}; | ||
padding: 4px 6px; | ||
border-radius: 4px; | ||
font-size: 95%; | ||
cursor: default; | ||
`} | ||
`; | ||
|
||
export const AnchorButton = styled(Tooltip.Trigger)` | ||
border: none; | ||
background: ${blue[600]}; | ||
color: white; | ||
padding: 8px 16px; | ||
border-radius: 4px; | ||
font-size: 16px; | ||
|
||
&:focus-visible { | ||
outline: 2px solid ${blue[400]}; | ||
outline-offset: 2px; | ||
} | ||
|
||
&:hover, | ||
&[data-state='open'] { | ||
background: ${blue[800]}; | ||
} | ||
`; |
52 changes: 52 additions & 0 deletions
52
docs/data/base/components/tooltip/UnstyledTooltipFollowCursor.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,52 @@ | ||
import * as React from 'react'; | ||
import * as Tooltip from '@base_ui/react/Tooltip'; | ||
import { styled } from '@mui/system'; | ||
|
||
export default function UnstyledTooltipFollowCursor() { | ||
return ( | ||
<div style={{ display: 'flex', gap: 12 }}> | ||
<Tooltip.Root followCursorAxis="both"> | ||
<AnchorButton>Anchor</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
</div> | ||
); | ||
} | ||
|
||
const blue = { | ||
400: '#3399FF', | ||
600: '#0072E6', | ||
800: '#004C99', | ||
}; | ||
|
||
export const TooltipPopup = styled(Tooltip.Popup)` | ||
${({ theme }) => ` | ||
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'}; | ||
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'}; | ||
padding: 4px 6px; | ||
border-radius: 4px; | ||
font-size: 95%; | ||
cursor: default; | ||
`} | ||
`; | ||
|
||
export const AnchorButton = styled(Tooltip.Trigger)` | ||
border: none; | ||
background: ${blue[600]}; | ||
color: white; | ||
padding: 8px 16px; | ||
border-radius: 4px; | ||
font-size: 16px; | ||
|
||
&:focus-visible { | ||
outline: 2px solid ${blue[400]}; | ||
outline-offset: 2px; | ||
} | ||
|
||
&:hover, | ||
&[data-state='open'] { | ||
background: ${blue[800]}; | ||
} | ||
`; |
6 changes: 6 additions & 0 deletions
6
docs/data/base/components/tooltip/UnstyledTooltipFollowCursor.tsx.preview
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,6 @@ | ||
<Tooltip.Root followCursorAxis="both"> | ||
<AnchorButton>Anchor</AnchorButton> | ||
<Tooltip.Positioner sideOffset={5}> | ||
<TooltipPopup>Tooltip</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> |
110 changes: 110 additions & 0 deletions
110
docs/data/base/components/tooltip/UnstyledTooltipIntroduction/system/index.js
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,110 @@ | ||
import * as React from 'react'; | ||
import * as Tooltip from '@base_ui/react/Tooltip'; | ||
import { styled } from '@mui/system'; | ||
|
||
export default function UnstyledTooltipIntroduction() { | ||
return ( | ||
<div style={{ display: 'flex', gap: 10 }}> | ||
<Tooltip.Provider closeDelay={100}> | ||
<Tooltip.Root> | ||
<AnchorButton aria-label="bold">B</AnchorButton> | ||
<Tooltip.Positioner sideOffset={7}> | ||
<TooltipPopup> | ||
Bold | ||
<TooltipArrow /> | ||
</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
<Tooltip.Root> | ||
<AnchorButton aria-label="italic">I</AnchorButton> | ||
<Tooltip.Positioner sideOffset={7}> | ||
<TooltipPopup> | ||
Italic | ||
<TooltipArrow /> | ||
</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
<Tooltip.Root> | ||
<AnchorButton aria-label="underline">U</AnchorButton> | ||
<Tooltip.Positioner sideOffset={7}> | ||
<TooltipPopup> | ||
Underline | ||
<TooltipArrow /> | ||
</TooltipPopup> | ||
</Tooltip.Positioner> | ||
</Tooltip.Root> | ||
</Tooltip.Provider> | ||
</div> | ||
); | ||
} | ||
|
||
const blue = { | ||
400: '#3399FF', | ||
600: '#0072E6', | ||
800: '#004C99', | ||
}; | ||
|
||
export const TooltipPopup = styled(Tooltip.Popup)` | ||
${({ theme }) => ` | ||
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'}; | ||
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'}; | ||
padding: 4px 6px; | ||
border-radius: 4px; | ||
font-size: 95%; | ||
cursor: default; | ||
`} | ||
`; | ||
|
||
export const AnchorButton = styled(Tooltip.Trigger)` | ||
border: none; | ||
background: ${blue[600]}; | ||
color: white; | ||
padding: 8px 16px; | ||
border-radius: 4px; | ||
font-size: 16px; | ||
|
||
&:focus-visible { | ||
outline: 2px solid ${blue[400]}; | ||
outline-offset: 2px; | ||
} | ||
|
||
&:hover, | ||
&[data-state='open'] { | ||
background: ${blue[800]}; | ||
} | ||
|
||
&[aria-label='bold'] { | ||
font-weight: bold; | ||
} | ||
|
||
&[aria-label='italic'] { | ||
font-style: italic; | ||
} | ||
|
||
&[aria-label='underline'] { | ||
text-decoration: underline; | ||
} | ||
`; | ||
|
||
export const TooltipArrow = styled(Tooltip.Arrow)` | ||
${({ theme }) => ` | ||
width: 10px; | ||
height: 10px; | ||
transform: rotate(45deg); | ||
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'}; | ||
z-index: -1; | ||
|
||
&[data-side='top'] { | ||
bottom: -5px; | ||
} | ||
&[data-side='right'] { | ||
left: -5px; | ||
} | ||
&[data-side='bottom'] { | ||
top: -5px; | ||
} | ||
&[data-side='left'] { | ||
right: -5px; | ||
} | ||
`} | ||
`; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already on master, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I added it here to validate it first and because the docs/demos were broken without it before the other PR got merged