Skip to content

Commit f318ecf

Browse files
committed
chore(website): Update examples for useTooltip disabled option
1 parent a934ae9 commit f318ecf

File tree

4 files changed

+15
-34
lines changed

4 files changed

+15
-34
lines changed

packages/documentation/src/components/AppBarAction.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export default function AppBarAction({
2222
onContextMenu,
2323
...props
2424
}: Props): ReactElement {
25-
const handlers = {
25+
const { elementProps, tooltipProps } = useTooltip({
26+
baseId: id,
27+
disabled: !tooltip,
2628
onClick,
2729
onBlur,
2830
onFocus,
@@ -31,18 +33,11 @@ export default function AppBarAction({
3133
onMouseLeave,
3234
onTouchStart,
3335
onContextMenu,
34-
};
35-
const { elementProps, tooltipProps } = useTooltip({
36-
baseId: id,
37-
...handlers,
3836
});
3937

4038
return (
4139
<>
42-
<RMDAppBarAction
43-
{...props}
44-
{...(tooltip ? elementProps : { id, ...handlers })}
45-
>
40+
<RMDAppBarAction {...props} {...elementProps}>
4641
{children}
4742
</RMDAppBarAction>
4843
<Tooltip {...tooltipProps}>{tooltip}</Tooltip>

packages/documentation/src/components/AppBarNav.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export default function AppBarNav({
2222
onContextMenu,
2323
...props
2424
}: Props): ReactElement {
25-
const handlers = {
25+
const { elementProps, tooltipProps } = useTooltip({
26+
baseId: id,
27+
disabled: !tooltip,
2628
onClick,
2729
onBlur,
2830
onFocus,
@@ -31,18 +33,11 @@ export default function AppBarNav({
3133
onMouseLeave,
3234
onTouchStart,
3335
onContextMenu,
34-
};
35-
const { elementProps, tooltipProps } = useTooltip({
36-
baseId: id,
37-
...handlers,
3836
});
3937

4038
return (
4139
<>
42-
<RMDAppBarNav
43-
{...props}
44-
{...(tooltip ? elementProps : { id, ...handlers })}
45-
>
40+
<RMDAppBarNav {...props} {...elementProps}>
4641
{children}
4742
</RMDAppBarNav>
4843
<Tooltip {...tooltipProps}>{tooltip}</Tooltip>

packages/documentation/src/components/Button.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export default function Button({
2222
onContextMenu,
2323
...props
2424
}: Props): ReactElement {
25-
const handlers = {
25+
const { elementProps, tooltipProps } = useTooltip({
26+
baseId: id,
27+
disabled: !tooltip,
2628
onClick,
2729
onBlur,
2830
onFocus,
@@ -31,15 +33,11 @@ export default function Button({
3133
onMouseLeave,
3234
onTouchStart,
3335
onContextMenu,
34-
};
35-
const { elementProps, tooltipProps } = useTooltip({
36-
baseId: id,
37-
...handlers,
3836
});
3937

4038
return (
4139
<>
42-
<RMDButton {...props} {...(tooltip ? elementProps : { id, ...handlers })}>
40+
<RMDButton {...props} {...elementProps}>
4341
{children}
4442
</RMDButton>
4543
<Tooltip {...tooltipProps}>{tooltip}</Tooltip>

packages/documentation/src/components/Demos/Badge/TooltippedBadgedButton.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export default forwardRef<HTMLButtonElement, TooltippedBadgedButtonProps>(
3131
},
3232
ref
3333
) {
34-
const handlers = {
34+
const { elementProps, tooltipProps } = useTooltip({
35+
baseId: id,
3536
onClick,
3637
onBlur,
3738
onFocus,
@@ -40,19 +41,11 @@ export default forwardRef<HTMLButtonElement, TooltippedBadgedButtonProps>(
4041
onKeyDown,
4142
onTouchStart,
4243
onContextMenu,
43-
};
44-
const { elementProps, tooltipProps } = useTooltip({
45-
baseId: id,
46-
...handlers,
4744
});
4845

4946
return (
5047
<>
51-
<BadgedButton
52-
{...props}
53-
{...(tooltip ? elementProps : { id, ...handlers })}
54-
ref={ref}
55-
>
48+
<BadgedButton {...props} {...elementProps} ref={ref}>
5649
{children}
5750
</BadgedButton>
5851
<Tooltip

0 commit comments

Comments
 (0)