From 85e3281f75956ffe2fea2129c6593116c23cdc71 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 4 Sep 2022 20:59:19 +0300 Subject: feat(corp/tvixbolt): add some additional information on the page A little bit easier to grasp what's going on then just a blank page with a textbox ... Change-Id: I16f456035173813d60d88ff7e5ebd14712f77ec3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6330 Tested-by: BuildkiteCI Reviewed-by: tazjin --- corp/tvixbolt/src/main.rs | 83 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 7 deletions(-) (limited to 'corp/tvixbolt/src') diff --git a/corp/tvixbolt/src/main.rs b/corp/tvixbolt/src/main.rs index 122a84e0ac6a..d43241da6333 100644 --- a/corp/tvixbolt/src/main.rs +++ b/corp/tvixbolt/src/main.rs @@ -14,6 +14,50 @@ struct Model { code: String, } +fn tvixbolt_overview() -> Html { + html! { + <> +

+ {"This page lets you explore the bytecode generated by the "} + {"Tvix"} + {" compiler for the Nix language. See the "} + {"Tvix announcement"} + {" for some background information on Tvix itself."} +

+

+ {"Tvix is still "}{"extremely work-in-progress"}{" and you "} + {"should expect to be able to cause bugs and errors in this tool."} +

+ + } +} + +fn footer_link(location: &'static str, name: &str) -> Html { + html! { + <> + {name}{" | "} + + } +} + +fn footer() -> Html { + html! { + <> +
+
+ +

{"ಠ_ಠ"}

+
+ + } +} + impl Component for Model { type Message = Msg; type Properties = (); @@ -37,8 +81,10 @@ impl Component for Model { // This gives us a component's "`Scope`" which allows us to send messages, etc to the component. let link = ctx.link(); html! { + <>
-

{"tvixbolt"}

+

{"tvixbolt 0.1-alpha"}

+ {tvixbolt_overview()}
{"Input"} @@ -55,16 +101,39 @@ impl Component for Model {
-
- - -
+
+ + +

-

{"Result:"}

- {eval(&self.code).display()} + {self.run()} + {footer()} + + } + } +} + +impl Model { + fn run(&self) -> Html { + if self.code.is_empty() { + return html! { +

+ {"Enter some Nix code above to get started. Don't know Nix yet? "} + {"Check out "} + {"nix-1p"} + {"!"} +

+ }; + } + + html! { + <> +

{"Result:"}

+ {eval(&self.code).display()} + } } } -- cgit 1.4.1