Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

chore(svelte): Migrate all icons to Lucide/custom icons#63246

Merged
fkling merged 6 commits into
mainfrom
fkling/srch-467-move-to-icon2
Jun 13, 2024
Merged

chore(svelte): Migrate all icons to Lucide/custom icons#63246
fkling merged 6 commits into
mainfrom
fkling/srch-467-move-to-icon2

Conversation

@fkling

@fkling fkling commented Jun 13, 2024

Copy link
Copy Markdown
Contributor

Closes srch-467

tl;dr: This commit switches all remaining mdi icons to lucide.

This commit does a couple of things to make the migration to lucide icons and to the Icon2 (now Icon again) component complete:

  • Use lucide icons instead of mdi icons
  • Turn custom icons back to SVG files and use unplugin-icons custom collections support to reference them
  • Rename Icon component to SVGIcon. We still need it for integrating with shared web app code.
  • Rename Icon2 component to Icon.
  • Update to svelte@4.2.18 to bring in a fix for <svelte:component which is used by (now) Icon.

I put our generic icons in assets/icons/ and the specific symbol icons in assets/symbol/icons. They can be referenced via ISgName and ISymbolName. I'm open to changes to the location and the naming.

If the same icon wasn't available in lucide I tried to find one that made sense semantically. I expect we'll make another pass (in a separate PR) to adjust icons and tweak icon sizes/colors.

Test plan

pnpm build and svelte check

@cla-bot cla-bot Bot added the cla-signed label Jun 13, 2024
@fkling fkling force-pushed the fkling/srch-467-move-to-icon2 branch from 6b19b5e to 90fe8f8 Compare June 13, 2024 12:09
width: $icon-size;
height: $icon-size;
color: var(--icon-fill-color, var(--icon-color, inherit));
color: var(--icon-fill-color, var(--color, inherit));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This brings in line with how the original Icon component works. But we should probably rethink the API for colorization, I find it a bit confusing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, nice. I ran into this adding an icon in another PR I'm working on. Basically, --icon-color is set at the root, so inherit was never triggering. Solved it before I even got to ask about it 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was renamed from Icon2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was renamed from Icon.

<div class="header">
<Button variant="icon" on:click={toggle} aria-label="{expanded ? 'Hide' : 'Show'} file diff">
<Icon inline svgPath={expanded ? mdiChevronDown : mdiChevronRight} />
<Icon inline icon={expanded ? ILucideChevronDown : ILucideChevronRight} />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I feel like we should have a dedicated component for this. We use this quite often.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This file wasn't used anymore.

@fkling fkling marked this pull request as ready for review June 13, 2024 12:21
@fkling fkling requested a review from a team June 13, 2024 12:21

@camdencheek camdencheek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Woot! Thanks for cleaning this up!

"//:node_modules/@codemirror/search",
"//:node_modules/@codemirror/state",
"//:node_modules/@codemirror/view",
"//:node_modules/@mdi/js",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚀

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll have to re-add it for the context specific suggestions 🤷‍♂️


export let title: string
export let svgIconPath: string = ''
export let icon: ComponentProps<Icon>['icon']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, that's a much nicer type name than what I came up with when I attempted this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Q: why not use the exported IconComponent type from Icon?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought it makes to use this type in Svelte components where the Icon component is actually used, and use the dedicated type in TS files where we just define other types.

<Icon svgPath={icons[severity]} --icon-size="16px" --color={isError ? 'var(--danger)' : 'var(--text-title)'} />
<Icon
icon={icons[severity]}
aria-label={severity}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for auditing the aria properties while you're at it!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I could have done more but I didn't want to stuff too much into a single PR

import type { RepositoryGitRevAuthor } from './RepositoryRevPicker.gql'

export let iconPath: string
export let icon: ComponentProps<Icon>['icon']|undefined = undefined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similarly, why not use IconComponent?

@fkling fkling merged commit 81e5d69 into main Jun 13, 2024
@fkling fkling deleted the fkling/srch-467-move-to-icon2 branch June 13, 2024 16:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants