2023-12-31 03:08:05 +00:00
|
|
|
let
|
|
|
|
style = import ../nixite/style.nix;
|
|
|
|
html = import ../nixite/html.nix;
|
|
|
|
it = import ./it.nix;
|
|
|
|
|
|
|
|
my =
|
|
|
|
(style.styled "p" "p" {} {
|
|
|
|
some-style = "some value";
|
|
|
|
})
|
2023-12-31 03:08:41 +00:00
|
|
|
(style.styled "div" "div" {class = ["something"];} {
|
2023-12-31 03:08:05 +00:00
|
|
|
this = "that";
|
|
|
|
})
|
2023-12-31 03:08:41 +00:00
|
|
|
(style.styled "s" "div" {
|
|
|
|
id = "s";
|
|
|
|
class = ["something"];
|
|
|
|
} {
|
|
|
|
s = "yes";
|
|
|
|
})
|
|
|
|
(style.styled "foobar" "div" {class = ["foo" "bar"];} {
|
2023-12-31 03:08:05 +00:00
|
|
|
something = "something";
|
|
|
|
})
|
|
|
|
(style.style "body" {
|
|
|
|
foo = "bar";
|
2023-12-31 03:41:46 +00:00
|
|
|
})
|
|
|
|
(style.styled "list" "ul" {
|
|
|
|
__child = child:
|
2023-12-31 04:27:09 +00:00
|
|
|
assert builtins.isList child; (map (html.tag "li" {}) child);
|
|
|
|
} {});
|
2023-12-31 03:08:05 +00:00
|
|
|
in [
|
2023-12-31 03:08:41 +00:00
|
|
|
(it "makes a p component" {
|
|
|
|
expected = html.tag "p" {} "yes";
|
|
|
|
actual = my.p {} "yes";
|
|
|
|
})
|
2023-12-31 04:27:09 +00:00
|
|
|
(it "does not error without attrs" {
|
|
|
|
expected = html.tag "p" {} "yes";
|
|
|
|
actual = my.p "yes";
|
|
|
|
})
|
2023-12-31 03:08:41 +00:00
|
|
|
(it "makes a component" {
|
|
|
|
expected = html.tag "div" {class = ["something"];} "foobar";
|
|
|
|
actual = my.div {} "foobar";
|
|
|
|
})
|
|
|
|
(it "makes special components" {
|
|
|
|
expected = html.tag "div" {
|
|
|
|
id = "s";
|
|
|
|
class = ["something"];
|
|
|
|
} "foobar";
|
|
|
|
actual = my.s {} "foobar";
|
|
|
|
})
|
|
|
|
(it "works on many classes" {
|
|
|
|
expected = html.tag "div" {class = ["foo" "bar"];} "foobar";
|
|
|
|
actual = my.foobar {} "foobar";
|
|
|
|
})
|
2023-12-31 03:41:46 +00:00
|
|
|
(it "does custom behavour" {
|
|
|
|
expected = toString (html.tag "ul" {} [
|
|
|
|
(html.tag "li" {} "1")
|
|
|
|
(html.tag "li" {} "2")
|
|
|
|
]);
|
2023-12-31 04:27:09 +00:00
|
|
|
actual = toString (my.list {} ["1" "2"]);
|
2023-12-31 03:41:46 +00:00
|
|
|
})
|
2023-12-31 03:08:41 +00:00
|
|
|
(it "combines attrs" {
|
|
|
|
expected = html.tag "div" {
|
|
|
|
id = "foo";
|
|
|
|
class = ["something"];
|
|
|
|
} "foobar";
|
|
|
|
actual = my.div {id = "foo";} "foobar";
|
|
|
|
})
|
|
|
|
(it "makes a style" {
|
|
|
|
expected = ''
|
|
|
|
p {
|
|
|
|
some-style: some value;
|
|
|
|
}
|
|
|
|
div.something {
|
|
|
|
this: that;
|
|
|
|
}
|
|
|
|
div.something#s {
|
|
|
|
s: yes;
|
|
|
|
}
|
|
|
|
div.foo.bar {
|
|
|
|
something: something;
|
|
|
|
}
|
|
|
|
body {
|
|
|
|
foo: bar;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
actual = my.style;
|
|
|
|
})
|
|
|
|
]
|