-
Notifications
You must be signed in to change notification settings - Fork 22
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
APP-2206: break apart tooltip component for custom usage #384
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7dd8ee4
APP-2206: break apart tooltip component for custom usage
mcous b055189
fixup: fix tests
mcous 6ef04f0
fixup: add storybook
mcous f1b940c
fixup: typo
mcous 85c09b8
fixup: typo
mcous 5365408
fixup: do not spread location defaults around
mcous b13a60c
fixup: no !
mcous 190b164
fixup: add JSDoc for tooltip style functions
mcous 5fd22c1
Merge branch 'main' into APP-2206_more-tooltip-tweaks
mcous 018d0ed
fixup: rebump
mcous b4da83d
Merge branch 'main' into APP-2206_more-tooltip-tweaks
mcous ffaba85
fixup: prevent tooltip flash before styles are calculated
mcous 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 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 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 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 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 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export { default as Tooltip } from './tooltip.svelte'; | ||
export type { TooltipLocation, TooltipState } from './tooltip-styles'; | ||
export { default as TooltipContainer } from './tooltip-container.svelte'; | ||
export { default as TooltipTarget } from './tooltip-target.svelte'; | ||
export { default as TooltipText } from './tooltip-text.svelte'; | ||
export type { TooltipLocation, TooltipVisibility } from './tooltip-styles'; |
This file contains 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,40 @@ | ||
<!-- | ||
@component | ||
|
||
A wrapper component to contain a tooltip and the element it describes. | ||
|
||
Used alongside <TooltipTarget> and <TooltipText> to create more | ||
customized tooltips when the regular <Tooltip> can't be used. | ||
|
||
For example, you may want to attach the tooltip of an input control | ||
to an icon, even though the tooltip describes the input, not the icon. | ||
|
||
```svelte | ||
<TooltipContainer let:tooltipID> | ||
<Label> | ||
Name | ||
<TooltipTarget> | ||
<Icon | ||
tabindex="0" | ||
cx="cursor-pointer" | ||
name="information-outline" | ||
/> | ||
</TooltipTarget> | ||
<TextInput | ||
slot="input" | ||
aria-describedby={tooltipID} | ||
/> | ||
</Label> | ||
<TooltipText>Cool name you got there!</TooltipText> | ||
</TooltipContainer> | ||
``` | ||
--> | ||
<svelte:options immutable /> | ||
|
||
<script lang="ts"> | ||
import { provideTooltipContext } from './tooltip-styles'; | ||
|
||
const { id } = provideTooltipContext(); | ||
</script> | ||
|
||
<slot tooltipID={id} /> |
This file contains 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.
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.
This appears to be a limitation of the Svelte ESLint plugin; it's a little buggy when it comes to correctly manipulating the parse tree when TS is involved (e.g. sveltejs/eslint-plugin-svelte#583).
I've been moving type exports to separate pure TS files to work around the issue. It's a little irritating to move the interfaces out of the component that uses them; but it's worth it to avoid losing type safety