-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
plugin.ts
37 lines (34 loc) · 952 Bytes
/
plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import plugin from 'tailwindcss/plugin';
import { getCSSRulesForIcons } from './clean';
import { getDynamicCSSRules } from './dynamic';
import type {
CleanIconifyPluginOptions,
DynamicIconifyPluginOptions,
} from './options';
/**
* Generate styles for dynamic selector: class="icon-[mdi-light--home]"
*/
export function addDynamicIconSelectors(options?: DynamicIconifyPluginOptions) {
const prefix = options?.prefix || 'icon';
return plugin(({ matchComponents }) => {
matchComponents({
[prefix]: (icon: string) => getDynamicCSSRules(icon, options),
});
});
}
/**
* Generate styles for preset list of icons
*/
export function addCleanIconSelectors(
icons: string[] | string,
options?: CleanIconifyPluginOptions
) {
const rules = getCSSRulesForIcons(icons, options);
return plugin(({ addUtilities }) => {
addUtilities(rules);
});
}
/**
* Export types
*/
export type { CleanIconifyPluginOptions, DynamicIconifyPluginOptions };