Skip to content
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

Merged
merged 4 commits into from
Sep 16, 2020

Conversation

eschutho
Copy link
Member

@eschutho eschutho commented Sep 4, 2020

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:
Screen Recording 2020-09-04 at 2 41 12 PM

Existing:
Screen Recording 2020-09-04 at 12 15 21 PM

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

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

*/

import React from 'react';
import { ReactWrapper, shallow } from 'enzyme';
Copy link
Member

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.

Copy link
Member Author

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();
Copy link
Member

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.

Copy link
Member Author

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):
Screen Recording 2020-09-08 at 6 12 57 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Args/controls LGTM!

@mistercrunch
Copy link
Member

Welcome to the repo and community @eschutho !

welcome

}}
/>
<span
style={{ verticalAlign: 'top', ...style }}
Copy link
Member

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;
  }
`

Copy link
Member

@rusackas rusackas left a 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!

@eschutho eschutho marked this pull request as draft September 9, 2020 01:02
@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2020

Codecov Report

Merging #10799 into master will decrease coverage by 0.86%.
The diff coverage is n/a.

Impacted file tree graph

@@            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     
Flag Coverage Δ
#javascript ?
#python 60.36% <ø> (-0.65%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/db_engines/hive.py 0.00% <0.00%> (-85.72%) ⬇️
superset/db_engine_specs/hive.py 53.90% <0.00%> (-30.08%) ⬇️
superset/db_engine_specs/mysql.py 79.16% <0.00%> (-12.50%) ⬇️
superset/db_engine_specs/presto.py 70.85% <0.00%> (-11.44%) ⬇️
superset/examples/world_bank.py 97.10% <0.00%> (-2.90%) ⬇️
superset/examples/birth_names.py 97.36% <0.00%> (-2.64%) ⬇️
superset/views/database/mixins.py 80.70% <0.00%> (-1.76%) ⬇️
superset/models/core.py 86.66% <0.00%> (-1.67%) ⬇️
superset/views/core.py 74.24% <0.00%> (-0.25%) ⬇️
superset/connectors/sqla/models.py 89.48% <0.00%> (-0.25%) ⬇️
... and 432 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f685825...b45d96a. Read the comment docs.

@eschutho
Copy link
Member Author

eschutho commented Sep 9, 2020

@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.

@eschutho eschutho marked this pull request as ready for review September 9, 2020 21:00
@rusackas
Copy link
Member

@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 styled should now be imported from @superset-ui/core (due to the big consolidation effort there)

@eschutho
Copy link
Member Author

@rusackas my bad for not checking up on this after rebasing! Thanks for calling it out.

@eschutho eschutho changed the title use svg for checkbox component feat: use svg for checkbox component Sep 16, 2020
Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@rusackas rusackas merged commit d3e9c56 into apache:master Sep 16, 2020
@rusackas rusackas deleted the elizabeth/checkbox-story branch September 16, 2020 19:03
@nytai nytai mentioned this pull request Sep 16, 2020
6 tasks
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* 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]>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.38.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 0.38.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants