-
Notifications
You must be signed in to change notification settings - Fork 63
Refactor VIcon
to set the size using a tailwind class instead of the size
prop
#1895
Conversation
Storybook and Tailwind configuration previews: Ready Storybook: https://wordpress.github.io/openverse-frontend/_preview/1895 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
Size Change: -2.27 kB (0%) Total Size: 821 kB
ℹ️ View Unchanged
|
66cc5af
to
fe8c412
Compare
src/components/VButton.vue
Outdated
? 'border border-tx' | ||
: 'border border-tx focus-visible:ring focus-visible:ring-pink', |
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.
'plain--avoid' is used in several places. Changing the base style could have unforeseen changes that are not captured in VRT. Can you add snapshots to other usages of this button variant?
src/components/VIcon/VIcon.vue
Outdated
* | ||
* @default 6 | ||
*/ | ||
size: { | ||
type: Number, | ||
default: 6, | ||
validator: (val: number) => [4, 5, 6].includes(val), | ||
validator: (val: number) => [4, 5, 6, 8, 12].includes(val), |
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.
Instead of this being a prop, the parent should be able to set h-*
and w-*
styles on the component. This seems a very contrived way to provide more sizes.
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.
Also the new sizes added here, being dynamic, should be added to tailwind.safelist.txt
.
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 suggest that we scrap the size
prop altogether, and just use h-* w-*
classes set by the parent component, with a fallback of h-6 w-6
?
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 suggesting scrapping the prop in the long term and adding the safelist to approve the PR.
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 do like the API design of size
type props, but I think it makes the most sense when standardized across a component library with lots of small, composable ui building blocks. I agree with @dhruvkb's suggestion here.
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've removed the prop, and added a dynamically generated size to the safelist.
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.
@zackkrida, @dhruvkb, I've tried using classes, but then there is a problem with default and overrides:
- if we add
w-6 h-6
by default, then to override them, we would need to add!
important modifier. - if we do not add a default, then we would need to add the size classes to all VIcons.
So, I went back to the size
prop as a cleaner option, and opened an alternative PR: #1928
99c72be
to
932d4e3
Compare
VIconButton
and add VSearchBarButton
VIcon
to set the size using a tailwind class instead of the size
prop
Replace all `size`s with `w-x h-x` classes Reuse VSearchBarButton instead of a separate VClearButton component Add 8 to safelist and fix iconSize (it's string, not a number) Revert changes to plain--avoid button
24fccd4
to
5ee0c1c
Compare
Based on the high urgency of this PR, the following reviewers are being gently reminded to review this PR: @zackkrida Excluding weekend1 days, this PR was updated 2 day(s) ago. PRs labelled with high urgency are expected to be reviewed within 2 weekday(s)2. @obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings. Footnotes |
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.
Works as expected. I don't want to block it for precautionary E2E tests, those can be added separately.
Closing this PR because we have decided that keeping the |
Fixes
Fixes #1894 by @obulat
Description
This PR removes the numeric
size
prop fromVIcon
component. This is because there are too many sizes in the app to make it useful, especially since we have to add all the dynamically generated size classes (likew-${size} h-$size
) to tailwind's safelist.Testing Instructions
You can view the buttons in the Storybook.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin