Skip to content

Commit 1aab382

Browse files
committed
feat: add UnoCSS snap usage
1 parent 4d40739 commit 1aab382

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/utils/icons.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { getTransformedId } from '../store'
55
import { getSvgSymbol } from './pack'
66
import {
77
API_ENTRY,
8-
bufferToString,
98
ClearSvg,
10-
getSvg,
119
SvgToAstro,
1210
SvgToDataURL,
1311
SvgToJSX,
@@ -17,6 +15,8 @@ import {
1715
SvgToSvelte,
1816
SvgToTSX,
1917
SvgToVue,
18+
bufferToString,
19+
getSvg,
2020
toComponentName,
2121
} from './svg'
2222
import { svgToPngDataUrl } from './svgToPng'
@@ -68,6 +68,8 @@ export const SnippetMap: Record<string, Record<string, Snippet>> = {
6868
'astro': { name: 'Astro', lang: 'astro', prettierParser: 'typescript' },
6969
'react-native': { name: 'React Native', lang: 'tsx', prettierParser: 'typescript' },
7070
'unplugin': { name: 'Unplugin Icons', lang: 'tsx', prettierParser: 'typescript' },
71+
'unocss': { name: 'UnoCSS', lang: 'html', prettierParser: 'html' },
72+
'unocss-attributify': { name: 'UnoCSS', tag: 'attributify', lang: 'html', prettierParser: 'html' },
7173
},
7274
Links: {
7375
url: { name: 'URL', lang: 'html', prettierParser: 'html' },
@@ -128,6 +130,10 @@ export async function getIconSnippet(
128130
return SvgToReactNative(await getSvg(collections, icon, undefined, color), toComponentName(icon), snippet)
129131
case 'unplugin':
130132
return `import ${toComponentName(icon)} from '~icons/${icon.split(':')[0]}/${icon.split(':')[1]}'`
133+
case 'unocss':
134+
return `<div class="i-${icon}" />`
135+
case 'unocss-attributify':
136+
return `<div i-${icon} />`
131137
}
132138
}
133139

0 commit comments

Comments
 (0)