Skip to content

Instantly share code, notes, and snippets.

@dela3499
Last active August 29, 2016 01:26
Show Gist options
  • Save dela3499/337bc37d84e199025f30efec3c44b353 to your computer and use it in GitHub Desktop.
Save dela3499/337bc37d84e199025f30efec3c44b353 to your computer and use it in GitHub Desktop.
This is a scaffold for Elm projects. Takes care of basic imports, along with model, view, and update information.
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "4.0.0 <= v < 5.0.0",
"elm-lang/html": "1.0.0 <= v < 2.0.0",
"elm-lang/window": "1.0.0 <= v < 2.0.0",
"elm-lang/mouse": "1.0.0 <= v < 2.0.0",
"Skinney/collections-ng": "2.0.0 <= v < 3.0.0"
},
"elm-version": "0.17.0 <= v < 0.18.0"
}
import Html exposing ( Html, text, div, span, input, textarea, img, table, tr, th, td, i, p, a )
import Html.Events exposing ( on, targetValue, onClick, onDoubleClick, onInput )
import Html.Attributes exposing ( .. )
import Html.App as Html
import Color exposing ( .. )
import Maybe exposing ( withDefault, andThen )
import CollectionsNg.Array as Array exposing ( Array )
--import Array exposing ( Array )
import Set exposing ( Set )
import Dict exposing ( Dict )
import Random
import Result
import List
import Regex
import String
import Time
import Window
import Mouse
import Task
import Debug
main =
Html.program
{ init = ( initialModel, initCmd )
, view = view
, update = update
, subscriptions = subscriptions
}
initCmd = triggerGetSize
triggerGetSize: Cmd Msg
triggerGetSize = Task.perform ( \_ -> EmptyMsg ) ( \size -> SetWindowSize ( size.width, size.height ) ) Window.size
subscriptions: Model -> Sub Msg
subscriptions model =
Sub.batch
[ Window.resizes ( \size -> SetWindowSize ( size.width, size.height ) )
]
type alias Model =
{ windowSize: ( Int, Int )
}
initialModel =
{ windowSize = ( 0, 0 )
}
type Msg
= EmptyMsg
| SetWindowSize ( Int, Int )
update: Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
EmptyMsg ->
( model, Cmd.none )
SetWindowSize windowSize ->
( { model | windowSize = windowSize }, Cmd.none )
view : Model -> Html Msg
view model =
div
[ ]
[ model.windowSize |> toString |> text ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment