forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkitchen-sink.test.js
165 lines (160 loc) · 3.54 KB
/
kitchen-sink.test.js
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import fs from 'fs'
import path from 'path'
import { run, css } from './util/run'
test('it works', () => {
let config = {
darkMode: 'class',
content: [path.resolve(__dirname, './kitchen-sink.test.html')],
corePlugins: { preflight: false },
theme: {
extend: {
screens: {
range: { min: '1280px', max: '1535px' },
multi: [{ min: '640px', max: '767px' }, { max: '868px' }],
},
gradientColorStops: {
foo: '#bada55',
},
backgroundImage: {
'hero--home-1': "url('/images/homepage-1.jpg')",
},
},
},
plugins: [
function ({ addVariant }) {
addVariant(
'foo',
({ container }) => {
container.walkRules((rule) => {
rule.selector = `.foo\\:${rule.selector.slice(1)}`
rule.walkDecls((decl) => {
decl.important = true
})
})
},
{ before: 'sm' }
)
},
function ({ addUtilities, addBase, theme }) {
addBase({
h1: {
fontSize: theme('fontSize.2xl'),
fontWeight: theme('fontWeight.bold'),
'&:first-child': {
marginTop: '0px',
},
},
})
addUtilities(
{
'.magic-none': {
magic: 'none',
},
'.magic-tons': {
magic: 'tons',
},
},
['responsive', 'hover']
)
},
],
}
let input = css`
@layer utilities {
.custom-util {
background: #abcdef;
}
*,
::before,
::after {
margin: 10px;
}
}
@layer components {
.test-apply-font-variant {
@apply ordinal tabular-nums;
}
.custom-component {
background: #123456;
}
*,
::before,
::after {
padding: 5px;
}
.foo .bg-black {
appearance: none;
}
}
@layer base {
div {
background: #654321;
}
}
.theme-test {
font-family: theme('fontFamily.sans');
color: theme('colors.blue.500');
}
@screen lg {
.screen-test {
color: purple;
}
}
.apply-1 {
@apply mt-6;
}
.apply-2 {
@apply mt-6;
}
.apply-test {
@apply mt-6 bg-pink-500 hover:font-bold focus:hover:font-bold sm:bg-green-500 sm:focus:even:bg-pink-200;
}
.apply-components {
@apply container mx-auto;
}
.drop-empty-rules {
@apply hover:font-bold;
}
.apply-group {
@apply group-hover:font-bold;
}
.apply-dark-mode {
@apply dark:font-bold;
}
.apply-with-existing:hover {
@apply font-normal sm:bg-green-500;
}
.multiple,
.selectors {
@apply font-bold group-hover:font-normal;
}
.list {
@apply space-x-4;
}
.nested {
.example {
@apply font-bold hover:font-normal;
}
}
.apply-order-a {
@apply m-5 mt-6;
}
.apply-order-b {
@apply mt-6 m-5;
}
.apply-dark-group-example-a {
@apply dark:group-hover:bg-green-500;
}
.crazy-example {
@apply sm:motion-safe:group-active:focus:opacity-10;
}
@tailwind base;
@tailwind components;
@tailwind utilities;
`
return run(input, config).then((result) => {
let expectedPath = path.resolve(__dirname, './kitchen-sink.test.css')
let expected = fs.readFileSync(expectedPath, 'utf8')
expect(result.css).toMatchFormattedCss(expected)
})
})