Skip to content

Commit

Permalink
feat: Expose showTimeout and hideTimeout props for Tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
frankieyan committed Oct 23, 2024
1 parent 0eea18f commit 6716d8e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it.

# Next

- [Feat] Expose `showTimeout` and `hideTimeout` props for `Tooltip`

# v26.0.0

- [BREAKING] Remove unused `secondaryLabel` from `TexTfield`, `PasswordField`, `SelectField`, `TextArea`, and `SwitchField`.
- [BREAKING] Remove `hint` from from `TexTfield`, `PasswordField`, `SelectField`, `TextArea`, and `SwitchField`.
- [BREAKING] Remove `hint` from from `Textfield`, `PasswordField`, `SelectField`, `TextArea`, and `SwitchField`.
- Please use `message` instead.
- [Feat] Update read only style for `TextField` and `TextArea` when `readOnly` is `true`.
- [Feat] Add `disableResize` option to `TextArea` to disallow manual resizing.
Expand Down
10 changes: 9 additions & 1 deletion src/tooltip/tooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ TooltipPlaygroundStory.args = {
position: 'top',
gapSize: 5,
withArrow: false,
showTimeout: 500,
hideTimeout: 100,
}

TooltipPlaygroundStory.argTypes = {
Expand All @@ -94,12 +96,16 @@ export function TooltipRichContentStory({
position,
gapSize,
withArrow,
}: Pick<TooltipProps, 'position' | 'gapSize' | 'withArrow'>) {
showTimeout,
hideTimeout,
}: Pick<TooltipProps, 'position' | 'gapSize' | 'withArrow' | 'showTimeout' | 'hideTimeout'>) {
return (
<StoryTemplate
position={position}
gapSize={gapSize}
withArrow={withArrow}
showTimeout={showTimeout}
hideTimeout={hideTimeout}
content={
<Stack space="medium" padding="small" align="start">
<Text weight="bold" size="subtitle">
Expand All @@ -122,6 +128,8 @@ TooltipRichContentStory.args = {
position: 'bottom',
gapSize: 10,
withArrow: true,
showTimeout: 500,
hideTimeout: 100,
}

TooltipRichContentStory.argTypes = {
Expand Down
16 changes: 15 additions & 1 deletion src/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ interface TooltipProps extends ObfuscatedClassName {
* @default false
*/
withArrow?: boolean

/**
* The amount of time in milliseconds to wait before showing the tooltip
* @default 500
*/
showTimeout?: number

/**
* The amount of time in milliseconds to wait before hiding the tooltip
* @default 100
*/
hideTimeout?: number
}

function Tooltip({
Expand All @@ -74,9 +86,11 @@ function Tooltip({
position = 'top',
gapSize = 3,
withArrow = false,
showTimeout = 500,
hideTimeout = 100,
exceptionallySetClassName,
}: TooltipProps) {
const tooltip = useTooltipStore({ placement: position, showTimeout: 500, hideTimeout: 100 })
const tooltip = useTooltipStore({ placement: position, showTimeout, hideTimeout })
const isOpen = tooltip.useState('open')

const child = React.Children.only(
Expand Down

0 comments on commit 6716d8e

Please sign in to comment.