add ideas on hown
This commit is contained in:
parent
d5a868499f
commit
0ee3983aed
4 changed files with 116 additions and 0 deletions
2
www/hown/README.md
Normal file
2
www/hown/README.md
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Html With Nix (HOWN/hown)
|
||||
Hown is a system for static html/css compilation with the NixExpr language.
|
||||
6
www/hown/default.nix
Normal file
6
www/hown/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{mix, ...} @ inputs:
|
||||
mix.newMixture inputs (mixture: {
|
||||
includes.public = [
|
||||
./tty.nix
|
||||
];
|
||||
})
|
||||
8
www/hown/index.html
Normal file
8
www/hown/index.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!-->
|
||||
{Text, mkTypingEffect, ...}:
|
||||
mkTypingEffect {
|
||||
head = Text "$ Do butterflies cry when they're sad?";
|
||||
body = Text "Segmentation fault (core dumped)";
|
||||
}
|
||||
<-->
|
||||
|
||||
100
www/hown/tty.nix
Normal file
100
www/hown/tty.nix
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
# XXX: TODO: The howl.Div, howl.Text, ... types implement
|
||||
# XXX: TODO: the HtmlTag' typeclass, which in turn implements
|
||||
# XXX: TODO: a morphism to the nt.String type. This makes compiling
|
||||
# XXX: TODO: to html super duper simple!!
|
||||
{
|
||||
nt,
|
||||
howl,
|
||||
...
|
||||
}: let
|
||||
inherit
|
||||
(nt)
|
||||
projectOnto
|
||||
;
|
||||
|
||||
inherit
|
||||
(howl)
|
||||
# HTML
|
||||
Div
|
||||
Text
|
||||
# CSS
|
||||
StyleClass
|
||||
StyleSheet
|
||||
ContinuousAnimation
|
||||
DiscreteAnimation
|
||||
;
|
||||
in {
|
||||
typing = StyleSheet {
|
||||
include = [./tty.css];
|
||||
|
||||
classes = {
|
||||
typing-wrapper = null;
|
||||
typing-prompt = promptLength: commandLength: duration: period:
|
||||
StyleClass {
|
||||
width = promptLength + commandLength; # ignore cursor
|
||||
border.right = "TODO"; # cursor
|
||||
|
||||
# hide what the animation hasn't shown yet
|
||||
whitespace = "nowrap";
|
||||
overflow = "hidden";
|
||||
|
||||
# run typing animation then start cursor blink
|
||||
animations = [
|
||||
(DiscreteAnimation {
|
||||
inherit duration;
|
||||
keyframes = {
|
||||
"0"
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
typing-result = typingDuration: delay:
|
||||
StyleClass {
|
||||
visibility = "hidden";
|
||||
whitespace = "pre-wrap"; # preserve linebreaks
|
||||
|
||||
# show result once typing duration + delay is over
|
||||
animations = [
|
||||
(ContinuousAnimation {
|
||||
name = "unhide-result";
|
||||
duration = 1; # animation-duration
|
||||
# timingFn = ; # animation-timing-function
|
||||
delay = typingDuration + delay; # animation-delay
|
||||
# animation-iteration-count
|
||||
direction = "forwards"; # animation-direction
|
||||
# animation-fill-mode
|
||||
# animation-play-state
|
||||
keyframes = {
|
||||
"100" = {
|
||||
visibility = "visible";
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
mkTypingEffect = decl': let
|
||||
decl =
|
||||
decl'
|
||||
|> projectOnto
|
||||
{
|
||||
head = "";
|
||||
body = "";
|
||||
};
|
||||
in
|
||||
Div {
|
||||
id = "typing-wrapper";
|
||||
content = [
|
||||
(Div {
|
||||
id = "typing-prompt";
|
||||
content = Text decl.head;
|
||||
})
|
||||
(Div {
|
||||
id = "typing-result";
|
||||
content = Text decl.body;
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue