add and use categoryForId

This commit is contained in:
Matt Charlton 2019-11-20 14:48:23 +00:00 committed by Brian Hicks
parent 657cc5d21f
commit 4518d67431
2 changed files with 42 additions and 2 deletions

View File

@ -3,6 +3,7 @@ module ModuleExample exposing
, ModuleExample
, ModuleMessages
, categoryForDisplay
, categoryForId
, categoryFromString
, view
)
@ -127,6 +128,45 @@ categoryForDisplay category =
Animations ->
"Animations"
categoryForId : Category -> String
categoryForId category =
case category of
Tables ->
"tables"
Inputs ->
"inputs"
Widgets ->
"widgets"
Layout ->
"layout"
Buttons ->
"buttons-and-links"
Icons ->
"icons"
Messaging ->
"alerts-and-messages"
Modals ->
"modals"
Colors ->
"colors"
Text ->
"text-and-fonts"
Pages ->
"error-pages"
Animations ->
"animations"
view : Bool -> ModuleExample msg -> Html msg
view showFocusLink { name, content } =

View File

@ -7,7 +7,7 @@ import Html.Attributes
import Html.Styled as Html exposing (Html, img)
import Html.Styled.Attributes as Attributes exposing (..)
import Model exposing (..)
import ModuleExample as ModuleExample exposing (Category(..), ModuleExample, categoryForDisplay)
import ModuleExample as ModuleExample exposing (Category(..), ModuleExample, categoryForDisplay, categoryForId)
import Nri.Ui.Colors.V1 as Colors
import Nri.Ui.Css.VendorPrefixed as VendorPrefixed
import Nri.Ui.Fonts.V1 as Fonts
@ -58,7 +58,7 @@ view_ model =
, nriThemedModules model.moduleStates
|> List.filter (\doodad -> category == doodad.category)
|> List.map (ModuleExample.view True)
|> Html.div [ class (categoryForDisplay category) ]
|> Html.div [ id (categoryForId category) ]
|> Html.map UpdateModuleStates
]
]