-
Notifications
You must be signed in to change notification settings - Fork 14k
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
feat: use svg for checkbox component #10799
Conversation
*/ | ||
|
||
import React from 'react'; | ||
import { ReactWrapper, shallow } from 'enzyme'; |
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 FYI, this shallow
will break if we use any Emotion theme vars in the component (which we probably will before long, e.g. to affect the color(s) of the SVG). the theming helpers one line below also include a "styledShallow" you can import to solve that.
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.
Looks like the styledShallow won't work without the HOC from Emotion because of the dive
after the shallow render, but I think it could be a good plan to add emotion to this anyway.
|
||
// eslint-disable-next-line no-unused-vars | ||
export const Component = _args => { | ||
const [{ checked, style }, updateArgs] = useArgs(); |
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.
Pretty cool, I didn't know this even existed, actually. Nice that it lets the components do the toggling.
I still like the idea of knobs, too, so you can control any given component from a common location. I wonder if there's a way that both can co-exist, e.g. this updateArgs
toggles the checked
prop and toggles the knob's checkbox.
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.
FWICT storybook seems to be trying to move people to args instead of knobs, since args is part of original package instead of an addon: https://github.com/storybookjs/storybook/blob/next/addons/controls/README.md#knobs-to-custom-args
I put together a draft of the buttons as an arg/controls to see if we could migrate knobs to args, and it seems to work, but wdyt?
Here's a view of the checkbox and button as args/controls (ignore the knob stories for now):
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.
Args/controls LGTM!
Welcome to the repo and community @eschutho ! |
}} | ||
/> | ||
<span | ||
style={{ verticalAlign: 'top', ...style }} |
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.
We could probably use emotion to make this <span...
a <Styles...
tag, using Emotion, to address this alignment and the piecemeal ones added to the SVG files, like so:
const Styles=styled.span`
vertical-align: top;
...
svg {
vertical-align: top;
}
`
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.
Little nits/comments that may or may not be worth addressing, but it looks like a great improvement!
0be9a62
to
b45d96a
Compare
Codecov Report
@@ Coverage Diff @@
## master #10799 +/- ##
==========================================
- Coverage 61.22% 60.36% -0.87%
==========================================
Files 802 373 -429
Lines 37814 23875 -13939
Branches 3555 0 -3555
==========================================
- Hits 23153 14412 -8741
+ Misses 14475 9463 -5012
+ Partials 186 0 -186
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
b45d96a
to
a305281
Compare
@rusackas I updated the button story to use args/controls... it's about the same amount of code, but there are implicit args that you get for free. See what you think. |
a305281
to
9174184
Compare
@eschutho I think this one's ready to rock, but just needs a little touchup to pass CI. Sorry it sat here so long! One thing I see causing CI to fail is that |
9174184
to
70e86dc
Compare
@rusackas my bad for not checking up on this after rebasing! Thanks for calling it out. |
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.
LGTM! Thanks!
* use svg for checkbox component * add vertical align to svg * use emotion styling * update import to superset core Co-authored-by: Elizabeth Thompson <[email protected]>
SUMMARY
Replaces the use of font-awesome for checkboxes with the svg components that already exist. There's also the potential to add the existing "half-checked" svg icon to the checkbox component as a prop as a future improvement.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
There are some minor visual differences with the new component:
Proposed:
Existing:
TEST PLAN
A story and test were added, but it can be manually tested in the save dashboard modal as in the example.
ADDITIONAL INFORMATION