Skip to content

Commit 80169bd

Browse files
committed
Remove Sketch dependency
1 parent 766d539 commit 80169bd

File tree

19 files changed

+156
-181
lines changed

19 files changed

+156
-181
lines changed

e2e/demo/manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ packages = [
2525
{ name = "glint", version = "1.2.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "2214C7CEFDE457CEE62140C3D4899B964E05236DA74E4243DFADF4AF29C382BB" },
2626
{ name = "glisten", version = "7.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "1A53CF9FB3231A93FF7F1BD519A43DC968C1722F126CDD278403A78725FC5189" },
2727
{ name = "gramps", version = "3.0.1", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "59194B3980110B403EE6B75330DB82CDE05FC8138491C2EAEACBC7AAEF30B2E8" },
28-
{ name = "grille_pain", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "sketch", "sketch_lustre"], source = "local", path = "../.." },
28+
{ name = "grille_pain", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre"], source = "local", path = "../.." },
2929
{ name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" },
3030
{ name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" },
3131
{ name = "lustre", version = "4.6.4", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "CC59564624A4A1D855B5FEB55D979A072B328D0368E82A1639F180840D6288E9" },

e2e/demo/src/demo.gleam

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import gleam/list
33
import gleam/pair
44
import gleam/result
55
import grille_pain
6-
import grille_pain/internals/view/theme
76
import grille_pain/lustre/toast
87
import grille_pain/toast/level
98
import layout
@@ -106,31 +105,31 @@ fn simple_toasts() {
106105
]),
107106
layout.actions_wrapper([], [
108107
layout.toast_button(
109-
theme.light,
108+
"#fff",
110109
layout.palette.black,
111110
[event.on_click(DisplayBasicToast("Toast", toast.toast))],
112111
[html.text("Toast")],
113112
),
114113
layout.toast_button(
115-
theme.success,
114+
"#07bc0c",
116115
layout.palette.white,
117116
[event.on_click(DisplayBasicToast("Success", toast.success))],
118117
[html.text("Success")],
119118
),
120119
layout.toast_button(
121-
theme.info,
120+
"#3498db",
122121
layout.palette.white,
123122
[event.on_click(DisplayBasicToast("Info", toast.info))],
124123
[html.text("Info")],
125124
),
126125
layout.toast_button(
127-
theme.warning,
126+
"#f1c40f",
128127
layout.palette.white,
129128
[event.on_click(DisplayBasicToast("Warning", toast.warning))],
130129
[html.text("Warning")],
131130
),
132131
layout.toast_button(
133-
theme.error,
132+
"#e74c3c",
134133
layout.palette.white,
135134
[event.on_click(DisplayBasicToast("Error", toast.error))],
136135
[html.text("Error")],
@@ -162,31 +161,31 @@ fn custom_toasts(model: Model) {
162161
]),
163162
layout.actions_wrapper([], [
164163
layout.toast_button(
165-
theme.light,
164+
"#fff",
166165
layout.palette.black,
167166
[event.on_click(DisplayCustomToast(level.Standard))],
168167
[html.text("Toast")],
169168
),
170169
layout.toast_button(
171-
theme.success,
170+
"#07bc0c",
172171
layout.palette.white,
173172
[event.on_click(DisplayCustomToast(level.Success))],
174173
[html.text("Success")],
175174
),
176175
layout.toast_button(
177-
theme.info,
176+
"#3498db",
178177
layout.palette.white,
179178
[event.on_click(DisplayCustomToast(level.Info))],
180179
[html.text("Info")],
181180
),
182181
layout.toast_button(
183-
theme.warning,
182+
"#f1c40f",
184183
layout.palette.white,
185184
[event.on_click(DisplayCustomToast(level.Warning))],
186185
[html.text("Warning")],
187186
),
188187
layout.toast_button(
189-
theme.error,
188+
"#e74c3c",
190189
layout.palette.white,
191190
[event.on_click(DisplayCustomToast(level.Error))],
192191
[html.text("Error")],
@@ -205,31 +204,31 @@ fn sticky_toasts() {
205204
]),
206205
layout.actions_wrapper([], [
207206
layout.toast_button(
208-
theme.light,
207+
"#fff",
209208
layout.palette.black,
210209
[event.on_click(DisplayStickyToast(level.Standard))],
211210
[html.text("Toast")],
212211
),
213212
layout.toast_button(
214-
theme.success,
213+
"#07bc0c",
215214
layout.palette.white,
216215
[event.on_click(DisplayStickyToast(level.Success))],
217216
[html.text("Success")],
218217
),
219218
layout.toast_button(
220-
theme.info,
219+
"#3498db",
221220
layout.palette.white,
222221
[event.on_click(DisplayStickyToast(level.Info))],
223222
[html.text("Info")],
224223
),
225224
layout.toast_button(
226-
theme.warning,
225+
"#f1c40f",
227226
layout.palette.white,
228227
[event.on_click(DisplayStickyToast(level.Warning))],
229228
[html.text("Warning")],
230229
),
231230
layout.toast_button(
232-
theme.error,
231+
"#e74c3c",
233232
layout.palette.white,
234233
[event.on_click(DisplayStickyToast(level.Error))],
235234
[html.text("Error")],
@@ -238,7 +237,7 @@ fn sticky_toasts() {
238237
html.br_([]),
239238
layout.actions_wrapper([], [
240239
layout.toast_button(
241-
theme.error,
240+
"#e74c3c",
242241
layout.palette.white,
243242
[event.on_click(HideStickyToasts)],
244243
[html.text("Hide sticky toasts")],

gleam.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ repository = {type = "github", user = "ghivert", repo = "grille-pain"}
1313
[dependencies]
1414
gleam_stdlib = ">= 0.54.0 and < 1.0.0"
1515
lustre = ">= 4.5.0 and < 5.0.0"
16-
sketch = ">= 4.0.0 and < 5.0.0"
17-
sketch_lustre = ">= 2.0.0 and < 3.0.0"
1816

1917
[dev-dependencies]
2018
gleeunit = ">= 1.0.0 and < 2.0.0"

manifest.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ packages = [
88
{ name = "gleam_stdlib", version = "0.58.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "091F2D2C4A3A4E2047986C47E2C2C9D728A4E068ABB31FDA17B0D347E6248467" },
99
{ name = "gleeunit", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "0E6C83834BA65EDCAAF4FE4FB94AC697D9262D83E6F58A750D63C9F6C8A9D9FF" },
1010
{ name = "lustre", version = "4.6.4", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "CC59564624A4A1D855B5FEB55D979A072B328D0368E82A1639F180840D6288E9" },
11-
{ name = "sketch", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "sketch", source = "hex", outer_checksum = "AF090E77F6FD02467DABD8F0EDC1C329482853698FE6DB33B86D7D05C1BE32F4" },
12-
{ name = "sketch_lustre", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "sketch"], otp_app = "sketch_lustre", source = "hex", outer_checksum = "7F8CE798F2D3989D45DA4D4EDF0ABCE7EB84F5E6236A7C2F5A3AE8095FC9DDFF" },
1311
]
1412

1513
[requirements]
1614
gleam_stdlib = { version = ">= 0.54.0 and < 1.0.0" }
1715
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
1816
lustre = { version = ">= 4.5.0 and < 5.0.0" }
19-
sketch = { version = ">= 4.0.0 and < 5.0.0" }
20-
sketch_lustre = { version = ">= 2.0.0 and < 3.0.0" }

src/grille_pain.gleam

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import grille_pain/internals/data/model.{type Model, Model}
1515
import grille_pain/internals/data/msg.{type Msg}
1616
import grille_pain/internals/data/toast
1717
import grille_pain/internals/effect_manager
18+
import grille_pain/internals/global
1819
import grille_pain/internals/lustre/schedule.{schedule}
1920
import grille_pain/internals/setup
21+
import grille_pain/internals/view
2022
import grille_pain/options.{type Options}
2123
import lustre
2224
import lustre/effect
@@ -26,10 +28,9 @@ import lustre/effect
2628
/// Use `grille_pain/options` to provide and customise options.
2729
pub fn setup(opts: Options) {
2830
use #(lustre_root, shadow) <- result.try(setup.mount())
29-
use view <- result.try(setup.view(shadow))
3031
use dispatcher <- result.map({
3132
fn(_) { #(model.new(shadow, opts.timeout), effect.none()) }
32-
|> lustre.application(update, view)
33+
|> lustre.application(update, view.view)
3334
|> lustre.start(lustre_root, Nil)
3435
|> error.lustre
3536
})
@@ -149,7 +150,7 @@ fn update_display(model: Model) {
149150
use dispatch <- effect.from()
150151
dispatch({
151152
msg.LustreRequestedAnimationFrame({
152-
use <- request_animation_frame()
153+
use <- global.request_animation_frame()
153154
dispatch(msg.BrowserUpdatedToasts)
154155
})
155156
})
@@ -164,13 +165,10 @@ fn update_toasts(model: Model) {
164165
use dispatch <- effect.from()
165166
dispatch({
166167
msg.LustreRequestedAnimationFrame({
167-
use <- request_animation_frame()
168+
use <- global.request_animation_frame()
168169
dispatch(msg.LustreComputedToasts)
169170
})
170171
})
171172
}
172173
}
173174
}
174-
175-
@external(javascript, "./global.ffi.mjs", "requestAnimationFrame")
176-
fn request_animation_frame(next: fn() -> Nil) -> model.AnimationFrame

src/grille_pain/error.gleam

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import gleam/result
22
import lustre
3-
import sketch/error
43

54
pub type GrillePainError {
6-
SketchError(error.SketchError)
75
LustreError(lustre.Error)
86
ContextError(String)
97
}
108

11-
pub fn sketch(res: Result(a, error.SketchError)) {
12-
result.map_error(res, SketchError)
13-
}
14-
159
pub fn lustre(res: Result(a, lustre.Error)) {
1610
result.map_error(res, LustreError)
1711
}

src/grille_pain/internals/data/model.gleam

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ import grille_pain/internals/global
55
import grille_pain/internals/shadow.{type Shadow}
66
import grille_pain/toast/level.{type Level}
77

8-
pub type AnimationFrame
9-
108
pub type Model {
119
Model(
1210
toasts: List(Toast),
1311
id: Int,
1412
timeout: Int,
1513
root: Shadow,
16-
next_frame: Option(AnimationFrame),
14+
next_frame: Option(global.AnimationFrame),
1715
to_show: List(ToShow),
1816
)
1917
}

src/grille_pain/internals/data/msg.gleam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import gleam/option.{type Option}
2-
import grille_pain/internals/data/model
2+
import grille_pain/internals/global
33
import grille_pain/toast/level.{type Level}
44

55
pub type Msg {
66
BrowserUpdatedToasts
77
LustreComputedToasts
8-
LustreRequestedAnimationFrame(model.AnimationFrame)
8+
LustreRequestedAnimationFrame(global.AnimationFrame)
99
ToastHidDisplay(id: Int)
1010
ToastTimedOut(id: Int, iteration: Int)
1111
UserAddedToast(
File renamed without changes.

src/grille_pain/internals/data/toast.gleam

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,21 @@ pub fn by_iteration(toast: Toast, id: Int, iteration: Int) {
6969
toast.id == id && toast.iteration == iteration
7070
}
7171

72-
@external(javascript, "../../../toast.ffi.mjs", "computeToastSize")
72+
@external(javascript, "./toast.ffi.mjs", "computeToastSize")
7373
pub fn compute_size(_id: Int, _root: Shadow) -> Int {
7474
// That function can probably never be reached, since `grille_paint` will
7575
// never be instanciated on the BEAM.
7676
0
7777
}
7878

79-
@external(javascript, "../../../toast.ffi.mjs", "computeBottomPosition")
79+
@external(javascript, "./toast.ffi.mjs", "computeBottomPosition")
8080
pub fn compute_bottom_position(_root: Shadow, _id: Int) -> Int {
8181
// That function can probably never be reached, since `grille_paint` will
8282
// never be instanciated on the BEAM.
8383
0
8484
}
85+
86+
@external(javascript, "./toast.ffi.mjs", "uuid")
87+
pub fn uuid() -> String {
88+
""
89+
}

0 commit comments

Comments
 (0)