Skip to content

Commit 0b4a25b

Browse files
authored
fix: Replace use of unplugin-icons ~icon/ imports with @lucide/svelte package for default icons to remove Vite configuration. Fixes #618 (#625)
* fix: Replace use of unplugin-icons `~icon/` imports with `@lucide/svelte` package for default icons to remove Vite configuration. Fixes #618 * Improve discord/bluesky icon size * Move `@lucide/svelte` from `devDependencies` to `dependencies` * Update ApiDocs import
1 parent 0fd14bc commit 0b4a25b

30 files changed

+138
-112
lines changed

.changeset/stale-words-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte-ux': patch
3+
---
4+
5+
fix: Replace use of unplugin-icons `~icon/` imports with `@lucide/svelte` package for default icons to remove Vite configuration. Fixes #618

packages/svelte-ux/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@layerstack/svelte-table": "1.0.1-next.14",
6262
"@layerstack/tailwind": "2.0.0-next.17",
6363
"@layerstack/utils": "2.0.0-next.14",
64+
"@lucide/svelte": "^0.534.0",
6465
"d3-array": "^3.2.4",
6566
"d3-scale": "^4.0.2",
6667
"esm-env": "^1.2.2",

packages/svelte-ux/src/lib/components/ApiDocs.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
2-
import LucideGroup from '~icons/lucide/group';
3-
import LucideRadio from '~icons/lucide/radio';
2+
import LucideGroup from '@lucide/svelte/icons/group';
3+
import LucideRadio from '@lucide/svelte/icons/radio';
44
55
import Button from './Button.svelte';
66
import EmptyMessage from './EmptyMessage.svelte';

packages/svelte-ux/src/lib/components/Breadcrumb.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { cls } from '@layerstack/tailwind';
33
import { getComponentClasses } from './theme.js';
44
import { getSettings } from './settings.js';
5+
import Icon from './Icon.svelte';
56
67
export let items: TItem[] = [];
78
export let divider: string | undefined = undefined;
@@ -35,8 +36,7 @@
3536
{#if divider}
3637
<div class="divider opacity-25">{divider}</div>
3738
{:else}
38-
{@const Icon = icons.chevronRight}
39-
<Icon class="divider opacity-25" />
39+
<Icon data={icons.chevronRight} class="divider opacity-25" />
4040
{/if}
4141
</slot>
4242
{/if}

packages/svelte-ux/src/lib/components/Button.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,15 +476,15 @@
476476
<span in:slide={{ axis: 'x', duration: 200 }}>
477477
{#if typeof icon === 'function'}
478478
<!-- Component, such as unplugin-icons -->
479-
{@const Icon = icon}
480-
<Icon class={cls('pointer-events-none', settingsClasses.icon, classes.icon)} />
479+
<Icon data={icon} class={cls('pointer-events-none', settingsClasses.icon, classes.icon)} />
481480
{:else if typeof icon === 'string' || 'icon' in icon}
482481
<!-- font path/url/etc or font-awesome IconDefinition -->
483482
<Icon
484483
data={asIconData(icon)}
485484
class={cls('pointer-events-none', settingsClasses.icon, classes.icon)}
486485
/>
487486
{:else}
487+
<!-- Icon props -->
488488
<Icon class={cls('pointer-events-none', settingsClasses.icon, classes.icon)} {...icon} />
489489
{/if}
490490
</span>

packages/svelte-ux/src/lib/components/ErrorNotification.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import Button from './Button.svelte';
33
import Dialog from './Dialog.svelte';
4+
import Icon from './Icon.svelte';
45
import Notification from './Notification.svelte';
56
import { getSettings } from './settings.js';
67
import Toggle from './Toggle.svelte';
@@ -19,7 +20,7 @@
1920
<Toggle let:on={open} let:toggle>
2021
<Notification actionsPlacement="below" closeIcon on:close>
2122
<div slot="icon" class="self-start">
22-
<icons.alert class="text-danger" />
23+
<Icon data={icons.alert} class="text-danger" />
2324
</div>
2425
<div slot="title">{title}</div>
2526

packages/svelte-ux/src/lib/components/Field.svelte

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@
126126
<span class={cls('mr-3', rounded && !$$slots.prepend && 'ml-3')}>
127127
{#if typeof icon === 'function'}
128128
<!-- Component, such as unplugin-icons -->
129-
{@const Icon = icon}
130-
<Icon class="text-surface-content/50" />
129+
<Icon data={icon} class="text-surface-content/50" />
131130
{:else if typeof icon === 'string' || 'icon' in icon}
132131
<!-- font path/url/etc or font-awesome IconDefinition -->
133132
<Icon data={asIconData(icon)} class="text-surface-content/50" />
@@ -209,12 +208,11 @@
209208
<slot name="append" />
210209

211210
{#if error}
212-
<icons.info class="text-danger" />
211+
<Icon data={icons.info} class="text-danger" />
213212
{:else if iconRight}
214213
{#if typeof iconRight === 'function'}
215214
<!-- Component, such as unplugin-icons -->
216-
{@const Icon = iconRight}
217-
<Icon class="text-surface-content/50" />
215+
<Icon data={iconRight} class="text-surface-content/50" />
218216
{:else if typeof iconRight === 'string' || 'icon' in iconRight}
219217
<!-- font path/url/etc or font-awesome IconDefinition -->
220218
<Icon data={asIconData(iconRight)} class="text-surface-content/50" />

packages/svelte-ux/src/lib/components/Icon.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
<Icon
9191
class={cls(
9292
'Icon',
93-
'icon-container inline-block shrink-0 align-middle fill-current',
93+
// 'icon-container _inline-block shrink-0 _align-middle _fill-current',
94+
'size-[1.2em]', // default scale of unplugin-icons - https://github.com/unplugin/unplugin-icons?tab=readme-ov-file#options
9495
settingsClasses.root,
9596
classes.root,
9697
className

packages/svelte-ux/src/lib/components/ListItem.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,14 @@
8989
>
9090
{#if typeof icon === 'function'}
9191
<!-- Component, such as unplugin-icons -->
92-
{@const Icon = icon}
93-
<Icon class={cls(settingsClasses.icon, classes.icon)} />
92+
<Icon data={icon} class={cls(settingsClasses.icon, classes.icon)} />
9493
{:else if typeof icon === 'string' || 'icon' in icon}
9594
<Icon data={asIconData(icon)} class={cls(settingsClasses.icon, classes.icon)} />
9695
{/if}
9796
</Avatar>
9897
{:else if typeof icon === 'function'}
9998
<!-- Component, such as unplugin-icons -->
100-
{@const Icon = icon}
101-
<Icon class={cls(settingsClasses.icon, classes.icon)} />
99+
<Icon data={icon} class={cls(settingsClasses.icon, classes.icon)} />
102100
{:else if typeof icon === 'string' || 'icon' in icon}
103101
<Icon data={asIconData(icon)} class={cls(settingsClasses.icon, classes.icon)} />
104102
{/if}

packages/svelte-ux/src/lib/components/MenuButton.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
{#if menuIcon}
5555
{#if typeof menuIcon === 'function'}
5656
<!-- Component, such as unplugin-icons -->
57-
{@const Icon = menuIcon}
5857
<Icon
58+
data={menuIcon}
5959
class={cls(
6060
'opacity-50 transform transition-all -mr-2 duration-300',
6161
open && '-rotate-180',

0 commit comments

Comments
 (0)