mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2025-01-03 03:46:37 +03:00
Implement dynamic list
because of how debug.controls renders records, this implementation artificially indents. This should be fixed in order to make the controls actually usable
This commit is contained in:
parent
ee0e46f06d
commit
0534c35a17
@ -1,12 +1,14 @@
|
||||
module Debug.Control.Extra exposing
|
||||
( float, int
|
||||
, list, listItem, optionalListItem, optionalListItemDefaultChecked, optionalBoolListItem
|
||||
, dynamicList
|
||||
)
|
||||
|
||||
{-|
|
||||
|
||||
@docs float, int
|
||||
@docs list, listItem, optionalListItem, optionalListItemDefaultChecked, optionalBoolListItem
|
||||
@docs dynamicList
|
||||
|
||||
-}
|
||||
|
||||
@ -82,3 +84,28 @@ optionalBoolListItem name f accumulator =
|
||||
(Control.bool False)
|
||||
)
|
||||
(Control.map (++) accumulator)
|
||||
|
||||
|
||||
{-| -}
|
||||
dynamicList : Control a -> Control (List a)
|
||||
dynamicList value =
|
||||
list
|
||||
|> listItem "Entry" value
|
||||
|> addAnother value
|
||||
|
||||
|
||||
addAnother : Control a -> Control (List a) -> Control (List a)
|
||||
addAnother value accumulator =
|
||||
Control.field "Add another?"
|
||||
(Control.map
|
||||
(\maybe ->
|
||||
case maybe of
|
||||
Just l ->
|
||||
l
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
)
|
||||
(Control.maybe False (Control.lazy (\() -> dynamicList value)))
|
||||
)
|
||||
(Control.map (++) accumulator)
|
||||
|
@ -120,9 +120,7 @@ type alias Settings =
|
||||
{-| -}
|
||||
init : State
|
||||
init =
|
||||
{ settings =
|
||||
ControlExtra.list
|
||||
|> ControlExtra.listItem "entry" controlEntry
|
||||
{ settings = ControlExtra.dynamicList controlEntry
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user