Skip to content

Commit

Permalink
chore(website): Update examples for useTooltip disabled option
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Mar 18, 2022
1 parent a934ae9 commit f318ecf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
13 changes: 4 additions & 9 deletions packages/documentation/src/components/AppBarAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export default function AppBarAction({
onContextMenu,
...props
}: Props): ReactElement {
const handlers = {
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
disabled: !tooltip,
onClick,
onBlur,
onFocus,
Expand All @@ -31,18 +33,11 @@ export default function AppBarAction({
onMouseLeave,
onTouchStart,
onContextMenu,
};
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
...handlers,
});

return (
<>
<RMDAppBarAction
{...props}
{...(tooltip ? elementProps : { id, ...handlers })}
>
<RMDAppBarAction {...props} {...elementProps}>
{children}
</RMDAppBarAction>
<Tooltip {...tooltipProps}>{tooltip}</Tooltip>
Expand Down
13 changes: 4 additions & 9 deletions packages/documentation/src/components/AppBarNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export default function AppBarNav({
onContextMenu,
...props
}: Props): ReactElement {
const handlers = {
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
disabled: !tooltip,
onClick,
onBlur,
onFocus,
Expand All @@ -31,18 +33,11 @@ export default function AppBarNav({
onMouseLeave,
onTouchStart,
onContextMenu,
};
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
...handlers,
});

return (
<>
<RMDAppBarNav
{...props}
{...(tooltip ? elementProps : { id, ...handlers })}
>
<RMDAppBarNav {...props} {...elementProps}>
{children}
</RMDAppBarNav>
<Tooltip {...tooltipProps}>{tooltip}</Tooltip>
Expand Down
10 changes: 4 additions & 6 deletions packages/documentation/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export default function Button({
onContextMenu,
...props
}: Props): ReactElement {
const handlers = {
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
disabled: !tooltip,
onClick,
onBlur,
onFocus,
Expand All @@ -31,15 +33,11 @@ export default function Button({
onMouseLeave,
onTouchStart,
onContextMenu,
};
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
...handlers,
});

return (
<>
<RMDButton {...props} {...(tooltip ? elementProps : { id, ...handlers })}>
<RMDButton {...props} {...elementProps}>
{children}
</RMDButton>
<Tooltip {...tooltipProps}>{tooltip}</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default forwardRef<HTMLButtonElement, TooltippedBadgedButtonProps>(
},
ref
) {
const handlers = {
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
onClick,
onBlur,
onFocus,
Expand All @@ -40,19 +41,11 @@ export default forwardRef<HTMLButtonElement, TooltippedBadgedButtonProps>(
onKeyDown,
onTouchStart,
onContextMenu,
};
const { elementProps, tooltipProps } = useTooltip({
baseId: id,
...handlers,
});

return (
<>
<BadgedButton
{...props}
{...(tooltip ? elementProps : { id, ...handlers })}
ref={ref}
>
<BadgedButton {...props} {...elementProps} ref={ref}>
{children}
</BadgedButton>
<Tooltip
Expand Down

0 comments on commit f318ecf

Please sign in to comment.