Apparently nesting Control records causes deque to fail. de-nest

This commit is contained in:
Tessa Kelly 2020-09-04 08:52:47 -07:00
parent 7bb32b0787
commit 44975187d6

View File

@ -29,7 +29,8 @@ import Task
{-| -} {-| -}
type alias State = type alias State =
{ state : Modal.Model { state : Modal.Model
, settings : Control Settings , attributes : Control (List Modal.Attribute)
, settings : Control ViewSettings
} }
@ -37,24 +38,32 @@ type alias State =
init : State init : State
init = init =
{ state = Modal.init { state = Modal.init
, settings = initModalSettings , attributes = controlAttributes
, settings = initViewSettings
} }
type alias Settings = controlAttributes : Control (List Modal.Attribute)
controlAttributes =
Control.record (\a b c -> a :: b :: c :: [])
|> Control.field "Theme" controlTheme
|> Control.field "Title visibility" controlTitleVisibility
|> Control.field "Custom css" controlCss
type alias ViewSettings =
{ title : String { title : String
, showX : Bool , showX : Bool
, showContinue : Bool , showContinue : Bool
, showSecondary : Bool , showSecondary : Bool
, dismissOnEscAndOverlayClick : Bool , dismissOnEscAndOverlayClick : Bool
, content : String , content : String
, attributes : List Modal.Attribute
} }
initModalSettings : Control Settings initViewSettings : Control ViewSettings
initModalSettings = initViewSettings =
Control.record Settings Control.record ViewSettings
|> Control.field "Modal title" (Control.string "Modal Title") |> Control.field "Modal title" (Control.string "Modal Title")
|> Control.field "X button" (Control.bool True) |> Control.field "X button" (Control.bool True)
|> Control.field "Continue button" (Control.bool True) |> Control.field "Continue button" (Control.bool True)
@ -68,15 +77,6 @@ initModalSettings =
, "Candy cake danish gingerbread. Caramels toffee cupcake toffee sweet. Gummi bears candy cheesecake sweet. Pie gingerbread sugar plum halvah muffin icing marzipan wafer icing. Candy fruitcake gummies icing marzipan. Halvah jelly beans candy candy canes biscuit bonbon sesame snaps. Biscuit carrot cake croissant cake chocolate lollipop candy biscuit croissant. Topping jujubes apple pie croissant chocolate cake. Liquorice cookie dragée gummies cotton candy fruitcake lemon drops candy canes. Apple pie lemon drops gummies cake chocolate bar cake jelly-o tiramisu. Chocolate bar icing pudding marshmallow cake soufflé soufflé muffin. Powder lemon drops biscuit sugar plum cupcake carrot cake powder cake dragée. Bear claw gummi bears liquorice sweet roll." , "Candy cake danish gingerbread. Caramels toffee cupcake toffee sweet. Gummi bears candy cheesecake sweet. Pie gingerbread sugar plum halvah muffin icing marzipan wafer icing. Candy fruitcake gummies icing marzipan. Halvah jelly beans candy candy canes biscuit bonbon sesame snaps. Biscuit carrot cake croissant cake chocolate lollipop candy biscuit croissant. Topping jujubes apple pie croissant chocolate cake. Liquorice cookie dragée gummies cotton candy fruitcake lemon drops candy canes. Apple pie lemon drops gummies cake chocolate bar cake jelly-o tiramisu. Chocolate bar icing pudding marshmallow cake soufflé soufflé muffin. Powder lemon drops biscuit sugar plum cupcake carrot cake powder cake dragée. Bear claw gummi bears liquorice sweet roll."
] ]
) )
|> Control.field "Modal Attributes" controlAttributes
controlAttributes : Control (List Modal.Attribute)
controlAttributes =
Control.record (\a b c -> a :: b :: c :: [])
|> Control.field "Theme" controlTheme
|> Control.field "Title visibility" controlTitleVisibility
|> Control.field "Custom css" controlCss
controlTitleVisibility : Control Modal.Attribute controlTitleVisibility : Control Modal.Attribute
@ -131,15 +131,21 @@ example =
settings = settings =
Control.currentValue state.settings Control.currentValue state.settings
in in
[ Control.view UpdateSettings state.settings [ div [ css [ Css.displayFlex, Css.justifyContent Css.spaceAround ] ]
|> Html.fromUnstyled [ Control.view UpdateAttributes state.attributes
|> Html.fromUnstyled
, Control.view UpdateSettings state.settings
|> Html.fromUnstyled
]
, launchModalButton settings , launchModalButton settings
, Modal.view (modalSettings settings) settings.attributes state.state , Modal.view (modalSettings settings)
(Control.currentValue state.attributes)
state.state
] ]
} }
launchModalButton : Settings -> Html Msg launchModalButton : ViewSettings -> Html Msg
launchModalButton settings = launchModalButton settings =
let let
launchId = launchId =
@ -176,7 +182,7 @@ launchModalButton settings =
modalSettings : modalSettings :
Settings ViewSettings
-> ->
{ title : String { title : String
, wrapMsg : Modal.Msg -> Msg , wrapMsg : Modal.Msg -> Msg
@ -317,7 +323,8 @@ type Msg
= OpenModal { startFocusOn : String, returnFocusTo : String } = OpenModal { startFocusOn : String, returnFocusTo : String }
| ModalMsg Modal.Msg | ModalMsg Modal.Msg
| CloseModal | CloseModal
| UpdateSettings (Control Settings) | UpdateAttributes (Control (List Modal.Attribute))
| UpdateSettings (Control ViewSettings)
| Focus String | Focus String
| Focused (Result Dom.Error ()) | Focused (Result Dom.Error ())
@ -360,6 +367,9 @@ update msg state =
, Cmd.map ModalMsg cmd , Cmd.map ModalMsg cmd
) )
UpdateAttributes value ->
( { state | attributes = value }, Cmd.none )
UpdateSettings value -> UpdateSettings value ->
( { state | settings = value }, Cmd.none ) ( { state | settings = value }, Cmd.none )