JustinVoitel / svelte-hero-icons

Heroicons for SvelteKit (Project based on heroicons)
MIT License
118 stars 7 forks source link

[RFC] Universal Icon Component #3

Closed JustinVoitel closed 3 years ago

JustinVoitel commented 3 years ago

The proposal is that instead of exporting every icon into its own svelte component (which can lead to import waterfalls), we export only one component and pass the information what icon source to import(dynamically):

<script>
import Icon from "svelte-hero-icons"
</script>

<Icon src="ArrowUp" solid>

The string we pass to the src attribute can be supported by generated types via SvelteComponentTyped

This could lead to a much smaller package with a better API.

Priorities

JustinVoitel commented 3 years ago

Update

Unfortunately I couldn't get a working API using dynamic imports, so now you have to import icons like this:

<script>
   import Icon, {X, ArrowUp} from "svelte-hero-icon"
</script>

<Icon src={X} solid />
<Icon src={ArrowUp} />

not the simplest API, but close IMO

JustinVoitel commented 3 years ago

2 2.0.0 released