Skip to content

Commit 5761176

Browse files
committed
Add instructions and scaffolding for running locally
1 parent 653a67d commit 5761176

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"serve": ".",
3+
"targets": {
4+
"Arlos Alphabitiser": {
5+
"inputs": [
6+
"src/Main.elm"
7+
],
8+
"output": "build/main.js"
9+
}
10+
}
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script src="/build/main.js"></script>
2+
<div id="root"></div>
3+
<script>
4+
var app = Elm.Main.init({ node: document.getElementById("root") });
5+
</script>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module Main exposing (Msg(..), init, main, update, view)
2+
3+
import Browser
4+
import Html exposing (Html, div, input, text)
5+
import Html.Attributes exposing (placeholder, value)
6+
import Html.Events exposing (onInput)
7+
8+
9+
10+
-- MAIN
11+
-- When you have finished this exercise, this file will be an Elm program.
12+
--
13+
-- You can copy this file to Ellie (an online Elm sandbox - https://ellie-app.com/)
14+
-- to see it running and interact with it.
15+
--
16+
-- If you are solving the exercise locally (and not through the exercism online editor),
17+
-- you can additionally run it locally:
18+
-- - `rm src/Browser.elm` (delete a fake file that we need for the online editor),
19+
-- - `elm install elm/browser` (install the real version of the fake)
20+
-- - `elm make src/Main.elm` (compile the code and make an index.html file)
21+
-- - Then view index.html in a browser
22+
23+
24+
main =
25+
Browser.sandbox { init = init, update = update, view = view }
26+
27+
28+
29+
-- MODEL
30+
31+
32+
type alias Model =
33+
{ content : String
34+
}
35+
36+
37+
init : Model
38+
init =
39+
{ content = "" }
40+
41+
42+
43+
-- UPDATE
44+
45+
46+
type Msg
47+
= Change String
48+
49+
50+
update : Msg -> Model -> Model
51+
update msg model =
52+
case msg of
53+
Change newContent ->
54+
{ model | content = newContent }
55+
56+
57+
58+
-- VIEW
59+
60+
61+
view : Model -> Html Msg
62+
view model =
63+
div []
64+
[ input [ placeholder "Text to alphabetise", value model.content, onInput Change ] []
65+
, div [] [ text (model.content |> String.toLower |> String.toList |> List.sort |> String.fromList) ]
66+
]

0 commit comments

Comments
 (0)