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

WB-1611: Add support to custom paths/SVGs with PhosphorIcon #2117

Merged
merged 8 commits into from
Nov 27, 2023

Conversation

jandrade
Copy link
Member

Summary:

  • Removed the limitation of only using certain icon weights per size. Now we can
    use any icon weight with any size. Reworded the documentation to still recommend
    (but not enforce) those rules.

  • Added support for custom SVG imports. This is useful for icons that are not
    available in the PhosphorIcon library. This change was done by allowing more SVG
    paths in TypeScript. The PhosphorIcon component now accepts any SVG import as
    a prop.

Issue: https://khanacademy.atlassian.net/browse/WB-1611

Test plan:

Verify that the "Custom icons" story displays all the custom icons correctly.

?path=/docs/icon-phosphoricon--docs#custom-icons

@jandrade jandrade self-assigned this Nov 15, 2023
Copy link

changeset-bot bot commented Nov 15, 2023

🦋 Changeset detected

Latest commit: 2e33cfc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-icon Major
@khanacademy/wonder-blocks-accordion Patch
@khanacademy/wonder-blocks-birthday-picker Patch
@khanacademy/wonder-blocks-button Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-form Patch
@khanacademy/wonder-blocks-icon-button Patch
@khanacademy/wonder-blocks-link Patch
@khanacademy/wonder-blocks-search-field Patch
@khanacademy/wonder-blocks-switch Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-pill Patch
@khanacademy/wonder-blocks-tooltip Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot khan-actions-bot requested a review from a team November 15, 2023 22:32
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Nov 15, 2023

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/dirty-eyes-rhyme.md, .changeset/fifty-cherries-draw.md, types/assets.d.ts, __docs__/wonder-blocks-icon/phosphor-icon.argtypes.ts, __docs__/wonder-blocks-icon/phosphor-icon.stories.tsx, __docs__/wonder-blocks-icon/icons/article.svg, __docs__/wonder-blocks-icon/icons/course.svg, __docs__/wonder-blocks-icon/icons/crown.svg, __docs__/wonder-blocks-icon/icons/mastery-course-bold.svg, __docs__/wonder-blocks-icon/icons/mastery-course.svg, packages/wonder-blocks-icon/src/index.ts, packages/wonder-blocks-icon/src/types.ts, packages/wonder-blocks-banner/src/components/banner.tsx, packages/wonder-blocks-icon/src/components/phosphor-icon.tsx, packages/wonder-blocks-icon/src/components/__tests__/custom-icon-mock.svg, packages/wonder-blocks-icon/src/components/__tests__/phosphor-icon.test.tsx, packages/wonder-blocks-icon/src/components/__tests__/phosphor-icon.typestest.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

github-actions bot commented Nov 15, 2023

Size Change: +283 B (0%)

Total Size: 92.9 kB

Filename Size Change
packages/wonder-blocks-accordion/dist/es/index.js 3.67 kB +139 B (+4%)
packages/wonder-blocks-button/dist/es/index.js 4.27 kB +13 B (0%)
packages/wonder-blocks-clickable/dist/es/index.js 3.24 kB +9 B (0%)
packages/wonder-blocks-icon/dist/es/index.js 3.17 kB +121 B (+4%)
packages/wonder-blocks-theming/dist/es/index.js 1.21 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.72 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 1.13 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-color/dist/es/index.js 1.15 kB
packages/wonder-blocks-core/dist/es/index.js 3.67 kB
packages/wonder-blocks-data/dist/es/index.js 6.33 kB
packages/wonder-blocks-dropdown/dist/es/index.js 12 kB
packages/wonder-blocks-form/dist/es/index.js 5.34 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.54 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.06 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.88 kB
packages/wonder-blocks-link/dist/es/index.js 2.54 kB
packages/wonder-blocks-modal/dist/es/index.js 5.04 kB
packages/wonder-blocks-pill/dist/es/index.js 1.03 kB
packages/wonder-blocks-popover/dist/es/index.js 4.33 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.51 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.55 kB
packages/wonder-blocks-spacing/dist/es/index.js 158 B
packages/wonder-blocks-switch/dist/es/index.js 2.06 kB
packages/wonder-blocks-testing/dist/es/index.js 3.94 kB
packages/wonder-blocks-timing/dist/es/index.js 1.78 kB
packages/wonder-blocks-toolbar/dist/es/index.js 862 B
packages/wonder-blocks-tooltip/dist/es/index.js 5.05 kB
packages/wonder-blocks-typography/dist/es/index.js 1.49 kB

compressed-size-action

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Merging #2117 (2e33cfc) into main (db2b87c) will decrease coverage by 0.04%.
Report is 8 commits behind head on main.
The diff coverage is 95.34%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2117      +/-   ##
==========================================
- Coverage   97.09%   97.06%   -0.04%     
==========================================
  Files         243      243              
  Lines       28205    28233      +28     
  Branches     2463     2422      -41     
==========================================
+ Hits        27386    27404      +18     
- Misses        819      829      +10     
Files Coverage Δ
...ges/wonder-blocks-banner/src/components/banner.tsx 100.00% <100.00%> (ø)
...onder-blocks-icon/src/components/phosphor-icon.tsx 98.62% <95.12%> (-1.38%) ⬇️

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db2b87c...2e33cfc. Read the comment docs.

Copy link
Contributor

github-actions bot commented Nov 15, 2023

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-umycqcuufe.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 322
Tests with visual changes 1
Total stories 394
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 322

Copy link
Contributor

github-actions bot commented Nov 15, 2023

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (c9772d6) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2117"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2117

Copy link
Contributor

@nishasy nishasy left a comment

Choose a reason for hiding this comment

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

I left a couple small suggestions, but LGTM!

__docs__/wonder-blocks-icon/phosphor-icon.stories.tsx Outdated Show resolved Hide resolved
*/
icon: PhosphorIconMedium;
icon: PhosphorIconAsset | string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Can you update the argtypes to reflect this?

I also think it might be nice to have a story demonstrating how to use a PhosphorIconAsset vs string. I see you have a string example in the WithColor story, but I think it might be helpful to have something more explicit somewhere. And maybe you can also mention if one approach is preferred over the other if that's the case?

Copy link
Member Author

@jandrade jandrade Nov 16, 2023

Choose a reason for hiding this comment

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

The string case is covered in the CustomStyles story. I'll update the args table to be more explicit about that.

Copy link
Member

@somewhatabstract somewhatabstract left a comment

Choose a reason for hiding this comment

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

LGTM

My review uses Conventional Comments to add context and set expectations for the comments I am leaving.

*/
// export const CustomIcon: StoryComponentType = () => {
Copy link
Member

Choose a reason for hiding this comment

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

praise: Thanks for tidying up this.

@jandrade jandrade merged commit 96f675d into main Nov 27, 2023
12 of 13 checks passed
@jandrade jandrade deleted the phosphor-custom branch November 27, 2023 16:01
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.

4 participants