mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-28 10:17:49 +03:00
Adds keyboard shortcuts to all the examples
This commit is contained in:
parent
a84f0b9665
commit
311ba32ec3
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user