1
- import postcss from "postcss" ;
1
+ import type { Declaration } from "postcss" ;
2
2
3
3
const noop = ( ) => { } ;
4
4
5
- export const autoprefixer = postcss . plugin (
6
- "postcss-nodegui-autoprefixer" ,
7
- ( ) => {
8
- return root => {
9
- root . walkDecls ( decl => {
5
+ const autoprefixer = ( opts : any ) => {
6
+ return {
7
+ postcssPlugin : 'postcss-nodegui-autoprefixer' ,
8
+ Once ( root : any ) {
9
+ root . walkDecls ( ( decl : any ) => {
10
10
const autoPrefixer = getAutoPrefixerForProp ( decl . prop ) ;
11
11
autoPrefixer ( decl ) ;
12
12
} ) ;
13
- } ;
13
+ }
14
14
}
15
- ) ;
15
+ }
16
+ export const postcss = true ;
16
17
17
18
const getAutoPrefixerForProp = ( propName : string ) => {
18
19
const rules : Rules = {
19
- display : decl => {
20
+ display : decl => {
20
21
decl . prop = "qproperty-yDisplay" ;
21
22
} ,
22
23
"align-items" : decl => {
@@ -148,31 +149,31 @@ const getAutoPrefixerForProp = (propName: string) => {
148
149
"border-top" : decl => {
149
150
decl . cloneBefore ( {
150
151
prop : "qproperty-yBorderTop" ,
151
- value : parseInt ( ` ${ decl . value } ` )
152
+ value : decl . value
152
153
} ) ;
153
154
} ,
154
155
"border-right" : decl => {
155
156
decl . cloneBefore ( {
156
157
prop : "qproperty-yBorderRight" ,
157
- value : parseInt ( ` ${ decl . value } ` )
158
+ value : decl . value
158
159
} ) ;
159
160
} ,
160
161
"border-bottom" : decl => {
161
162
decl . cloneBefore ( {
162
163
prop : "qproperty-yBorderBottom" ,
163
- value : parseInt ( ` ${ decl . value } ` )
164
+ value : decl . value
164
165
} ) ;
165
166
} ,
166
167
"border-left" : decl => {
167
168
decl . cloneBefore ( {
168
169
prop : "qproperty-yBorderLeft" ,
169
- value : parseInt ( ` ${ decl . value } ` )
170
+ value : decl . value
170
171
} ) ;
171
172
} ,
172
173
"border-horizontal" : decl => {
173
174
decl . cloneBefore ( {
174
175
prop : "qproperty-yBorderHorizontal" ,
175
- value : parseInt ( ` ${ decl . value } ` )
176
+ value : decl . value
176
177
} ) ;
177
178
decl . cloneBefore ( { prop : "border-right" } ) ;
178
179
decl . cloneBefore ( { prop : "border-left" } ) ;
@@ -181,7 +182,7 @@ const getAutoPrefixerForProp = (propName: string) => {
181
182
"border-vertical" : decl => {
182
183
decl . cloneBefore ( {
183
184
prop : "qproperty-yBorderVertical" ,
184
- value : parseInt ( ` ${ decl . value } ` )
185
+ value : decl . value
185
186
} ) ;
186
187
decl . cloneBefore ( { prop : "border-bottom" } ) ;
187
188
decl . cloneBefore ( { prop : "border-top" } ) ;
@@ -190,37 +191,37 @@ const getAutoPrefixerForProp = (propName: string) => {
190
191
border : decl => {
191
192
decl . cloneBefore ( {
192
193
prop : "qproperty-yBorder" ,
193
- value : parseInt ( ` ${ decl . value } ` )
194
+ value : decl . value
194
195
} ) ;
195
196
} ,
196
197
"border-top-width" : decl => {
197
198
decl . cloneBefore ( {
198
199
prop : "qproperty-yBorderTop" ,
199
- value : parseInt ( ` ${ decl . value } ` )
200
+ value : decl . value
200
201
} ) ;
201
202
} ,
202
203
"border-right-width" : decl => {
203
204
decl . cloneBefore ( {
204
205
prop : "qproperty-yBorderRight" ,
205
- value : parseInt ( ` ${ decl . value } ` )
206
+ value : decl . value
206
207
} ) ;
207
208
} ,
208
209
"border-bottom-width" : decl => {
209
210
decl . cloneBefore ( {
210
211
prop : "qproperty-yBorderBottom" ,
211
- value : parseInt ( ` ${ decl . value } ` )
212
+ value : decl . value
212
213
} ) ;
213
214
} ,
214
215
"border-left-width" : decl => {
215
216
decl . cloneBefore ( {
216
217
prop : "qproperty-yBorderLeft" ,
217
- value : parseInt ( ` ${ decl . value } ` )
218
+ value : decl . value
218
219
} ) ;
219
220
} ,
220
221
"border-horizontal-width" : decl => {
221
222
decl . cloneBefore ( {
222
223
prop : "qproperty-yBorderHorizontal" ,
223
- value : parseInt ( ` ${ decl . value } ` )
224
+ value : decl . value
224
225
} ) ;
225
226
decl . cloneBefore ( { prop : "border-right" } ) ;
226
227
decl . cloneBefore ( { prop : "border-left" } ) ;
@@ -229,7 +230,7 @@ const getAutoPrefixerForProp = (propName: string) => {
229
230
"border-vertical-width" : decl => {
230
231
decl . cloneBefore ( {
231
232
prop : "qproperty-yBorderVertical" ,
232
- value : parseInt ( ` ${ decl . value } ` )
233
+ value : decl . value
233
234
} ) ;
234
235
decl . cloneBefore ( { prop : "border-bottom" } ) ;
235
236
decl . cloneBefore ( { prop : "border-top" } ) ;
@@ -238,15 +239,15 @@ const getAutoPrefixerForProp = (propName: string) => {
238
239
"border-width" : decl => {
239
240
decl . cloneBefore ( {
240
241
prop : "qproperty-yBorder" ,
241
- value : parseInt ( ` ${ decl . value } ` )
242
+ value : decl . value
242
243
} ) ;
243
244
}
244
245
} ;
245
246
return rules [ propName ] || noop ;
246
247
} ;
247
248
248
249
type Rules = {
249
- [ key : string ] : ( decl : postcss . Declaration ) => void ;
250
+ [ key : string ] : ( decl : Declaration ) => void ;
250
251
} ;
251
252
252
253
export default autoprefixer ;
0 commit comments