Adds keyboard shortcuts to all the examples

This commit is contained in:
Tessa Kelly 2020-06-19 14:42:28 -07:00
parent a84f0b9665
commit 311ba32ec3

View File

@ -22,6 +22,28 @@ type alias KeyboardShortcut =
}
{-| -}
view : List KeyboardShortcut -> Html msg
view keyboardShortcuts =
case keyboardShortcuts of
[] ->
text ""
_ ->
details []
[ summary [] [ text "Keyboard Support" ]
, ul [] (List.map viewKeyboardActions keyboardShortcuts)
]
viewKeyboardActions : KeyboardShortcut -> Html msg
viewKeyboardActions { keys, result } =
li []
[ strong [] [ text (String.join "+" (List.map keyToString keys)) ]
, text result
]
{-| -}
type Key
= Shift
@ -30,6 +52,22 @@ type Key
| Tab
keyToString : Key -> String
keyToString key =
case key of
Shift ->
"Shift"
Enter ->
"Enter"
Arrow direction ->
directionToString direction ++ " arrow"
Tab ->
"Tab"
{-| -}
type Direction
= Up
@ -38,9 +76,17 @@ type Direction
| Left
{-| -}
view : List KeyboardShortcut -> Html msg
view keyboardShortcuts =
div []
[ text "TODO"
]
directionToString : Direction -> String
directionToString direction =
case direction of
Up ->
"Up"
Right ->
"Right"
Down ->
"Down"
Left ->
"Left"