Skip to content

Commit 52ea4c7

Browse files
authored
Merge pull request #96 from willofindie/fix/issue-95
[Fix] Handle variable recursive evaluation
2 parents fc07367 + 2d19c6b commit 52ea4c7

File tree

13 files changed

+132
-11
lines changed

13 files changed

+132
-11
lines changed

examples/multi-root/proj-1/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
color: var(--color-1);
88
background-color: var(--color-2);
99

10+
/* LOL!! I didn't know adding a var() in the comment makes it visible for diagnostics */
11+
/* FIXME(phoenisx) When var() function is used with default values, the regex doesn't */
12+
/* work as expected */
1013
/* Non declared variable test */
1114
color: var(--space-2, 2rem);
1215
}

examples/multi-root/proj-3/index.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
@import "./theme.dark.css";
33

44
body {
5+
/* FIXME(phoenisx) Not working. It was working before */
6+
/* It started working after reload */
57
color: var(--primary-text);
68
background-color: var(--primary-bg);
79
padding: var(--container-spacing);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cssvar.files": ["testing-*.css"],
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
:root {
2+
--foo: #f00;
3+
--bar: var(--foo);
4+
}
5+
6+
.test {
7+
background: var(--foo);
8+
}
9+
10+
.test--two {
11+
--foo: var(--bar);
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:root {
2+
--foo: #f00;
3+
--joo: 4px;
4+
/* Following does not get normalised in post-processing, because of regex */
5+
--too: 2px var(--joo);
6+
--bar: var(--too);
7+
}
8+
9+
.test {
10+
/* --foo should point to #f00, but it isn't righ now */
11+
/* Need to find a way to set recursive value to previously declared variable */
12+
background: var(--foo);
13+
}
14+
15+
.test--two {
16+
--foo: var(--bar);
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* Folllowing is valid css */
2+
:root {
3+
--bar: var(--foo);
4+
}
5+
6+
.test {
7+
background: var(--foo);
8+
}
9+
10+
.test--two {
11+
--foo: var(--bar);
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* Folllowing is valid css */
2+
:root {
3+
--bar: var(--foo);
4+
}
5+
6+
.test {
7+
background: var(--foo);
8+
}
9+
10+
.test--two {
11+
--foo: var(--bar);
12+
}
13+
14+
.test--two.define {
15+
--foo: lightgreen;
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
:root {
2+
--fuzz: #fff;
3+
4+
--fuzz-large: var(--fuzz);
5+
--boo: var(--not-defined);
6+
}
7+
8+
@media (min-width: 768px) {
9+
:root {
10+
--boo: 48px;
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.card {
2+
background: var(--fuzz);
3+
padding: var(--not-defined);
4+
}
5+
6+
/* Just updating variables instead of having to re-define each property */
7+
.card--large {
8+
--fuzz: var(--fuzz-large);
9+
--not-defined: var(--boo);
10+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* Folllowing is valid css */
2+
:root {
3+
--bar: var(--foo);
4+
}
5+
6+
.test {
7+
background: var(--foo);
8+
}
9+
10+
.test--two {
11+
--foo: var(--bar);
12+
}
13+
14+
.test--two.define {
15+
--foo: lightgreen;
16+
}

0 commit comments

Comments
 (0)