noredink-ui/styleguide-app/Category.elm

149 lines
2.0 KiB
Elm
Raw Normal View History

module Category exposing
( Category(..)
, fromString
2022-05-20 23:47:40 +03:00
, forDisplay, forId, forRoute
, all
, sorter
)
{-|
@docs Category
@docs fromString
2022-05-20 23:47:40 +03:00
@docs forDisplay, forId, forRoute
@docs all
@docs sorter
-}
import Sort exposing (Sorter)
{-| -}
type Category
2021-11-12 01:56:04 +03:00
= Inputs
| Buttons
| Icons
| Layout
| Messaging
2021-11-12 01:48:31 +03:00
| Atoms
| Text
| Animations
{-| -}
all : List Category
all =
[ Animations
2021-11-12 01:48:31 +03:00
, Atoms
, Buttons
, Icons
, Inputs
, Layout
, Text
, Messaging
]
{-| Used for route changes
-}
fromString : String -> Result String Category
fromString string =
case string of
"Inputs" ->
Ok Inputs
"Layout" ->
Ok Layout
"Buttons" ->
Ok Buttons
"Icons" ->
Ok Icons
"Messaging" ->
Ok Messaging
2021-11-12 01:48:31 +03:00
"Atoms" ->
Ok Atoms
"Text" ->
Ok Text
"Animations" ->
Ok Animations
_ ->
Err "Invalid String"
{-| -}
forDisplay : Category -> String
forDisplay category =
case category of
Inputs ->
"Inputs"
Layout ->
"Layout"
Buttons ->
"Buttons and Links"
Icons ->
"Icons"
Messaging ->
"Alerts and Messages"
2021-11-12 01:48:31 +03:00
Atoms ->
"Atoms"
Text ->
"Text and Fonts"
Animations ->
"Animations"
2022-05-20 23:47:40 +03:00
{-| -}
forRoute : Category -> String
forRoute =
Debug.toString
{-| -}
sorter : Sorter Category
sorter =
Sort.by forId Sort.alphabetical
{-| -}
forId : Category -> String
forId category =
case category of
Inputs ->
"inputs"
Layout ->
"layout"
Buttons ->
"buttons-and-links"
Icons ->
"icons"
Messaging ->
"alerts-and-messages"
2021-11-12 01:48:31 +03:00
Atoms ->
"atoms"
Text ->
"text-and-fonts"
Animations ->
"animations"