@@ -16,6 +16,7 @@ module Internal.Model exposing
16 , LayoutContext(..)
16 , LayoutContext(..)
17 , Length(..)
17 , Length(..)
18 , Location(..)
18 , Location(..)
19 , NodeName(..)
20 , NodeName(..)
20 , Option(..)
21 , Option(..)
21 , OptionRecord
22 , OptionRecord
@@ -29,6 +30,7 @@ module Internal.Model exposing
29 , TransformComponent(..)
30 , TransformComponent(..)
30 , Transformation(..)
31 , Transformation(..)
31 , VAlign(..)
32 , VAlign(..)
33 , addNodeName
35 , addNodeName
@@ -40,7 +42,7 @@ module Internal.Model exposing
40 , asParagraph
42 , asParagraph
42 , asTextColumn
44 , asTextColumn
43− , boxShadowName
45+ , boxShadowClass
44 , columnClass
46 , columnClass
45 , composeTransformation
47 , composeTransformation
46 , contextClasses
48 , contextClasses
@@ -68,6 +70,7 @@ module Internal.Model exposing
68 , getWidth
70 , getWidth
69 , gridClass
71 , gridClass
70 , htmlClass
72 , htmlClass
71 , lengthClassName
74 , lengthClassName
@@ -76,41 +79,30 @@ module Internal.Model exposing
76 , onlyStyles
79 , onlyStyles
77 , optionsToRecord
80 , optionsToRecord
78 , paddingName
81 , paddingName
79 , pageClass
83 , pageClass
80 , paragraphClass
84 , paragraphClass
81 , reduceRecursive
85 , reduceRecursive
82− , reduceRecursiveCalcName
83 , reduceStyles
86 , reduceStyles
84 , reduceStylesRecursive
87 , reduceStylesRecursive
85 , removeNever
88 , removeNever
88 , renderFontClassName
89 , renderFontClassName
89 , renderHeight
90 , renderHeight
90 , renderRoot
91 , renderRoot
91 , renderWidth
93 , renderWidth
92 , rootStyle
94 , rootStyle
93 , rowClass
95 , rowClass
94 , singleClass
96 , singleClass
97 , spacingName
97 , spacingName
100− , textElement
99+ , textShadowClass
104 , toStyleSheet
101 , toStyleSheet
105− , toStyleSheetString
106 , transformClass
102 , transformClass
109 , unstyled
103 , unstyled
111 , unwrapDecorations
104 , unwrapDecorations
112− , unwrapDecsHelper
105+ , variantName
@@ -120,7 +112,7 @@ import Html.Attributes
120import Html.Keyed
112import Html.Keyed
121import Internal.Flag as Flag exposing (Flag)
113import Internal.Flag as Flag exposing (Flag)
122import Internal.Style exposing (classes, dot)
114import Internal.Style exposing (classes, dot)
123−import Json.Encode as Json
115+import Json.Encode as Encode
124import Set exposing (Set)
116import Set exposing (Set)
125import VirtualDom
117import VirtualDom
@@ -181,7 +173,8 @@ type Style
181 | Single String String String
173 | Single String String String
182 | Colored String String Color
174 | Colored String String Color
183 | SpacingStyle String Int Int
175 | SpacingStyle String Int Int
176+ | BorderWidth String Int Int Int Int
184− | PaddingStyle String Int Int Int Int
177+ | PaddingStyle String Float Float Float Float
185 | GridTemplateStyle
178 | GridTemplateStyle
186 { spacing : ( Length, Length )
179 { spacing : ( Length, Length )
187 , columns : List Length
180 , columns : List Length
@@ -212,12 +205,86 @@ type PseudoClass
209+type alias Adjustment =
217 | SansSerif
219 | SansSerif
218 | Monospace
220 | Monospace
219 | Typeface String
221 | Typeface String
220 | ImportFont String String
222 | ImportFont String String
225+ , adjustment : Maybe Adjustment
226+ , variants : List Variant
231+ = VariantActive String
233+ | VariantIndexed String Int
238+ VariantActive name ->
239+ "\"" ++ name ++ "\""
242+ "\"" ++ name ++ "\" 0"
244+ VariantIndexed name index ->
245+ "\"" ++ name ++ "\" " ++ String.fromInt index
250+ VariantActive name ->
256+ VariantIndexed name index ->
257+ name ++ "-" ++ String.fromInt index
260+renderVariants typeface =
263+ Just (String.join ", " (List.map renderVariant font.variants))
271+ VariantActive name ->
277+ VariantIndexed name index ->
278+ name == "smcp" && index == 1
281+hasSmallCaps typeface =
284+ List.any isSmallCaps font.variants
223type Property
290type Property
@@ -305,6 +372,13 @@ type NodeName
305 | Embedded String String
372 | Embedded String String
375+type NearbyChildren msg
377+ | ChildrenBehind (List (Html.Html msg))
378+ | ChildrenInFront (List (Html.Html msg))
379+ | ChildrenBehindAndInFront (List (Html.Html msg)) (List (Html.Html msg))
@@ -313,7 +387,7 @@ type alias Gathered msg =
313 { node : NodeName
387 { node : NodeName
314 , attributes : List (VirtualDom.Attribute msg)
388 , attributes : List (VirtualDom.Attribute msg)
315 , styles : List Style
389 , styles : List Style
316− , children : List (VirtualDom.Node msg)
390+ , children : NearbyChildren msg
317 , has : Flag.Field
391 , has : Flag.Field
@@ -381,7 +455,10 @@ finalizeNode has node attributes children embedMode parentContext =
381 Embedded nodeName internal ->
455 Embedded nodeName internal ->
382 VirtualDom.node nodeName
456 VirtualDom.node nodeName
383 attributes
457 attributes
458+ [ createNode internal
459+ [ Html.Attributes.class
384− [ createNode internal [ Html.Attributes.class (classes.any ++ " " ++ classes.single) ]
460+ (classes.any ++ " " ++ classes.single)
387 case parentContext of
464 case parentContext of
@@ -458,49 +535,45 @@ finalizeNode has node attributes children embedMode parentContext =
460embedWith static opts styles children =
537embedWith static opts styles children =
541+ |> List.foldl reduceStyles ( Set.empty, renderFocusStyle opts.focus )
543+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
545+ |> toStyleSheet opts
461 if static then
547 if static then
462− staticRoot
548+ staticRoot opts
463− :: (styles
549+ :: dynamicStyleSheet
464− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
466− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
468− |> toStyleSheet opts
470 :: children
550 :: children
473− (styles
553+ dynamicStyleSheet
474− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
476− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
478− |> toStyleSheet opts
480 :: children
554 :: children
483embedKeyed static opts styles children =
557embedKeyed static opts styles children =
561+ |> List.foldl reduceStyles ( Set.empty, renderFocusStyle opts.focus )
563+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
565+ |> toStyleSheet opts
484 if static then
567 if static then
485− ( "static-stylesheet", staticRoot )
568+ ( "static-stylesheet", staticRoot opts )
486 :: ( "dynamic-stylesheet"
569 :: ( "dynamic-stylesheet"
487− , styles
570+ , dynamicStyleSheet
488− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
490− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
492− |> toStyleSheet opts
494 :: children
572 :: children
497 ( "dynamic-stylesheet"
575 ( "dynamic-stylesheet"
498− , styles
576+ , dynamicStyleSheet
499− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
501− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
503− |> toStyleSheet opts
505 :: children
578 :: children
@@ -816,7 +889,16 @@ skippable flag style =
819−gatherAttrRecursive : String -> NodeName -> Flag.Field -> Transformation -> List Style -> List (VirtualDom.Attribute msg) -> List (VirtualDom.Node msg) -> List (Attribute aligned msg) -> Gathered msg
892+gatherAttrRecursive :
898+ -> List (VirtualDom.Attribute msg)
899+ -> NearbyChildren msg
900+ -> List (Attribute aligned msg)
820gatherAttrRecursive classes node has transform styles attrs children elementAttrs =
902gatherAttrRecursive classes node has transform styles attrs children elementAttrs =
821 case elementAttrs of
903 case elementAttrs of
@@ -950,7 +1032,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
951 gatherAttrRecursive (classes ++ " " ++ newClass)
1033 gatherAttrRecursive (classes ++ " " ++ newClass)
953− (Flag.merge addToFlags has)
1035+ (Flag.merge addToFlags (Flag.add Flag.width has))
954 transform
1036 transform
955 (newStyles ++ styles)
1037 (newStyles ++ styles)
@@ -971,7 +1053,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
972 "height-px-" ++ val
1054 "height-px-" ++ val
974− gatherAttrRecursive (name ++ " " ++ classes)
1056+ gatherAttrRecursive (Internal.Style.classes.heightExact ++ " " ++ name ++ " " ++ classes)
976 (Flag.add Flag.height has)
1058 (Flag.add Flag.height has)
977 transform
1059 transform
@@ -1028,7 +1110,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1029 gatherAttrRecursive (classes ++ " " ++ newClass)
1111 gatherAttrRecursive (classes ++ " " ++ newClass)
1031− (Flag.merge addToFlags has)
1113+ (Flag.merge addToFlags (Flag.add Flag.height has))
1032 transform
1114 transform
1033 (newStyles ++ styles)
1115 (newStyles ++ styles)
@@ -1060,20 +1142,15 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1060 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
1142 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
1062 Paragraph ->
1144 Paragraph ->
1063− let
1145+ -- previously we rendered a <p> tag, though apparently this invalidates the html if it has <div>s inside.
1064− newNode =
1146+ -- Since we can't guaranteee that there are no divs, we need another strategy.
1065− case node of
1147+ -- While it's not documented in many places, there apparently is a paragraph aria role
1066− Generic ->
1148+ -- https://github.com/w3c/aria/blob/11f85f41a5b621fdbe85fc9bcdcd270e653a48ba/common/script/roleInfo.js
1067− NodeName "p"
1149+ -- Though we'll need to wait till it gets released in an official wai-aria spec to use it.
1068−
1150+ -- If it's used at the moment, then Lighthouse complains (likely rightfully) that role paragraph is not recognized.
1075− gatherAttrRecursive classes
1151+ gatherAttrRecursive
1076− newNode
1152+ classes
1078 transform
1155 transform
@@ -1108,75 +1185,16 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1109 Styled styled ->
1186 Styled styled ->
1110 styles ++ styled.styles
1187 styles ++ styled.styles
1114− [ Html.Attributes.class <|
1118− [ Internal.Style.classes.nearby
1119− , Internal.Style.classes.single
1120− , Internal.Style.classes.above
1125− [ Internal.Style.classes.nearby
1126− , Internal.Style.classes.single
1127− , Internal.Style.classes.below
1132− [ Internal.Style.classes.nearby
1133− , Internal.Style.classes.single
1134− , Internal.Style.classes.onRight
1139− [ Internal.Style.classes.nearby
1140− , Internal.Style.classes.single
1141− , Internal.Style.classes.onLeft
1146− [ Internal.Style.classes.nearby
1147− , Internal.Style.classes.single
1148− , Internal.Style.classes.inFront
1153− [ Internal.Style.classes.nearby
1154− , Internal.Style.classes.single
1155− , Internal.Style.classes.behind
1169− styled.html NoStyleSheet asEl
1173− if location == Behind then
1174− Internal.Style.classes.hasBehind ++ " " ++ classes
1179− gatherAttrRecursive newClasses node has transform newStyles attrs (nearbyElement :: children) remaining
1189+ gatherAttrRecursive
1196+ (addNearbyElement location elem children)
1181 AlignX x ->
1199 AlignX x ->
1182 if Flag.present Flag.xAlign has then
1200 if Flag.present Flag.xAlign has then
@@ -1232,6 +1250,106 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1232 remaining
1250 remaining
1253+addNearbyElement location elem existing =
1256+ nearbyElement location elem
1259+ NoNearbyChildren ->
1262+ ChildrenBehind [ nearby ]
1265+ ChildrenInFront [ nearby ]
1267+ ChildrenBehind existingBehind ->
1270+ ChildrenBehind (nearby :: existingBehind)
1273+ ChildrenBehindAndInFront existingBehind [ nearby ]
1275+ ChildrenInFront existingInFront ->
1278+ ChildrenBehindAndInFront [ nearby ] existingInFront
1281+ ChildrenInFront (nearby :: existingInFront)
1283+ ChildrenBehindAndInFront existingBehind existingInFront ->
1286+ ChildrenBehindAndInFront (nearby :: existingBehind) existingInFront
1289+ ChildrenBehindAndInFront existingBehind (nearby :: existingInFront)
1292+nearbyElement location elem =
1294+ [ Html.Attributes.class <|
1298+ [ Internal.Style.classes.nearby
1299+ , Internal.Style.classes.single
1300+ , Internal.Style.classes.above
1305+ [ Internal.Style.classes.nearby
1306+ , Internal.Style.classes.single
1307+ , Internal.Style.classes.below
1312+ [ Internal.Style.classes.nearby
1313+ , Internal.Style.classes.single
1314+ , Internal.Style.classes.onRight
1319+ [ Internal.Style.classes.nearby
1320+ , Internal.Style.classes.single
1321+ , Internal.Style.classes.onLeft
1326+ [ Internal.Style.classes.nearby
1327+ , Internal.Style.classes.single
1328+ , Internal.Style.classes.inFront
1333+ [ Internal.Style.classes.nearby
1334+ , Internal.Style.classes.single
1335+ , Internal.Style.classes.behind
1349+ styled.html NoStyleSheet asEl
1235renderWidth w =
1353renderWidth w =
1236 case w of
1354 case w of
1237 Px px ->
1355 Px px ->
@@ -1318,7 +1436,7 @@ renderHeight h =
1318 "height-px-" ++ val
1436 "height-px-" ++ val
1320 ( Flag.none
1438 ( Flag.none
1321− , name
1439+ , Internal.Style.classes.heightExact ++ " " ++ name
1322 , [ Single name "height" (val ++ "px") ]
1440 , [ Single name "height" (val ++ "px") ]
@@ -1341,7 +1459,7 @@ renderHeight h =
1341 , [ Single
1459 , [ Single
1342 (Internal.Style.classes.any
1460 (Internal.Style.classes.any
1344− ++ Internal.Style.classes.row
1462+ ++ Internal.Style.classes.column
1345 ++ " > "
1463 ++ " > "
1346 ++ (Internal.Style.dot <| "height-fill-" ++ String.fromInt portion)
1464 ++ (Internal.Style.dot <| "height-fill-" ++ String.fromInt portion)
@@ -1360,7 +1478,9 @@ renderHeight h =
1362 "min-height"
1480 "min-height"
1481+ -- This needs to be !important because we're using `min-height: min-content`
1482+ -- to correct for safari's incorrect implementation of flexbox.
1363− (String.fromInt minSize ++ "px")
1483+ (String.fromInt minSize ++ "px !important")
1365 ( newFlag, newAttrs, newStyle ) =
1485 ( newFlag, newAttrs, newStyle ) =
1366 renderHeight len
1486 renderHeight len
@@ -1438,7 +1558,7 @@ element : LayoutContext -> NodeName -> List (Attribute aligned msg) -> Children
1438element context node attributes children =
1558element context node attributes children =
1439 attributes
1559 attributes
1440 |> List.reverse
1560 |> List.reverse
1441− |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] []
1561+ |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] NoNearbyChildren
1442 |> createElement context children
1562 |> createElement context children
@@ -1446,13 +1566,6 @@ untransformed =
1446 Untransformed
1566 Untransformed
1451−-- VirtualDom.text " "
1456createElement : LayoutContext -> Children (Element msg) -> Gathered msg -> Element msg
1569createElement : LayoutContext -> Children (Element msg) -> Gathered msg -> Element msg
1457createElement context children rendered =
1570createElement context children rendered =
@@ -1494,36 +1607,33 @@ createElement context children rendered =
1494 -- Same if it's a column or row with one child and width-content, height-content
1607 -- Same if it's a column or row with one child and width-content, height-content
1495 -- interferes with css grid
1608 -- interferes with css grid
1496 -- Maybe we could unpack text elements in a paragraph as well,
1609 -- Maybe we could unpack text elements in a paragraph as well,
1497− -- however embedded style elements that are larger than the line height will overlap with exisitng text.
1610+ -- however, embedded elements that are larger than the line height will overlap with exisitng text.
1498 -- I don't think that's what we want.
1611 -- I don't think that's what we want.
1500− context
1613+ -- context
1501− == asEl
1614+ -- == asEl
1502− || context
1615+ -- || context
1503− == asParagraph
1616+ -- == asParagraph
1505− ( VirtualDom.text
1618+ -- ( VirtualDom.text
1506− (if context == asParagraph then
1619+ -- (if context == asParagraph then
1507− str ++ " "
1620+ -- str
1512− :: htmls
1624+ -- :: htmls
1513− , existingStyles
1625+ -- , existingStyles
1628+ ( (if context == asEl then
1629+ textElementFill str
1517− ( textElement
1632+ textElement str
1518− (if context == asParagraph then
1524− :: htmls
1634+ :: htmls
1525− , existingStyles
1635+ , existingStyles
1528 Empty ->
1638 Empty ->
1529 ( htmls, existingStyles )
1639 ( htmls, existingStyles )
@@ -1565,38 +1675,30 @@ createElement context children rendered =
1565 -- TEXT OPTIMIZATION
1675 -- TEXT OPTIMIZATION
1566 -- You can have raw text if the element is an el, and has `width-content` and `height-content`
1676 -- You can have raw text if the element is an el, and has `width-content` and `height-content`
1567 -- Same if it's a column or row with one child and width-content, height-content
1677 -- Same if it's a column or row with one child and width-content, height-content
1569− context
1679+ -- context
1570− == asEl
1680+ -- == asEl
1571− || context
1681+ -- || context
1572− == asParagraph
1682+ -- == asParagraph
1574− ( ( key
1684+ -- ( ( key
1575− , VirtualDom.text
1685+ -- , VirtualDom.text
1576− (if context == asParagraph then
1583− :: htmls
1688+ -- :: htmls
1584− , existingStyles
1689+ -- , existingStyles
1693+ , if context == asEl then
1694+ textElementFill str
1590− (if context == asParagraph then
1594− str
1697+ textElement str
1597− :: htmls
1699+ :: htmls
1598− , existingStyles
1700+ , existingStyles
1601 Empty ->
1703 Empty ->
1602 ( htmls, existingStyles )
1704 ( htmls, existingStyles )
@@ -1619,7 +1721,9 @@ createElement context children rendered =
1619 (finalizeNode rendered.has
1721 (finalizeNode rendered.has
1620 rendered.node
1722 rendered.node
1621 rendered.attributes
1723 rendered.attributes
1622− (Keyed <| List.map (\x -> ( "nearby-elements-pls", x )) rendered.children ++ keyed)
1725+ (addKeyedChildren "nearby-element-pls" keyed rendered.children)
1623 NoStyleSheet
1727 NoStyleSheet
@@ -1627,7 +1731,13 @@ createElement context children rendered =
1628 { styles = allStyles
1732 { styles = allStyles
1629 , html =
1733 , html =
1630− finalizeNode rendered.has rendered.node rendered.attributes (Keyed (List.map (\x -> ( "nearby-elements-pls", x )) rendered.children ++ keyed))
1734+ finalizeNode
1737+ rendered.attributes
1739+ (addKeyedChildren "nearby-element-pls" keyed rendered.children)
1633 Unkeyed unkeyedChildren ->
1743 Unkeyed unkeyedChildren ->
@@ -1644,20 +1754,58 @@ createElement context children rendered =
1644 case newStyles of
1754 case newStyles of
1646 Unstyled
1756 Unstyled
1647− (finalizeNode rendered.has
1757+ (finalizeNode
1648 rendered.node
1759 rendered.node
1649 rendered.attributes
1760 rendered.attributes
1650− (Unkeyed <| rendered.children ++ unkeyed)
1761+ (Unkeyed (addChildren unkeyed rendered.children))
1651 NoStyleSheet
1762 NoStyleSheet
1654 allStyles ->
1765 allStyles ->
1656 { styles = allStyles
1767 { styles = allStyles
1657− , html = finalizeNode rendered.has rendered.node rendered.attributes (Unkeyed (rendered.children ++ unkeyed))
1768+ , html =
1772+ rendered.attributes
1773+ (Unkeyed (addChildren unkeyed rendered.children))
1777+addChildren existing nearbyChildren =
1778+ case nearbyChildren of
1779+ NoNearbyChildren ->
1782+ ChildrenBehind behind ->
1785+ ChildrenInFront inFront ->
1786+ existing ++ inFront
1788+ ChildrenBehindAndInFront behind inFront ->
1789+ behind ++ existing ++ inFront
1792+addKeyedChildren key existing nearbyChildren =
1793+ case nearbyChildren of
1794+ NoNearbyChildren ->
1797+ ChildrenBehind behind ->
1798+ List.map (\x -> ( key, x )) behind ++ existing
1800+ ChildrenInFront inFront ->
1801+ existing ++ List.map (\x -> ( key, x )) inFront
1803+ ChildrenBehindAndInFront behind inFront ->
1804+ List.map (\x -> ( key, x )) behind
1806+ ++ List.map (\x -> ( key, x )) inFront
@@ -1669,8 +1817,20 @@ defaultOptions =
1672−staticRoot =
1820+staticRoot : OptionRecord -> VirtualDom.Node msg
1824+ -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
1825+ VirtualDom.node "div"
1673− VirtualDom.node "style" [] [ VirtualDom.text Internal.Style.rules ]
1827+ [ VirtualDom.node "style" [] [ VirtualDom.text Internal.Style.rules ] ]
1829+ NoStaticStyleSheet ->
1833+ VirtualDom.node "elm-ui-static-rules" [ VirtualDom.property "rules" (Encode.string Internal.Style.rules) ] []
1676addWhen ifThis x to =
1836addWhen ifThis x to =
@@ -1788,7 +1948,7 @@ type Spacing
1790type Padding
1950type Padding
1791− = Padding String Int Int Int Int
1951+ = Padding String Float Float Float Float
1794extractSpacingAndPadding : List (Attribute aligned msg) -> ( Maybe Padding, Maybe Spacing )
1954extractSpacingAndPadding : List (Attribute aligned msg) -> ( Maybe Padding, Maybe Spacing )
@@ -1884,35 +2044,44 @@ getHeight attrs =
2047+textElementClasses : String
2048+textElementClasses =
2053+ ++ classes.widthContent
2055+ ++ classes.heightContent
1887textElement : String -> VirtualDom.Node msg
2058textElement : String -> VirtualDom.Node msg
1888textElement str =
2059textElement str =
1889 Html.div
2060 Html.div
1890 [ Html.Attributes.class
2061 [ Html.Attributes.class
1891− (String.join " "
2062+ textElementClasses
1894− , classes.widthContent
1895− , classes.heightContent
1899 [ Html.text str ]
2064 [ Html.text str ]
2067+textElementFillClasses : String
2068+textElementFillClasses =
2073+ ++ classes.widthFill
2075+ ++ classes.heightFill
1902textElementFill : String -> VirtualDom.Node msg
2078textElementFill : String -> VirtualDom.Node msg
1903textElementFill str =
2079textElementFill str =
1904− VirtualDom.node "div"
2080+ Html.div
1905− [ VirtualDom.property "className"
2081+ [ Html.Attributes.class
1906− (Json.string <|
2082+ textElementFillClasses
1910− , classes.widthFill
1911− , classes.heightFill
1915− [ VirtualDom.text str ]
2084+ [ Html.text str ]
1918type Children x
2087type Children x
@@ -1920,10 +2089,6 @@ type Children x
1920 | Keyed (List ( String, x ))
2089 | Keyed (List ( String, x ))
1924−-- toHtml : OptionRecord -> Element msg -> VirtualDom.Node msg
1927toHtml mode el =
2092toHtml mode el =
1928 case el of
2093 case el of
1929 Unstyled html ->
2094 Unstyled html ->
@@ -1959,8 +2124,7 @@ renderRoot optionList attributes child =
1961type RenderMode
2126type RenderMode
1963− | Layout
2127+ = Layout
1964 | NoStaticStyleSheet
2128 | NoStaticStyleSheet
1965 | WithVirtualCss
2129 | WithVirtualCss
@@ -2009,8 +2173,8 @@ rootStyle =
2009 , SansSerif
2173 , SansSerif
2012− [ StyleClass Flag.bgColor (Colored ("bg-color-" ++ formatColorClass (Rgba 1 1 1 0)) "background-color" (Rgba 1 1 1 0))
2176+ [ StyleClass Flag.bgColor (Colored ("bg-" ++ formatColorClass (Rgba 1 1 1 0)) "background-color" (Rgba 1 1 1 0))
2013− , StyleClass Flag.fontColor (Colored ("font-color-" ++ formatColorClass (Rgba 0 0 0 1)) "color" (Rgba 0 0 0 1))
2177+ , StyleClass Flag.fontColor (Colored ("fc-" ++ formatColorClass (Rgba 0 0 0 1)) "color" (Rgba 0 0 0 1))
2014 , StyleClass Flag.fontSize (FontSize 20)
2178 , StyleClass Flag.fontSize (FontSize 20)
2015 , StyleClass Flag.fontFamily <|
2179 , StyleClass Flag.fontFamily <|
2016 FontFamily (List.foldl renderFontClassName "font-" families)
2180 FontFamily (List.foldl renderFontClassName "font-" families)
@@ -2042,14 +2206,49 @@ renderFontClassName font current =
2042 |> String.toLower
2206 |> String.toLower
2043 |> String.words
2207 |> String.words
2044 |> String.join "-"
2208 |> String.join "-"
2210+ FontWith { name } ->
2048renderFocusStyle :
2218renderFocusStyle :
2049 FocusStyle
2219 FocusStyle
2050− -> Style
2220+ -> List Style
2051renderFocusStyle focus =
2221renderFocusStyle focus =
2222+ [ Style (Internal.Style.dot classes.focusedWithin ++ ":focus-within")
2223+ (List.filterMap identity
2224+ [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
2225+ , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
2228+ Property "box-shadow"
2230+ { color = shadow.color
2233+ |> Tuple.mapFirst toFloat
2234+ |> Tuple.mapSecond toFloat
2237+ toFloat shadow.blur
2239+ toFloat shadow.size
2244+ , Just <| Property "outline" "none"
2248+ ((Internal.Style.dot classes.any ++ ":focus .focusable, ")
2052− Style (Internal.Style.dot classes.any ++ ":focus .focusable, " ++ Internal.Style.dot classes.any ++ ".focusable:focus")
2249+ ++ (Internal.Style.dot classes.any ++ ".focusable:focus, ")
2250+ ++ (".ui-slide-bar:focus + " ++ Internal.Style.dot classes.any ++ " .focusable-thumb")
2053 (List.filterMap identity
2252 (List.filterMap identity
2054 [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
2253 [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
2055 , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
2254 , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
@@ -2072,6 +2271,7 @@ renderFocusStyle focus =
2072 , Just <| Property "outline" "none"
2271 , Just <| Property "outline" "none"
2077focusDefaultStyle : { backgroundColor : Maybe Color, borderColor : Maybe Color, shadow : Maybe Shadow }
2277focusDefaultStyle : { backgroundColor : Maybe Color, borderColor : Maybe Color, shadow : Maybe Shadow }
@@ -2083,7 +2283,7 @@ focusDefaultStyle =
2083 { color =
2283 { color =
2084 Rgba (155 / 255) (203 / 255) 1 1
2284 Rgba (155 / 255) (203 / 255) 1 1
2085 , offset = ( 0, 0 )
2285 , offset = ( 0, 0 )
2086− , blur = 3
2286+ , blur = 0
2087 , size = 3
2287 , size = 3
@@ -2151,498 +2351,734 @@ optionsToRecord options =
2154−renderFont : List Font -> String
2354+toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2155−renderFont families =
2355+toStyleSheet options styleSheet =
2356+ case options.mode of
2358+ -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
2359+ VirtualDom.node "div"
2361+ [ VirtualDom.node "style"
2363+ [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2366+ NoStaticStyleSheet ->
2367+ -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
2368+ VirtualDom.node "div"
2370+ [ VirtualDom.node "style"
2372+ [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2376+ VirtualDom.node "elm-ui-rules"
2377+ [ VirtualDom.property "rules"
2378+ (encodeStyles options styleSheet)
2383+renderTopLevelValues rules =
2157− fontName font =
2385+ withImport font =
2158 case font of
2386 case font of
2159− Serif ->
2387+ ImportFont _ url ->
2160− "serif"
2388+ Just ("@import url('" ++ url ++ "');")
2390+ -- FontWith with ->
2391+ -- case with.url of
2393+ -- Just ("@import url('" ++ x ++ "');")
2162− SansSerif ->
2399+ allNames =
2163− "sans-serif"
2400+ List.map Tuple.first rules
2165− Monospace ->
2402+ fontImports ( name, typefaces ) =
2166− "monospace"
2403+ let
2405+ String.join "\n" (List.filterMap withImport typefaces)
2168− Typeface name ->
2409+ fontAdjustments ( name, typefaces ) =
2169− "\"" ++ name ++ "\""
2410+ case typefaceAdjustment typefaces of
2413+ (List.map (renderNullAdjustmentRule name) allNames)
2171− ImportFont name url ->
2415+ Just adjustment ->
2172− "\"" ++ name ++ "\""
2416+ String.join ""
2417+ (List.map (renderFontAdjustmentRule name adjustment) allNames)
2174− families
2419+ String.join "\n" (List.map fontImports rules)
2175− |> List.map fontName
2176− |> String.join ", "
2420+ ++ String.join "\n" (List.map fontAdjustments rules)
2179−toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2423+renderNullAdjustmentRule fontToAdjust otherFontName =
2180−toStyleSheet options styleSheet =
2424+ let
2181− VirtualDom.node "style" [] [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2425+ name =
2426+ if fontToAdjust == otherFontName then
2430+ otherFontName ++ " ." ++ fontToAdjust
2437+ ++ classes.sizeByCapital
2442+ ++ classes.sizeByCapital
2444+ [ ( "line-height", "1" )
2450+ ++ classes.sizeByCapital
2452+ ++ Internal.Style.classes.text
2456+ ++ classes.sizeByCapital
2458+ ++ Internal.Style.classes.text
2460+ [ ( "vertical-align", "0" )
2461+ , ( "line-height", "1" )
2184−toStyleSheetString : OptionRecord -> List Style -> String
2185−toStyleSheetString options stylesheet =
2187− renderTopLevels rule =
2189− FontFamily name typefaces ->
2193− ImportFont _ url ->
2194− Just ("@import url('" ++ url ++ "');")
2196− _ ->
2466+fontRule name modifier ( parentAdj, textAdjustment ) =
2197− Nothing
2467+ [ bracket
2199− typefaces
2469+ ++ name
2200− |> List.filterMap getImports
2470+ ++ "."
2201− |> String.join "\n"
2471+ ++ modifier
2202− |> Just
2472+ ++ ", "
2485+ ++ Internal.Style.classes.text
2491+ ++ Internal.Style.classes.text
2207− renderProps force (Property key val) existing =
2497+renderFontAdjustmentRule fontToAdjust ( full, capital ) otherFontName =
2208− if force then
2498+ let
2209− existing ++ "\n " ++ key ++ ": " ++ val ++ " !important;"
2499+ name =
2500+ if fontToAdjust == otherFontName then
2212− existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
2504+ otherFontName ++ " ." ++ fontToAdjust
2507+ (fontRule name classes.sizeByCapital capital ++ fontRule name classes.fullSize full)
2214− renderStyle maybePseudo selector props =
2509+
2510+bracket selector rules =
2512+ renderPair ( name, val ) =
2513+ name ++ ": " ++ val ++ ";"
2515+ selector ++ " {" ++ String.join "" (List.map renderPair rules) ++ "}"
2518+fontAdjustmentRules converted =
2519+ ( [ ( "display", "block" )
2521+ , [ ( "display", "inline-block" )
2522+ , ( "line-height", String.fromFloat converted.height )
2523+ , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2524+ , ( "font-size", String.fromFloat converted.size ++ "em" )
2529+typefaceAdjustment typefaces =
2215− case maybePseudo of
2532+ case found of
2216 Nothing ->
2533 Nothing ->
2217− selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}"
2534+ case face of
2536+ case with.adjustment of
2542+ ( fontAdjustmentRules
2543+ (.full (convertAdjustment adjustment))
2544+ , fontAdjustmentRules
2545+ (.capital (convertAdjustment adjustment))
2219− Just pseudo ->
2548+ _ ->
2220− case pseudo of
2549+ found
2222− case options.hover of
2226− ForceHover ->
2551+ Just _ ->
2227− selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}"
2552+ found
2230− selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}"
2232− Focus ->
2558+fontName font =
2233− let
2559+ case font of
2234− renderedProps =
2560+ Serif ->
2235− List.foldl (renderProps False) "" props
2561+ "serif"
2246− ++ "-fs:not(.focus) {"
2256− , ".focusable-parent:focus ~ "
2266− Active ->
2563+ SansSerif ->
2267− selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}"
2564+ "sans-serif"
2269− renderStyleRule rule maybePseudo =
2566+ Monospace ->
2270− case rule of
2567+ "monospace"
2271− Style selector props ->
2272− renderStyle maybePseudo selector props
2274− Shadows name prop ->
2569+ Typeface name ->
2275− renderStyle
2570+ "\"" ++ name ++ "\""
2277− ("." ++ name)
2572+ ImportFont name url ->
2278− [ Property "box-shadow" prop
2573+ "\"" ++ name ++ "\""
2575+ FontWith { name } ->
2576+ "\"" ++ name ++ "\""
2579+topLevelValue rule =
2581+ FontFamily name typefaces ->
2582+ Just ( name, typefaces )
2588+renderProps force (Property key val) existing =
2590+ existing ++ "\n " ++ key ++ ": " ++ val ++ " !important;"
2593+ existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
2596+encodeStyles options stylesheet =
2602+ renderStyleRule options style Nothing
2604+ ( getStyleName style, Encode.list Encode.string styled )
2609+toStyleSheetString : OptionRecord -> List Style -> String
2610+toStyleSheetString options stylesheet =
2612+ combine style rendered =
2613+ { rules = rendered.rules ++ renderStyleRule options style Nothing
2615+ case topLevelValue style of
2620+ topLevel :: rendered.topLevel
2623+ case List.foldl combine { topLevel = [], rules = [] } stylesheet of
2624+ { topLevel, rules } ->
2625+ renderTopLevelValues topLevel ++ String.concat rules
2628+renderStyle : OptionRecord -> Maybe PseudoClass -> String -> List Property -> List String
2629+renderStyle options maybePseudo selector props =
2630+ case maybePseudo of
2632+ [ selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2637+ case options.hover of
2642+ [ selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}" ]
2645+ [ selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2281− Transparency name transparency ->
2647+ Focus ->
2283− opacity =
2649+ renderedProps =
2284− (1 - transparency)
2650+ List.foldl (renderProps False) "" props
2288− renderStyle
2652+ [ selector ++ "-fs:focus {" ++ renderedProps ++ "\n}"
2289− maybePseudo
2653+ , ("." ++ classes.any ++ ":focus " ++ selector ++ "-fs {")
2290− ("." ++ name)
2654+ ++ renderedProps
2291− [ Property "opacity" (String.fromFloat opacity)
2655+ ++ "\n}"
2656+ , (selector ++ "-fs:focus-within {")
2659+ , (".ui-slide-bar:focus + " ++ Internal.Style.dot classes.any ++ " .focusable-thumb" ++ selector ++ "-fs {")
2294− FontSize i ->
2664+ Active ->
2295− renderStyle
2665+ [ selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2297− (".font-size-" ++ String.fromInt i)
2298− [ Property "font-size" (String.fromInt i ++ "px")
2301− FontFamily name typefaces ->
2305− [ Property "font-family" (renderFont typefaces)
2308− Single class prop val ->
2668+renderStyleRule : OptionRecord -> Style -> Maybe PseudoClass -> List String
2669+renderStyleRule options rule maybePseudo =
2671+ Style selector props ->
2309− renderStyle
2672+ renderStyle options maybePseudo selector props
2312− [ Property prop val
2315− Colored class prop color ->
2674+ Shadows name prop ->
2316− renderStyle
2675+ renderStyle options
2317− maybePseudo
2676+ maybePseudo
2318− ("." ++ class)
2677+ ("." ++ name)
2319− [ Property prop (formatColor color)
2678+ [ Property "box-shadow" prop
2322− SpacingStyle cls x y ->
2681+ Transparency name transparency ->
2324− class =
2683+ opacity =
2325− "." ++ cls
2684+ (1 - transparency)
2688+ renderStyle options
2691+ [ Property "opacity" (String.fromFloat opacity)
2327− xPx =
2694+ FontSize i ->
2695+ renderStyle options
2697+ (".font-size-" ++ String.fromInt i)
2328− String.fromInt x ++ "px"
2698+ [ Property "font-size" (String.fromInt i ++ "px")
2330− yPx =
2701+ FontFamily name typefaces ->
2705+ |> List.filterMap renderVariants
2706+ |> String.join ", "
2709+ [ Property "font-family"
2711+ |> List.map fontName
2331− String.fromInt y ++ "px"
2712+ |> String.join ", "
2714+ , Property "font-feature-settings" features
2715+ , Property "font-variant"
2716+ (if List.any hasSmallCaps typefaces then
2334− "." ++ Internal.Style.classes.row
2720+ "normal"
2724+ renderStyle options
2336− wrappedRow =
2729+ Single class prop val ->
2337− "." ++ Internal.Style.classes.wrapped ++ row
2730+ renderStyle options
2733+ [ Property prop val
2339− column =
2736+ Colored class prop color ->
2340− "." ++ Internal.Style.classes.column
2737+ renderStyle options
2740+ [ Property prop (formatColor color)
2342− page =
2743+ SpacingStyle cls x y ->
2343− "." ++ Internal.Style.classes.page
2744+ let
2345− paragraph =
2748+ halfX =
2346− "." ++ Internal.Style.classes.paragraph
2749+ String.fromFloat (toFloat x / 2) ++ "px"
2348− left =
2751+ halfY =
2349− "." ++ Internal.Style.classes.alignLeft
2752+ String.fromFloat (toFloat y / 2) ++ "px"
2352− "." ++ Internal.Style.classes.alignRight
2755+ String.fromInt x ++ "px"
2355− "." ++ Internal.Style.classes.any
2758+ String.fromInt y ++ "px"
2357− single =
2760+ row =
2358− "." ++ Internal.Style.classes.single
2761+ "." ++ Internal.Style.classes.row
2361− [ renderStyle maybePseudo (class ++ row ++ " > " ++ any) [ Property "margin-right" xPx ]
2363− -- margins don't apply to last element of normal, unwrapped rows
2763+ wrappedRow =
2364− , renderStyle maybePseudo (class ++ row ++ " > " ++ any ++ ":last-child") [ Property "margin" "0" ]
2764+ "." ++ Internal.Style.classes.wrapped ++ row
2366− -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2766+ column =
2367− , renderStyle maybePseudo
2767+ "." ++ Internal.Style.classes.column
2368− (class ++ wrappedRow ++ " > " ++ any)
2369− [ Property "margin" ("0 " ++ xPx ++ " " ++ yPx ++ " 0")
2371− , renderStyle maybePseudo
2372− (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2373− [ Property "margin-right" "0"
2376− -- columns
2769+ page =
2377− , renderStyle maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2770+ "." ++ Internal.Style.classes.page
2378− , renderStyle maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2379− , renderStyle maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2380− , renderStyle maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2383− (class ++ paragraph)
2384− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2388− ("textarea" ++ class)
2389− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2394− -- (class ++ paragraph ++ " > " ++ any)
2395− -- [ Property "margin-right" xPx
2396− -- , Property "margin-bottom" yPx
2400− (class ++ paragraph ++ " > " ++ left)
2401− [ Property "margin-right" xPx
2405− (class ++ paragraph ++ " > " ++ right)
2406− [ Property "margin-left" xPx
2410− (class ++ paragraph ++ "::after")
2772+ paragraph =
2411− [ Property "content" "''"
2773+ "." ++ Internal.Style.classes.paragraph
2412− , Property "display" "block"
2413− , Property "height" "0"
2414− , Property "width" "0"
2415− , Property "margin-top" (String.fromInt (-1 * (y // 2)) ++ "px")
2419− (class ++ paragraph ++ "::before")
2420− [ Property "content" "''"
2421− , Property "display" "block"
2422− , Property "height" "0"
2423− , Property "width" "0"
2424− , Property "margin-bottom" (String.fromInt (-1 * (y // 2)) ++ "px")
2428− PaddingStyle cls top right bottom left ->
2775+ left =
2429− let
2776+ "." ++ Internal.Style.classes.alignLeft
2437− [ Property "padding"
2438− (String.fromInt top
2440− ++ String.fromInt right
2442− ++ String.fromInt bottom
2444− ++ String.fromInt left
2449− GridTemplateStyle template ->
2778+ right =
2450− let
2779+ "." ++ Internal.Style.classes.alignRight
2453− ++ String.join "-" (List.map lengthClassName template.rows)
2455− ++ String.join "-" (List.map lengthClassName template.columns)
2457− ++ lengthClassName (Tuple.first template.spacing)
2459− ++ lengthClassName (Tuple.second template.spacing)
2462− toGridLength (Tuple.second template.spacing)
2465− toGridLength (Tuple.first template.spacing)
2468− toGridLengthHelper Nothing Nothing x
2470− toGridLengthHelper minimum maximum x =
2473− String.fromInt px ++ "px"
2476− case ( minimum, maximum ) of
2477− ( Nothing, Nothing ) ->
2480− ( Just minSize, Nothing ) ->
2481− "minmax(" ++ String.fromInt minSize ++ "px, " ++ "max-content)"
2483− ( Nothing, Just maxSize ) ->
2484− "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2486− ( Just minSize, Just maxSize ) ->
2487− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2490− case ( minimum, maximum ) of
2491− ( Nothing, Nothing ) ->
2492− String.fromInt i ++ "fr"
2494− ( Just minSize, Nothing ) ->
2495− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt i ++ "fr" ++ "fr)"
2497− ( Nothing, Just maxSize ) ->
2498− "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2500− ( Just minSize, Just maxSize ) ->
2501− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2504− toGridLengthHelper (Just m) maximum len
2507− toGridLengthHelper minimum (Just m) len
2511− |> List.map toGridLength
2512− |> String.join ySpacing
2513− |> (\x -> "-ms-grid-columns: " ++ x ++ ";")
2517− |> List.map toGridLength
2518− |> String.join ySpacing
2519− |> (\x -> "-ms-grid-rows: " ++ x ++ ";")
2522− class ++ "{" ++ msColumns ++ msRows ++ "}"
2526− |> List.map toGridLength
2528− |> (\x -> "grid-template-columns: " ++ x ++ ";")
2532− |> List.map toGridLength
2534− |> (\x -> "grid-template-rows: " ++ x ++ ";")
2537− "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2540− "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2543− class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2546− "@supports (display:grid) {" ++ modernGrid ++ "}"
2550− GridPosition position ->
2781+ any =
2551− let
2782+ "." ++ Internal.Style.classes.any
2554− ++ String.fromInt position.row
2556− ++ String.fromInt position.col
2558− ++ String.fromInt position.width
2560− ++ String.fromInt position.height
2565− ++ String.fromInt position.row
2567− , "-ms-grid-row-span: "
2568− ++ String.fromInt position.height
2570− , "-ms-grid-column: "
2571− ++ String.fromInt position.col
2573− , "-ms-grid-column-span: "
2574− ++ String.fromInt position.width
2579− class ++ "{" ++ msPosition ++ "}"
2584− ++ String.fromInt position.row
2586− ++ String.fromInt (position.row + position.height)
2589− ++ String.fromInt position.col
2591− ++ String.fromInt (position.col + position.width)
2596− class ++ "{" ++ modernPosition ++ "}"
2599− "@supports (display:grid) {" ++ modernGrid ++ "}"
2603− PseudoSelector class styles ->
2784+ single =
2785+ "." ++ Internal.Style.classes.single
2788+ [ renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ " + " ++ any) [ Property "margin-left" xPx ]
2790+ -- margins don't apply to last element of normal, unwrapped rows
2791+ -- , renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ ":first-child") [ Property "margin" "0" ]
2792+ -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2793+ , renderStyle options
2795+ (class ++ wrappedRow ++ " > " ++ any)
2796+ [ Property "margin" (halfY ++ " " ++ halfX)
2799+ -- , renderStyle options maybePseudo
2800+ -- (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2801+ -- [ Property "margin-right" "0"
2804+ , renderStyle options maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2805+ , renderStyle options maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2806+ , renderStyle options maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2807+ , renderStyle options maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2808+ , renderStyle options
2810+ (class ++ paragraph)
2811+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2813+ , renderStyle options
2815+ ("textarea" ++ any ++ class)
2816+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2817+ , Property "height" ("calc(100% + " ++ String.fromInt y ++ "px)")
2820+ -- , renderStyle options
2822+ -- (class ++ paragraph ++ " > " ++ any)
2823+ -- [ Property "margin-right" xPx
2824+ -- , Property "margin-bottom" yPx
2826+ , renderStyle options
2828+ (class ++ paragraph ++ " > " ++ left)
2829+ [ Property "margin-right" xPx
2831+ , renderStyle options
2833+ (class ++ paragraph ++ " > " ++ right)
2834+ [ Property "margin-left" xPx
2836+ , renderStyle options
2838+ (class ++ paragraph ++ "::after")
2839+ [ Property "content" "''"
2840+ , Property "display" "block"
2841+ , Property "height" "0"
2842+ , Property "width" "0"
2843+ , Property "margin-top" (String.fromInt (-1 * (y // 2)) ++ "px")
2845+ , renderStyle options
2847+ (class ++ paragraph ++ "::before")
2848+ [ Property "content" "''"
2849+ , Property "display" "block"
2850+ , Property "height" "0"
2851+ , Property "width" "0"
2852+ , Property "margin-bottom" (String.fromInt (-1 * (y // 2)) ++ "px")
2856+ PaddingStyle cls top right bottom left ->
2862+ renderStyle options
2865+ [ Property "padding"
2866+ (String.fromFloat top
2868+ ++ String.fromFloat right
2870+ ++ String.fromFloat bottom
2872+ ++ String.fromFloat left
2877+ BorderWidth cls top right bottom left ->
2605− renderPseudoRule style =
2879+ class =
2606− renderStyleRule style (Just class)
2880+ "."
2608− List.map renderPseudoRule styles
2882+ in
2883+ renderStyle options
2886+ [ Property "border-width"
2887+ (String.fromInt top
2889+ ++ String.fromInt right
2891+ ++ String.fromInt bottom
2893+ ++ String.fromInt left
2898+ GridTemplateStyle template ->
2902+ ++ String.join "-" (List.map lengthClassName template.rows)
2904+ ++ String.join "-" (List.map lengthClassName template.columns)
2906+ ++ lengthClassName (Tuple.first template.spacing)
2908+ ++ lengthClassName (Tuple.second template.spacing)
2911+ toGridLength (Tuple.second template.spacing)
2914+ toGridLength (Tuple.first template.spacing)
2917+ toGridLengthHelper Nothing Nothing x
2919+ toGridLengthHelper minimum maximum x =
2922+ String.fromInt px ++ "px"
2925+ case ( minimum, maximum ) of
2926+ ( Nothing, Nothing ) ->
2929+ ( Just minSize, Nothing ) ->
2930+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ "max-content)"
2932+ ( Nothing, Just maxSize ) ->
2933+ "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2935+ ( Just minSize, Just maxSize ) ->
2936+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2939+ case ( minimum, maximum ) of
2940+ ( Nothing, Nothing ) ->
2941+ String.fromInt i ++ "fr"
2943+ ( Just minSize, Nothing ) ->
2944+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt i ++ "fr" ++ "fr)"
2946+ ( Nothing, Just maxSize ) ->
2947+ "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2949+ ( Just minSize, Just maxSize ) ->
2950+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2953+ toGridLengthHelper (Just m) maximum len
2956+ toGridLengthHelper minimum (Just m) len
2960+ |> List.map toGridLength
2961+ |> String.join ySpacing
2962+ |> (\x -> "-ms-grid-columns: " ++ x ++ ";")
2966+ |> List.map toGridLength
2967+ |> String.join ySpacing
2968+ |> (\x -> "-ms-grid-rows: " ++ x ++ ";")
2971+ class ++ "{" ++ msColumns ++ msRows ++ "}"
2975+ |> List.map toGridLength
2609 |> String.join " "
2976 |> String.join " "
2977+ |> (\x -> "grid-template-columns: " ++ x ++ ";")
2611− Transform transform ->
2979+ rows =
2612− let
2980+ template.rows
2613− val =
2981+ |> List.map toGridLength
2614− transformValue transform
2982+ |> String.join " "
2983+ |> (\x -> "grid-template-rows: " ++ x ++ ";")
2616− class =
2985+ gapX =
2617− transformClass transform
2986+ "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2619− case ( class, val ) of
2620− ( Just cls, Just v ) ->
2624− [ Property "transform"
2629− ""
2989+ "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2631− combine style rendered =
2991+ modernGrid =
2632− { rendered
2992+ class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2633− | rules = rendered.rules ++ renderStyleRule style Nothing
2635− case renderTopLevels style of
2639− Just topLevel ->
2994+ supports =
2640− rendered.topLevel ++ topLevel
2995+ "@supports (display:grid) {" ++ modernGrid ++ "}"
3001+ GridPosition position ->
3005+ ++ String.fromInt position.row
3007+ ++ String.fromInt position.col
3009+ ++ String.fromInt position.width
3011+ ++ String.fromInt position.height
3016+ ++ String.fromInt position.row
3018+ , "-ms-grid-row-span: "
3019+ ++ String.fromInt position.height
3021+ , "-ms-grid-column: "
3022+ ++ String.fromInt position.col
3024+ , "-ms-grid-column-span: "
3025+ ++ String.fromInt position.width
3030+ class ++ "{" ++ msPosition ++ "}"
3035+ ++ String.fromInt position.row
3037+ ++ String.fromInt (position.row + position.height)
3040+ ++ String.fromInt position.col
3042+ ++ String.fromInt (position.col + position.width)
3047+ class ++ "{" ++ modernPosition ++ "}"
3050+ "@supports (display:grid) {" ++ modernGrid ++ "}"
2643− case List.foldl combine { rules = "", topLevel = "" } stylesheet of
3052+ [ base
2644− { topLevel, rules } ->
3053+ , supports
2645− topLevel ++ rules
3054+ ]
3056+ PseudoSelector class styles ->
3058+ renderPseudoRule style =
3059+ renderStyleRule options style (Just class)
3061+ List.concatMap renderPseudoRule styles
3063+ Transform transform ->
3066+ transformValue transform
3069+ transformClass transform
3071+ case ( class, val ) of
3072+ ( Just cls, Just v ) ->
3073+ renderStyle options
3076+ [ Property "transform"
2648lengthClassName : Length -> String
3084lengthClassName : Length -> String
@@ -2682,12 +3118,12 @@ formatTextShadow shadow =
2685−textShadowName shadow =
3121+textShadowClass shadow =
2686 String.concat
3122 String.concat
2688− , String.fromFloat (Tuple.first shadow.offset) ++ "px"
3124+ , floatClass (Tuple.first shadow.offset) ++ "px"
2689− , String.fromFloat (Tuple.second shadow.offset) ++ "px"
3125+ , floatClass (Tuple.second shadow.offset) ++ "px"
2690− , String.fromFloat shadow.blur ++ "px"
3126+ , floatClass shadow.blur ++ "px"
2691 , formatColorClass shadow.color
3127 , formatColorClass shadow.color
@@ -2708,17 +3144,17 @@ formatBoxShadow shadow =
2711−boxShadowName shadow =
3147+boxShadowClass shadow =
2712 String.concat <|
3148 String.concat <|
2713 [ if shadow.inset then
3149 [ if shadow.inset then
2714 "box-inset"
3150 "box-inset"
2718− , String.fromFloat (Tuple.first shadow.offset) ++ "px"
3154+ , floatClass (Tuple.first shadow.offset) ++ "px"
2719− , String.fromFloat (Tuple.second shadow.offset) ++ "px"
3155+ , floatClass (Tuple.second shadow.offset) ++ "px"
2720− , String.fromFloat shadow.blur ++ "px"
3156+ , floatClass shadow.blur ++ "px"
2721− , String.fromFloat shadow.size ++ "px"
3157+ , floatClass shadow.size ++ "px"
2722 , formatColorClass shadow.color
3158 , formatColorClass shadow.color
@@ -2763,6 +3199,17 @@ paddingName top right bottom left =
2763 ++ String.fromInt left
3199 ++ String.fromInt left
3202+paddingNameFloat top right bottom left =
3206+ ++ floatClass right
3208+ ++ floatClass bottom
2766getStyleName : Style -> String
3213getStyleName : Style -> String
2767getStyleName style =
3214getStyleName style =
2768 case style of
3215 case style of
@@ -2793,6 +3240,9 @@ getStyleName style =
2793 PaddingStyle cls top right bottom left ->
3240 PaddingStyle cls top right bottom left ->
3243+ BorderWidth cls top right bottom left ->
2796 GridTemplateStyle template ->
3246 GridTemplateStyle template ->
2797 "grid-rows-"
3247 "grid-rows-"
2798 ++ String.join "-" (List.map lengthClassName template.rows)
3248 ++ String.join "-" (List.map lengthClassName template.rows)
@@ -3025,3 +3475,76 @@ onlyStyles attr =
3481+{- Font Adjustments -}
3484+convertAdjustment adjustment =
3500+ ((ascender - newBaseline) / 2) + newBaseline
3503+ ((ascender - descender) / 2) + descender
3506+ [ adjustment.capital
3507+ , adjustment.baseline
3508+ , adjustment.descender
3509+ , adjustment.lowercase
3513+ Maybe.withDefault adjustment.capital (List.maximum lines)
3516+ Maybe.withDefault adjustment.descender (List.minimum lines)
3520+ |> List.filter (\x -> x /= descender)
3522+ |> Maybe.withDefault adjustment.baseline
3528+ 1 / (ascender - newBaseline)
3531+ 1 / (ascender - descender)
3536+ -- (oldMiddle - newFullMiddle) * 2
3539+ adjust fullSize (ascender - descender) fullVertical
3541+ adjust capitalSize (ascender - newBaseline) capitalVertical
3545+adjust size height vertical =
3546+ { vertical = vertical