Last active
September 11, 2016 07:22
-
-
Save gerred/2f963d5865c571be495559c69f42b1f4 to your computer and use it in GitHub Desktop.
insane skullduggery
This file contains hidden or 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
view : Model -> Html Msg | |
view model = | |
Material.Scheme.topWithScheme Color.BlueGrey Color.LightBlue <| | |
Layout.render Mdl | |
model.mdl | |
[ Layout.selectedTab model.selectedTab | |
, Layout.onSelectTab SelectTab | |
, Layout.fixedHeader | |
, Layout.fixedDrawer | |
] | |
{ header = header model | |
, drawer = drawer model | |
, tabs = | |
( tabs model | |
, [] | |
) | |
, main = body model | |
} |
This file contains hidden or 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
type Location | |
= Login | |
| Dashboard | |
| Tools (Maybe ToolsRoute.Location) | |
type alias Model = | |
Maybe Location | |
tabs2Location : Model -> Int -> Maybe Location | |
tabs2Location model k = | |
case model of | |
Just (Tools a) -> | |
Just (Tools (nth k <| List.map (\x -> x.route) ToolsRoute.tabs)) | |
_ -> | |
model | |
urlFor : Location -> String | |
urlFor loc = | |
let | |
url = | |
case loc of | |
Login -> | |
"/" | |
Dashboard -> | |
"/dashboard" | |
Tools (Just k) -> | |
"/tools" ++ ToolsRoute.urlFor k | |
Tools Nothing -> | |
"/tools" | |
in | |
"#" ++ url |
This file contains hidden or 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
type Location | |
= Dashboard | |
| Browser | |
urlFor : Location -> String | |
urlFor loc = | |
let | |
url = | |
case loc of | |
Dashboard -> | |
"/" | |
Browser -> | |
"/browser" | |
in | |
url | |
type alias Tool = | |
{ title : String | |
, url : String | |
, route : Location | |
} | |
tabs : List Tool | |
tabs = | |
[ { title = "Dashboard", url = "dashboard", route = Dashboard } | |
, { title = "Tools", url = "browser", route = Browser } | |
] | |
nth : Int -> List a -> Maybe a | |
nth k xs = | |
List.drop k xs |> List.head | |
This file contains hidden or 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
NavigateTo maybeLocation -> | |
case maybeLocation of | |
Nothing -> | |
model ! [] | |
Just location -> | |
model ! [ Navigation.newUrl (Route.urlFor location) ] | |
SelectTab k -> | |
let | |
newRoute = | |
tabs2Location model.route k | |
in | |
case newRoute of | |
Nothing -> | |
model ! [] | |
Just location -> | |
{ model | selectedTab = k, route = newRoute } | |
! [ Navigation.newUrl (Route.urlFor location) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment