noredink-ui/styleguide-app/ModuleExample.elm

192 lines
3.5 KiB
Elm
Raw Normal View History

2018-09-26 17:02:10 +03:00
module ModuleExample exposing
( Category(..)
, ModuleExample
, ModuleMessages
, categoryForDisplay
, categoryFromString
, view
)
2018-02-13 00:32:38 +03:00
import Css exposing (..)
import Html.Styled as Html exposing (Html, img)
import Html.Styled.Attributes as Attributes
2018-03-17 03:16:16 +03:00
import Nri.Ui.Colors.V1 exposing (..)
2018-02-13 00:32:38 +03:00
type alias ModuleExample msg =
{ filename : String
, content : List (Html msg)
, category : Category
}
{-| -}
type alias ModuleMessages moduleMsg parentMsg =
{ noOp : parentMsg
, showItWorked : String -> parentMsg
, wrapper : moduleMsg -> parentMsg
}
type Category
= Layout
| Inputs
| Buttons
| Icons
| Behaviors
| Messaging
| Modals
| Writing
| NotesToDeveloper
| Colors
| Text
2018-03-02 00:34:44 +03:00
| TextWriting
2018-03-17 01:33:42 +03:00
| Fonts
2018-02-13 00:32:38 +03:00
| DynamicSymbols
| Pages
| QuestionTypes
{-| Used for route changes
-}
categoryFromString : String -> Result String Category
categoryFromString string =
case string of
"Layout" ->
Ok Layout
"Inputs" ->
Ok Inputs
"Behaviors" ->
Ok Behaviors
"Buttons" ->
Ok Buttons
"Icons" ->
Ok Icons
"Messaging" ->
Ok Messaging
"Modals" ->
Ok Modals
"Writing" ->
Ok Writing
"NotesToDeveloper" ->
Ok NotesToDeveloper
"Colors" ->
Ok Colors
"Text" ->
Ok Text
2018-03-02 00:34:44 +03:00
"TextWriting" ->
Ok TextWriting
2018-03-01 01:04:22 +03:00
2018-03-17 01:33:42 +03:00
"Fonts" ->
Ok Fonts
2018-02-13 00:32:38 +03:00
"DynamicSymbols" ->
Ok DynamicSymbols
"Pages" ->
Ok Pages
"QuestionTypes" ->
Ok QuestionTypes
_ ->
Err "Invalid String"
categoryForDisplay : Category -> String
categoryForDisplay category =
case category of
Layout ->
"Layout"
Inputs ->
"Inputs"
Behaviors ->
"Behaviors"
Buttons ->
"Buttons"
Icons ->
"Icons"
Messaging ->
"Messaging"
Modals ->
"Modals"
Writing ->
"Writing"
NotesToDeveloper ->
"NotesToDeveloper"
Colors ->
"Colors"
Text ->
"Text"
2018-03-02 00:34:44 +03:00
TextWriting ->
"TextWriting"
2018-03-01 01:04:22 +03:00
2018-03-17 01:33:42 +03:00
Fonts ->
"Fonts"
2018-02-13 00:32:38 +03:00
DynamicSymbols ->
"Dynamic Symbols"
Pages ->
"Pages"
QuestionTypes ->
"Question types / Quiz UI"
view : Bool -> ModuleExample msg -> Html msg
view showFocusLink { filename, content } =
Html.div
[]
[ Html.styled Html.div
[ display block
, backgroundColor glacier
, padding (px 20)
, marginTop (px 20)
]
[]
[ Html.styled Html.h2
[ color gray20
, fontFamilies [ qt "Source Code Pro", "Consolas", "Courier", "monospace" ]
, fontSize (px 20)
]
[]
2018-02-13 00:32:38 +03:00
[ Html.text filename
, Html.text " "
, if showFocusLink then
Html.a
[ Attributes.href <| "#doodad/" ++ filename ]
2018-02-13 00:32:38 +03:00
[ Html.text "(see only this)" ]
2018-09-26 17:02:10 +03:00
2018-02-13 00:32:38 +03:00
else
Html.text ""
]
]
, Html.styled Html.div
[ padding2 (px 20) zero ]
[]
content
2018-02-13 00:32:38 +03:00
]