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

Get rid of <sl-icon> #122

Merged
merged 2 commits into from
Feb 9, 2024
Merged

Get rid of <sl-icon> #122

merged 2 commits into from
Feb 9, 2024

Conversation

oyamauchi
Copy link
Member

Description

The SVG project icons can't be included via <img> because they
are colored using currentColor. They also can't be included via
Parcel's bundle-text named pipeline becase

The way we used <sl-icon>, it was fetching the svg file over the
network and dynamically inserting it into the DOM. This instead uses
another Parcel plugin to import an svg file as a React component at
build time. Getting it to work is kinda finicky. Ssee
parcel-bundler/parcel#7587, plus the workaround I ended up using in
the not-merged PR parcel-bundler/parcel#7711. The list of transformers
for jsx:*.{js,jsx} is copied from Parcel's default config for those
file types.

The icons are set to width 1em to allow them to be sized by the
font-size at the usage site, like <sl-icon>.

Test Plan

Look at the project icons in all contexts where they appear: project
multiselect, icon tab bar in pill mode, icon tab bar in dropdown mode.

Copy link

vercel bot commented Jan 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
embed-rewiringamerica-org ✅ Ready (Inspect) Visit Preview Feb 6, 2024 11:35pm

## Description

The SVG project icons can't be included via `<img>` because they
are colored using `currentColor`. They also can't be included via
Parcel's `bundle-text` named pipeline becase

The way we used `<sl-icon>`, it was fetching the svg file over the
network and dynamically inserting it into the DOM. This instead uses
another Parcel plugin to import an svg file as a React component at
build time. Getting it to work is kinda finicky. Ssee
parcel-bundler/parcel#7587, plus the workaround I ended up using in
the not-merged PR parcel-bundler/parcel#7711. The list of transformers
for `jsx:*.{js,jsx}` is copied from Parcel's default config for those
file types.

The icons are set to width `1em` to allow them to be sized by the
font-size at the usage site, like `<sl-icon>`.

## Test Plan

Look at the project icons in all contexts where they appear: project
multiselect, icon tab bar in pill mode, icon tab bar in dropdown mode.
@@ -9,7 +8,7 @@ import { Spinner } from './spinner';
export type Option<T extends string> = {
value: T;
label: string;
iconURL?: URL;
Copy link
Member

Choose a reason for hiding this comment

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

Would this be more idiomatic React as just Icon?: React.ReactElement? And then <Icon/> instead of {icon()}?

Definitely don't feel strongly about it, but I had to scan back and forth a couple of times to work out how getIcon was plumbed through into renderTag.

Copy link
Member

Choose a reason for hiding this comment

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

This comment was supposed to be on the added line not the removed line. Makes sense in side by side diff but confusing in the main PR view!

Copy link
Member

Choose a reason for hiding this comment

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

Is it right that this diff replaces the locales import helpers?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, those have actually been unused for a while and I forgot to remove them.

Copy link
Member

@RandomEtc RandomEtc left a comment

Choose a reason for hiding this comment

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

LGTM except for the question about the removal of the locales import, which I thought was happening in #126.

@oyamauchi oyamauchi merged commit 400c392 into main Feb 9, 2024
3 checks passed
@oyamauchi oyamauchi deleted the owen.sl-icon branch February 9, 2024 19:47
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