Skip to content

Commit 493bcba

Browse files
authored
feat(cli): add support for phosphor icons (#1575)
1 parent 7505621 commit 493bcba

File tree

6 files changed

+123
-39
lines changed

6 files changed

+123
-39
lines changed

apps/v4/public/r/icons/index.json

Lines changed: 75 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,186 +2,223 @@
22
"AlertCircle": {
33
"lucide": "AlertCircle",
44
"radix": "ExclamationTriangleIcon",
5-
"tabler": "IconExclamationCircle"
5+
"tabler": "IconExclamationCircle",
6+
"phosphor": "PhWarningCircle"
67
},
78
"ArrowLeft": {
89
"lucide": "ArrowLeft",
910
"radix": "ArrowLeftIcon",
10-
"tabler": "IconArrowLeft"
11+
"tabler": "IconArrowLeft",
12+
"phosphor": "PhArrowLeft"
1113
},
1214
"ArrowRight": {
1315
"lucide": "ArrowRight",
1416
"radix": "ArrowRightIcon",
15-
"tabler": "IconArrowRight"
17+
"tabler": "IconArrowRight",
18+
"phosphor": "PhArrowRight"
1619
},
1720
"ArrowUpDown": {
1821
"lucide": "ArrowUpDown",
1922
"radix": "CaretSortIcon",
20-
"tabler": "IconArrowsSort"
23+
"tabler": "IconArrowsSort",
24+
"phosphor": "PhArrowsVertical"
2125
},
2226
"BellRing": {
2327
"lucide": "BellRing",
2428
"radix": "BellIcon",
25-
"tabler": "IconBellRinging"
29+
"tabler": "IconBellRinging",
30+
"phosphor": "PhBellRinging"
2631
},
2732
"Bold": {
2833
"lucide": "Bold",
2934
"radix": "FontBoldIcon",
30-
"tabler": "IconBold"
35+
"tabler": "IconBold",
36+
"phosphor": "PhTextB"
3137
},
3238
"Calculator": {
3339
"lucide": "Calculator",
3440
"radix": "ComponentPlaceholderIcon",
35-
"tabler": "IconCalculator"
41+
"tabler": "IconCalculator",
42+
"phosphor": "PhCalculator"
3643
},
3744
"Calendar": {
3845
"lucide": "Calendar",
3946
"radix": "CalendarIcon",
40-
"tabler": "IconCalendar"
47+
"tabler": "IconCalendar",
48+
"phosphor": "PhCalendarBlank"
4149
},
4250
"Check": {
4351
"lucide": "Check",
4452
"radix": "CheckIcon",
45-
"tabler": "IconCheck"
53+
"tabler": "IconCheck",
54+
"phosphor": "PhCheck"
4655
},
4756
"ChevronDown": {
4857
"lucide": "ChevronDown",
4958
"radix": "ChevronDownIcon",
50-
"tabler": "IconChevronDown"
59+
"tabler": "IconChevronDown",
60+
"phosphor": "PhCaretDown"
5161
},
5262
"ChevronLeft": {
5363
"lucide": "ChevronLeft",
5464
"radix": "ChevronLeftIcon",
55-
"tabler": "IconChevronLeft"
65+
"tabler": "IconChevronLeft",
66+
"phosphor": "PhCaretLeft"
5667
},
5768
"ChevronRight": {
5869
"lucide": "ChevronRight",
5970
"radix": "ChevronRightIcon",
60-
"tabler": "IconChevronRight"
71+
"tabler": "IconChevronRight",
72+
"phosphor": "PhCaretRight"
6173
},
6274
"ChevronUp": {
6375
"lucide": "ChevronUp",
6476
"radix": "ChevronUpIcon",
65-
"tabler": "IconChevronUp"
77+
"tabler": "IconChevronUp",
78+
"phosphor": "PhCaretUp"
6679
},
6780
"ChevronsUpDown": {
6881
"lucide": "ChevronsUpDown",
6982
"radix": "CaretSortIcon",
70-
"tabler": "IconSelector"
83+
"tabler": "IconSelector",
84+
"phosphor": "PhCaretUpDown"
7185
},
7286
"Circle": {
7387
"lucide": "Circle",
7488
"radix": "DotFilledIcon",
75-
"tabler": "IconCircle"
89+
"tabler": "IconCircle",
90+
"phosphor": "PhCircle"
7691
},
7792
"Copy": {
7893
"lucide": "Copy",
7994
"radix": "CopyIcon",
80-
"tabler": "IconCopy"
95+
"tabler": "IconCopy",
96+
"phosphor": "PhCopy"
8197
},
8298
"CreditCard": {
8399
"lucide": "CreditCard",
84100
"radix": "ComponentPlaceholderIcon",
85-
"tabler": "IconCreditCard"
101+
"tabler": "IconCreditCard",
102+
"phosphor": "PhCreditCard"
86103
},
87104
"GripVertical": {
88105
"lucide": "GripVertical",
89106
"radix": "DragHandleDots2Icon",
90-
"tabler": "IconGripVertical"
107+
"tabler": "IconGripVertical",
108+
"phosphor": "PhDotsSixVertical"
91109
},
92110
"Italic": {
93111
"lucide": "Italic",
94112
"radix": "FontItalicIcon",
95-
"tabler": "IconItalic"
113+
"tabler": "IconItalic",
114+
"phosphor": "PhTextItalic"
96115
},
97116
"Loader2": {
98117
"lucide": "Loader2",
99118
"radix": "ReloadIcon",
100-
"tabler": "IconLoader2"
119+
"tabler": "IconLoader2",
120+
"phosphor": "PhCircleNotch"
101121
},
102122
"Mail": {
103123
"lucide": "Mail",
104124
"radix": "EnvelopeClosedIcon",
105-
"tabler": "IconMail"
125+
"tabler": "IconMail",
126+
"phosphor": "PhEnvelopeSimple"
106127
},
107128
"MailOpen": {
108129
"lucide": "MailOpen",
109130
"radix": "EnvelopeOpenIcon",
110-
"tabler": "IconMailOpened"
131+
"tabler": "IconMailOpened",
132+
"phosphor": "PhEnvelopeSimpleOpen"
111133
},
112134
"Minus": {
113135
"lucide": "Minus",
114136
"radix": "MinusIcon",
115-
"tabler": "IconMinus"
137+
"tabler": "IconMinus",
138+
"phosphor": "PhMinus"
116139
},
117140
"Moon": {
118141
"lucide": "Moon",
119142
"radix": "MoonIcon",
120-
"tabler": "IconMoon"
143+
"tabler": "IconMoon",
144+
"phosphor": "PhMoon"
121145
},
122146
"MoreHorizontal": {
123147
"lucide": "MoreHorizontal",
124148
"radix": "DotsHorizontalIcon",
125-
"tabler": "IconDots"
149+
"tabler": "IconDots",
150+
"phosphor": "PhDotsThree"
126151
},
127152
"PanelLeft": {
128153
"lucide": "PanelLeft",
129154
"radix": "ViewVerticalIcon",
130-
"tabler": "IconLayoutSidebar"
155+
"tabler": "IconLayoutSidebar",
156+
"phosphor": "PhSidebarSimple"
131157
},
132158
"Plus": {
133159
"lucide": "Plus",
134160
"radix": "PlusIcon",
135-
"tabler": "IconPlus"
161+
"tabler": "IconPlus",
162+
"phosphor": "PhPlus"
136163
},
137164
"Search": {
138165
"lucide": "Search",
139166
"radix": "MagnifyingGlassIcon",
140-
"tabler": "IconSearch"
167+
"tabler": "IconSearch",
168+
"phosphor": "PhMagnifyingGlass"
141169
},
142170
"Send": {
143171
"lucide": "Send",
144172
"radix": "PaperPlaneIcon",
145-
"tabler": "IconSend"
173+
"tabler": "IconSend",
174+
"phosphor": "PhPaperPlaneTilt"
146175
},
147176
"Settings": {
148177
"lucide": "Settings",
149178
"radix": "GearIcon",
150-
"tabler": "IconSettings"
179+
"tabler": "IconSettings",
180+
"phosphor": "PhGear"
151181
},
152182
"Slash": {
153183
"lucide": "Slash",
154184
"radix": "SlashIcon",
155-
"tabler": "IconSlash"
185+
"tabler": "IconSlash",
186+
"phosphor": "PhCaretRight"
156187
},
157188
"Smile": {
158189
"lucide": "Smile",
159190
"radix": "FaceIcon",
160-
"tabler": "IconMoodSmile"
191+
"tabler": "IconMoodSmile",
192+
"phosphor": "PhSmiley"
161193
},
162194
"Sun": {
163195
"lucide": "Sun",
164196
"radix": "SunIcon",
165-
"tabler": "IconSun"
197+
"tabler": "IconSun",
198+
"phosphor": "PhSun"
166199
},
167200
"Terminal": {
168201
"lucide": "Terminal",
169202
"radix": "RocketIcon",
170-
"tabler": "IconTerminal"
203+
"tabler": "IconTerminal",
204+
"phosphor": "PhTerminal"
171205
},
172206
"Underline": {
173207
"lucide": "Underline",
174208
"radix": "UnderlineIcon",
175-
"tabler": "IconUnderline"
209+
"tabler": "IconUnderline",
210+
"phosphor": "PhTextUnderline"
176211
},
177212
"User": {
178213
"lucide": "User",
179214
"radix": "PersonIcon",
180-
"tabler": "IconUser"
215+
"tabler": "IconUser",
216+
"phosphor": "PhUser"
181217
},
182218
"X": {
183219
"lucide": "X",
184220
"radix": "Cross2Icon",
185-
"tabler": "IconX"
221+
"tabler": "IconX",
222+
"phosphor": "PhX"
186223
}
187-
}
224+
}

packages/cli/src/utils/icon-libraries.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ export const ICON_LIBRARIES = {
1414
package: '@tabler/icons-vue',
1515
import: '@tabler/icons-vue',
1616
},
17+
phosphor: {
18+
name: '@phosphor-icons/vue',
19+
package: '@phosphor-icons/vue',
20+
import: '@phosphor-icons/vue',
21+
},
1722
}

packages/cli/src/utils/transformers/transform-icons.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import { ICON_LIBRARIES } from '@/src/utils/icon-libraries'
55
// Lucide is the default icon library in the registry.
66
const SOURCE_LIBRARY = 'lucide'
77

8+
// Precompute the set of known icon library import sources to avoid hardcoding lists.
9+
const ICON_LIBRARY_IMPORTS = new Set(
10+
Object.values(ICON_LIBRARIES)
11+
.map(l => l.import)
12+
.filter(Boolean),
13+
)
14+
815
export function transformIcons(opts: TransformOpts, registryIcons: Record<string, Record<string, string>>): CodemodPlugin {
916
return {
1017
type: 'codemod',
@@ -32,7 +39,7 @@ export function transformIcons(opts: TransformOpts, registryIcons: Record<string
3239
traverseScriptAST(scriptAST, {
3340

3441
visitImportDeclaration(path) {
35-
if (![ICON_LIBRARIES.tabler.import, ICON_LIBRARIES.radix.import, ICON_LIBRARIES.lucide.import].includes(`${path.node.source.value}`))
42+
if (!ICON_LIBRARY_IMPORTS.has(String(path.node.source.value)))
3643
return this.traverse(path)
3744

3845
for (const specifier of path.node.specifiers ?? []) {

packages/cli/test/commands/init.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ it.skip('init config-full', async () => {
3333
'lucide-vue-next',
3434
'@radix-icons/vue',
3535
'@tabler/icons-vue',
36+
'@phosphor-icons/vue',
3637
],
3738
registryDependencies: [],
3839
tailwind: {
@@ -102,6 +103,7 @@ it.skip('init config-full', async () => {
102103
'reka-ui',
103104
'@radix-icons/vue',
104105
'@tabler/icons-vue',
106+
'@phosphor-icons/vue',
105107
],
106108
{
107109
cwd: targetDir,

packages/cli/test/utils/__snapshots__/transform-icons.test.ts.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ import { Primitive } from "reka-ui";
2626
"
2727
`;
2828

29+
exports[`transformIcons > transforms phosphor icons 1`] = `
30+
"<script setup>
31+
import { PhCheck } from '@phosphor-icons/vue';
32+
import { Primitive } from "reka-ui";
33+
</script>
34+
35+
<template>
36+
<PhCheck />
37+
<Primitive />
38+
</template>
39+
"
40+
`;
41+
2942
exports[`transformIcons > transforms radix icons 1`] = `
3043
"<script setup>
3144
import { CheckIcon } from '@radix-icons/vue';

packages/cli/test/utils/transform-icons.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@ import { describe, expect, it } from 'vitest'
22
import { transform } from '../../src/utils/transformers'
33

44
describe('transformIcons', () => {
5+
it('transforms phosphor icons', async () => {
6+
const result = await transform({
7+
filename: 'app.vue',
8+
raw: `<script lang="ts" setup>
9+
import { Check } from 'lucide-vue-next'
10+
import { Primitive } from 'reka-ui'
11+
</script>
12+
13+
<template>
14+
<Check />
15+
<Primitive />
16+
</template>
17+
`,
18+
config: {
19+
iconLibrary: 'phosphor',
20+
},
21+
})
22+
expect(result).toMatchSnapshot()
23+
})
24+
525
it('transforms tabler icons', async () => {
626
const result = await transform({
727
filename: 'app.vue',

0 commit comments

Comments
 (0)