From 8a92d905a01e9ca311980d9404b9fd9737b62a21 Mon Sep 17 00:00:00 2001 From: Celso Bonutti Date: Thu, 10 Mar 2022 10:35:40 -0300 Subject: [PATCH] always show Premium Pennant on Premium-content RadioButton --- src/Nri/Ui/RadioButton/V4.elm | 42 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Nri/Ui/RadioButton/V4.elm b/src/Nri/Ui/RadioButton/V4.elm index f206d253..6d388552 100644 --- a/src/Nri/Ui/RadioButton/V4.elm +++ b/src/Nri/Ui/RadioButton/V4.elm @@ -1,6 +1,6 @@ module Nri.Ui.RadioButton.V4 exposing ( view - , premium, showPennant + , premium, onPennantClick , disclosure , onSelect , Attribute @@ -18,7 +18,7 @@ module Nri.Ui.RadioButton.V4 exposing ### Content -@docs premium, showPennant +@docs premium, onPennantClick @docs disclosure @@ -110,13 +110,13 @@ premium premiumDisplay = { config | premiumDisplay = premiumDisplay } -{-| Show Premium pennant on Premium content. +{-| Makes the Premium pennant clickable. When the pennant is clicked, the msg that's passed in will fire. -} -showPennant : msg -> Attribute value msg -showPennant premiumMsg = +onPennantClick : msg -> Attribute value msg +onPennantClick premiumMsg = Attribute <| \config -> { config | premiumMsg = Just premiumMsg } @@ -408,10 +408,7 @@ view { label, name, value, valueToString, selectedValue } attributes = ( PremiumDisplay.Free, _ ) -> text "" - ( _, Nothing ) -> - text "" - - ( _, Just premiumMsg ) -> + ( _, premiumMsg ) -> premiumPennant premiumMsg ] ] @@ -426,18 +423,27 @@ view { label, name, value, valueToString, selectedValue } attributes = ) -premiumPennant : msg -> Html msg +premiumPennant : Maybe msg -> Html msg premiumPennant onClick = + let + attrs = + [ ClickableSvg.exactWidth 26 + , ClickableSvg.exactHeight 24 + , ClickableSvg.css + [ marginLeft (px 8) + , verticalAlign middle + ] + ] + in ClickableSvg.button "Premium" Pennant.premiumFlag - [ ClickableSvg.onClick onClick - , ClickableSvg.exactWidth 26 - , ClickableSvg.exactHeight 24 - , ClickableSvg.css - [ marginLeft (px 8) - , verticalAlign middle - ] - ] + <| + case onClick of + Just msg -> + ClickableSvg.onClick msg :: attrs + + Nothing -> + attrs radioInputIcon :