mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-21 12:41:39 +03:00
Refactor to make customizing the title per route possible
This commit is contained in:
parent
455ffb3796
commit
d0cff1a4f6
@ -169,37 +169,43 @@ subscriptions model =
|
|||||||
|
|
||||||
view : Model -> Document Msg
|
view : Model -> Document Msg
|
||||||
view model =
|
view model =
|
||||||
{ title = "Style Guide"
|
|
||||||
, body =
|
|
||||||
[ view_ model |> Html.toUnstyled
|
|
||||||
, Sprite.attach |> Html.map never |> Html.toUnstyled
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
view_ : Model -> Html Msg
|
|
||||||
view_ model =
|
|
||||||
let
|
let
|
||||||
findExampleByName name =
|
findExampleByName name =
|
||||||
Dict.values model.moduleStates
|
Dict.values model.moduleStates
|
||||||
|> List.filter (\m -> m.name == name)
|
|> List.filter (\m -> m.name == name)
|
||||||
|> List.head
|
|> List.head
|
||||||
|
|
||||||
|
toBody view_ =
|
||||||
|
List.map Html.toUnstyled
|
||||||
|
[ view_
|
||||||
|
, Html.map never Sprite.attach
|
||||||
|
]
|
||||||
in
|
in
|
||||||
case model.route of
|
case model.route of
|
||||||
Routes.Doodad doodad ->
|
Routes.Doodad doodad ->
|
||||||
case findExampleByName doodad of
|
case findExampleByName doodad of
|
||||||
Just example ->
|
Just example ->
|
||||||
viewExample model example
|
{ title = "Style Guide"
|
||||||
|> Html.map (UpdateModuleStates example.name)
|
, body =
|
||||||
|
viewExample model example
|
||||||
|
|> Html.map (UpdateModuleStates example.name)
|
||||||
|
|> toBody
|
||||||
|
}
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
notFound
|
{ title = "Style Guide"
|
||||||
|
, body = toBody notFound
|
||||||
|
}
|
||||||
|
|
||||||
Routes.Category category ->
|
Routes.Category category ->
|
||||||
viewCategory model category
|
{ title = "Style Guide"
|
||||||
|
, body = toBody (viewCategory model category)
|
||||||
|
}
|
||||||
|
|
||||||
Routes.All ->
|
Routes.All ->
|
||||||
viewAll model
|
{ title = "Style Guide"
|
||||||
|
, body = toBody (viewAll model)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
viewExample : Model -> Example a msg -> Html msg
|
viewExample : Model -> Example a msg -> Html msg
|
||||||
|
Loading…
Reference in New Issue
Block a user