forked from elk-zone/elk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unocss.config.ts
151 lines (141 loc) · 5.1 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
151
import type { Variant } from 'unocss'
import process from 'node:process'
import { variantParentMatcher } from '@unocss/preset-mini/utils'
import {
defineConfig,
presetAttributify,
presetIcons,
presetTypography,
presetUno,
presetWebFonts,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
export default defineConfig({
shortcuts: [
{
'border-base': 'border-$c-border',
'border-dark': 'border-$c-border-dark',
'border-strong': 'border-$c-text-base',
'border-bg-base': 'border-$c-bg-base',
'border-primary-light': 'border-$c-primary-light',
// background
'bg-base': 'bg-$c-bg-base',
'bg-border': 'bg-$c-border',
'bg-active': 'bg-$c-bg-active',
'bg-secondary': 'bg-$c-text-secondary',
'bg-secondary-light': 'bg-$c-text-secondary-light',
'bg-primary-light': 'bg-$c-primary-light',
'bg-primary-fade': 'bg-$c-primary-fade',
'bg-card': 'bg-$c-bg-card',
'bg-code': 'bg-$c-bg-code',
'bg-dm': 'bg-$c-bg-dm',
// text colors
'text-base': 'text-$c-text-base',
'text-code': 'text-$c-text-code',
'text-inverted': 'text-$c-bg-base',
'text-secondary': 'text-$c-text-secondary',
'text-secondary-light': 'text-$c-text-secondary-light',
// buttons
'btn-base': 'cursor-pointer disabled:pointer-events-none disabled:bg-$c-bg-btn-disabled disabled:text-$c-text-btn-disabled',
'btn-solid': 'btn-base px-4 py-2 rounded text-inverted bg-$c-primary hover:bg-$c-primary-active',
'btn-outline': 'btn-base px-4 py-2 rounded text-$c-primary border border-$c-primary hover:bg-$c-primary hover:text-inverted',
'btn-text': 'btn-base px-4 py-2 text-$c-primary hover:text-$c-primary-active',
'btn-action-icon': 'btn-base hover:bg-active rounded-full h9 w9 flex items-center justify-center disabled:bg-transparent disabled:text-$c-text-secondary',
'btn-danger': 'btn-base px-4 py-2 rounded text-white bg-$c-danger hover:bg-$c-danger-active',
// input
'input-base-focus': 'focus:outline-none focus:border-$c-primary',
'input-base-disabled': 'disabled:pointer-events-none disabled:bg-gray-500/5 disabled:text-gray-500/50',
'input-base': 'p2 rounded w-full bg-transparent border border-dark input-base-focus input-base-disabled',
'input-error': 'border-$c-error focus:(outline-offset-0 outline-$c-error outline-1px)',
'select-settings': 'p3 border border-base rounded w-full block bg-base',
// link
'text-link-rounded': 'focus:outline-none focus:ring-(2 primary inset) hover:bg-active rounded md:rounded-full px2 mx--2',
// utils
'flex-center': 'items-center justify-center',
'flex-v-center': 'items-center',
'flex-h-center': 'justify-center',
'bg-hover-overflow': 'relative z-0 transition-colors duration-250 after-content-empty after:(absolute inset--4px bg-transparent rounded-full z--1 transition-colors duration-250) hover:after:(bg-active)',
'timeline-title-style': 'text-primary text-lg font-bold',
},
[/^elk-group-hover[:-]([a-z0-9/-]+)$/, ([,r]) => `media-mouse-group-hover-${r} group-active-${r}`],
],
presets: [
presetUno({
attributifyPseudo: true,
}),
presetAttributify(),
presetIcons({
scale: 1.2,
extraProperties: {
'color': 'inherit',
// Avoid crushing of icons in crowded situations
'min-width': '1.2em',
},
}),
presetTypography(),
presetWebFonts({
provider: 'none',
fonts: {
script: 'Homemade Apple',
},
}),
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
],
theme: {
colors: {
primary: {
DEFAULT: 'var(--c-primary)',
active: 'var(--c-primary-active)',
},
danger: {
DEFAULT: 'var(--c-danger)',
active: 'var(--c-danger-active)',
},
},
},
variants: [
...(process.env.TAURI_PLATFORM
? <Variant<any>[]>[(matcher) => {
if (!matcher.startsWith('native:'))
return
return {
matcher: matcher.slice(7),
layer: 'native',
}
}]
: []),
...(process.env.TAURI_PLATFORM !== 'macos'
? <Variant<any>[]>[
(matcher) => {
if (!matcher.startsWith('native-mac:'))
return
return {
matcher: matcher.slice(11),
layer: 'native-mac',
}
},
]
: []
),
variantParentMatcher('fullscreen', '@media (display-mode: fullscreen)'),
variantParentMatcher('coarse-pointer', '@media (pointer: coarse)'),
],
rules: [
// scrollbar-hide
[/^scrollbar-hide$/, (_, { constructCSS }) => {
let res = constructCSS({ 'scrollbar-width': 'none' })
res += `\n${res.replace('{scrollbar-width:none;}', '::-webkit-scrollbar{display: none;}')}`
return res
}],
[/^h-100dvh$/, (_, { constructCSS }) => {
let res = constructCSS({ height: '100vh' })
res += `\n${res.replace('{height:100vh;}', '{height:100vh;height:100dvh;}')}`
return res
}],
['box-shadow-outline', { 'box-shadow': '0 0 0 1px var(--c-primary)' }],
],
})