explorer: add a dynamic source code view

This commit is contained in:
Christophe de Vienne 2021-05-21 23:52:33 +02:00
parent 59b3e43bb0
commit c24a664d1a
2 changed files with 36 additions and 0 deletions

View File

@ -34,6 +34,10 @@ book =
[ Background.color <| MaterialColor.fromColor MaterialColor.gray ]
Nothing
viewButton
|> Story.addBloc Tooling.FullWidthBloc
[]
(Just "source code")
viewButtonSource
)
|> Story.addStory
(Story.optionListStory "Palette"
@ -88,6 +92,31 @@ viewButton palette text icon onPress size _ _ =
}
viewButtonSource palette text icon onPress size _ _ =
Tooling.sourceCode <|
"""Widget.button
(Material.containedButton palette
|> Customize.elementButton [ Element.height <| Element.px """
++ String.fromInt size
++ """ ]
)
{ text =\""""
++ text
++ """"
, icon = MaterialIcons.done |> Icon.elmMaterialIcons Widget.Material.Types.Color
, onPress = """
++ (case onPress of
Nothing ->
"Nothing"
Just () ->
"Just ()"
)
++ """
}
"""
type alias Model =
Int

View File

@ -408,3 +408,10 @@ canvas view =
, Element.centerY
]
view
sourceCode : String -> Element msg
sourceCode code =
("```\n" ++ code ++ "\n```")
|> Markdown.toHtml []
|> Element.html