diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2024-01-30 20:19:56 +0000 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2024-01-30 20:19:56 +0000 |
commit | 447f12f3c4265fb4220cb70425b055101681ca56 (patch) | |
tree | e5d3a077046bac4095f06a33b1c75e992e5f0129 /examples/03-controlled-inputs | |
parent | 98ed6018a4fd16f6e3bfb95a94a2ee82af861f6c (diff) | |
download | lustre-447f12f3c4265fb4220cb70425b055101681ca56.tar.gz lustre-447f12f3c4265fb4220cb70425b055101681ca56.zip |
:recycle: Refactor some bits.
Diffstat (limited to 'examples/03-controlled-inputs')
-rw-r--r-- | examples/03-controlled-inputs/src/app.gleam | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/03-controlled-inputs/src/app.gleam b/examples/03-controlled-inputs/src/app.gleam index 8e713ea..babef7a 100644 --- a/examples/03-controlled-inputs/src/app.gleam +++ b/examples/03-controlled-inputs/src/app.gleam @@ -43,6 +43,7 @@ fn update(model: Model, msg: Msg) -> Model { case msg { GotInput(value) -> { let length = string.length(value) + case length <= model.max { True -> Model(..model, value: value, length: length) False -> model @@ -55,8 +56,9 @@ fn update(model: Model, msg: Msg) -> Model { // VIEW ------------------------------------------------------------------------ fn view(model: Model) -> Element(Msg) { - let styles = [#("width", "100vw"), #("height", "100vh")] + let styles = [#("width", "100vw"), #("height", "100vh"), #("padding", "1rem")] let length = int.to_string(model.length) + let max = int.to_string(model.max) ui.centre( [attribute.style(styles)], @@ -66,7 +68,7 @@ fn view(model: Model) -> Element(Msg) { [], [element.text("Write a message:")], ui.input([attribute.value(model.value), event.on_input(GotInput)]), - [element.text(length <> "/10")], + [element.text(length <> "/" <> max)], ), ui.button([event.on_click(Reset)], [element.text("Reset")]), ), |