carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.85k stars 1.81k forks source link

[icons-react] Use a size prop, don’t export 4 bespoke sprites/components per icon #5170

Closed vpicone closed 3 years ago

vpicone commented 4 years ago

Looking to add copy + paste react code to the website icon library. We want avoid giving a hard-coded size (<Add32 />).

A generic <Add size='sm/md/lg/xl' /> component would make for a much better candidate for copy+paste. The current API makes it hard to know what sizes are available, users are more likely to have a failed import than a prop-type failure.

I think our initial implementation of this package was beholden to the idea that we’d come up with hand tuned, bespoke icon assets at each size. This isn’t scaleable and results in idiosyncrasies when components are used together. (Example + and -).

By simply reducing the width of the 32 px svg and scaling down, we'd be able to accomodate all 4 sizes with a single component.

joshblack commented 3 years ago

Tracking in: https://github.com/carbon-design-system/carbon/issues/8139