1
+ import { MiniwindCssEntries } from '../../..'
1
2
import { MiniwindRule } from '../../../types'
2
- import { h } from '../../../utils'
3
+ import { directionMap , h } from '../../../utils'
3
4
4
5
export const positions : MiniwindRule [ ] = [
5
6
[ 'relative' , { position : 'relative' } ] ,
@@ -8,76 +9,74 @@ export const positions: MiniwindRule[] = [
8
9
]
9
10
10
11
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' } ] ,
45
18
]
46
19
47
- export const justifyItems : MiniwindRule [ ] = [
48
- // TODO: https://windicss.org/utilities/positioning.html#justify-items
49
- ]
20
+ const basicSet = [ 'auto' , 'start' , 'end' , 'center' , 'stretch' ]
50
21
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 } ] )
54
27
55
28
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' } ] ,
57
35
]
58
36
59
37
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' } ] ,
61
43
]
62
44
63
45
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' } ] ,
65
51
]
66
52
67
53
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' } ] ,
69
61
]
70
62
71
- export const placeItems : MiniwindRule [ ] = [
72
- // TODO:
73
- ]
63
+ export const placeItems : MiniwindRule [ ] = basicSet
64
+ . map ( i => [ `place-items-${ i } ` , { 'place-items' : i } ] )
74
65
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
+ }
78
72
79
73
export const insets : MiniwindRule [ ] = [
80
- // TODO:
74
+ [ / ^ i n s e t - ( 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
+ [ / ^ ( t o p | l e f t | r i g h t | b o t t o m | i n s e t ) - ( .+ ) $ / i, ( [ , d , v ] ) => ( { [ d ] : handleInsetValue ( v ) } ) ] ,
81
80
]
82
81
83
82
export const floats : MiniwindRule [ ] = [
0 commit comments