Skip to content

Commit

Permalink
fix: override of default timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Hivert <[email protected]>
  • Loading branch information
ghivert committed May 20, 2024
1 parent db63175 commit 3a9f1fd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/grille_pain/internals/data/model.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 7 additions & 13 deletions src/grille_pain/internals/view/progress_bar.gleam
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand All @@ -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_, _)
Expand Down
2 changes: 0 additions & 2 deletions src/grille_pain/lustre/toast.gleam
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import gleam/io
import grille_pain/toast
import lustre/effect

Expand Down Expand Up @@ -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)
}
2 changes: 0 additions & 2 deletions src/grille_pain/toast.gleam
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -61,6 +60,5 @@ pub fn warning(content: String) {
}

pub fn custom(options: Options, content: String) {
io.debug("there ?")
dispatch_toast(options, content)
}

0 comments on commit 3a9f1fd

Please sign in to comment.