8000 feat: more rules · unocss/unocss@db071c9 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit db071c9

Browse files
committed
feat: more rules
1 parent a094ad0 commit db071c9

File tree

4 files changed

+76
-52
lines changed

4 files changed

+76
-52
lines changed

src/generator/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ export function createGenerator(userConfig: MiniwindUserConfig = {}) {
5151

5252
tokensArray.forEach((tokens) => {
5353
tokens.forEach((raw) => {
54+
if (matched.has(raw))
55+
return
56+
5457
// use caches if possible
5558
if (_cache.get(raw)) {
5659
const r = _cache.get(raw)

src/presets/default/rules/flex.ts

Lines changed: 15 additions & 0 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ import { MiniwindRule } from '../../../types'
22

33
export const flex: MiniwindRule[] = [
44
['flex', { display: 'flex' }],
5+
['inline-flex', { display: 'inline-flex' }],
56
['flex-col', { 'flex-direction': 'column' }],
7+
['flex-col-reverse', { 'flex-direction': 'column-reverse' }],
68
['flex-row', { 'flex-direction': 'row' }],
9+
['flex-row-reverse', { 'flex-direction': 'row-reverse' }],
10+
['flex-wrap', { 'flex-wrap': 'wrap' }],
11+
['flex-wrap-reverse', { 'flex-wrap': 'wrap-reverse' }],
12+
['flex-nowrap', { 'flex-wrap': 'nowrap' }],
13+
['flex-1', { flex: '1 1 0%' }],
14+
['flex-auto', { flex: '1 1 auto' }],
15+
['flex-initial', { flex: '0 1 auto' }],
16+
['flex-none', { flex: 'none' }],
17+
[/^flex-\[(.+)\]$/, ([, d]) => ({ flex: d })],
18+
['flex-grow', { 'flex-grow': 1 }],
19+
['flex-grow-0', { 'flex-grow': 0 }],
20+
['flex-shrink', { 'flex-shrink': 1 }],
21+
['flex-shrink-0', { 'flex-shrink': 0 }],
722
]

src/presets/default/rules/positions.ts

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { MiniwindCssEntries } from '../../..'
12
import { MiniwindRule } from '../../../types'
2-
import { h } from '../../../utils'
3+
import { directionMap, h } from '../../../utils'
34

45
export const positions: MiniwindRule[] = [
56
['relative', { position: 'relative' }],
@@ -8,76 +9,74 @@ export const positions: MiniwindRule[] = [
89
]
910

1011
export const justifies: MiniwindRule[] = [
11-
['justify-start', {
12-
'-webkit-box-pack': 'start',
13-
'-ms-flex-pack': 'start',
14-
'-webkit-justify-content': 'flex-start',
15-
'justify-content': 'flex-start',
16-
}],
17-
['justify-end', {
18-
'-webkit-box-pack': 'end',
19-
'-ms-flex-pack': 'end',
20-
'-webkit-justify-content': 'flex-end',
21-
'justify-content': 'flex-end',
22-
}],
23-
['justify-center', {
24-
'-webkit-box-pack': 'center',
25-
'-ms-flex-pack': 'center',
26-
'-webkit-justify-content': 'center',
27-
'justify-content': 'center',
28-
}],
29-
['justify-between', {
30-
'-webkit-box-pack': 'justify',
31-
'-ms-flex-pack': 'justify',
32-
'-webkit-justify-content': 'space-between',
33-
'justify-content': 'space-between',
34-
}],
35-
['justify-around', {
36-
'-ms-flex-pack': 'distribute',
37-
'-webkit-justify-content': 'space-around',
38-
'justify-content': 'space-around',
39-
}],
40-
['justify-evenly', {
41-
'-ms-flex-pack': 'space-evenly',
42-
'-webkit-justify-content': 'space-evenly',
43-
'justify-content': 'space-evenly',
44-
}],
12+
['justify-start', { 'justify-content': 'flex-start' }],
13+
['justify-end', { 'justify-content': 'flex-end' }],
14+
['justify-center', { 'justify-content': 'center' }],
15+
['justify-between', { 'justify-content': 'space-between' }],
16+
['justify-around', { 'justify-content': 'space-around' }],
17+
['justify-evenly', { 'justify-content': 'space-evenly' }],
4518
]
4619

47-
export const justifyItems: MiniwindRule[] = [
48-
// TODO: https://windicss.org/utilities/positioning.html#justify-items
49-
]
20+
const basicSet = ['auto', 'start', 'end', 'center', 'stretch']
5021

51-
export const justifySelfs: MiniwindRule[] = [
52-
// TODO: https://windicss.org/utilities/positioning.html#justify-items
53-
]
22+
export const justifyItems: MiniwindRule[] = basicSet
23+
.map(i => [`justify-items-${i}`, { 'justify-items': i }])
24+
25+
export const justifySelfs: MiniwindRule[] = basicSet
26+
.map(i => [`justify-self-${i}`, { 'justify-self': i }])
5427

5528
export const alignContents: MiniwindRule[] = [
56-
// TODO:
29+
['content-start', { 'align-content': 'flex-start' }],
30+
['content-end', { 'align-content': 'flex-end' }],
31+
['content-center', { 'align-content': 'center' }],
32+
['content-between', { 'align-content': 'space-between' }],
33+
['content-around', { 'align-content': 'space-around' }],
34+
['content-evenly', { 'align-content': 'space-evenly' }],
5735
]
5836

5937
export const alignItems: MiniwindRule[] = [
60-
// TODO:
38+
['items-start', { 'align-items': 'flex-start' }],
39+
['items-end', { 'align-items': 'flex-end' }],
40+
['items-center', { 'align-items': 'center' }],
41+
['items-baseline', { 'align-items': 'baseline' }],
42+
['items-stretch', { 'align-items': 'stretch' }],
6143
]
6244

6345
export const alignSelfs: MiniwindRule[] = [
64-
// TODO:
46+
['self-auto', { 'align-self': 'auto' }],
47+
['self-start', { 'align-self': 'flex-start' }],
48+
['self-end', { 'align-self': 'flex-end' }],
49+
['self-center', { 'align-self': 'center' }],
50+
['self-stretch', { 'align-items': 'stretch' }],
6551
]
6652

6753
export const placeContents: MiniwindRule[] = [
68-
// TODO:
54+
['place-content-start', { 'place-content': 'start' }],
55+
['place-content-end', { 'place-content': 'end' }],
56+
['place-content-center', { 'place-content': 'center' }],
57+
['place-content-between', { 'place-content': 'space-between' }],
58+
['place-content-around', { 'place-content': 'space-around' }],
59+
['place-content-evenly', { 'place-content': 'space-evenly' }],
60+
['place-content-stretch', { 'place-content': 'stretch' }],
6961
]
7062

71-
export const placeItems: MiniwindRule[] = [
72-
// TODO:
73-
]
63+
export const placeItems: MiniwindRule[] = basicSet
64+
.map(i => [`place-items-${i}`, { 'place-items': i }])
7465

75-
export const placeSelfs: MiniwindRule[] = [
76-
// TODO:
77-
]
66+
export const placeSelfs: MiniwindRule[] = basicSet
67+
.map(i => [`place-self-${i}`, { 'place-self': i }])
68+
69+
function handleInsetValue(v: string): string | number | undefined {
70+
return { auto: 'auto', full: '100%' }[v] || h.bracket.fraction.number(v)
71+
}
7872

7973
export const insets: MiniwindRule[] = [
80-
// TODO:
74+
[/^inset-(x|y)-(.+)$/i, ([, d, v]): MiniwindCssEntries | undefined => {
75+
const r = handleInsetValue(v)
76+
if (r != null)
77+
return directionMap[d].map(i => [i.slice(1), r])
78+
}],
79+
[/^(top|left|right|bottom|inset)-(.+)$/i, ([, d, v]) => ({ [d]: handleInsetValue(v) })],
8180
]
8281

8382
export const floats: MiniwindRule[] = [

src/presets/default/rules/static.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ export const displays: MiniwindRule[] = [
55
['block', { display: 'block' }],
66
['inline-block', { display: 'inline-block' }],
77
['table', { display: 'table' }],
8+
['contents', { display: 'contents' }],
9+
['flow-root', { display: 'flow-root' }],
10+
['list-item', { display: 'list-item' }],
811
['hidden', { display: 'none' }],
912
]
1013

1114
export const appearances: MiniwindRule[] = [
1215
['outline-none', { 'outline': '2px solid transparent', 'outline-offset': '2px' }],
1316
['appearance-none', { appearance: 'none' }],
17+
['visible', { visibility: 'visible' }],
18+
['invisible', { visibility: 'hidden' }],
19+
['backface-visible', { 'backface-visibility': 'visible' }],
20+
['backface-hidden', { 'backface-visibility': 'hidden' }],
1421
]
1522

1623
export const cursors: MiniwindRule[] = [

0 commit comments

Comments
 (0)
0