-
Notifications
You must be signed in to change notification settings - Fork 24
/
unocss.config.ts
150 lines (147 loc) · 3.69 KB
/
unocss.config.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import path from 'path';
import {
defineConfig,
// presetAttributify,
presetIcons,
presetTypography,
presetUno,
presetWebFonts,
presetWind,
transformerDirectives,
transformerVariantGroup,
} from 'unocss';
import { getWindiBreakpoint } from './src/enums/breakpointEnum';
import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders';
export default defineConfig({
include: [
/src\/(.+\/)*.+\.(vue|html|jsx|tsx|ts|js|json)$/,
/public\/(.+\/)*.+\.html$/,
/index.html$/,
],
exclude: ['node_modules', '.git'],
shortcuts: [
[
'app-ease-spin',
'animate-name-spin-rotate animate-count-infinite animate-ease-[cubic-bezier(0.37,0.35,0.35,0.97)]',
],
[
'app-layout-header-anction-icon',
'cursor-pointer h-full px-2.5 flex justify-between items-center hover:bg-$hover-color',
],
[
'app-mtabs-anction-btn-wrapper',
'flex-1 border-l border-$app-border-color cursor-pointer transition-property-colors ease-in-out-300 flex-jc-ac text-$app-text-color',
],
['app-mtabs-anction-btn', 'op60 group-hover:op100 text-18px'],
],
theme: {
screen: getWindiBreakpoint,
fontFamily: {
segoe: ['Segoe UI', 'Roboto', 'Helvetica Neue', 'Arial', 'Noto Sans', 'sans-serif'],
},
outline: {
primary: ['2px solid var(--app-primary-color)', '0px'],
},
},
rules: [
[
/^flex((-(js|je|jc|jb|ja|jev|as|ae|ac|ab|ast|row|rowr|col|colr)){1,3})$/,
([, keyStr]) => {
return {
display: 'flex',
...Object.fromEntries(
keyStr
.split('-')
.slice(1)
.map((item) => {
return handleShortKeys(item);
})
),
};
},
],
[
/^ease-(?:(in|out|in-out)-)(\d+)$/,
([, timingFun, duration]) => {
return {
'transition-timing-function': `var(--app-bezier${
['in', 'out'].includes(timingFun) ? `-${timingFun}` : ''
})`,
'transition-duration': `${duration}ms`,
};
},
],
],
presets: [
presetUno(),
// presetAttributify({
// prefix: 'u:',
// prefixedOnly: false,
// }),
presetWind(),
presetIcons({
warn: true,
// mode: 'background-img',
collections: {
'my-svg': FileSystemIconLoader(path.resolve(process.cwd(), 'src/assets/icons')),
},
extraProperties: {
display: 'inline-block',
},
customizations: {
customize(props) {
props.width = '1em';
props.height = '1em';
return props;
},
},
}),
presetTypography(),
presetWebFonts({
fonts: {
'dm-sans': 'DM Sans',
'dm-serif': 'DM Serif Display',
},
}),
],
transformers: [transformerDirectives(), transformerVariantGroup()],
});
function handleShortKeys(key: string): string[] {
const J = 'justify-content';
const A = 'align-items';
const D = 'flex-direction';
switch (key) {
case 'js':
return [J, 'flex-start'];
case 'je':
return [J, 'flex-end'];
case 'jc':
return [J, 'center'];
case 'jb':
return [J, 'space-between'];
case 'ja':
return [J, 'space-around'];
case 'jev':
return [J, 'space-evenly'];
case 'as':
return [A, 'flex-start'];
case 'ae':
return [A, 'flex-end'];
case 'ac':
return [A, 'center'];
case 'ab':
return [A, 'baseline'];
case 'ast':
return [A, 'stretch'];
case 'row':
return [D, 'row'];
case 'rowr':
return [D, 'row-reverse'];
case 'col':
return [D, 'column'];
case 'colr':
return [D, 'column-reverse'];
default:
return [];
}
}