Skip to content

Commit 0d2add4

Browse files
committed
Update grille_pain for Sketch 4.0.0
1 parent f76159b commit 0d2add4

33 files changed

+465
-394
lines changed

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 80,
3+
"semi": false,
4+
"singleQuote": true,
5+
"arrowParens": "avoid",
6+
"trailingComma": "es5",
7+
"proseWrap": "always"
8+
}

e2e/demo/gleam.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ version = "1.0.0"
1414
# https://gleam.run/writing-gleam/gleam-toml/.
1515

1616
[dependencies]
17-
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
17+
gleam_stdlib = ">= 0.54.0 and < 1.0.0"
1818
grille_pain = {path = "../.."}
19-
lustre = ">= 4.4.3 and < 5.0.0"
20-
sketch = ">= 3.0.2 and < 4.0.0"
21-
sketch_lustre = ">= 1.0.1 and < 2.0.0"
22-
pprint = ">= 1.0.3 and < 2.0.0"
19+
lustre = ">= 4.6.3 and < 5.0.0"
20+
sketch = ">= 4.0.0 and < 5.0.0"
21+
sketch_lustre = ">= 2.0.0 and < 3.0.0"
2322

2423
[dev-dependencies]
25-
gleeunit = ">= 1.0.0 and < 2.0.0"
26-
lustre_dev_tools = ">= 1.5.4 and < 2.0.0"
24+
gleeunit = ">= 1.3.0 and < 2.0.0"
25+
lustre_dev_tools = ">= 1.6.5 and < 2.0.0"

e2e/demo/manifest.toml

Lines changed: 34 additions & 39 deletions
Large diffs are not rendered by default.

e2e/demo/src/demo.gleam

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import gleam/list
33
import gleam/pair
44
import gleam/result
55
import grille_pain
6-
import grille_pain/internals/view/colors
6+
import grille_pain/internals/view/theme
77
import grille_pain/lustre/toast
88
import grille_pain/toast/level
99
import layout
@@ -35,10 +35,9 @@ pub type Msg {
3535
pub fn main() {
3636
let init = fn(_) { #(Model(timeout: 0, stickys: []), effect.none()) }
3737
let assert Ok(_) = grille_pain.simple()
38-
let assert Ok(cache) = sketch.cache(strategy: sketch.Ephemeral)
38+
let assert Ok(stylesheet) = sketch.stylesheet(strategy: sketch.Ephemeral)
3939
let assert Ok(_) =
40-
view
41-
|> sketch_lustre.compose(sketch_lustre.node(), _, cache)
40+
view(_, stylesheet)
4241
|> lustre.application(init, update, _)
4342
|> lustre.start("#app", Nil)
4443
}
@@ -101,31 +100,31 @@ fn simple_toasts() {
101100
]),
102101
layout.actions_wrapper([], [
103102
layout.toast_button(
104-
colors.light,
103+
theme.light,
105104
layout.palette.black,
106105
[event.on_click(DisplayBasicToast("Toast", toast.toast))],
107106
[html.text("Toast")],
108107
),
109108
layout.toast_button(
110-
colors.success,
109+
theme.success,
111110
layout.palette.white,
112111
[event.on_click(DisplayBasicToast("Success", toast.success))],
113112
[html.text("Success")],
114113
),
115114
layout.toast_button(
116-
colors.info,
115+
theme.info,
117116
layout.palette.white,
118117
[event.on_click(DisplayBasicToast("Info", toast.info))],
119118
[html.text("Info")],
120119
),
121120
layout.toast_button(
122-
colors.warning,
121+
theme.warning,
123122
layout.palette.white,
124123
[event.on_click(DisplayBasicToast("Warning", toast.warning))],
125124
[html.text("Warning")],
126125
),
127126
layout.toast_button(
128-
colors.error,
127+
theme.error,
129128
layout.palette.white,
130129
[event.on_click(DisplayBasicToast("Error", toast.error))],
131130
[html.text("Error")],
@@ -157,31 +156,31 @@ fn custom_toasts(model: Model) {
157156
]),
158157
layout.actions_wrapper([], [
159158
layout.toast_button(
160-
colors.light,
159+
theme.light,
161160
layout.palette.black,
162161
[event.on_click(DisplayCustomToast(level.Standard))],
163162
[html.text("Toast")],
164163
),
165164
layout.toast_button(
166-
colors.success,
165+
theme.success,
167166
layout.palette.white,
168167
[event.on_click(DisplayCustomToast(level.Success))],
169168
[html.text("Success")],
170169
),
171170
layout.toast_button(
172-
colors.info,
171+
theme.info,
173172
layout.palette.white,
174173
[event.on_click(DisplayCustomToast(level.Info))],
175174
[html.text("Info")],
176175
),
177176
layout.toast_button(
178-
colors.warning,
177+
theme.warning,
179178
layout.palette.white,
180179
[event.on_click(DisplayCustomToast(level.Warning))],
181180
[html.text("Warning")],
182181
),
183182
layout.toast_button(
184-
colors.error,
183+
theme.error,
185184
layout.palette.white,
186185
[event.on_click(DisplayCustomToast(level.Error))],
187186
[html.text("Error")],
@@ -200,31 +199,31 @@ fn sticky_toasts() {
200199
]),
201200
layout.actions_wrapper([], [
202201
layout.toast_button(
203-
colors.light,
202+
theme.light,
204203
layout.palette.black,
205204
[event.on_click(DisplayStickyToast(level.Standard))],
206205
[html.text("Toast")],
207206
),
208207
layout.toast_button(
209-
colors.success,
208+
theme.success,
210209
layout.palette.white,
211210
[event.on_click(DisplayStickyToast(level.Success))],
212211
[html.text("Success")],
213212
),
214213
layout.toast_button(
215-
colors.info,
214+
theme.info,
216215
layout.palette.white,
217216
[event.on_click(DisplayStickyToast(level.Info))],
218217
[html.text("Info")],
219218
),
220219
layout.toast_button(
221-
colors.warning,
220+
theme.warning,
222221
layout.palette.white,
223222
[event.on_click(DisplayStickyToast(level.Warning))],
224223
[html.text("Warning")],
225224
),
226225
layout.toast_button(
227-
colors.error,
226+
theme.error,
228227
layout.palette.white,
229228
[event.on_click(DisplayStickyToast(level.Error))],
230229
[html.text("Error")],
@@ -233,7 +232,7 @@ fn sticky_toasts() {
233232
html.br_([]),
234233
layout.actions_wrapper([], [
235234
layout.toast_button(
236-
colors.error,
235+
theme.error,
237236
layout.palette.white,
238237
[event.on_click(HideStickyToasts)],
239238
[html.text("Hide sticky toasts")],
@@ -242,7 +241,8 @@ fn sticky_toasts() {
242241
])
243242
}
244243

245-
fn view(model: Model) {
244+
fn view(model: Model, stylesheet: sketch.StyleSheet) {
245+
use <- sketch_lustre.render(stylesheet, in: [sketch_lustre.node()])
246246
layout.body([], [
247247
layout.main([], [
248248
header(),

e2e/demo/src/layout.gleam

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import sketch as s
1+
import sketch/css
2+
import sketch/css/length.{px, vh}
23
import sketch/lustre/element/html
3-
import sketch/size.{px, vh}
44

55
pub type Palette {
66
Palette(
@@ -35,85 +35,86 @@ pub const palette = Palette(
3535
pub fn body(attributes, children) {
3636
let font_family =
3737
"-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif"
38-
s.class([
39-
s.color(palette.black),
40-
s.font_family(font_family),
41-
s.min_height(vh(100)),
42-
s.margin(px(-10)),
43-
s.background(palette.aged_plastic_yellow),
44-
s.display("flex"),
45-
s.flex_direction("column"),
46-
s.justify_content("center"),
38+
css.class([
39+
css.color(palette.black),
40+
css.font_family(font_family),
41+
css.min_height(vh(100)),
42+
css.margin(px(-10)),
43+
css.background(palette.aged_plastic_yellow),
44+
css.display("flex"),
45+
css.flex_direction("column"),
46+
css.justify_content("center"),
4747
])
4848
|> html.div(attributes, children)
4949
}
5050

5151
pub fn main(attributes, children) {
52-
s.class([
53-
s.padding(px(24)),
54-
s.max_width(px(700)),
55-
s.margin_("0 auto"),
56-
s.display("flex"),
57-
s.flex_direction("column"),
58-
s.gap(px(48)),
52+
css.class([
53+
css.padding(px(24)),
54+
css.max_width(px(700)),
55+
css.margin_("0 auto"),
56+
css.display("flex"),
57+
css.flex_direction("column"),
58+
css.gap(px(48)),
5959
])
6060
|> html.main(attributes, children)
6161
}
6262

6363
pub fn lucy(attributes) {
64-
html.img(s.class([s.width(px(60))]), attributes)
64+
html.img(css.class([css.width(px(60))]), attributes)
6565
}
6666

6767
pub fn header_wrapper(attributes, children) {
68-
s.class([s.display("flex"), s.gap(px(12)), s.align_items("center")])
68+
css.class([css.display("flex"), css.gap(px(12)), css.align_items("center")])
6969
|> html.div(attributes, children)
7070
}
7171

7272
pub fn title_wrapper(attributes, children) {
73-
s.class([s.display("flex"), s.flex_direction("column"), s.gap(px(6))])
73+
css.class([css.display("flex"), css.flex_direction("column"), css.gap(px(6))])
7474
|> html.div(attributes, children)
7575
}
7676

7777
pub fn title(attributes, children) {
78-
s.class([s.font_weight("600"), s.font_size(px(24))])
78+
css.class([css.font_weight("600"), css.font_size(px(24))])
7979
|> html.div(attributes, children)
8080
}
8181

8282
pub fn subtitle(attributes, children) {
83-
s.class([s.font_weight("500"), s.color(palette.underwater_blue)])
83+
css.class([css.font_weight("500"), css.color(palette.underwater_blue)])
8484
|> html.div(attributes, children)
8585
}
8686

8787
pub fn actions_wrapper(attributes, children) {
88-
html.div(s.class([s.display("flex"), s.gap(px(12))]), attributes, children)
88+
css.class([css.display("flex"), css.gap(px(12))])
89+
|> html.div(attributes, children)
8990
}
9091

9192
pub fn toast_button(background, color, attributes, children) {
92-
s.class([
93-
s.font_family("inherit"),
94-
s.cursor("pointer"),
95-
s.appearance("none"),
96-
s.background(background),
97-
s.border("none"),
98-
s.color(color),
99-
s.font_size(px(20)),
100-
s.padding_("12px 24px"),
101-
s.border_radius(px(10)),
102-
s.font_weight("600"),
103-
s.box_shadow("2px 2px 2px 1px #bbb"),
104-
s.transition(".3s box-shadow"),
105-
s.active([s.box_shadow("inset 2px 2px 5px 1px #aaa")]),
93+
css.class([
94+
css.font_family("inherit"),
95+
css.cursor("pointer"),
96+
css.appearance("none"),
97+
css.background(background),
98+
css.border("none"),
99+
css.color(color),
100+
css.font_size(px(20)),
101+
css.padding_("12px 24px"),
102+
css.border_radius(px(10)),
103+
css.font_weight("600"),
104+
css.box_shadow("2px 2px 2px 1px #bbb"),
105+
css.transition(".3s box-shadow"),
106+
css.active([css.box_shadow("inset 2px 2px 5px 1px #aaa")]),
106107
])
107108
|> html.button(attributes, children)
108109
}
109110

110111
pub fn section(attributes, children) {
111-
s.class([s.display("flex"), s.flex_direction("column"), s.gap(px(12))])
112+
css.class([css.display("flex"), css.flex_direction("column"), css.gap(px(12))])
112113
|> html.section(attributes, children)
113114
}
114115

115116
pub fn section_title(attributes, children) {
116-
s.class([s.font_size(size.rem(1.05)), s.font_weight("600")])
117+
css.class([css.font_size(length.rem(1.05)), css.font_weight("600")])
117118
|> html.h2(attributes, children)
118119
}
119120

gleam.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ name = "grille_pain"
22
target = "javascript"
33
version = "1.1.0"
44

5+
gleam = ">= 1.8.0"
6+
57
description = "Toaster, made in lustre, for gleam"
68
internal_modules = ["grille_pain/internals", "grille_pain/internals/*"]
79
licences = ["MIT"]
810
links = [{title = "Sponsor", href = "https://github.com/sponsors/ghivert"}]
911
repository = {type = "github", user = "ghivert", repo = "grille-pain"}
1012

1113
[dependencies]
12-
birl = ">= 1.6.1 and < 2.0.0"
13-
gleam_stdlib = ">= 0.36.0 and < 1.0.0"
14-
lustre = ">= 4.4.4 and < 5.0.0"
15-
sketch = ">= 3.0.2 and < 4.0.0"
16-
sketch_lustre = ">= 1.0.0 and < 2.0.0"
17-
plinth = ">= 0.4.12 and < 1.0.0"
14+
birl = ">= 1.8.0 and < 2.0.0"
15+
gleam_stdlib = ">= 0.54.0 and < 1.0.0"
16+
lustre = ">= 4.6.3 and < 5.0.0"
17+
sketch = ">= 4.0.0 and < 5.0.0"
18+
sketch_lustre = ">= 2.0.0 and < 3.0.0"
1819

1920
[dev-dependencies]
2021
gleeunit = ">= 1.1.2 and < 2.0.0"

manifest.toml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,24 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" },
6-
{ name = "conversation", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "conversation", source = "hex", outer_checksum = "908B46F60444442785A495197D482558AD8B849C3714A38FAA1940358CC8CCCD" },
7-
{ name = "gleam_erlang", version = "0.28.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "BE551521F708DCE5CB954AFBBDF08519C1C44986521FD40753608825F48FFA9E" },
8-
{ name = "gleam_http", version = "3.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "EA66440C2269F7CED0F6845E5BD0DB68095775D627FA709A841CA78A398D6D56" },
9-
{ name = "gleam_javascript", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "F98328FCF573DA6F3A35D7F6CB3F9FF19FD5224CCBA9151FCBEAA0B983AF2F58" },
10-
{ name = "gleam_json", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "CB10B0E7BF44282FB25162F1A24C1A025F6B93E777CCF238C4017E4EEF2CDE97" },
11-
{ name = "gleam_otp", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "F7EA44C81679B2A6032FF1B3851F0EFB43F4F1F1CAC616CB7F4A18497F39FAB9" },
12-
{ name = "gleam_stdlib", version = "0.41.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1B2F80CB1B66B027E3198A2FF71EF3F2F31DF89ED97AD606F25FD387A4C3C1EF" },
13-
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
14-
{ name = "lustre", version = "4.6.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "486C3CFBD126939CAD2CA8B92A979A2DAADA5BABAA62BF2B163CD21E257BD4A1" },
15-
{ name = "plinth", version = "0.5.0", build_tools = ["gleam"], requirements = ["conversation", "gleam_javascript", "gleam_json", "gleam_stdlib"], otp_app = "plinth", source = "hex", outer_checksum = "9B0ECC110316F55432DC544847B7F4E98B73D3F598CB3EE844570FB1EFB3F8BE" },
16-
{ name = "ranger", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "1566C272B1D141B3BBA38B25CB761EF56E312E79EC0E2DFD4D3C19FB0CC1F98C" },
17-
{ name = "sketch", version = "3.1.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "sketch", source = "hex", outer_checksum = "6CBFAAA92C37F1F44FC552FD9E9DAC34598BDEB5F873B6191C696DC67D85AD00" },
18-
{ name = "sketch_lustre", version = "1.0.3", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "plinth", "sketch"], otp_app = "sketch_lustre", source = "hex", outer_checksum = "DD5437B10D4BB8AB45A19820B17883188B8568B6ED7885D7D073A983F4984E79" },
5+
{ name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
6+
{ name = "gleam_erlang", version = "0.34.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C38F2A128BAA0CEF17C3000BD2097EB80634E239CE31A86400C4416A5D0FDCC" },
7+
{ name = "gleam_json", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C55C5C2B318533A8072D221C5E06E5A75711C129E420DD1CE463342106012E5D" },
8+
{ name = "gleam_otp", version = "0.16.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "50DA1539FC8E8FA09924EB36A67A2BBB0AD6B27BCDED5A7EF627057CF69D035E" },
9+
{ name = "gleam_regexp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "7F5E0C0BBEB3C58E57C9CB05FA9002F970C85AD4A63BA1E55CBCB35C15809179" },
10+
{ name = "gleam_stdlib", version = "0.54.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "723BA61A2BAE8D67406E59DD88CEA1B3C3F266FC8D70F64BE9FEC81B4505B927" },
11+
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
12+
{ name = "gleeunit", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "0E6C83834BA65EDCAAF4FE4FB94AC697D9262D83E6F58A750D63C9F6C8A9D9FF" },
13+
{ name = "lustre", version = "4.6.3", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "BDF833368F6C8F152F948D5B6A79866E9881CB80CB66C0685B3327E7DCBFB12F" },
14+
{ name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
15+
{ name = "sketch", version = "4.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "sketch", source = "hex", outer_checksum = "AF090E77F6FD02467DABD8F0EDC1C329482853698FE6DB33B86D7D05C1BE32F4" },
16+
{ name = "sketch_lustre", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "sketch"], otp_app = "sketch_lustre", source = "hex", outer_checksum = "7F8CE798F2D3989D45DA4D4EDF0ABCE7EB84F5E6236A7C2F5A3AE8095FC9DDFF" },
1917
]
2018

2119
[requirements]
22-
birl = { version = ">= 1.6.1 and < 2.0.0" }
23-
gleam_stdlib = { version = ">= 0.36.0 and < 1.0.0" }
20+
birl = { version = ">= 1.8.0 and < 2.0.0" }
21+
gleam_stdlib = { version = ">= 0.54.0 and < 1.0.0" }
2422
gleeunit = { version = ">= 1.1.2 and < 2.0.0" }
25-
lustre = { version = ">= 4.4.4 and < 5.0.0" }
26-
plinth = { version = ">= 0.4.12 and < 1.0.0" }
27-
sketch = { version = ">= 3.0.2 and < 4.0.0" }
28-
sketch_lustre = { version = ">= 1.0.0 and < 2.0.0" }
23+
lustre = { version = ">= 4.6.3 and < 5.0.0" }
24+
sketch = { version = ">= 4.0.0 and < 5.0.0" }
25+
sketch_lustre = { version = ">= 2.0.0 and < 3.0.0" }

0 commit comments

Comments
 (0)