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

UI icon size #6736

Merged
merged 3 commits into from
May 16, 2019
Merged

UI icon size #6736

merged 3 commits into from
May 16, 2019

Conversation

meirish
Copy link
Contributor

@meirish meirish commented May 15, 2019

Adds a size property to the new Icon component so that we don't have to use the component's CSS classes for sizing.

Screen Shot 2019-05-15 at 8 24 27 AM

@meirish meirish requested review from a team May 15, 2019 13:26
@johncowen
Copy link

Hey 👋

Only had a quick glance at this, but my immediate thought was - how come you decided you wanted to move away from class? It kinda feels like class is the right tool for this? Maybe its just I don't understand the background.

Would be good to understand some of the reasoning behind this!

Thanks,

John

@meirish
Copy link
Contributor Author

meirish commented May 15, 2019

Hey @johncowen ! Yeah there's a bit of a story there :D

So Icon replaces an older component ICon, and there we allowed passing through an arbitrary number that would get passed to the SVG's height and width attributes in the template. Icon uses the SVGs from the structure-icons repo so we wanted a standard set of sizes and those got implemented via classes on the component, and the first pass was using those classes when we needed them. So in a way we went from one extreme with no restrictions on size, to another extreme where it was sized just via CSS classes, to somewhere in the middle where we restrict the allowed classes via a property.

The motivation here, moving from classes specific to the component all over the application to a property on the component, is really just one of encapsulation. The sizing classes are implementation details and it felt like having to use them for sizing all over the application was leaking those details. If the sizing classes are encapsulated in the component itself, they can be changed in one spot if needed at a later date. This encapsulation also keeps the interface / api surface of the component in JS, not a combination of JS and CSS which is a tidier boundary. If an application needs to do additional styling with it, there's still that option via CSS, but it's then an application concern, not a component one.

Copy link

@johncowen johncowen left a comment

Choose a reason for hiding this comment

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

Oki doki, just seems strange to me that I set sizes of things for everything else using a class.
Also, on this component if I want to change the size I use the size attribute, but if I want to change the color I use class=""?

Most importantly though it needs to feel right to you, so as long as you are happy with it, it's all good with me!

Code looks fine, I had a comment, but then went 'oh yeah, I see now!', but left the comment in just to see if I guessed right


storiesOf('Icon/', module)
.addParameters({ options: { showPanel: false } })
.addParameters({ options: { showPanel: true} })

Choose a reason for hiding this comment

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

Not sure if you left this in by accident (showPanel: true)? Ah, maybe you want the panel in now as you have a setting you can tweak.? Will leave this comment in just incase, but 99% sure this is good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is so that the knobs panel shows up when you click Icon in the sidebar, otherwise it's hidden. We usually hide it if we're not using the knobs decorator, but since I added it here, I flipped it to true.

Choose a reason for hiding this comment

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

Sweet gotcha 👍

@meirish meirish merged commit 033b547 into master May 16, 2019
@meirish meirish deleted the ui-icon-size branch May 16, 2019 19:49
catsby added a commit that referenced this pull request May 16, 2019
* master: (85 commits)
  UI icon - add size (#6736)
  Add Priority Queue library to sdk (#6664)
  Add spellcheck="false" to form fields (#6744)
  Maximum typo in Vault UI (#6743)
  docs: Fix Markdown formatting error in AWS Auth (#6745)
  changelog++
  Update OIDC Provider Setup docs (#6739)
  Update to use newer sdk
  Copy LogInput from audit package, add OptMarshaler interface  (#6735)
  docs: fixed typo (#6732)
  Fix typo
  changelog++
  Use Go modules in CircleCI (#6729)
  Fix recovery key backup path documentation
  Vendoring updated grpc
  Add link to R client on libraries list (#6722)
  UI ember engines (#6718)
  changelog++
  Update grpc and protos (#6725)
  changelog++
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants