From f5c7ee38a19473cf155d205b19822a3af24cc482 Mon Sep 17 00:00:00 2001 From: Tessa Kelly Date: Thu, 2 Jul 2020 12:54:08 -0700 Subject: [PATCH] Begin replacing focusables type --- src/Nri/Ui/Modal/V9.elm | 68 +++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/src/Nri/Ui/Modal/V9.elm b/src/Nri/Ui/Modal/V9.elm index c1728f9b..33d58feb 100644 --- a/src/Nri/Ui/Modal/V9.elm +++ b/src/Nri/Ui/Modal/V9.elm @@ -276,8 +276,8 @@ custom styles = {-| -} -type Focusable msg - = Focusable (Attribute msg) (List (Attribute msg)) +type alias Focusable msg = + Attribute msg {-| -} @@ -290,43 +290,6 @@ multipleFocusableElementView : ) -> Focusable msg multipleFocusableElementView f = - Focusable (multipleFocusableElementView_ (\attributes -> f attributes)) [] - - -{-| -} -onlyFocusableElementView : - ({ onlyFocusableElement : List (Html.Attribute msg) - } - -> Html msg - ) - -> Focusable msg -onlyFocusableElementView f = - Focusable - (Attribute - (\config -> - { config - | content = - \{ onlyFocusableElement } -> - f - { onlyFocusableElement = onlyFocusableElement - } - } - ) - ) - [ Attribute (\config -> { config | autofocusOn = Last }) - ] - - -{-| -} -multipleFocusableElementView_ : - ({ firstFocusableElement : List (Html.Attribute msg) - , lastFocusableElement : List (Html.Attribute msg) - , autofocusElement : Html.Attribute msg - } - -> Html msg - ) - -> Attribute msg -multipleFocusableElementView_ f = Attribute (\config -> { config @@ -341,6 +304,27 @@ multipleFocusableElementView_ f = ) +{-| -} +onlyFocusableElementView : + ({ onlyFocusableElement : List (Html.Attribute msg) + } + -> Html msg + ) + -> Focusable msg +onlyFocusableElementView f = + Attribute + (\config -> + { config + | content = + \{ onlyFocusableElement } -> + f + { onlyFocusableElement = onlyFocusableElement + } + , autofocusOn = Last + } + ) + + -- VIEW @@ -368,9 +352,7 @@ view theme config getFocusable model = } focusables = - case getFocusable viewFuncs of - Focusable fst rst -> - fst :: rst + getFocusable viewFuncs in view_ config.wrapMsg @@ -411,7 +393,7 @@ view theme config getFocusable model = , Css.border Css.zero ] ] - ++ focusables + ++ [ focusables ] ) model |> List.singleton