module Static.View.Menu exposing (Menu, decoder, view) import Element exposing (..) import Element.Background as Bg import Element.Font as Font import Json.Decode as D exposing (Decoder) type alias Menu = { href : String , name : String } decoder : Decoder Menu decoder = D.map2 Menu (D.field "href" D.string) (D.field "name" D.string) view : List Menu -> Element msg view items = column [ width (px 160) , height fill , Bg.color (rgb255 88 99 122) , spacing 2 , padding 2 ] (items |> List.foldl ((::) << itemView) [ titleView ] |> List.reverse ) titleView : Element msg titleView = el [ Font.size 24 , Font.color (rgb255 255 255 255) , Font.bold ] (text "menu") itemView : Menu -> Element msg itemView item = link [ paddingXY 2 0 , width fill ] { url = item.href , label = el [ Bg.color (rgb255 255 255 255) , width fill , padding 4 ] (text item.name) }