Skip to content

Instantly share code, notes, and snippets.

@giisyu
Last active October 21, 2016 14:11
Show Gist options
  • Save giisyu/6463ce002c80e29bc70b95bb45401b29 to your computer and use it in GitHub Desktop.
Save giisyu/6463ce002c80e29bc70b95bb45401b29 to your computer and use it in GitHub Desktop.
Elmでマテリアルデザイン ref: http://qiita.com/jooex/items/c4f9b6dcc8014803456e
elm-package install debois/elm-mdl -y
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500|Roboto+Mono|Roboto+Condensed:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.2.0/material.teal-red.min.css" />
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500|Roboto+Mono|Roboto+Condensed:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.2.0/material.teal-red.min.css" />
... model =
{要素}.render Mdl -- Msgで設定したMdl
[ n , ..] -- インデックス。どのパーツかの判断用
model.mdl -- modelで設定したmdlを渡す
[ ... -- Optionを付ける。cssとかイベントとかをつけたり、要素毎の設定がある。
, ...
, ... ]
[ .. -- 子要素。Titleなど要素毎に決まった入れるものがあったりする。
, ..
]
...
import Material.Tabs as Tabs
menuTab model =
Tabs.render Mdl
[ 5, 2 ]
model.mdl
[ Tabs.ripple
, Tabs.onSelectTab SetTab
, Tabs.activeTab model.tab
]
[ Tabs.label [] [ text "basic" ]
, Tabs.label [] [ text "" ]
]
[ heroParaTable model ]
module Main exposing(..)
import Html exposing (text)
import Html.App exposing(program)
main = program {init = init , update = update , view = view ,subscriptions = subscriptions}
init = "" ! []
update msg model = model ! []
view model = text "hello"
subscriptions model = Sub.none
import Material
import Material.Button as Button
import Material.Options as Options exposing (css)
type alias Model = { mdl : Material.Model }
init : ( Model,Cmd a )
init = { mdl = Material.model } ! []
type Msg = Mdl ((Material.Msg Msg))
update msg model =
case msg of
Mdl msg' -> Material.update msg' model
module Main exposing(..)
import Html exposing (text)
import Html.App exposing(program)
import Html.Attributes exposing (href, class, style)
import Material
import Material.Scheme
import Material.Button as Button
import Material.Options as Options exposing (css)
main = program {init = init , update = update , view = view ,subscriptions = subscriptions}
type alias Model = {mdl :Material.Model }
type Msg = Mdl ((Material.Msg Msg))
init : (Model,Cmd a)
init = {mdl = Material.model } ! []
update msg model =
case msg of
Mdl msg' -> Material.update msg' model
view model = text "hello"
subscriptions model = Sub.none
import Material.List as Lists
view model =
Lists.ul []
<| List.indexedMap element model.data
element index data =
Lists.li [Lists.withBody]
[ Lists.content [] [ text data.supplier
, Lists.body [] [ text data.address ] ]
]
import Material.Options as Options exposing (css)
wrapCss =
[ css "position" "fixed"
, css "width" "100%"
]
allWrap model =
Options.div
wrapCss
[ allView model ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment