forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivideWidth.js
More file actions
65 lines (58 loc) · 2.11 KB
/
divideWidth.js
File metadata and controls
65 lines (58 loc) · 2.11 KB
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
import _ from 'lodash'
export default function() {
return function({ addUtilities, e, theme, variants, target }) {
if (target('divideWidth') === 'ie11') {
const generators = [
(size, modifier) => ({
[`.${e(`divide-y${modifier}`)} > :not(template) ~ :not(template)`]: {
'border-top-width': size,
},
[`.${e(`divide-x${modifier}`)} > :not(template) ~ :not(template)`]: {
'border-left-width': size,
},
}),
]
const utilities = _.flatMap(generators, generator => {
return _.flatMap(theme('divideWidth'), (value, modifier) => {
return generator(value, modifier === 'default' ? '' : `-${modifier}`)
})
})
addUtilities(utilities, variants('divideWidth'))
return
}
const generators = [
(size, modifier) => ({
[`.${e(`divide-y${modifier}`)} > :not(template) ~ :not(template)`]: {
'--divide-y-reverse': '0',
'border-top-width': `calc(${
size === '0' ? '0px' : size
} * calc(1 - var(--divide-y-reverse)))`,
'border-bottom-width': `calc(${size === '0' ? '0px' : size} * var(--divide-y-reverse))`,
},
[`.${e(`divide-x${modifier}`)} > :not(template) ~ :not(template)`]: {
'--divide-x-reverse': '0',
'border-right-width': `calc(${size === '0' ? '0px' : size} * var(--divide-x-reverse))`,
'border-left-width': `calc(${
size === '0' ? '0px' : size
} * calc(1 - var(--divide-x-reverse)))`,
},
}),
]
const utilities = _.flatMap(generators, generator => {
return [
..._.flatMap(theme('divideWidth'), (value, modifier) => {
return generator(value, modifier === 'default' ? '' : `-${modifier}`)
}),
{
'.divide-y-reverse > :not(template) ~ :not(template)': {
'--divide-y-reverse': '1',
},
'.divide-x-reverse > :not(template) ~ :not(template)': {
'--divide-x-reverse': '1',
},
},
]
})
addUtilities(utilities, variants('divideWidth'))
}
}