-
-
Notifications
You must be signed in to change notification settings - Fork 779
/
align.ts
25 lines (22 loc) · 865 Bytes
/
align.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
import type { Rule } from '@unocss/core'
import { globalKeywords } from '../_utils/mappings'
const verticalAlignAlias: Record<string, string> = {
'mid': 'middle',
'base': 'baseline',
'btm': 'bottom',
'baseline': 'baseline',
'top': 'top',
'start': 'top',
'middle': 'middle',
'bottom': 'bottom',
'end': 'bottom',
'text-top': 'text-top',
'text-bottom': 'text-bottom',
'sub': 'sub',
'super': 'super',
...Object.fromEntries(globalKeywords.map(x => [x, x])),
}
export const verticalAligns: Rule[] = [
[/^(?:vertical|align|v)-([-\w]+)$/, ([, v]) => ({ 'vertical-align': verticalAlignAlias[v] }), { autocomplete: `(vertical|align|v)-(${Object.keys(verticalAlignAlias).join('|')})` }],
]
export const textAligns: Rule[] = ['center', 'left', 'right', 'justify', 'start', 'end', ...globalKeywords].map(v => [`text-${v}`, { 'text-align': v }])