├── tests ├── .gitignore └── Tests.elm ├── .gitignore ├── src ├── Utils.elm └── Main.elm ├── index.html ├── package.json ├── elm.json └── README.md /tests/.gitignore: -------------------------------------------------------------------------------- 1 | /elm-stuff/ 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | elm-stuff 2 | node_modules 3 | dist/* 4 | -------------------------------------------------------------------------------- /src/Utils.elm: -------------------------------------------------------------------------------- 1 | module Utils exposing (..) 2 | 3 | import String 4 | 5 | 6 | capitalize : String -> String 7 | capitalize name = 8 | let 9 | first = 10 | String.left 1 name |> String.toUpper 11 | 12 | rest = 13 | String.dropLeft 1 name 14 | in 15 | first ++ rest 16 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "elm-quickstart", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "watch": "elm-live src/*.elm --open --pushstate -- --output=dist/bundle.js", 8 | "test": "elm-test" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "elm": "^0.19.0", 14 | "elm-live": "^3.0.6" 15 | }, 16 | "dependencies": { 17 | "elm-test": "^0.19.0-beta6" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/Tests.elm: -------------------------------------------------------------------------------- 1 | module Tests exposing (..) 2 | 3 | import Test exposing (..) 4 | import Expect 5 | import String 6 | import Utils 7 | 8 | 9 | all : Test 10 | all = 11 | describe "A Test Suite" 12 | [ test "Capitalizes a lower case word" <| 13 | \() -> 14 | Expect.equal (Utils.capitalize "john") "John" 15 | , test "Does not change an already capitalized word" <| 16 | \() -> 17 | Expect.equal (Utils.capitalize "John") "John" 18 | ] 19 | -------------------------------------------------------------------------------- /elm.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "application", 3 | "source-directories": [ 4 | "src" 5 | ], 6 | "elm-version": "0.19.0", 7 | "dependencies": { 8 | "direct": { 9 | "elm/browser": "1.0.0", 10 | "elm/core": "1.0.0", 11 | "elm/html": "1.0.0", 12 | "elm/json": "1.0.0", 13 | "elm/time": "1.0.0", 14 | "elm/url": "1.0.0", 15 | "elm-explorations/test": "1.1.0" 16 | }, 17 | "indirect": { 18 | "elm/random": "1.0.0", 19 | "elm/virtual-dom": "1.0.0" 20 | } 21 | }, 22 | "test-dependencies": { 23 | "direct": {}, 24 | "indirect": {} 25 | } 26 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Elm Quickstart 2 | This is a repository that can be cloned or copied in order to start a new basic 3 | Elm application. It sets up the following: 4 | 5 | * Basic HTML application with model, update, view and subscriptions. 6 | * Small utility module used to demonstrate testing. 7 | * npm setup to run build or tests. 8 | 9 | To use this repository, you should follow these steps. 10 | 11 | 1. npm install -g elm 12 | 13 | 2. npm install -g elm-live 14 | 15 | 3. npm install -g elm-test@0.19.0-beta6 16 | 17 | 4. npm install 18 | 19 | 5. npm run test 20 | 21 | 6. npm run watch 22 | 23 | The *watch* step will run the elm-live build process and launch the browser. 24 | Future code changes will automatically trigger a rebuild and the browser will 25 | live reload with your changes. 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Main.elm: -------------------------------------------------------------------------------- 1 | module Main exposing (..) 2 | 3 | import Browser 4 | import Html exposing (..) 5 | import Html.Attributes exposing (..) 6 | import Utils 7 | 8 | 9 | main : Program Flags Model Msg 10 | main = 11 | Browser.element 12 | { init = init 13 | , view = view 14 | , update = update 15 | , subscriptions = subscriptions 16 | } 17 | 18 | 19 | type alias Flags = 20 | () 21 | 22 | 23 | 24 | -- Model 25 | 26 | 27 | type alias Model = 28 | { name : String } 29 | 30 | 31 | init : Flags -> ( Model, Cmd Msg ) 32 | init flags = 33 | ( Model "world", Cmd.none ) 34 | 35 | 36 | 37 | -- Update 38 | 39 | 40 | type Msg 41 | = NoOp 42 | 43 | 44 | update : Msg -> Model -> ( Model, Cmd Msg ) 45 | update msg model = 46 | case msg of 47 | NoOp -> 48 | ( model, Cmd.none ) 49 | 50 | 51 | 52 | -- View 53 | 54 | 55 | view : Model -> Html Msg 56 | view model = 57 | h1 [] 58 | [ text ("Hello " ++ (Utils.capitalize model.name)) ] 59 | 60 | 61 | 62 | -- Subscriptions 63 | 64 | 65 | subscriptions : Model -> Sub Msg 66 | subscriptions model = 67 | Sub.none 68 | --------------------------------------------------------------------------------