Skip to content
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

feat: Expose showTimeout and hideTimeout props for Tooltip #845

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading