Skip to content

Commit 2d3a8cf

Browse files
authored
Adds a bunch of tests for complex HSL() color values (#38)
* Adds a bunch of tests for complex HSL() color values * Delete .DS_Store (#37)
1 parent 9705f2b commit 2d3a8cf

File tree

2 files changed

+111
-29
lines changed

2 files changed

+111
-29
lines changed

test/analyzer/values/input.css

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
.rule1 {
2-
color: red;
2+
margin: 0;
33
/* comment */
44
}
55

66
@media screen {
77
.rule2 {
8-
color: red
8+
margin: 0;
99
}
1010
.rule3 {
11-
color: red !important;
11+
margin: 0 !important;
1212
/* comment */
1313
}
1414
/* comment */
@@ -23,21 +23,56 @@
2323
}
2424

2525
/* Colors */
26-
.color4 { color: #aff034; }
27-
.color5 { color: rgb(100, 200, 10); }
28-
.color6 { color: rgba(100, 200, 10, 0.5); }
29-
.color7 { color: rgba(100, 200, 10, .5); }
30-
.color8 { background-color: hsl(100, 20%, 30%); }
31-
.color9 { background-color: hsla(100, 20%, 30%, 0.5); }
32-
.color10 { border: 1px solid #aaa; }
33-
.color11 { outline: 1px solid tomato; }
34-
.color12 { border-color: Aqua; }
35-
.color13 { outline-color: whitesmoke; }
36-
.color14and15 { background: linear-gradient(90deg, purple 0, purple 100%) }
37-
.color16 { color: #0000ff00; }
38-
.color17 { background: rgba(2,2,2,.2) }
39-
.color18 { background: hsl(100, 10%, 20%) }
40-
.color19-20-21-22 { background: linear-gradient(to right, hsl(360, 100%, 100%), rgb(255, 255, 255), #fff, white) }
26+
.color-hex {
27+
color: #aff034;
28+
border: 1px solid #aaa;
29+
color: #0000ff00; /* Including opacity */
30+
}
31+
.color-rgb {
32+
color: rgb(100, 200, 10);
33+
color: rgba(100, 200, 10, 0.5);
34+
color: rgba(100, 200, 10, .5);
35+
background: rgba(2,2,2,.2);
36+
}
37+
.color-hsl {
38+
color: hsl(100, 20%, 30%);
39+
color: hsla(100, 20%, 30%, 0.5);
40+
background: hsl(100, 10%, 20%);
41+
42+
/**
43+
* Complex examples from
44+
* https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Examples_2
45+
*/
46+
47+
/* These examples all specify the same color: a lavender. */
48+
color: hsl(270,60%,70%);
49+
color: hsl(270, 60%, 70%);
50+
color: hsl(270 60% 70%);
51+
color: hsl(270deg, 60%, 70%);
52+
color: hsl(4.71239rad, 60%, 70%);
53+
color: hsl(.75turn, 60%, 70%);
54+
55+
/* These examples all specify the same color: a lavender that is 15% opaque. */
56+
color: hsl(270, 60%, 50%, .15);
57+
color: hsl(270, 60%, 50%, 15%);
58+
color: hsl(270 60% 50% / .15);
59+
color: hsl(270 60% 50% / 15%);
60+
}
61+
.color-keyword {
62+
outline: 1px solid tomato;
63+
border-color: Aqua;
64+
outline-color: whitesmoke;
65+
background: linear-gradient(90deg, purple 0, purple 100%);
66+
}
67+
.color-mixed {
68+
background: linear-gradient(
69+
to right,
70+
hsl(360, 100%, 100%),
71+
rgb(255, 255, 255),
72+
#fff,
73+
white
74+
);
75+
}
4176
.color-false {
4277
background-image:
4378
url('icon-blue.png'),
@@ -81,8 +116,16 @@
81116
.font-size5 { font: medium serif; }
82117
.font-size6 { font: normal normal 1.2em serif; }
83118
.font-size7 { font: 400 1.3em/1 serif; }
84-
.font-false { font: inherit; font: initial; font: auto; }
85-
.font-false { font-size: inherit; font-size: initial; font-size: auto; }
119+
.font-false {
120+
font: inherit;
121+
font: initial;
122+
font: auto;
123+
}
124+
.font-false {
125+
font-size: inherit;
126+
font-size: initial;
127+
font-size: auto;
128+
}
86129

87130
/**
88131
* Font-families
@@ -97,7 +140,11 @@
97140
font: 1em/ 1 serif;
98141
font: 1em /1 serif;
99142
}
100-
.font-family-keywords { font-family: inherit; font-family: initial; font-family: auto; }
143+
.font-family-keywords {
144+
font-family: inherit;
145+
font-family: initial;
146+
font-family: auto;
147+
}
101148
.font-families-github {
102149
font-family:"Arial Black", "Arial Bold", Gadget, sans-serif;
103150
font-family:"Brush Script MT", cursive;

test/analyzer/values/output.json

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"total": 73,
2+
"total": 83,
33
"fontfamilies": {
44
"total": 18,
55
"totalUnique": 12,
@@ -121,11 +121,11 @@
121121
"count": 1
122122
}
123123
],
124-
"share": 0.0547945205479452
124+
"share": 0.04819277108433735
125125
},
126126
"colors": {
127-
"total": 22,
128-
"totalUnique": 19,
127+
"total": 29,
128+
"totalUnique": 28,
129129
"unique": [
130130
{
131131
"value": "#0000ff00",
@@ -147,6 +147,10 @@
147147
"value": "Aqua",
148148
"count": 1
149149
},
150+
{
151+
"value": "hsl(.75turn, 60%, 70%)",
152+
"count": 1
153+
},
150154
{
151155
"value": "hsl(100, 10%, 20%)",
152156
"count": 1
@@ -155,10 +159,45 @@
155159
"value": "hsl(100, 20%, 30%)",
156160
"count": 1
157161
},
162+
{
163+
"value": "hsl(270 60% 50% / .15)",
164+
"count": 1
165+
}, {
166+
"value": "hsl(270 60% 50% / 15%)",
167+
"count": 1
168+
},
169+
{
170+
"value": "hsl(270 60% 70%)",
171+
"count": 1
172+
},
173+
{
174+
"value": "hsl(270, 60%, 50%, .15)",
175+
"count": 1
176+
},
177+
{
178+
"value": "hsl(270, 60%, 50%, 15%)",
179+
"count": 1
180+
},
181+
{
182+
"value": "hsl(270, 60%, 70%)",
183+
"count": 1
184+
},
185+
{
186+
"value": "hsl(270,60%,70%)",
187+
"count": 1
188+
},
189+
{
190+
"value": "hsl(270deg, 60%, 70%)",
191+
"count": 1
192+
},
158193
{
159194
"value": "hsl(360, 100%, 100%)",
160195
"count": 1
161196
},
197+
{
198+
"value": "hsl(4.71239rad, 60%, 70%)",
199+
"count": 1
200+
},
162201
{
163202
"value": "hsla(100, 20%, 30%, 0.5)",
164203
"count": 1
@@ -167,10 +206,6 @@
167206
"value": "purple",
168207
"count": 2
169208
},
170-
{
171-
"value": "red",
172-
"count": 3
173-
},
174209
{
175210
"value": "rgb(100, 200, 10)",
176211
"count": 1

0 commit comments

Comments
 (0)