Skip to content

Commit b4ee977

Browse files
Merge pull request #50 from andrewMacmurray/cleanup-examples
Cleanup examples
2 parents f8d9532 + b68bec3 commit b4ee977

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2584
-2505
lines changed

examples/dom-operations/package-lock.json

Lines changed: 183 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/dom-operations/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6+
"type": "module",
67
"scripts": {
78
"start": "vite"
89
},
910
"author": "",
1011
"license": "ISC",
1112
"devDependencies": {
12-
"vite": "6.0.9",
13+
"vite": "^7.3.0",
1314
"vite-plugin-elm": "^3.0.1"
1415
}
1516
}

examples/dom-operations/src/Main.elm

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import Browser
44
import Browser.Dom as Dom
55
import ConcurrentTask exposing (ConcurrentTask)
66
import ConcurrentTask.Browser.Dom
7-
import Html exposing (Html, button, div, input, p, text)
8-
import Html.Attributes exposing (class, id)
7+
import Html as H exposing (Html)
8+
import Html.Attributes as A
99
import Html.Events exposing (onClick)
1010
import Json.Decode as Decode
1111

@@ -222,33 +222,49 @@ port receive : (Decode.Value -> msg) -> Sub msg
222222

223223
view : Model -> Html Msg
224224
view model =
225-
div [ class "row" ]
226-
[ input [ id "input" ] []
227-
, div [ class "box", id "box" ] [ text "What size am i?" ]
228-
, div [ class "scrolly-box", id "scrolly-box" ]
229-
[ text "Scroll mee!!"
230-
, p [] [ text "..." ]
231-
, p [] [ text "..." ]
232-
, p [] [ text "..." ]
233-
, p [] [ text "..." ]
234-
, p [] [ text "..." ]
235-
, p [] [ text "..." ]
225+
H.div
226+
[ A.class "col gap-xs pa-s"
227+
, A.style "max-width" "800px"
228+
]
229+
[ H.input [ A.id "input" ] []
230+
, H.div
231+
[ A.class "pa-s"
232+
, A.style "background-color" "dodgerblue"
233+
, A.style "color" "white"
234+
, A.id "box"
235+
]
236+
[ H.text "What size am i?" ]
237+
, H.div
238+
[ A.class "pa-s"
239+
, A.style "width" "100px"
240+
, A.style "height" "100px"
241+
, A.style "background-color" "cornflowerblue"
242+
, A.style "overflow-y" "scroll"
243+
, A.id "scrolly-box"
244+
]
245+
[ H.text "Scroll mee!!"
246+
, H.p [] [ H.text "..." ]
247+
, H.p [] [ H.text "..." ]
248+
, H.p [] [ H.text "..." ]
249+
, H.p [] [ H.text "..." ]
250+
, H.p [] [ H.text "..." ]
251+
, H.p [] [ H.text "..." ]
236252
]
237253
, showViewport model
238254
, showWindowViewport model
239255
, showElement model
240-
, div [ class "buttons" ]
241-
[ button [ onClick FocusClicked ] [ text "Focus the Input" ]
242-
, button [ onClick BlurClicked ] [ text "Blur the Input" ]
256+
, H.div [ A.class "row gap-xs" ]
257+
[ H.button [ onClick FocusClicked ] [ H.text "Focus the Input" ]
258+
, H.button [ onClick BlurClicked ] [ H.text "Blur the Input" ]
243259
]
244-
, div [ class "buttons" ]
245-
[ button [ onClick SetViewportOfElementClicked ] [ text "Scroll top of the scroll box" ]
246-
, button [ onClick ScrollTopClicked ] [ text "Scroll Window to Top" ]
260+
, H.div [ A.class "row gap-xs" ]
261+
[ H.button [ onClick SetViewportOfElementClicked ] [ H.text "Scroll top of the scroll box" ]
262+
, H.button [ onClick ScrollTopClicked ] [ H.text "Scroll Window to Top" ]
247263
]
248-
, div [ class "buttons" ]
249-
[ button [ onClick GetBoxViewportClicked ] [ text "Get Viewport of the blue box" ]
250-
, button [ onClick GetWindowViewportClicked ] [ text "Get Window Viewport" ]
251-
, button [ onClick GetElementClicked ] [ text "Get Element size of the blue box" ]
264+
, H.div [ A.class "row gap-xs" ]
265+
[ H.button [ onClick GetBoxViewportClicked ] [ H.text "Get Viewport of the blue box" ]
266+
, H.button [ onClick GetWindowViewportClicked ] [ H.text "Get Window Viewport" ]
267+
, H.button [ onClick GetElementClicked ] [ H.text "Get Element size of the blue box" ]
252268
]
253269
]
254270

@@ -257,36 +273,36 @@ showViewport : Model -> Html msg
257273
showViewport model =
258274
case model.foundViewport of
259275
Nothing ->
260-
text ""
276+
H.text ""
261277

262278
Just vp ->
263-
div []
264-
[ div [] [ text "Found blue box viewport!" ]
265-
, div [] [ text (Debug.toString vp) ]
279+
H.div []
280+
[ H.div [] [ H.text "Found blue box viewport!" ]
281+
, H.div [] [ H.text (Debug.toString vp) ]
266282
]
267283

268284

269285
showWindowViewport : Model -> Html msg
270286
showWindowViewport model =
271287
case model.foundWindowViewport of
272288
Nothing ->
273-
text ""
289+
H.text ""
274290

275291
Just vp ->
276-
div []
277-
[ div [] [ text "Found window viewport!" ]
278-
, div [] [ text (Debug.toString vp) ]
292+
H.div []
293+
[ H.div [] [ H.text "Found window viewport!" ]
294+
, H.div [] [ H.text (Debug.toString vp) ]
279295
]
280296

281297

282298
showElement : Model -> Html msg
283299
showElement model =
284300
case model.foundElement of
285301
Nothing ->
286-
text ""
302+
H.text ""
287303

288304
Just vp ->
289-
div []
290-
[ div [] [ text "Found blue box element size!" ]
291-
, div [] [ text (Debug.toString vp) ]
305+
H.div []
306+
[ H.div [] [ H.text "Found blue box element size!" ]
307+
, H.div [] [ H.text (Debug.toString vp) ]
292308
]
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
76
<title>Browser Tasks</title>
8-
<link href="./style.css" rel="stylesheet">
9-
</head>
7+
</head>
108

11-
<body>
9+
<body>
1210
<main></main>
1311
<script type="module" src="./index.ts"></script>
14-
</body>
15-
16-
</html>
12+
</body>
13+
</html>

examples/dom-operations/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import "../../util/style.css";
2+
13
import { Elm } from "./Main.elm";
24
import * as ConcurrentTask from "../../../runner";
35

examples/dom-operations/src/style.css

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { defineConfig } from "vite";
22
import elmPlugin from "vite-plugin-elm";
3+
import { customLogger } from "../util/vite-logger";
34

45
export default defineConfig({
56
root: "./src",
67
plugins: [elmPlugin()],
8+
customLogger,
79
});

examples/localstorage-fruit-trees/elm.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"elm/browser": "1.0.2",
1111
"elm/core": "1.0.5",
1212
"elm/html": "1.0.0",
13-
"elm/json": "1.1.3",
14-
"mdgriffith/elm-ui": "1.1.8"
13+
"elm/json": "1.1.3"
1514
},
1615
"indirect": {
1716
"elm/time": "1.0.0",

0 commit comments

Comments
 (0)