Skip to main content

stylex_constants/constants/
priorities.rs

1use phf::phf_map;
2
3pub static PSEUDO_CLASS_PRIORITIES: phf::Map<&'static str, &'static f64> = phf_map! {
4  ":is" => &40.0,
5  ":where" => &40.0,
6  ":not" => &40.0,
7  ":has" => &45.0,
8  ":dir" => &50.0,
9  ":lang" => &51.0,
10  ":first-child" => &52.0,
11  ":first-of-type" => &53.0,
12  ":last-child" => &54.0,
13  ":last-of-type" => &55.0,
14  ":only-child" => &56.0,
15  ":only-of-type" => &57.0,
16
17  ":nth-child" => &60.0,
18  ":nth-last-child" => &61.0,
19  ":nth-of-type" => &62.0,
20  ":nth-last-of-type" => &63.0, // "nth-last-of-type" is the same priority as "nth-of-typ.0e
21  ":empty" => &70.0,
22
23  ":link" => &80.0,
24  ":any-link" => &81.0,
25  ":local-link" => &82.0,
26  ":target-within" => &83.0,
27  ":target" => &84.0,
28  ":visited" => &85.0,
29
30  ":enabled" => &91.0,
31  ":disabled" => &92.0,
32  ":required" => &93.0,
33  ":optional" => &94.0,
34  ":read-only" => &95.0,
35  ":read-write" => &96.0,
36  ":placeholder-shown" => &97.0,
37  ":in-range" => &98.0,
38  ":out-of-range" => &99.0,
39
40  ":default" => &100.0,
41  ":checked" => &101.0,
42  ":indeterminate" => &101.0,
43  ":blank" => &102.0,
44  ":valid" => &103.0,
45  ":invalid" => &104.0,
46  ":user-invalid" => &105.0,
47
48  ":autofill" => &110.0,
49
50  ":picture-in-picture" => &120.0,
51  ":modal" => &121.0,
52  ":fullscreen" => &122.0,
53  ":paused" => &123.0,
54  ":playing" => &124.0,
55  ":current" => &125.0,
56  ":past" => &126.0,
57  ":future" => &127.0,
58
59  ":hover" => &130.0,
60  ":focusWithin" => &140.0,
61  ":focus" => &150.0,
62  ":focusVisible" => &160.0,
63  ":active" => &170.0,
64};
65
66pub static AT_RULE_PRIORITIES: phf::Map<&'static str, &'static f64> = phf_map! {
67  "@supports" => &30.0,
68  "@media" => &200.0,
69  "@container" => &300.0,
70};
71
72pub static PSEUDO_ELEMENT_PRIORITY: f64 = 5000.0;
73
74pub static CAMEL_CASE_PRIORITIES: phf::Map<&'static str, &'static str> = phf_map! {
75  "translatex" => "translateX",
76  "translatey" => "translateY",
77  "translatez" => "translateZ",
78  "scalex" => "scaleX",
79  "scaley" => "scaleY",
80  "scalez" => "scaleZ",
81  "rotatex" => "rotateX",
82  "rotatey" => "rotateY",
83  "rotatez" => "rotateZ",
84  "skewx" => "skewX",
85  "skewy" => "skewY",
86  "skewz" => "skewZ",
87};