-
Notifications
You must be signed in to change notification settings - Fork 4
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
Move tooltip to next #887
Move tooltip to next #887
Changes from 4 commits
fe6309f
5e5c452
3a11bbe
ec4c39d
1ae1447
6db6e9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { Story, Meta } from '@storybook/react'; | ||
import React from 'react'; | ||
import { Counter, Props } from './Counter'; | ||
import { Button } from '../Button/Button'; | ||
import { Tooltip } from '../Tooltip/Tooltip'; | ||
|
||
export default { | ||
|
@@ -20,6 +21,19 @@ Default.args = { | |
plusButtonText: 'Add by 1', | ||
}; | ||
|
||
/* TODO: replace <ForwardRefButton> with EDS button since it's already using forwardRef */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we quickly add forwardRef to the existing button now? not sure how long EDS button conversion will take & it's nicer not having to hunt down TODOs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep we can, and will do |
||
const ForwardRefButton = React.forwardRef((props, ref) => ( | ||
<Button | ||
variant="bare" | ||
iconPosition="after" | ||
iconName="question-mark-circle" | ||
aria-label="Hover this button to trigger the tooltip" | ||
text="Hover this button to trigger the tooltip" | ||
buttonRef={ref} | ||
/> | ||
)); | ||
ForwardRefButton.displayName = 'ForwardRefButton'; | ||
|
||
export const DefaultWithTooltip = Template.bind({}); | ||
DefaultWithTooltip.args = { | ||
value: 1, | ||
|
@@ -30,8 +44,8 @@ DefaultWithTooltip.args = { | |
plusButtonText: 'Add by 1', | ||
fieldNote: 'This is a counter field', | ||
labelAfter: ( | ||
<Tooltip buttonText="Select this button to trigger the tooltip"> | ||
Some text to help with a form field | ||
<Tooltip content="Some text to help with a form field"> | ||
<ForwardRefButton /> | ||
</Tooltip> | ||
), | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,126 @@ | ||
@import '../../design-tokens/mixins.css'; | ||
/* stylelint-disable selector-pseudo-class-no-unknown */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're here, probs worth configuring this rule to ignore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add to |
||
|
||
/*------------------------------------*\ | ||
#TOOLTIP | ||
\*------------------------------------*/ | ||
|
||
/** | ||
* 1) An icon that appears | ||
* 1) Tippyjs provides .tippy-box, which has two child elements: .tippy-content and .tippy-arrow | ||
* 2) Tippyjs also attaches data-attribute `data-placement` depending on how the tooltip is aligned | ||
*/ | ||
|
||
.tooltip { | ||
display: inline-block; | ||
position: relative; | ||
overflow: visible; | ||
border-style: solid; | ||
border-width: var(--eds-border-width-sm); | ||
border-radius: var(--eds-border-radius-lg); | ||
box-shadow: var(--eds-theme-box-shadow); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we need a ticket for updating the tokens 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think all tokens are subject to change while design is doing discovery right now; so we can feel free to replace the values with our existing ones There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, to clarify, are you saying to add a token to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. either add a token to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah thanks for the explanation, will update shadow token There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
@media (prefers-reduced-motion) { | ||
transition-property: none; | ||
} | ||
} | ||
|
||
.tooltip__trigger { | ||
display: inline-block; | ||
cursor: pointer; | ||
/** | ||
* 1) Enables opacity fade animation | ||
*/ | ||
.tooltip[data-state="hidden"] { | ||
opacity: 0; | ||
} | ||
|
||
&:focus-visible { | ||
@mixin focus; | ||
} | ||
.tooltip :global(.tippy-content) { | ||
padding-left: var(--eds-size-2); | ||
padding-right: var(--eds-size-2); | ||
padding-bottom: var(--eds-size-1); | ||
padding-top: var(--eds-size-1); | ||
} | ||
|
||
/** | ||
* 1) Color Variants | ||
*/ | ||
.tooltip--light { | ||
border-color: var(--eds-color-neutral-300); | ||
color: var(--eds-color-neutral-700); | ||
background-color: var(--eds-color-neutral-100); | ||
--arrow-color: var(--eds-color-neutral-300); | ||
} | ||
|
||
.tooltip--dark { | ||
border-color: var(--eds-color-neutral-700); | ||
color: var(--eds-color-neutral-white); | ||
background-color: var(--eds-color-neutral-700); | ||
--arrow-color: var(--eds-color-neutral-700); | ||
} | ||
|
||
.tooltip__content { | ||
display: none; | ||
/** | ||
* 1) Add arrows | ||
*/ | ||
.tooltip :global(.tippy-arrow) { | ||
position: absolute; | ||
bottom: 130%; | ||
left: 50%; | ||
margin-left: -96px; | ||
width: 12rem; | ||
padding: var(--eds-size-1); | ||
background: var(--eds-color-neutral-white); | ||
color: var(--eds-theme-color-body-foreground); | ||
border-width: var(--eds-theme-border-width); | ||
|
||
width: var(--eds-size-2); | ||
height: var(--eds-size-2); | ||
} | ||
|
||
.tooltip :global(.tippy-arrow::before) { | ||
position: absolute; | ||
|
||
border-style: solid; | ||
border-color: var(--eds-theme-color-neutral-subtle-border); | ||
border-radius: var(--eds-theme-border-radius); | ||
box-shadow: var(--eds-theme-box-shadow); | ||
border-color: transparent; | ||
border-width: var(--eds-size-1); | ||
|
||
&:focus-visible { | ||
@mixin focus; | ||
} | ||
content: ""; | ||
} | ||
|
||
.tooltip--right & { | ||
bottom: auto; | ||
top: -50%; | ||
left: 130%; | ||
margin-left: 0; | ||
} | ||
.tooltip[data-placement^="top"] :global(.tippy-arrow) { | ||
left: 0; | ||
|
||
.tooltip--below & { | ||
bottom: inherit; | ||
} | ||
transform: translate3d(73px, 0, 0); | ||
} | ||
|
||
.tooltip--left & { | ||
bottom: auto; | ||
left: auto; | ||
top: -50%; | ||
right: calc(130% + 5px); | ||
} | ||
.tooltip[data-placement^="bottom"] :global(.tippy-arrow) { | ||
top: 0; | ||
left: 0; | ||
|
||
.tooltip.eds-is-active & { | ||
display: flex; | ||
justify-content: center; | ||
z-index: var(--eds-z-index-100); | ||
} | ||
transform: translate3d(73px, 0, 0); | ||
} | ||
|
||
.tooltip[data-placement^="left"] :global(.tippy-arrow) { | ||
top: 0; | ||
right: 0; | ||
|
||
transform: translate3d(0, 19px, 0); | ||
} | ||
|
||
.tooltip[data-placement^="right"] :global(.tippy-arrow) { | ||
top: 0; | ||
left: 0; | ||
|
||
transform: translate3d(0, 25px, 0); | ||
} | ||
|
||
.tooltip[data-placement^="top"] :global(.tippy-arrow::before) { | ||
left: 0; | ||
|
||
border-top-color: var(--arrow-color); | ||
border-bottom-width: 0; | ||
} | ||
|
||
.tooltip[data-placement^="bottom"] :global(.tippy-arrow::before) { | ||
left: 0; | ||
|
||
border-bottom-color: var(--arrow-color); | ||
border-top-width: 0; | ||
top: -7px; | ||
} | ||
|
||
.tooltip[data-placement^="left"] :global(.tippy-arrow::before) { | ||
border-left-color: var(--arrow-color); | ||
border-right-width: 0; | ||
right: -7px; | ||
} | ||
|
||
.tooltip__icon { | ||
fill: var(--eds-theme-color-primary-foreground); | ||
.tooltip[data-placement^="right"] :global(.tippy-arrow::before) { | ||
border-right-color: var(--arrow-color); | ||
border-left-width: 0; | ||
left: -7px; | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||||
/*------------------------------------*\ | ||||||
#TOOLTIP STORIES | ||||||
\*------------------------------------*/ | ||||||
|
||||||
/** | ||||||
* 1) Spacing is required for the Tooltip to be placed where alignment is indicated, | ||||||
* otherwise Tippy will place somewhere else due to lack of space | ||||||
*/ | ||||||
|
||||||
.trigger--spacing { | ||||||
margin: 9rem; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird number but it's appropriate required for the tooltip to place where alignment is indicated, otherwise Tippy places somewhere else due to lack of space There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe leave that in a comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, added comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's also do the footnote commenting thing brad had, i.e.:
Suggested change
to note that this specific line is connected to the 1) comment above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do |
||||||
} | ||||||
|
||||||
.trigger--spacing-top { | ||||||
margin-top: 9rem; | ||||||
} | ||||||
.trigger--spacing-bottom { | ||||||
margin-bottom: 9rem; | ||||||
} | ||||||
.trigger--spacing-left { | ||||||
margin-left: 9rem; | ||||||
} | ||||||
.trigger--spacing-right { | ||||||
margin-right: 9rem; | ||||||
} | ||||||
|
||||||
.trigger--spacing-left-large { | ||||||
margin-left: 24rem; | ||||||
} |
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.
Wow thanks for all the spelling updates! ❤️
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.
I somehow feel like this was some sort of test and you passed.