Add lustre start
This commit is contained in:
parent
f824ab7fc2
commit
d21a5fb99f
6 changed files with 101 additions and 1 deletions
|
@ -8,3 +8,4 @@ gleam_http = "~> 3.5"
|
|||
gleam_json = "~> 0.6.0"
|
||||
gleam_javascript = "~> 0.6.0"
|
||||
gleam_fetch = "~> 0.2.0"
|
||||
lustre = "~> 3.0"
|
||||
|
|
1
index.html
Symbolic link
1
index.html
Symbolic link
|
@ -0,0 +1 @@
|
|||
build/dev/javascript/geo_therminator/priv/index.html
|
|
@ -2,11 +2,12 @@
|
|||
# You typically do not need to edit this file
|
||||
|
||||
packages = [
|
||||
{ name = "gleam_fetch", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "D0C9E9CAE8D6EFCCC3A9FF817DCA9ED327097222086D91DE4F6CA8FBAB02D79F" },
|
||||
{ name = "gleam_fetch", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_http"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "D0C9E9CAE8D6EFCCC3A9FF817DCA9ED327097222086D91DE4F6CA8FBAB02D79F" },
|
||||
{ name = "gleam_http", version = "3.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "FAE9AE3EB1CA90C2194615D20FFFD1E28B630E84DACA670B28D959B37BCBB02C" },
|
||||
{ name = "gleam_javascript", version = "0.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "BFEBB63ABE4A1694E07DEFD19B160C2980304B5D775A89D4B02E7DE7C9D8008B" },
|
||||
{ name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" },
|
||||
{ name = "gleam_stdlib", version = "0.30.2", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "8D8BF3790AA31176B1E1C0B517DD74C86DA8235CF3389EA02043EE4FD82AE3DC" },
|
||||
{ name = "lustre", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "5D4938048F24F0F04EFCBF1ED62485228EBF4317F4235DB66DDBA6E1B33BAC50" },
|
||||
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
|
||||
]
|
||||
|
||||
|
@ -16,3 +17,4 @@ gleam_http = { version = "~> 3.5" }
|
|||
gleam_javascript = { version = "~> 0.6.0" }
|
||||
gleam_json = { version = "~> 0.6.0" }
|
||||
gleam_stdlib = { version = "~> 0.30" }
|
||||
lustre = { version = "~> 3.0" }
|
||||
|
|
23
priv/index.html
Normal file
23
priv/index.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>GeoTherminator</title>
|
||||
|
||||
<script type="module">
|
||||
import { main } from "./build/dev/javascript/geo_therminator/geo_t/web.mjs";
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
main();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main data-lustre-app></main>
|
||||
<noscript>Sorry mate, JavaScript is required. :/</noscript>
|
||||
</body>
|
||||
|
||||
</html>
|
27
src/geo_t/web.gleam
Normal file
27
src/geo_t/web.gleam
Normal file
|
@ -0,0 +1,27 @@
|
|||
import lustre
|
||||
import lustre/element/html.{div}
|
||||
import geo_t/config.{Config}
|
||||
import geo_t/web/login_view
|
||||
|
||||
pub fn main() {
|
||||
let app = lustre.simple(init, update, view)
|
||||
let assert Ok(_) = lustre.start(app, "[data-lustre-app]", Nil)
|
||||
|
||||
Nil
|
||||
}
|
||||
|
||||
pub type Model {
|
||||
Model(config: Config, login: login_view.Model)
|
||||
}
|
||||
|
||||
fn init(_) {
|
||||
Model(config: config.load_config(), login: login_view.init())
|
||||
}
|
||||
|
||||
fn update(model: Model, _msg) {
|
||||
model
|
||||
}
|
||||
|
||||
fn view(model: Model) {
|
||||
div([], [login_view.view(model.login)])
|
||||
}
|
46
src/geo_t/web/login_view.gleam
Normal file
46
src/geo_t/web/login_view.gleam
Normal file
|
@ -0,0 +1,46 @@
|
|||
import gleam/int
|
||||
import lustre/element.{Element}
|
||||
import lustre/element/html
|
||||
import lustre/attribute
|
||||
import lustre/event
|
||||
|
||||
pub type Model {
|
||||
Model(username: String, password: String)
|
||||
}
|
||||
|
||||
pub fn init() -> Model {
|
||||
Model("", "")
|
||||
}
|
||||
|
||||
pub type Msg {
|
||||
AttemptLogin
|
||||
}
|
||||
|
||||
pub fn update(model: Model, msg: Msg) -> Model {
|
||||
model
|
||||
}
|
||||
|
||||
pub fn view(model: Model) -> Element(Msg) {
|
||||
html.div(
|
||||
[],
|
||||
[
|
||||
html.h1([], [element.text("Log in")]),
|
||||
html.form(
|
||||
[attribute.attribute("method", "post")],
|
||||
[
|
||||
html.input([
|
||||
attribute.type_("text"),
|
||||
attribute.name("username"),
|
||||
attribute.required(True),
|
||||
]),
|
||||
html.input([
|
||||
attribute.type_("password"),
|
||||
attribute.name("password"),
|
||||
attribute.required(True),
|
||||
]),
|
||||
html.button([attribute.type_("submit")], [element.text("Log in")]),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue