Merge pull request #688 from NoRedInk/raven/fix-segmented-control-styles

SegmentedControl honours FillContainer
This commit is contained in:
Juan Edi 2021-04-13 18:53:50 -03:00 committed by GitHub
commit 2f2dbae6e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 17 deletions

View File

@ -126,7 +126,13 @@ viewRadioGroup config =
{ id = option.idString ++ "-tooltip"
, trigger = inner
}
option.tooltip
(case config.positioning of
Left FillContainer ->
Tooltip.containerCss [ Css.width (Css.pct 100) ] :: option.tooltip
_ ->
option.tooltip
)
name =
dashify (String.toLower config.legend)

View File

@ -63,7 +63,7 @@ example =
, SegmentedControl.viewRadioGroup
{ legend = "SegmentedControls 'viewSelectRadio' example"
, onSelect = SelectRadio
, options = List.take options.count (buildRadioOptions state.radioTooltip options.content)
, options = List.take options.count (buildRadioOptions options state.radioTooltip options.content)
, selected = state.optionallySelected
, positioning = options.positioning
}
@ -146,8 +146,8 @@ buildOptions { content, longContent, tooltips } openTooltip =
]
buildRadioOptions : Maybe Int -> Content -> List (SegmentedControl.Radio Int Msg)
buildRadioOptions currentlyHovered content =
buildRadioOptions : { options | tooltips : Bool } -> Maybe Int -> Content -> List (SegmentedControl.Radio Int Msg)
buildRadioOptions options currentlyHovered content =
let
buildOption : Int -> ( String, Svg ) -> SegmentedControl.Radio Int Msg
buildOption value ( text, icon ) =
@ -162,20 +162,24 @@ buildRadioOptions currentlyHovered content =
, value = value
, idString = String.fromInt value
, tooltip =
[ Tooltip.plaintext text
, Tooltip.open (currentlyHovered == Just value)
, Tooltip.fitToContent
, Tooltip.onHover
(\hovered ->
HoverRadio
(if hovered then
Just value
if options.tooltips then
[ Tooltip.plaintext text
, Tooltip.open (currentlyHovered == Just value)
, Tooltip.fitToContent
, Tooltip.onHover
(\hovered ->
HoverRadio
(if hovered then
Just value
else
Nothing
)
)
]
else
Nothing
)
)
]
else
[]
, attributes = []
}
in