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: v5 icons #2647

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft

feat: v5 icons #2647

wants to merge 53 commits into from

Conversation

denkristoffer
Copy link
Collaborator

@denkristoffer denkristoffer commented Jan 10, 2024

Purpose of PR

Forma 36 v5 icons alpha.

Storybook here: https://5fd1dda724cc620021ace8c5-xtuzuwaspq.chromatic.com/?path=/story/components-icons--overview

How to review

Most of the changed files are deletions of the old icons. Actual changes are the following files:

Click to see the list

What's new

  • Icons are based on Phosphor icons
  • Three icon sizes:
    • Tiny: 14px
    • Small: 16px
    • Medium: 20px
  • Variants are gone, instead icons take a new color prop where you can use our tokens.
  • The trimmed prop is gone too!
  • Icons take an isActive prop that renders an active state. This state has a filled look, entirely different from the default icon.

Approach

Generation & utils

This is a full implementation of the proposal from #2637. It adds a few icon utility functions we can use going forward.

generateIconComponent is basically our existing generateIcon function, it returns a Box component with an SVG tag.

generateComponentWithVariants makes it easier to create a component that returns different sub-components based on which variant you pass the original component. This let's us return one type of icon when the isActive prop is true an another type of icon when it's false. This function can be extended in the future if we need to support other variants.

wrapPhosphorIcon is a function that takes an icon imported from @phosphor-icons/react, wraps it in our own Icon component, and makes sure to pass the necessary props to the Phosphor icon when we want to override size or colour.

generateForma36Icon is the last level abstraction needed. It takes an icon imported from @phosphor-icons/react and uses wrapPhosphorIcon and generateComponentWithVariants to create a fully-fledged icon component that behaves as our own icons do.

Package compiling/build

Unless changed before we merge this work, changes were made for the icon and icons packages and documented here 0b047d5#diff-40f60e1037245d7b8a98a7325d53890a717da9979adeb54a61a795c4ba07f9c9

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link

github-actions bot commented Jan 11, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
CommonJS 467.53 KB (+258.05% 🔺) 9.4 s (+258.05% 🔺) 115 ms (+103.02% 🔺) 9.5 s
Module 463.82 KB (+263.86% 🔺) 9.3 s (+263.86% 🔺) 138 ms (+188.85% 🔺) 9.5 s

* fix: pass testId prop as data-test-id to element

* chore: bump icons-alpha version

* chore: bump icons alpha version
* refactor: properly pass down the props from Icon to Phosphor

* chore: bump icon and icons package version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants