-
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
Conversation
5b0f0b1
to
3a11bbe
Compare
Codecov Report
@@ Coverage Diff @@
## next #887 +/- ##
===========================================
+ Coverage 61.70% 79.78% +18.08%
===========================================
Files 2 4 +2
Lines 47 94 +47
Branches 21 27 +6
===========================================
+ Hits 29 75 +46
- Misses 17 18 +1
Partials 1 1
Continue to review full report at Codecov.
|
); | ||
}; | ||
export default Tooltip; |
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.
Noticed the original components were not exporting default
, is that something we should also do?
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.
Oh yeah, that's funny. They're always importing components like import { Button } from '../Button/Button';
. I personally prefer exporting default, but I don't feel strongly about this since in the app they're going to import components like that anyway (import {Button} from "@chanzuckerberg/eds-components";
).
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 don't think it hurts for us to have the extra Button/index.ts
file, and like the extra flexibility it gives 🙂 if that's not reflected in the plop-templates could you update them as well?
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.
@anniehu4 @dierat @jinlee93 This is all good stuff, and happy to adopt whatever ergonomic things like this help the cause. FWIW, I wrote a post that broke down the pros and cons of all these approaches: https://bradfrost.com/blog/post/this-or-that-component-names-index-js-or-component-js/
src/components/Tooltip/Tooltip.tsx
Outdated
buttonText, | ||
...other | ||
}) => { | ||
variant?: 'light' | 'dark'; |
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.
Should this be inverted
?
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'm not sure 🤔 inverted
is when the color scheme is inverted so it will have enough contrast on a dark background, but both of these variants work on light and dark backgrounds. Actually, this might be a good time to bring up whether we really need both of them, and, if we do, what are the guidelines around when to use which?
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.
yeah that's a great point @dierat
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.
Flagged this conundrum with the team over here and we're hopefully helping make some calls here: https://bigmedium.slack.com/archives/C0310HJ9WEN/p1646949365214339
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 comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, to clarify, are you saying to add a token to shadows.json
, or not using a token for now and assigning a value to box-shadow
?
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.
either add a token to shadows.json
or update one of the base tokens to match ours 🙂 we should always be using a tier 2 token, but the values are owned by us, and will probably evolve over the next few weeks. so not sure it's worth to update all of them up front, but if we notice discrepancies we can default to the values we were already using for the component
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.
Ah thanks for the explanation, will update shadow token md
,
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.
@@ -0,0 +1,20 @@ | |||
.trigger--spacing { | |||
margin: 9rem; |
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.
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
let's also do the footnote commenting thing brad had, i.e.:
margin: 9rem; | |
margin: 9rem; /* 1 */ |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
/* TODO: replace ForwardRefButton with EDS button since it's already using forwardRef */ | ||
const ForwardRefButton = React.forwardRef((props: Props, ref) => ( | ||
<Button {...props} buttonRef={ref} /> | ||
)); | ||
ForwardRefButton.displayName = 'ForwardRefButton'; |
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 is required for for Tippy. Button that will be imported from EDS already uses forwardRef
@@ -88,7 +88,7 @@ Here's another example: | |||
|
|||
### CSS Nesting | |||
|
|||
EDS uses [PostCSS Nested](https://github.com/postcss/postcss-nested) to provide some developer ergononics. As a general principle, nesting should be used sparingly and is only used in the following situations: | |||
EDS uses [PostCSS Nested](https://github.com/postcss/postcss-nested) to provide some developer ergonomics. As a general principle, nesting should be used sparingly and is only used in the following situations: |
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.
@@ -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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Yep we can, and will do
src/components/Tooltip/Tooltip.tsx
Outdated
*/ | ||
children?: ReactNode; | ||
content?: React.ReactNode; |
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 wonder if this should be text
based on the prop guidelines Big Medium uses.
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.
Changed to text
, thanks
src/components/Tooltip/Tooltip.tsx
Outdated
* The visually-hidden button text for the tooltip trigger button | ||
* The trigger element the tooltip appears next to. | ||
* | ||
* Use this instead of `children` if the trigger element is being | ||
* stored in a ref. Most cases will use `children` and not | ||
* `reference`. | ||
*/ | ||
buttonText?: string; |
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 can't figure out what this prop was 🤔 Do you understand the comment?
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.
|
||
useEffect(() => { | ||
if (isActive) { |
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.
Interesting that their version of the component is focusable. I wonder why.
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.
Hmmm in my understanding, tooltip does not receive focus
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.
maybe they were trying to handle tooltips w/ interactive content 🤔 we don't want that tho
This pull request has been linked to Shortcut Story #187512: Move Tooltip to new architecture. |
variant === 'light' && styles['tooltip--light'], | ||
variant === 'dark' && styles['tooltip--dark'], |
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.
Do you know if we've cleared with BM if we're using ampersands or object literals for these subjective classes? The code guidelines still has it using the object literals, but I think we want to keep using the ampersands. https://github.com/chanzuckerberg/edu-design-system/blob/next/docs/CODE_GUIDELINES.md#define-componentclassname
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.
Oooh good q, I do like ampersands b/c I feel like it's easier to read
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 think they wanted to see an example in code first. So here it is! @bradfrost @ifrost1 @csnizik any concerns with this syntax?
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.
Via offline eng sync, committing to this style of syntax
Very nice! So the open questions I still have about our process based on seeing this change are:
Does that sound right? |
Yup that sounds right, thanks for surfacing these questions |
src/components/Tooltip/Tooltip.tsx
Outdated
<Tippy | ||
{...rest} | ||
className={clsx( | ||
styles.tooltip, |
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 is a really small thing but I wonder if we want to use the brackets and quotation syntax for class names all the time for consistency or not (I see they used styles['tooltip']
in their version of the component).
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.
let's be consistent with the brackets + quotes
|
||
export interface Props { | ||
// Full list of Tippy props: https://atomiks.github.io/tippyjs/v6/all-props/ | ||
type TooltipProps = { |
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.
Just noticed that they use Prop
and we use component name + Props
. We often have several sub components in a file, so it may make sense to just keep using component name + Props
for consistency.
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.
Sounds good, will change to Prop
and also export it
@@ -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 comment
The 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
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
since we're here, probs worth configuring this rule to ignore global
: https://stylelint.io/user-guide/rules/list/selector-pseudo-class-no-unknown/#ignorepseudoclasses-regex-string
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.
Will add to stylelintrc
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 comment
The 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
@@ -0,0 +1,20 @@ | |||
.trigger--spacing { | |||
margin: 9rem; |
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.
let's also do the footnote commenting thing brad had, i.e.:
margin: 9rem; | |
margin: 9rem; /* 1 */ |
to note that this specific line is connected to the 1) comment above
src/components/Tooltip/Tooltip.tsx
Outdated
*/ | ||
align?: 'right' | 'below' | 'left'; | ||
children?: React.ReactElement; |
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.
nit: can we keep the props alphabetized
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.
Yes! Alphabetizing
src/components/Tooltip/Tooltip.tsx
Outdated
buttonText, | ||
...other | ||
}) => { | ||
variant?: 'light' | 'dark'; |
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.
yeah that's a great point @dierat
|
||
useEffect(() => { | ||
if (isActive) { |
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.
maybe they were trying to handle tooltips w/ interactive content 🤔 we don't want that tho
src/components/Tooltip/Tooltip.tsx
Outdated
<Tippy | ||
{...rest} | ||
className={clsx( | ||
styles.tooltip, |
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.
let's be consistent with the brackets + quotes
); | ||
}; | ||
export default Tooltip; |
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 don't think it hurts for us to have the extra Button/index.ts
file, and like the extra flexibility it gives 🙂 if that's not reflected in the plop-templates could you update them as well?
variant === 'light' && styles['tooltip--light'], | ||
variant === 'dark' && styles['tooltip--dark'], |
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 think they wanted to see an example in code first. So here it is! @bradfrost @ifrost1 @csnizik any concerns with this syntax?
aria-label="Hover this button to trigger the tooltip" | ||
text="Hover this button to trigger the tooltip" |
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.
Nit - I don't think you need both the text
and aria-label
here since they're the same.
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.
fixed, thanks
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 saw go ahead without deprecating the dark variant; we can do that separately.
Sounds good to me |
Will go ahead and merge as comments have been addressed. Deprecating the dark variant can be done in a separate PR after clearer deprecation guidelines have been established, and deprecation badge for storybook has been merged |
* chore: move Tooltip to next * chore: update counter story since it uses tooltip * chore: add tooltip styling comments * chore: update prop and comments * chore: respond to comments * chore: nit: remove redundant prop in story
* chore: move Tooltip to next * chore: update counter story since it uses tooltip * chore: add tooltip styling comments * chore: update prop and comments * chore: respond to comments * chore: nit: remove redundant prop in story
[sc-187512]
Summary:
Test Plan:
Screen.Recording.2022-03-07.at.4.27.39.PM.mov