Paramaterize the gened code

This commit is contained in:
Tessa Kelly 2022-07-08 19:17:34 -07:00
parent 795b01e3b9
commit 151ba0a9d5
6 changed files with 40 additions and 7 deletions

View File

@ -38,6 +38,7 @@ example =
{ label = "Planning Diagnostics"
, name = "planningDiagnosticCircled"
, icon = AssignmentIcon.planningDiagnosticCircled
, renderSvgCode = \name -> "AssignmentIcon." ++ name
}
, update = IconExamples.update
, subscriptions = \_ -> Sub.none

View File

@ -58,12 +58,19 @@ type alias Settings =
, icon : ( String, Svg )
, label : String
, showBorder : Bool
, renderSvgCode : String -> String
}
{-| -}
init : { label : String, name : String, icon : Svg } -> Settings
init { label, name, icon } =
init :
{ label : String
, name : String
, icon : Svg
, renderSvgCode : String -> String
}
-> Settings
init { label, name, icon, renderSvgCode } =
{ showIconName = False
, iconSelectorExpanded = False
, color = fromCssColor Colors.greenDark
@ -72,6 +79,7 @@ init { label, name, icon } =
, icon = ( name, icon )
, label = label
, showBorder = True
, renderSvgCode = renderSvgCode
}
@ -362,7 +370,7 @@ viewResults state =
, "\n\n\n"
, "renderedSvg : Svg\n"
, "renderedSvg =\n"
, " UiIcon." ++ Tuple.first state.icon ++ "\n"
, " " ++ state.renderSvgCode (Tuple.first state.icon) ++ "\n"
, " |> Svg.withColor color\n"
, " |> Svg.withWidth (Css.px " ++ String.fromFloat state.width ++ ")\n"
, " |> Svg.withHeight (Css.px " ++ String.fromFloat state.height ++ ")\n"

View File

@ -38,7 +38,13 @@ example =
, version = 1
, categories = [ Icons ]
, keyboardSupport = []
, state = IconExamples.init { label = "NoRedInk", name = "noredink", icon = Logo.noredink }
, state =
IconExamples.init
{ label = "NoRedInk"
, name = "noredink"
, icon = Logo.noredink
, renderSvgCode = \name -> "Logo." ++ name
}
, update = IconExamples.update
, subscriptions = \_ -> Sub.none
, preview =

View File

@ -34,7 +34,13 @@ example =
, version = 2
, categories = [ Icons ]
, keyboardSupport = []
, state = IconExamples.init { label = "Premium", name = "premiumFlag", icon = Pennant.premiumFlag }
, state =
IconExamples.init
{ label = "Premium"
, name = "premiumFlag"
, icon = Pennant.premiumFlag
, renderSvgCode = \name -> "Pennant." ++ name
}
, update = IconExamples.update
, subscriptions = \_ -> Sub.none
, preview =

View File

@ -34,7 +34,13 @@ example =
, version = 1
, categories = List.singleton Icons
, keyboardSupport = []
, state = IconExamples.init { label = "Bold", name = "bold", icon = viewSprite Sprite.bold }
, state =
IconExamples.init
{ label = "Bold"
, name = "bold"
, icon = viewSprite Sprite.bold
, renderSvgCode = \name -> "Svg.init \"\" [ Sprite.use Sprite." ++ name ++ " ] "
}
, update = IconExamples.update
, subscriptions = \_ -> Sub.none
, preview = IconExamples.preview (List.map Tuple.second sprites)

View File

@ -33,7 +33,13 @@ example =
, version = 1
, categories = List.singleton Icons
, keyboardSupport = []
, state = IconExamples.init { label = "Mastered", name = "starFilled", icon = UiIcon.starFilled }
, state =
IconExamples.init
{ label = "Mastered"
, name = "starFilled"
, icon = UiIcon.starFilled
, renderSvgCode = \name -> "UiIcon." ++ name
}
, update = IconExamples.update
, subscriptions = \_ -> Sub.none
, preview =