Repository navigation
[tooltip] Fix disabled prop on Triggers
#4049
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
de5461d
[tooltip] Fix `disabled` prop on Triggers
michaldudak 8409c22
Lint
michaldudak 2bbed8c
Refactoring, docs
michaldudak 90b11dd
PR feedback
michaldudak 078fced
Merge remote-tracking branch 'upstream/master' into disabled-tooltips…
michaldudak 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
186 changes: 186 additions & 0 deletions
186
docs/src/app/(private)/experiments/tooltip/disabled.module.css
This file contains hidden or 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,186 @@ | ||
| .Container { | ||
| display: flex; | ||
| gap: 0.5rem; | ||
| flex-wrap: wrap; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .ButtonGroup { | ||
| display: flex; | ||
| } | ||
|
|
||
| .IconButton { | ||
| box-sizing: border-box; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| width: 2.5rem; | ||
| height: 2.5rem; | ||
| padding: 0; | ||
| margin: 0; | ||
| outline: 0; | ||
| border: 1px solid var(--color-gray-200); | ||
| background-color: var(--color-gray-50); | ||
| color: var(--color-gray-900); | ||
| user-select: none; | ||
|
|
||
| &[data-popup-open] { | ||
| background-color: var(--color-gray-100); | ||
| } | ||
|
|
||
| &:focus-visible { | ||
| outline: 2px solid var(--color-blue); | ||
| outline-offset: -1px; | ||
| } | ||
|
|
||
| @media (hover: hover) { | ||
| &:hover { | ||
| background-color: var(--color-gray-100); | ||
| } | ||
| } | ||
|
|
||
| &:active { | ||
| background-color: var(--color-gray-100); | ||
| } | ||
|
|
||
| &:only-child { | ||
| border-radius: 0.375rem; | ||
| } | ||
|
|
||
| &:first-child:not(:only-child) { | ||
| border-radius: 0.375rem 0 0 0.375rem; | ||
| } | ||
|
|
||
| &:last-child:not(:only-child) { | ||
| border-radius: 0 0.375rem 0.375rem 0; | ||
| } | ||
|
|
||
| &:not(:first-child) { | ||
| border-left: none; | ||
| } | ||
| } | ||
|
|
||
| .Icon { | ||
| width: 1.25rem; | ||
| height: 1.25rem; | ||
| } | ||
|
|
||
| .Positioner { | ||
| height: var(--positioner-height); | ||
| width: var(--positioner-width); | ||
| max-width: var(--available-width); | ||
| } | ||
|
|
||
| .Popup { | ||
| box-sizing: border-box; | ||
| font-size: 0.875rem; | ||
| line-height: 1.25rem; | ||
| padding: 0.25rem 0.5rem; | ||
| border-radius: 0.375rem; | ||
| background-color: canvas; | ||
| transform-origin: var(--transform-origin); | ||
| transition: | ||
| transform 150ms, | ||
| opacity 150ms; | ||
|
|
||
| &[data-starting-style], | ||
| &[data-ending-style] { | ||
| opacity: 0; | ||
| transform: scale(0.9); | ||
| } | ||
|
|
||
| &[data-instant] { | ||
| transition: none; | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: light) { | ||
| outline: 1px solid var(--color-gray-200); | ||
| box-shadow: | ||
| 0 10px 15px -3px var(--color-gray-200), | ||
| 0 4px 6px -4px var(--color-gray-200); | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| outline: 1px solid var(--color-gray-300); | ||
| outline-offset: -1px; | ||
| } | ||
| } | ||
|
|
||
| .Arrow { | ||
| display: flex; | ||
|
|
||
| &[data-side='top'] { | ||
| bottom: -8px; | ||
| rotate: 180deg; | ||
| } | ||
|
|
||
| &[data-side='bottom'] { | ||
| top: -8px; | ||
| rotate: 0deg; | ||
| } | ||
|
|
||
| &[data-side='left'] { | ||
| right: -13px; | ||
| rotate: 90deg; | ||
| } | ||
|
|
||
| &[data-side='right'] { | ||
| left: -13px; | ||
| rotate: -90deg; | ||
| } | ||
| } | ||
|
|
||
| .ArrowFill { | ||
| fill: canvas; | ||
| } | ||
|
|
||
| .ArrowOuterStroke { | ||
| @media (prefers-color-scheme: light) { | ||
| fill: var(--color-gray-200); | ||
| } | ||
| } | ||
|
|
||
| .ArrowInnerStroke { | ||
| @media (prefers-color-scheme: dark) { | ||
| fill: var(--color-gray-300); | ||
| } | ||
| } | ||
|
|
||
| .Button { | ||
| box-sizing: border-box; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| min-height: 2.5rem; | ||
| padding: 0 0.875rem; | ||
| margin: 0; | ||
| outline: 0; | ||
| border: 1px solid var(--color-gray-200); | ||
| border-radius: 0.375rem; | ||
| background-color: var(--color-gray-50); | ||
| font-family: inherit; | ||
| font-size: 1rem; | ||
| font-weight: 500; | ||
| line-height: 1.5rem; | ||
| color: var(--color-gray-900); | ||
| user-select: none; | ||
|
|
||
| @media (hover: hover) { | ||
| &:hover:not([data-disabled]) { | ||
| background-color: var(--color-gray-100); | ||
| } | ||
| } | ||
|
|
||
| &:active:not([data-disabled]) { | ||
| background-color: var(--color-gray-100); | ||
| } | ||
|
|
||
| &:focus-visible { | ||
| outline: 2px solid var(--color-blue); | ||
| outline-offset: -1px; | ||
| } | ||
|
|
||
| &[data-disabled] { | ||
| opacity: 0.5; | ||
| } | ||
| } |
This file contains hidden or 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,72 @@ | ||
| 'use client'; | ||
| import * as React from 'react'; | ||
| import { Button } from '@base-ui/react/button'; | ||
| import { Tooltip } from '@base-ui/react/tooltip'; | ||
| import styles from './disabled.module.css'; | ||
|
|
||
| const demoTooltip = Tooltip.createHandle(); | ||
|
|
||
| export default function TooltipDetachedTriggersSimpleDemo() { | ||
| return ( | ||
| <React.Fragment> | ||
| <div className={styles.ButtonGroup}> | ||
| <Tooltip.Trigger className={styles.Button} handle={demoTooltip}> | ||
| Enabled trigger | ||
| </Tooltip.Trigger> | ||
|
|
||
| <Tooltip.Trigger className={styles.Button} handle={demoTooltip} disabled> | ||
| Disabled trigger | ||
| </Tooltip.Trigger> | ||
|
|
||
| <Tooltip.Trigger | ||
| className={styles.Button} | ||
| handle={demoTooltip} | ||
| render={<Button disabled focusableWhenDisabled />} | ||
| > | ||
| Enabled trigger rendered as disabled button | ||
| </Tooltip.Trigger> | ||
|
|
||
| <Tooltip.Trigger | ||
| className={styles.Button} | ||
| handle={demoTooltip} | ||
| disabled | ||
| render={<Button disabled focusableWhenDisabled />} | ||
| > | ||
| Disabled trigger rendered as disabled button | ||
| </Tooltip.Trigger> | ||
| </div> | ||
|
|
||
| <Tooltip.Root handle={demoTooltip}> | ||
| <Tooltip.Portal> | ||
| <Tooltip.Positioner sideOffset={10}> | ||
| <Tooltip.Popup className={styles.Popup}> | ||
| <Tooltip.Arrow className={styles.Arrow}> | ||
| <ArrowSvg /> | ||
| </Tooltip.Arrow> | ||
| Tooltip | ||
| </Tooltip.Popup> | ||
| </Tooltip.Positioner> | ||
| </Tooltip.Portal> | ||
| </Tooltip.Root> | ||
| </React.Fragment> | ||
| ); | ||
| } | ||
|
|
||
| function ArrowSvg(props: React.ComponentProps<'svg'>) { | ||
| return ( | ||
| <svg width="20" height="10" viewBox="0 0 20 10" fill="none" {...props}> | ||
| <path | ||
| d="M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z" | ||
| className={styles.ArrowFill} | ||
| /> | ||
| <path | ||
| d="M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z" | ||
| className={styles.ArrowOuterStroke} | ||
| /> | ||
| <path | ||
| d="M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z" | ||
| className={styles.ArrowInnerStroke} | ||
| /> | ||
| </svg> | ||
| ); | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
"Whether the trigger is disabled" should probably be updated