From 1441c5e5d891ca02432fabfb1e71c08c12853c77 Mon Sep 17 00:00:00 2001 From: Tessa Kelly Date: Mon, 8 Apr 2019 17:48:31 -0700 Subject: [PATCH] :art: clean up how logic is passed around --- src/Nri/Ui/SlideModal/V1.elm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Nri/Ui/SlideModal/V1.elm b/src/Nri/Ui/SlideModal/V1.elm index 073d540b..03fad0fa 100644 --- a/src/Nri/Ui/SlideModal/V1.elm +++ b/src/Nri/Ui/SlideModal/V1.elm @@ -77,7 +77,7 @@ view config (State { currentPanelIndex, previousPanel }) = case Maybe.andThen (summarize config.panels) currentPanelIndex of Just summary -> viewBackdrop - (viewModal config.height previousPanel (viewPanels config.parentMsg summary)) + (viewModal config previousPanel summary) Nothing -> Html.text "" @@ -126,8 +126,12 @@ summarize panels current = Nothing -viewModal : Css.Vh -> Maybe ( Direction, Panel ) -> ( String, List (Html msg) ) -> Html msg -viewModal height previous ( labelledById, panel ) = +viewModal : Config msg -> Maybe ( Direction, Panel ) -> Summary -> Html msg +viewModal config previous summary = + let + ( labelledById, currentPanel ) = + viewCurrentPanel config.parentMsg summary + in Keyed.node "div" [ css [ Css.width (Css.px 600) @@ -144,11 +148,12 @@ viewModal height previous ( labelledById, panel ) = (case previous of Just ( direction, previousPanel ) -> [ viewPreviousPanel direction previousPanel - , ( labelledById, panelContainer height direction panel ) + , ( labelledById, panelContainer config.height direction currentPanel ) ] Nothing -> - [ ( labelledById, panelContainer height FromRTL panel ) ] + [ ( labelledById, panelContainer config.height FromRTL currentPanel ) + ] ) @@ -282,8 +287,8 @@ type alias Panel = } -viewPanels : (State -> msg) -> Summary -> ( String, List (Html msg) ) -viewPanels parentMsg ({ current } as summary) = +viewCurrentPanel : (State -> msg) -> Summary -> ( String, List (Html msg) ) +viewCurrentPanel parentMsg ({ current } as summary) = ( panelId current , [ viewIcon current.icon , Text.subHeading