Skip to content

Commit

Permalink
Include css class name in compiled output (#467)
Browse files Browse the repository at this point in the history
Co-authored-by: matthewmcgarvey <[email protected]>
  • Loading branch information
gdotdesign and matthewmcgarvey authored Jul 2, 2021
1 parent bde5229 commit 3b7e55a
Show file tree
Hide file tree
Showing 31 changed files with 209 additions and 111 deletions.
45 changes: 45 additions & 0 deletions spec/compilers/component_namespaced_with_style
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
component Ui.Dropdown {
style base {
background: red;
}

fun render : Html {
<div::base>
"test"
</div>
}
}

component Main {
fun render : Html {
<Ui.Dropdown/>
}
}
--------------------------------------------------------------------------------
class A extends _C {
render() {
return _h("div", {
className: `Ui·Dropdown_base`
}, [
`test`
]);
}
};

A.displayName = "Ui.Dropdown";

class B extends _C {
render() {
return $a();
}
};

B.displayName = "Main";

const $a = _m(() => _h(A, {}));

_insertStyles(`
.Ui·Dropdown_base {
background: red;
}
`);
8 changes: 4 additions & 4 deletions spec/compilers/css_definition
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ component Main {
}
--------------------------------------------------------------------------------
class A extends _C {
$a() {
$Main_test() {
const _ = {
[`--a-a`]: this.a + `px 0px`
};
Expand All @@ -27,16 +27,16 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_test`,
style: _style([this.$Main_test()])
});
}
};

A.displayName = "Main";

_insertStyles(`
.a {
.Main_test {
margin: var(--a-a);
}
`);
2 changes: 1 addition & 1 deletion spec/compilers/css_font_face
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ component Main {
class A extends _C {
render() {
return _h("div", {
className: `a`
className: `Main_test`
});
}
};
Expand Down
4 changes: 2 additions & 2 deletions spec/compilers/css_font_face_with_qoutes
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ component Main {
class A extends _C {
render() {
return _h("div", {
className: `a`
className: `Main_test`
});
}
};

A.displayName = "Main";

_insertStyles(`
.a {
.Main_test {
font-family: "myFirstFont";
}

Expand Down
6 changes: 3 additions & 3 deletions spec/compilers/css_keyframes
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class A extends _C {
});
}

$a() {
$Main_test() {
const _ = {
[`--a-a`]: this.a
};
Expand All @@ -51,8 +51,8 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_test`,
style: _style([this.$Main_test()])
});
}
};
Expand Down
10 changes: 5 additions & 5 deletions spec/compilers/css_media
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ component Main {
}
--------------------------------------------------------------------------------
class A extends _C {
$a() {
$Main_test() {
const _ = {
[`--a-a`]: this.a,
[`--b-a`]: this.a
Expand All @@ -34,21 +34,21 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_test`,
style: _style([this.$Main_test()])
});
}
};

A.displayName = "Main";

_insertStyles(`
.a div {
.Main_test div {
color: var(--a-a);
}

@media (screen) {
.a {
.Main_test {
color: var(--b-a);
}
}
Expand Down
10 changes: 5 additions & 5 deletions spec/compilers/css_media_with_if
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ component Main {
}
--------------------------------------------------------------------------------
class A extends _C {
$a() {
$Main_test() {
const _ = {};

(true ? Object.assign(_, {
Expand All @@ -27,21 +27,21 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_test`,
style: _style([this.$Main_test()])
});
}
};

A.displayName = "Main";

_insertStyles(`
.a {
.Main_test {
color: yellow;
}

@media (max-width: 300px) {
.a {
.Main_test {
color: var(--a-a);
}
}
Expand Down
10 changes: 5 additions & 5 deletions spec/compilers/css_selector
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ component Main {
}
--------------------------------------------------------------------------------
class A extends _C {
$a() {
$Main_test() {
const _ = {
[`--a-a`]: this.a
};
Expand All @@ -33,20 +33,20 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_test`,
style: _style([this.$Main_test()])
});
}
};

A.displayName = "Main";

_insertStyles(`
.a div {
.Main_test div {
color: var(--a-a);
}

.a:focus {
.Main_test:focus {
color: red;
}
`);
12 changes: 6 additions & 6 deletions spec/compilers/css_selector_multiple
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ component Main {
}
--------------------------------------------------------------------------------
class A extends _C {
$a() {
$Main_test() {
const _ = {
[`--a-a`]: this.a
};
Expand All @@ -34,24 +34,24 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_test`,
style: _style([this.$Main_test()])
});
}
};

A.displayName = "Main";

_insertStyles(`
.a div {
.Main_test div {
color: var(--a-a);
}

.a:focus {
.Main_test:focus {
color: red;
}

.a:hover {
.Main_test:hover {
color: red;
}
`);
8 changes: 4 additions & 4 deletions spec/compilers/css_string
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class A extends _C {
});
}

$a() {
$Main_unicode() {
const _ = {
[`--a-a`]: `"Hi"` + ` blah ` + this.a + ` ` + `"Here is some content; Thanks ${this.a}"`
};
Expand All @@ -37,8 +37,8 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_unicode`,
style: _style([this.$Main_unicode()])
}, [
_h("span", {})
]);
Expand All @@ -48,7 +48,7 @@ class A extends _C {
A.displayName = "Main";

_insertStyles(`
.a span::after {
.Main_unicode span::after {
content: var(--a-a);
}
`);
8 changes: 4 additions & 4 deletions spec/compilers/css_supports
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class A extends _C {
});
}

$a() {
$Main_test() {
const _ = {
[`--a-a`]: this.a
};
Expand All @@ -35,8 +35,8 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a()])
className: `Main_test`,
style: _style([this.$Main_test()])
});
}
};
Expand All @@ -45,7 +45,7 @@ A.displayName = "Main";

_insertStyles(`
@supports (screen) {
.a {
.Main_test {
color: var(--a-a);
}
}
Expand Down
8 changes: 4 additions & 4 deletions spec/compilers/css_with_ands
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ component Main {
class A extends _C {
render() {
return _h("div", {
className: `a`
className: `Main_test`
});
}
};

A.displayName = "Main";

_insertStyles(`
.a:focus {
.Main_test:focus {
color: red;
}

.a[someattribute] {
.Main_test[someattribute] {
color: red;
}

.a.someclass {
.Main_test.someclass {
color: red;
}
`);
8 changes: 4 additions & 4 deletions spec/compilers/css_with_arguments
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ component Main {
}
--------------------------------------------------------------------------------
class A extends _C {
$a(a) {
$Main_test(a) {
const _ = {
[`--a-a`]: a
};
Expand All @@ -19,16 +19,16 @@ class A extends _C {

render() {
return _h("div", {
className: `a`,
style: _style([this.$a(`red`)])
className: `Main_test`,
style: _style([this.$Main_test(`red`)])
});
}
};

A.displayName = "Main";

_insertStyles(`
.a {
.Main_test {
color: var(--a-a);
}
`);
Loading

0 comments on commit 3b7e55a

Please sign in to comment.