From 3a9f1fd6a41e10941bd1d63aeb5022a9d6cbfc6e Mon Sep 17 00:00:00 2001 From: Guillaume Hivert Date: Mon, 20 May 2024 14:09:31 +0200 Subject: [PATCH] fix: override of default timeout Signed-off-by: Guillaume Hivert --- src/grille_pain/internals/data/model.gleam | 2 +- .../internals/view/progress_bar.gleam | 20 +++++++------------ src/grille_pain/lustre/toast.gleam | 2 -- src/grille_pain/toast.gleam | 2 -- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/grille_pain/internals/data/model.gleam b/src/grille_pain/internals/data/model.gleam index eacc13b..04bbac9 100644 --- a/src/grille_pain/internals/data/model.gleam +++ b/src/grille_pain/internals/data/model.gleam @@ -27,7 +27,7 @@ pub fn add( let new_toast = toast.new(model.id, content, level, timeout, model.root) let new_toasts = [new_toast, ..model.toasts] let new_id = model.id + 1 - Model(..model, toasts: new_toasts, id: new_id, timeout: timeout) + Model(..model, toasts: new_toasts, id: new_id) } fn update_toast(model: Model, id: Int, updater: fn(Toast) -> Toast) { diff --git a/src/grille_pain/internals/view/progress_bar.gleam b/src/grille_pain/internals/view/progress_bar.gleam index 25fda85..d7c3594 100644 --- a/src/grille_pain/internals/view/progress_bar.gleam +++ b/src/grille_pain/internals/view/progress_bar.gleam @@ -1,5 +1,5 @@ +import gleam/function import gleam/int -import gleam/io import gleam/string import grille_pain/internals/data/toast.{type Toast} import grille_pain/internals/view/colors @@ -9,16 +9,12 @@ import sketch import sketch/size.{px} pub fn view(toast: Toast) { - io.debug(toast) - html.div( - [ - pb_play_state(toast.running), - pb_background_color(toast.level), - pb_animation(toast.animation_duration), - pb_base(), - ], - [], - ) + function.flip(html.div)([], [ + pb_play_state(toast.running), + pb_background_color(toast.level), + pb_animation(toast.animation_duration), + pb_base(), + ]) } fn pb_base() { @@ -28,8 +24,6 @@ fn pb_base() { } fn pb_animation(duration: Int) { - io.debug("duration") - io.debug(duration) let duration_ = int.to_string(duration / 1000) [sketch.animation(duration_ <> "s linear 0s progress_bar")] |> sketch.dynamic("toast-duration-" <> duration_, _) diff --git a/src/grille_pain/lustre/toast.gleam b/src/grille_pain/lustre/toast.gleam index e83fff1..61c8044 100644 --- a/src/grille_pain/lustre/toast.gleam +++ b/src/grille_pain/lustre/toast.gleam @@ -1,4 +1,3 @@ -import gleam/io import grille_pain/toast import lustre/effect @@ -35,6 +34,5 @@ pub fn warning(content: String) { pub fn custom(options: toast.Options, content: String) { use _dispatch <- effect.from() - io.debug("nsauternsauitensrtaue") toast.custom(options, content) } diff --git a/src/grille_pain/toast.gleam b/src/grille_pain/toast.gleam index a396c4b..35b5117 100644 --- a/src/grille_pain/toast.gleam +++ b/src/grille_pain/toast.gleam @@ -1,4 +1,3 @@ -import gleam/io import gleam/option.{type Option, None, Some} import grille_pain/internals/data/msg import grille_pain/internals/ffi @@ -61,6 +60,5 @@ pub fn warning(content: String) { } pub fn custom(options: Options, content: String) { - io.debug("there ?") dispatch_toast(options, content) }