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

Add size prop to icon packages #8139

Closed
1 of 8 tasks
joshblack opened this issue Mar 22, 2021 · 5 comments
Closed
1 of 8 tasks

Add size prop to icon packages #8139

joshblack opened this issue Mar 22, 2021 · 5 comments
Labels
epic Special label used by ZenHub for epic functionality package: icons @carbon/icons package: icons-react @carbon/icons-react package: icons-vue @carbon/icons-vue package: pictograms @carbon/pictograms package: pictograms-react @carbon/pictograms-react type: enhancement 💡

Comments

@joshblack
Copy link
Contributor

joshblack commented Mar 22, 2021

We currently have ~1,250 icons in our icon packages. Since our system supports 4 sizes, this ends up with ~5,000 modules (1250 icons * 4 sizes each). Add in a default entry point for each icon and its size, and that becomes ~6250 files that get shipped in a package.

Historically, we've had to invest some time to fix infrastructure issues that have come from trying to satisfy packages that can grow to this size. In addition, it is easy for these packages to deopt and cause consumers to ship megabytes more code than they intend to when using this module.

Moving forward, we are moving from our "component per icon/size" strategy to a "icon with size prop" approach. While this could increase the size of individual icons that support multiple sizes, this would decrease the overall file size of each package and would allow better code re-use for icons that are downsized from 32x32 (which are the majority)

Packages impacted

  • @carbon/icons
  • @carbon/icons-react
  • @carbon/icons-angular
  • @carbon/icons-vue

Checklist

  • Add a new builder called react-next to the react builder and include it in icons-react
    • This builder should no longer emit icon components with the size in the name
    • It should instead emit components that support a size prop
      • If a component has a bespoke SVG at a specific size, the component should use that SVG when that size is specified
    • This builder should emit files at the top-level as CommonJS exports
      • Namespaced modules may follow the namespace folder path and then follow the above rule
  • Add support for passing through deprecation message with new setup
  • Figure out flow for module names that are awkwardly generated in React
  • Add a new builder called vanilla-next to the builders and include it in icons
    • It should follow the new icon rules specified above
  • Add a new builder called vue-next to the builders and include it in icons-vue
    • It should follow the new icon rules specified above
  • Update carbon-components-react icon usage to use this new size approach
    • Use this work item as an opportunity to write a codemod
  • Update existing builders to emit a deprecation notice that points users to new approach
@joshblack joshblack added type: enhancement 💡 package: icons @carbon/icons package: icons-react @carbon/icons-react package: icons-vue @carbon/icons-vue package: pictograms @carbon/pictograms package: pictograms-react @carbon/pictograms-react labels Mar 22, 2021
@joshblack joshblack added the epic Special label used by ZenHub for epic functionality label Mar 22, 2021
@metonym
Copy link
Collaborator

metonym commented Mar 30, 2021

Sounds like a great plan. Will the metadata.json file still be shipped?

@joshblack
Copy link
Contributor Author

Hey @metonym! 👋

Yes, definitely. We might end up doing a dedicated @carbon/icons-metadata package too to help with some of the generated size problems but we'll definitely makes sure this is available 👍

@metonym
Copy link
Collaborator

metonym commented Apr 1, 2021

Awesome – thank you Josh

@dkahlau
Copy link

dkahlau commented Jul 1, 2022

Will there ever be a vue-next implementation?

@joshblack
Copy link
Contributor Author

Hi @veganD! 👋 At the moment there isn't a plan to add support but it's definitely something that we want to do. Unfortunately, it came down to time and what the team is able to maintain with our focus on React and the styles. We're super open to contributions for this or working with folks who would like to add in support for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Special label used by ZenHub for epic functionality package: icons @carbon/icons package: icons-react @carbon/icons-react package: icons-vue @carbon/icons-vue package: pictograms @carbon/pictograms package: pictograms-react @carbon/pictograms-react type: enhancement 💡
Projects
Archived in project
Development

No branches or pull requests

3 participants