Skip to content

Commit ccbe771

Browse files
committed
fix: 避免将 rgab 色值转为 hexalpha
1 parent cc39775 commit ccbe771

File tree

4 files changed

+143
-108
lines changed

4 files changed

+143
-108
lines changed

__test__/index.spec.mjs.md

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Generated by [AVA](https://avajs.dev).
2424
width: "176px",␊
2525
height: "24px",␊
2626
borderRadius: "100px",␊
27-
backgroundColor: "#000000b3",␊
27+
backgroundColor: "rgba(0, 0, 0, .7)",␊
2828
display: "flex",␊
2929
alignItems: "center",␊
3030
justifyContent: "center",␊
@@ -173,14 +173,14 @@ Generated by [AVA](https://avajs.dev).
173173
return <div className='cc'>␊
174174
175175
<span className='line1 txt' style={{␊
176-
fontSize: "12px",␊
176+
display: "inline-flex",␊
177177
textOverflow: "ellipsis",␊
178178
whiteSpace: "nowrap",␊
179-
display: "inline-flex",␊
179+
fontSize: "12px",␊
180+
flexShrink: "0px",␊
180181
overflow: "hidden",␊
181-
lineHeight: "1",␊
182182
color: "#999",␊
183-
flexShrink: "0px"␊
183+
lineHeight: "1"␊
184184
}}>成员123: 4000+</span>␊
185185
186186
<div className='cnt_row4'>␊
@@ -203,11 +203,11 @@ Generated by [AVA](https://avajs.dev).
203203
whiteSpace: "nowrap",␊
204204
display: "inline-flex",␊
205205
lineHeight: "1",␊
206-
flexShrink: "0px",␊
207-
textOverflow: "ellipsis",␊
208206
overflow: "hidden",␊
209207
color: "#999",␊
210-
fontSize: "12px"␊
208+
flexShrink: "0px",␊
209+
fontSize: "12px",␊
210+
textOverflow: "ellipsis"␊
211211
}}>成员123: 4000+</span>␊
212212
213213
<div className='cnt_row4'>␊
@@ -247,21 +247,21 @@ Generated by [AVA](https://avajs.dev).
247247
<>␊
248248
249249
<img className='icon' src='//img20.360buyimg.com/img/jfs/t1/166410/12/38783/3147/64f58062Fd7737e2b/5aaf0205cd1ce175.png' style={{␊
250-
width: "18px",␊
251-
height: "18px"␊
250+
height: "18px",␊
251+
width: "18px"␊
252252
}}></img>␊
253253
254254
<>␊
255255
256256
<span className='line1 instruction' style={{␊
257-
display: "inline-flex",␊
258-
flexShrink: "0px",␊
259-
whiteSpace: "nowrap",␊
260257
fontSize: "12px",␊
261-
lineHeight: "1",␊
262-
overflow: "hidden",␊
263258
textOverflow: "ellipsis",␊
264-
color: "#fff"␊
259+
whiteSpace: "nowrap",␊
260+
color: "#fff",␊
261+
overflow: "hidden",␊
262+
display: "inline-flex",␊
263+
flexShrink: "0px",␊
264+
lineHeight: "1"␊
265265
}}>超能芭比 5分钟前查看团购</span>␊
266266
267267
</>␊
@@ -271,99 +271,99 @@ Generated by [AVA](https://avajs.dev).
271271
</div>␊
272272
273273
<div className='cnt_row1' style={{␊
274+
gap: "10px",␊
274275
width: "311px",␊
275276
height: "50px",␊
276-
alignItems: "center",␊
277-
gap: "10px",␊
278277
display: "flex",␊
279-
justifyContent: "flex-start",␊
280-
position: "relative"␊
278+
alignItems: "center",␊
279+
position: "relative",␊
280+
justifyContent: "flex-start"␊
281281
}}>␊
282282
283283
<img className='img' src='//img12.360buyimg.com/img/jfs/t1/100881/15/44805/18567/64f58062F1b45e0cb/caf065a7410087ce.png' style={{␊
284-
height: "50px",␊
285-
width: "50px"␊
284+
width: "50px",␊
285+
height: "50px"␊
286286
}}></img>␊
287287
288288
<div className='cnt_col' style={{␊
289-
justifyContent: "center",␊
290-
alignItems: "flex-start",␊
291-
gap: "8px",␊
289+
flexDirection: "column",␊
290+
display: "flex",␊
292291
width: "145px",␊
293292
height: "50px",␊
294-
display: "flex",␊
295-
flexDirection: "column"␊
293+
alignItems: "flex-start",␊
294+
justifyContent: "center",␊
295+
gap: "8px"␊
296296
}}>␊
297297
298298
<span className='line1 instruction1' style={{␊
299299
width: "116px",␊
300-
color: "#000",␊
301-
display: "inline-flex",␊
302300
overflow: "hidden",␊
303-
textOverflow: "ellipsis",␊
304301
whiteSpace: "nowrap",␊
305-
fontSize: "16px",␊
306302
lineHeight: "1",␊
303+
display: "inline-flex",␊
304+
color: "#000",␊
305+
textOverflow: "ellipsis",␊
306+
fontSize: "16px",␊
307307
flexShrink: "0px"␊
308308
}}>巴拉巴拉小魔仙</span>␊
309309
310310
<span className='line1 txt' style={{␊
311-
lineHeight: "1",␊
312-
whiteSpace: "nowrap",␊
313-
flexShrink: "0px",␊
314-
display: "inline-flex",␊
315311
color: "#999",␊
316312
fontSize: "12px",␊
313+
whiteSpace: "nowrap",␊
314+
overflow: "hidden",␊
315+
lineHeight: "1",␊
316+
flexShrink: "0px",␊
317317
textOverflow: "ellipsis",␊
318-
overflow: "hidden"␊
318+
display: "inline-flex"␊
319319
}}>成员: 4000+</span>␊
320320
321321
</div>␊
322322
323323
<div className='cnt_row2' style={{␊
324-
borderColor: "#999",␊
325-
alignItems: "flex-start",␊
326-
display: "flex",␊
327-
height: "23px",␊
328-
paddingRight: "8px",␊
329-
gap: "-94px",␊
330-
width: "110px",␊
331-
paddingTop: "4px",␊
332324
paddingLeft: "8px",␊
325+
flexShrink: "0px",␊
333326
zIndex: "12",␊
327+
borderRadius: "12px",␊
328+
gap: "-94px",␊
329+
borderStyle: "solid",␊
330+
height: "23px",␊
334331
left: "201px",␊
332+
paddingRight: "8px",␊
333+
width: "110px",␊
334+
position: "absolute",␊
335335
justifyContent: "space-between",␊
336-
borderStyle: "solid",␊
337-
borderRadius: "12px",␊
338336
top: "3px",␊
339-
flexShrink: "0px",␊
340-
paddingBottom: "4px",␊
337+
alignItems: "flex-start",␊
338+
borderColor: "#999",␊
339+
display: "flex",␊
340+
paddingTop: "4px",␊
341341
borderWidth: "1px",␊
342-
position: "absolute"␊
342+
paddingBottom: "4px"␊
343343
}}>␊
344344
345345
{this.getDom()}␊
346346
347347
<img className='icon1' src='//img11.360buyimg.com/img/jfs/t1/175578/35/40256/1981/64f58062Fddaf1a21/f1111d9988a65ccc.png' style={{␊
348-
height: "15px",␊
349-
width: "15px"␊
348+
width: "15px",␊
349+
height: "15px"␊
350350
}}></img>␊
351351
352352
<span className='instruction2' style={{␊
353-
overflow: "hidden",␊
354-
textAlign: "center",␊
355353
flexShrink: "0px",␊
354+
lineHeight: "1.36",␊
356355
color: "#999",␊
356+
overflow: "hidden",␊
357357
fontSize: "11px",␊
358-
lineHeight: "1.36"␊
358+
textAlign: "center"␊
359359
}}>slslsl-jsj</span>␊
360360
361361
<span className='txt1' style={{␊
362+
lineHeight: "1.36",␊
363+
textAlign: "center",␊
362364
flexShrink: "0px",␊
363365
color: "#222",␊
364-
textAlign: "center",␊
365-
fontSize: "11px",␊
366-
lineHeight: "1.36"␊
366+
fontSize: "11px"␊
367367
}}>复制</span>␊
368368
369369
</div>␊
@@ -372,29 +372,29 @@ Generated by [AVA](https://avajs.dev).
372372
373373
<div className='cnt_row3' style={{␊
374374
alignItems: "center",␊
375-
justifyContent: "space-between",␊
376375
display: "flex",␊
376+
justifyContent: "space-between",␊
377+
height: "44px",␊
377378
gap: "-311px",␊
378-
width: "311px",␊
379-
height: "44px"␊
379+
width: "311px"␊
380380
}}>␊
381381
382382
<span className='line2 txt2' style={{␊
383383
width: "290px",␊
384-
display: "inline-flex",␊
385-
color: "#999",␊
384+
fontSize: "12px",␊
386385
lineHeight: "1.83",␊
386+
color: "#999",␊
387387
flexShrink: "0px",␊
388-
fontSize: "12px"␊
388+
display: "inline-flex"␊
389389
}}>␊
390390
391391
团长介绍:售前售后进群售前售后进群售前售后进群售前售后进群VXklsidohh...␊
392392
393393
</span>␊
394394
395395
<img className='img1' src='//img14.360buyimg.com/img/jfs/t1/206378/24/25778/195/64eca527F378f17a2/c1623681708609fd.png' style={{␊
396-
width: "6px",␊
397-
height: "10px"␊
396+
height: "10px",␊
397+
width: "6px"␊
398398
}}></img>␊
399399
400400
</div>␊

__test__/index.spec.mjs.snap

21 Bytes
Binary file not shown.

src/style_write.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
use std::{cell::RefCell, collections::HashMap, rc::Rc};
22

3-
use swc_common::{sync::Lrc, SourceMap, errors::{Handler, ColorConfig}};
3+
use swc_common::{
4+
errors::{ColorConfig, Handler},
5+
sync::Lrc,
6+
SourceMap,
7+
};
48
use swc_ecma_ast::Program;
5-
use swc_ecma_parser::{StringInput, Syntax, lexer::Lexer, Parser};
9+
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax};
610
use swc_ecma_visit::VisitMutWith;
711

812
use crate::{
913
style_parser::StyleDeclaration,
10-
visitor::{JSXRecord, SpanKey, ModuleMutVisitor, JSXMutVisitor},
14+
visitor::{JSXMutVisitor, JSXRecord, ModuleMutVisitor, SpanKey},
1115
};
1216

1317
pub struct StyleWrite<'i> {
@@ -58,22 +62,23 @@ function __calc_style__(classnames, styleObj) {
5862
parser
5963
.parse_module()
6064
.map_err(|e| e.into_diagnostic(&handler).emit())
61-
.expect("解析插入代码失败")
65+
.expect("解析插入代码失败"),
6266
));
6367
{
64-
let mut jsx_mut_visitor = JSXMutVisitor::new(
65-
self.jsx_record.clone(),
66-
self.style_record.clone(),
67-
68-
);
69-
self.module.borrow_mut().visit_mut_with(&mut jsx_mut_visitor);
68+
let mut jsx_mut_visitor =
69+
JSXMutVisitor::new(self.jsx_record.clone(), self.style_record.clone());
70+
self
71+
.module
72+
.borrow_mut()
73+
.visit_mut_with(&mut jsx_mut_visitor);
7074
}
7175
{
72-
let mut insert_mut_visitor = ModuleMutVisitor::new(
73-
self.all_style.clone(),
74-
insert_module.clone(),
75-
);
76-
self.module.borrow_mut().visit_mut_with(&mut insert_mut_visitor);
76+
let mut insert_mut_visitor =
77+
ModuleMutVisitor::new(self.all_style.clone(), insert_module.clone());
78+
self
79+
.module
80+
.borrow_mut()
81+
.visit_mut_with(&mut insert_mut_visitor);
7782
}
7883
}
7984
}

0 commit comments

Comments
 (0)