-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.rs
62 lines (53 loc) · 1.26 KB
/
inventory.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! for situations where you have a set of components,
//! and you want to register the classes you use from different files without too much complexity
use zephyr::{register_class, Zephyr};
fn main() {
let z = Zephyr::new();
let generated_css = z.generate_from_inventory();
let head = head(&generated_css);
let header = header();
let body = body();
let html = format!(
r#"
<!DOCTYPE html>
<html>
{head}
<body>
{header}
{body}
</body>
</html>
"#
);
std::fs::write("./examples/index.html", html).unwrap();
}
fn head(generated_css: &str) -> String {
format!(
r#"
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>{generated_css}</style>
</head>
"#
)
}
fn header() -> String {
let class = register_class!("color[#e20f00] color[green]hover content['*']$before");
format!(
r#"
<p class="{class}">
this text is red, but green on hover
</p>
"#
)
}
fn body() -> String {
let class = register_class!("mt[10rem] content[attr(after)]$after color[red]$after");
format!(
r#"
<p class="{class}" after="hi, this is an after text">
this text has a lot of margin
</p>
"#
)
}