----------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} ----------------------------------------------------------------------------- -- | -- Module : Miso.Native.X.Element.Svg.Property -- Copyright : (C) 2016-2026 David M. Johnson -- License : BSD3-style (see the file LICENSE) -- Maintainer : David M. Johnson <code@dmj.io> -- Stability : experimental -- Portability : non-portable -- -- @since 1.13.0.0 ---------------------------------------------------------------------------- module Miso.Native.X.Element.Svg.Property ( -- *** Property content_ , contentRaw_ , src_ ) where ----------------------------------------------------------------------------- import Miso.String (MisoString, ms) import Miso.Types (Attribute, View) import Miso.Property import Miso.Html.Render (toHtmlWith) ----------------------------------------------------------------------------- -- | https://lynxjs.org/api/elements/built-in/svg.html#content -- -- Inline SVG XML content. -- -- > content_ "<svg>...</svg>" -- contentRaw_ :: MisoString -> Attribute model action contentRaw_ :: forall model action. MisoString -> Attribute model action contentRaw_ = MisoString -> MisoString -> Attribute model action forall model action. MisoString -> MisoString -> Attribute model action textProp MisoString "content" ----------------------------------------------------------------------------- -- | https://lynxjs.org/api/elements/built-in/svg.html#content -- -- Inline SVG XML content using 'Miso.miso' 'Miso.Types.View' Syntax. -- -- > content_ context props model (svg_ [] []) -- -- N.B. Must use "Miso.Svg" and 'Miso.Svg.Element.svg_' combinator. -- -- The content is serialised to a string when the attribute is built, so there -- is no running component to take @context@, @props@ or @model@ from: the -- caller supplies all three, and 'Miso.Types.vcontext' \/ 'Miso.Types.vprops' -- \/ 'Miso.Types.vmodel' inside the content resolve against those values. To -- draw from the enclosing component, obtain them with 'Miso.Types.withContext' -- \/ 'Miso.Types.withProps' \/ 'Miso.Types.withModel' above the element and -- pass them down: -- -- > withContext $ \context -> withProps $ \props -> withModel $ \model -> -- > svg_ -- > [ content_ context props model $ Svg.svg_ -- > [ textProp "xmlns" "http://www.w3.org/2000/svg" ] -- > [ Svg.circle_ [ Svg.fill_ color ] [] ] -- > ] -- > [] -- -- or use 'Miso.Native.X.Element.Svg.svgWith_', which does that lifting and -- lets the content itself use 'Miso.Types.vcontext' \/ 'Miso.Types.vprops' \/ -- 'Miso.Types.vmodel'. -- -- -- @since 1.14.0.0 content_ :: context -> props -> model -> View context props model action -> Attribute model action content_ :: forall context props model action. context -> props -> model -> View context props model action -> Attribute model action content_ context context props props model model = MisoString -> MisoString -> Attribute model action forall model action. MisoString -> MisoString -> Attribute model action textProp MisoString "content" (MisoString -> Attribute model action) -> (View context props model action -> MisoString) -> View context props model action -> Attribute model action forall b c a. (b -> c) -> (a -> b) -> a -> c . ByteString -> MisoString forall str. ToMisoString str => str -> MisoString ms (ByteString -> MisoString) -> (View context props model action -> ByteString) -> View context props model action -> MisoString forall b c a. (b -> c) -> (a -> b) -> a -> c . context -> props -> model -> View context props model action -> ByteString forall context props model action. context -> props -> model -> View context props model action -> ByteString toHtmlWith context context props props model model ----------------------------------------------------------------------------- -- | https://lynxjs.org/api/elements/built-in/svg.html#src -- -- SVG resource URL. -- -- > src_ "https://url.com/image.svg" -- src_ :: MisoString -> Attribute model action src_ :: forall model action. MisoString -> Attribute model action src_ = MisoString -> MisoString -> Attribute model action forall model action. MisoString -> MisoString -> Attribute model action textProp MisoString "src" -----------------------------------------------------------------------------