Last active
June 10, 2016 18:21
-
-
Save imetallica/da86b8fbafce1f545d6a99949d0f5244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MetroUi exposing (..) | |
import Html exposing (Html, text, div, h1) | |
import Html.App as App | |
import MetroUi.Widgets.Accordion as Accordion | |
import MetroUi.Widgets.Frame as Frame | |
type alias MetroUiModel = | |
{ accordion : Accordion.Model | |
, bigAccordion : Accordion.Model } | |
type Msg = | |
AccordionMsg Accordion.Msg | |
frame1 = Frame.defaultFrame "frame-1" "Hey" "Hello World!" | |
frame2 = Frame.defaultFrameWithIcon "frame-2" "mif-earth fg-yellow" "Hey" "Hello World!" | |
frame1WithColor = Frame.frameWithColor "frame-color-0" [ "bg-green", "bg-active-emerald" ] "Hi! I'm green" "Greeeeeen." | |
frame2WithColor = Frame.frameWithIconAndColor "frame-color-1" [ "bg-red" ] "mif-earth fg-white" "Hi! I'm red" "Reeeeed." | |
init : ( MetroUiModel, Cmd Msg ) | |
init = | |
let | |
( accordion, accordionCmd ) = Accordion.defaultAccordion "acc-0" [ frame1, frame1WithColor ] | |
( bigAccordion, bigAccordionCmd ) = Accordion.defaultBigAccordion "acc-1" [ frame2, frame2WithColor ] | |
in | |
( MetroUiModel accordion bigAccordion, Cmd.batch [ accordionCmd, bigAccordionCmd ] ) | |
update : Msg -> MetroUiModel -> ( MetroUiModel, Cmd Msg ) | |
update message model = | |
case message of | |
AccordionMsg msg -> | |
let | |
( accordion, accordionCmd1 ) = Accordion.update msg model.accordion | |
cmd1 = Cmd.map AccordionMsg accordionCmd1 | |
( bigAccordion, accordionCmd2 ) = Accordion.update msg model.bigAccordion | |
cmd2 = Cmd.map AccordionMsg accordionCmd2 | |
in | |
( { model | accordion = accordion, bigAccordion = bigAccordion }, Cmd.batch [ cmd1, cmd2 ] ) | |
subscriptions model = | |
Sub.none | |
view : MetroUiModel -> Html Msg | |
view model = | |
div [] | |
[ App.map AccordionMsg ( Accordion.view model.accordion ) | |
, App.map AccordionMsg ( Accordion.view model.bigAccordion ) ] | |
main = | |
App.program ( | |
{ init = init | |
, update = update | |
, subscriptions = subscriptions | |
, view = view } ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment