Adds radio example

This commit is contained in:
Tessa Kelly 2022-03-24 16:18:21 -07:00
parent 4a8fbbe5be
commit 3ce976c4a9

View File

@ -73,11 +73,11 @@ example =
, { sectionName = "viewRadioGroup" , { sectionName = "viewRadioGroup"
, code = , code =
[ "viewRadioGroup" [ "viewRadioGroup"
, " { onSelect : a -> msg" , " { onSelect = SelectRadio"
, " , options : List (Radio a msg)" , " , options = " ++ ControlView.codeFromList radioOptions
, " , selected : Maybe a" , " , selected = " ++ Debug.toString state.optionallySelected
, " , positioning : Positioning" , " , positioning = " ++ Tuple.first options.positioning
, " , legend : String" , " , legend = \"SegmentedControls 'viewSelectRadio' example\""
, " }" , " }"
] ]
|> String.join "\n" |> String.join "\n"
@ -257,27 +257,20 @@ buildRadioOptions options currentlyHovered content =
icon icon
("Source " ++ Debug.toString (value + 1)) ("Source " ++ Debug.toString (value + 1))
in in
( [ "{ icon = icon_" ( [ "{ icon = " ++ Debug.toString (Maybe.map (\_ -> "UiIcon." ++ toLower label) icon_)
, ", label = Html.text label" , ", label = Html.text " ++ label
, ", value = value" , ", value = " ++ String.fromInt value
, ", idString = String.fromInt value" , ", idString = String.fromInt " ++ String.fromInt value
, ", tooltip = []" , ", tooltip = "
++ (if options.tooltips then
("\n\t\t[ Tooltip.plaintext " ++ String.fromInt value)
++ ("\n\t\t, Tooltip.onHover (OpenTooltip " ++ String.fromInt value ++ ")")
++ ("\n\t\t, Tooltip.open (openTooltip == Just " ++ String.fromInt value ++ ")")
++ "\n\t\t]"
--, if options.tooltips then else
-- [ Tooltip.plaintext text "[]"
-- , Tooltip.open (currentlyHovered == Just value) )
-- , Tooltip.fitToContent
-- , Tooltip.onHover
-- (\hovered ->
-- HoverRadio
-- (if hovered then
-- Just value
-- else
-- Nothing
-- )
-- )
-- ]
-- else []
, ", attributes = []" , ", attributes = []"
, "}" , "}"
] ]