@@ -16,7 +16,6 @@ module Internal.Model exposing
16 , LayoutContext(..)
16 , LayoutContext(..)
17 , Length(..)
17 , Length(..)
18 , Location(..)
18 , Location(..)
20 , NodeName(..)
19 , NodeName(..)
21 , Option(..)
20 , Option(..)
22 , OptionRecord
21 , OptionRecord
@@ -30,7 +29,6 @@ module Internal.Model exposing
30 , TransformComponent(..)
29 , TransformComponent(..)
31 , Transformation(..)
30 , Transformation(..)
32 , VAlign(..)
31 , VAlign(..)
35 , addNodeName
33 , addNodeName
@@ -42,7 +40,7 @@ module Internal.Model exposing
42 , asParagraph
40 , asParagraph
44 , asTextColumn
42 , asTextColumn
45− , boxShadowClass
43+ , boxShadowName
46 , columnClass
44 , columnClass
47 , composeTransformation
45 , composeTransformation
48 , contextClasses
46 , contextClasses
@@ -70,7 +68,6 @@ module Internal.Model exposing
70 , getWidth
68 , getWidth
71 , gridClass
69 , gridClass
72 , htmlClass
70 , htmlClass
74 , lengthClassName
71 , lengthClassName
@@ -79,30 +76,41 @@ module Internal.Model exposing
79 , onlyStyles
76 , onlyStyles
80 , optionsToRecord
77 , optionsToRecord
81 , paddingName
78 , paddingName
83 , pageClass
79 , pageClass
84 , paragraphClass
80 , paragraphClass
85 , reduceRecursive
81 , reduceRecursive
82+ , reduceRecursiveCalcName
86 , reduceStyles
83 , reduceStyles
87 , reduceStylesRecursive
84 , reduceStylesRecursive
88 , removeNever
85 , removeNever
89 , renderFontClassName
88 , renderFontClassName
90 , renderHeight
89 , renderHeight
91 , renderRoot
90 , renderRoot
93 , renderWidth
91 , renderWidth
94 , rootStyle
92 , rootStyle
95 , rowClass
93 , rowClass
96 , singleClass
94 , singleClass
97 , spacingName
97 , spacingName
99− , textShadowClass
100+ , textElement
101 , toStyleSheet
104 , toStyleSheet
105+ , toStyleSheetString
102 , transformClass
106 , transformClass
103 , unstyled
109 , unstyled
104 , unwrapDecorations
111 , unwrapDecorations
105− , variantName
112+ , unwrapDecsHelper
@@ -112,7 +120,7 @@ import Html.Attributes
112import Html.Keyed
120import Html.Keyed
113import Internal.Flag as Flag exposing (Flag)
121import Internal.Flag as Flag exposing (Flag)
114import Internal.Style exposing (classes, dot)
122import Internal.Style exposing (classes, dot)
115−import Json.Encode as Encode
123+import Json.Encode as Json
116import Set exposing (Set)
124import Set exposing (Set)
117import VirtualDom
125import VirtualDom
@@ -174,7 +182,7 @@ type Style
174 | Colored String String Color
182 | Colored String String Color
175 | SpacingStyle String Int Int
183 | SpacingStyle String Int Int
176 | BorderWidth String Int Int Int Int
184 | BorderWidth String Int Int Int Int
177− | PaddingStyle String Float Float Float Float
185+ | PaddingStyle String Int Int Int Int
178 | GridTemplateStyle
186 | GridTemplateStyle
179 { spacing : ( Length, Length )
187 { spacing : ( Length, Length )
180 , columns : List Length
188 , columns : List Length
@@ -205,86 +213,12 @@ type PseudoClass
209−type alias Adjustment =
219 | SansSerif
218 | SansSerif
220 | Monospace
219 | Monospace
221 | Typeface String
220 | Typeface String
222 | ImportFont String String
221 | 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
290type Property
224type Property
@@ -372,13 +306,6 @@ type NodeName
372 | Embedded String String
306 | 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))
@@ -387,7 +314,7 @@ type alias Gathered msg =
387 { node : NodeName
314 { node : NodeName
388 , attributes : List (VirtualDom.Attribute msg)
315 , attributes : List (VirtualDom.Attribute msg)
389 , styles : List Style
316 , styles : List Style
390− , children : NearbyChildren msg
317+ , children : List (VirtualDom.Node msg)
391 , has : Flag.Field
318 , has : Flag.Field
@@ -403,6 +330,7 @@ unstyled =
403 Unstyled << always
330 Unstyled << always
406finalizeNode has node attributes children embedMode parentContext =
334finalizeNode has node attributes children embedMode parentContext =
408 createNode nodeName attrs =
336 createNode nodeName attrs =
@@ -455,10 +383,7 @@ finalizeNode has node attributes children embedMode parentContext =
455 Embedded nodeName internal ->
383 Embedded nodeName internal ->
456 VirtualDom.node nodeName
384 VirtualDom.node nodeName
457 attributes
385 attributes
458− [ createNode internal
459− [ Html.Attributes.class
460− (classes.any ++ " " ++ classes.single)
386+ [ createNode internal [ Html.Attributes.class (classes.any ++ " " ++ classes.single) ]
464 case parentContext of
389 case parentContext of
@@ -535,45 +460,49 @@ finalizeNode has node attributes children embedMode parentContext =
537embedWith static opts styles children =
462embedWith static opts styles children =
541− |> List.foldl reduceStyles ( Set.empty, renderFocusStyle opts.focus )
543− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
545− |> toStyleSheet opts
547 if static then
463 if static then
548− staticRoot opts
464+ staticRoot
549− :: dynamicStyleSheet
465+ :: (styles
466+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
468+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
470+ |> toStyleSheet opts
550 :: children
472 :: children
553− dynamicStyleSheet
475+ (styles
476+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
478+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
480+ |> toStyleSheet opts
554 :: children
482 :: children
557embedKeyed static opts styles children =
485embedKeyed static opts styles children =
561− |> List.foldl reduceStyles ( Set.empty, renderFocusStyle opts.focus )
563− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
565− |> toStyleSheet opts
567 if static then
486 if static then
568− ( "static-stylesheet", staticRoot opts )
487+ ( "static-stylesheet", staticRoot )
569 :: ( "dynamic-stylesheet"
488 :: ( "dynamic-stylesheet"
570− , dynamicStyleSheet
489+ , styles
490+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
492+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
494+ |> toStyleSheet opts
572 :: children
496 :: children
575 ( "dynamic-stylesheet"
499 ( "dynamic-stylesheet"
576− , dynamicStyleSheet
500+ , styles
501+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
503+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
505+ |> toStyleSheet opts
578 :: children
507 :: children
@@ -889,16 +818,7 @@ skippable flag style =
892−gatherAttrRecursive :
821+gatherAttrRecursive : String -> NodeName -> Flag.Field -> Transformation -> List Style -> List (VirtualDom.Attribute msg) -> List (VirtualDom.Node msg) -> List (Attribute aligned msg) -> Gathered msg
898− -> List (VirtualDom.Attribute msg)
899− -> NearbyChildren msg
900− -> List (Attribute aligned msg)
902gatherAttrRecursive classes node has transform styles attrs children elementAttrs =
822gatherAttrRecursive classes node has transform styles attrs children elementAttrs =
903 case elementAttrs of
823 case elementAttrs of
@@ -1032,7 +952,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1033 gatherAttrRecursive (classes ++ " " ++ newClass)
953 gatherAttrRecursive (classes ++ " " ++ newClass)
1035− (Flag.merge addToFlags (Flag.add Flag.width has))
955+ (Flag.merge addToFlags has)
1036 transform
956 transform
1037 (newStyles ++ styles)
957 (newStyles ++ styles)
@@ -1053,7 +973,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1054 "height-px-" ++ val
974 "height-px-" ++ val
1056− gatherAttrRecursive (Internal.Style.classes.heightExact ++ " " ++ name ++ " " ++ classes)
976+ gatherAttrRecursive (name ++ " " ++ classes)
1058 (Flag.add Flag.height has)
978 (Flag.add Flag.height has)
1059 transform
979 transform
@@ -1110,7 +1030,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1111 gatherAttrRecursive (classes ++ " " ++ newClass)
1031 gatherAttrRecursive (classes ++ " " ++ newClass)
1113− (Flag.merge addToFlags (Flag.add Flag.height has))
1033+ (Flag.merge addToFlags has)
1114 transform
1034 transform
1115 (newStyles ++ styles)
1035 (newStyles ++ styles)
@@ -1142,15 +1062,20 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1142 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
1062 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
1144 Paragraph ->
1064 Paragraph ->
1145− -- previously we rendered a <p> tag, though apparently this invalidates the html if it has <div>s inside.
1065+ let
1146− -- Since we can't guaranteee that there are no divs, we need another strategy.
1066+ newNode =
1147− -- While it's not documented in many places, there apparently is a paragraph aria role
1067+ case node of
1148− -- https://github.com/w3c/aria/blob/11f85f41a5b621fdbe85fc9bcdcd270e653a48ba/common/script/roleInfo.js
1068+ Generic ->
1149− -- Though we'll need to wait till it gets released in an official wai-aria spec to use it.
1069+ NodeName "p"
1150− -- If it's used at the moment, then Lighthouse complains (likely rightfully) that role paragraph is not recognized.
1070+
1151− gatherAttrRecursive
1077+ gatherAttrRecursive classes
1152− classes
1078+ newNode
1155 transform
1080 transform
@@ -1185,16 +1110,75 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1186 Styled styled ->
1111 Styled styled ->
1187 styles ++ styled.styles
1112 styles ++ styled.styles
1116+ [ Html.Attributes.class <|
1120+ [ Internal.Style.classes.nearby
1121+ , Internal.Style.classes.single
1122+ , Internal.Style.classes.above
1127+ [ Internal.Style.classes.nearby
1128+ , Internal.Style.classes.single
1129+ , Internal.Style.classes.below
1134+ [ Internal.Style.classes.nearby
1135+ , Internal.Style.classes.single
1136+ , Internal.Style.classes.onRight
1141+ [ Internal.Style.classes.nearby
1142+ , Internal.Style.classes.single
1143+ , Internal.Style.classes.onLeft
1148+ [ Internal.Style.classes.nearby
1149+ , Internal.Style.classes.single
1150+ , Internal.Style.classes.inFront
1155+ [ Internal.Style.classes.nearby
1156+ , Internal.Style.classes.single
1157+ , Internal.Style.classes.behind
1171+ styled.html NoStyleSheet asEl
1175+ if location == Behind then
1176+ Internal.Style.classes.hasBehind ++ " " ++ classes
1189− gatherAttrRecursive
1181+ gatherAttrRecursive newClasses node has transform newStyles attrs (nearbyElement :: children) remaining
1196− (addNearbyElement location elem children)
1199 AlignX x ->
1183 AlignX x ->
1200 if Flag.present Flag.xAlign has then
1184 if Flag.present Flag.xAlign has then
@@ -1250,106 +1234,6 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1250 remaining
1234 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
1353renderWidth w =
1237renderWidth w =
1354 case w of
1238 case w of
1355 Px px ->
1239 Px px ->
@@ -1436,7 +1320,7 @@ renderHeight h =
1436 "height-px-" ++ val
1320 "height-px-" ++ val
1438 ( Flag.none
1322 ( Flag.none
1439− , Internal.Style.classes.heightExact ++ " " ++ name
1323+ , name
1440 , [ Single name "height" (val ++ "px") ]
1324 , [ Single name "height" (val ++ "px") ]
@@ -1459,7 +1343,7 @@ renderHeight h =
1459 , [ Single
1343 , [ Single
1460 (Internal.Style.classes.any
1344 (Internal.Style.classes.any
1462− ++ Internal.Style.classes.column
1346+ ++ Internal.Style.classes.row
1463 ++ " > "
1347 ++ " > "
1464 ++ (Internal.Style.dot <| "height-fill-" ++ String.fromInt portion)
1348 ++ (Internal.Style.dot <| "height-fill-" ++ String.fromInt portion)
@@ -1478,9 +1362,7 @@ renderHeight h =
1480 "min-height"
1364 "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.
1483− (String.fromInt minSize ++ "px !important")
1365+ (String.fromInt minSize ++ "px")
1485 ( newFlag, newAttrs, newStyle ) =
1367 ( newFlag, newAttrs, newStyle ) =
1486 renderHeight len
1368 renderHeight len
@@ -1558,7 +1440,7 @@ element : LayoutContext -> NodeName -> List (Attribute aligned msg) -> Children
1558element context node attributes children =
1440element context node attributes children =
1559 attributes
1441 attributes
1560 |> List.reverse
1442 |> List.reverse
1561− |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] NoNearbyChildren
1443+ |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] []
1562 |> createElement context children
1444 |> createElement context children
@@ -1566,6 +1448,13 @@ untransformed =
1566 Untransformed
1448 Untransformed
1453+-- VirtualDom.text " "
1569createElement : LayoutContext -> Children (Element msg) -> Gathered msg -> Element msg
1458createElement : LayoutContext -> Children (Element msg) -> Gathered msg -> Element msg
1570createElement context children rendered =
1459createElement context children rendered =
@@ -1607,33 +1496,36 @@ createElement context children rendered =
1607 -- Same if it's a column or row with one child and width-content, height-content
1496 -- Same if it's a column or row with one child and width-content, height-content
1608 -- interferes with css grid
1497 -- interferes with css grid
1609 -- Maybe we could unpack text elements in a paragraph as well,
1498 -- Maybe we could unpack text elements in a paragraph as well,
1610− -- however, embedded elements that are larger than the line height will overlap with exisitng text.
1499+ -- however embedded style elements that are larger than the line height will overlap with exisitng text.
1611 -- I don't think that's what we want.
1500 -- I don't think that's what we want.
1613− -- context
1502+ context
1614− -- == asEl
1503+ == asEl
1615− -- || context
1504+ || context
1616− -- == asParagraph
1505+ == asParagraph
1618− -- ( VirtualDom.text
1507+ ( VirtualDom.text
1619− -- (if context == asParagraph then
1508+ (if context == asParagraph then
1620− -- str
1509+ str ++ " "
1624− -- :: htmls
1514+ :: htmls
1625− -- , existingStyles
1515+ , existingStyles
1628− ( (if context == asEl then
1629− textElementFill str
1632− textElement str
1519+ ( textElement
1520+ (if context == asParagraph then
1634− :: htmls
1526+ :: htmls
1635− , existingStyles
1527+ , existingStyles
1638 Empty ->
1530 Empty ->
1639 ( htmls, existingStyles )
1531 ( htmls, existingStyles )
@@ -1675,30 +1567,38 @@ createElement context children rendered =
1675 -- TEXT OPTIMIZATION
1567 -- TEXT OPTIMIZATION
1676 -- You can have raw text if the element is an el, and has `width-content` and `height-content`
1568 -- You can have raw text if the element is an el, and has `width-content` and `height-content`
1677 -- Same if it's a column or row with one child and width-content, height-content
1569 -- Same if it's a column or row with one child and width-content, height-content
1679− -- context
1571+ context
1680− -- == asEl
1572+ == asEl
1681− -- || context
1573+ || context
1682− -- == asParagraph
1574+ == asParagraph
1684− -- ( ( key
1576+ ( ( key
1685− -- , VirtualDom.text
1577+ , VirtualDom.text
1578+ (if context == asParagraph then
1688− -- :: htmls
1585+ :: htmls
1689− -- , existingStyles
1586+ , existingStyles
1693− , if context == asEl then
1694− textElementFill str
1697− textElement str
1591+ , textElement
1592+ (if context == asParagraph then
1699− :: htmls
1599+ :: htmls
1700− , existingStyles
1600+ , existingStyles
1703 Empty ->
1603 Empty ->
1704 ( htmls, existingStyles )
1604 ( htmls, existingStyles )
@@ -1721,9 +1621,7 @@ createElement context children rendered =
1721 (finalizeNode rendered.has
1621 (finalizeNode rendered.has
1722 rendered.node
1622 rendered.node
1723 rendered.attributes
1623 rendered.attributes
1725− (addKeyedChildren "nearby-element-pls" keyed rendered.children)
1624+ (Keyed <| List.map (\x -> ( "nearby-elements-pls", x )) rendered.children ++ keyed)
1727 NoStyleSheet
1625 NoStyleSheet
@@ -1731,13 +1629,7 @@ createElement context children rendered =
1732 { styles = allStyles
1630 { styles = allStyles
1733 , html =
1631 , html =
1734− finalizeNode
1632+ finalizeNode rendered.has rendered.node rendered.attributes (Keyed (List.map (\x -> ( "nearby-elements-pls", x )) rendered.children ++ keyed))
1737− rendered.attributes
1739− (addKeyedChildren "nearby-element-pls" keyed rendered.children)
1743 Unkeyed unkeyedChildren ->
1635 Unkeyed unkeyedChildren ->
@@ -1754,58 +1646,20 @@ createElement context children rendered =
1754 case newStyles of
1646 case newStyles of
1756 Unstyled
1648 Unstyled
1757− (finalizeNode
1649+ (finalizeNode rendered.has
1759 rendered.node
1650 rendered.node
1760 rendered.attributes
1651 rendered.attributes
1761− (Unkeyed (addChildren unkeyed rendered.children))
1652+ (Unkeyed <| rendered.children ++ unkeyed)
1762 NoStyleSheet
1653 NoStyleSheet
1765 allStyles ->
1656 allStyles ->
1767 { styles = allStyles
1658 { styles = allStyles
1768− , html =
1659+ , html = finalizeNode rendered.has rendered.node rendered.attributes (Unkeyed (rendered.children ++ unkeyed))
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
@@ -1817,20 +1671,8 @@ defaultOptions =
1820−staticRoot : OptionRecord -> VirtualDom.Node msg
1674+staticRoot =
1824− -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
1825− VirtualDom.node "div"
1827− [ VirtualDom.node "style" [] [ VirtualDom.text Internal.Style.rules ] ]
1675+ 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) ] []
1836addWhen ifThis x to =
1678addWhen ifThis x to =
@@ -1948,7 +1790,7 @@ type Spacing
1950type Padding
1792type Padding
1951− = Padding String Float Float Float Float
1793+ = Padding String Int Int Int Int
1954extractSpacingAndPadding : List (Attribute aligned msg) -> ( Maybe Padding, Maybe Spacing )
1796extractSpacingAndPadding : List (Attribute aligned msg) -> ( Maybe Padding, Maybe Spacing )
@@ -2044,44 +1886,35 @@ getHeight attrs =
2047−textElementClasses : String
2048−textElementClasses =
2053− ++ classes.widthContent
2055− ++ classes.heightContent
2058textElement : String -> VirtualDom.Node msg
1889textElement : String -> VirtualDom.Node msg
2059textElement str =
1890textElement str =
2060 Html.div
1891 Html.div
2061 [ Html.Attributes.class
1892 [ Html.Attributes.class
2062− textElementClasses
1893+ (String.join " "
1896+ , classes.widthContent
1897+ , classes.heightContent
2064 [ Html.text str ]
1901 [ Html.text str ]
2067−textElementFillClasses : String
2068−textElementFillClasses =
2073− ++ classes.widthFill
2075− ++ classes.heightFill
2078textElementFill : String -> VirtualDom.Node msg
1904textElementFill : String -> VirtualDom.Node msg
2079textElementFill str =
1905textElementFill str =
2080− Html.div
1906+ VirtualDom.node "div"
2081− [ Html.Attributes.class
1907+ [ VirtualDom.property "className"
2082− textElementFillClasses
1908+ (Json.string <|
1912+ , classes.widthFill
1913+ , classes.heightFill
2084− [ Html.text str ]
1917+ [ VirtualDom.text str ]
2087type Children x
1920type Children x
@@ -2089,6 +1922,10 @@ type Children x
2089 | Keyed (List ( String, x ))
1922 | Keyed (List ( String, x ))
1926+-- toHtml : OptionRecord -> Element msg -> VirtualDom.Node msg
2092toHtml mode el =
1929toHtml mode el =
2093 case el of
1930 case el of
2094 Unstyled html ->
1931 Unstyled html ->
@@ -2124,7 +1961,8 @@ renderRoot optionList attributes child =
2126type RenderMode
1963type RenderMode
2127− = Layout
1965+ | Layout
2128 | NoStaticStyleSheet
1966 | NoStaticStyleSheet
2129 | WithVirtualCss
1967 | WithVirtualCss
@@ -2173,8 +2011,8 @@ rootStyle =
2173 , SansSerif
2011 , SansSerif
2176− [ StyleClass Flag.bgColor (Colored ("bg-" ++ formatColorClass (Rgba 1 1 1 0)) "background-color" (Rgba 1 1 1 0))
2014+ [ StyleClass Flag.bgColor (Colored ("bg-color-" ++ formatColorClass (Rgba 1 1 1 0)) "background-color" (Rgba 1 1 1 0))
2177− , StyleClass Flag.fontColor (Colored ("fc-" ++ formatColorClass (Rgba 0 0 0 1)) "color" (Rgba 0 0 0 1))
2015+ , StyleClass Flag.fontColor (Colored ("font-color-" ++ formatColorClass (Rgba 0 0 0 1)) "color" (Rgba 0 0 0 1))
2178 , StyleClass Flag.fontSize (FontSize 20)
2016 , StyleClass Flag.fontSize (FontSize 20)
2179 , StyleClass Flag.fontFamily <|
2017 , StyleClass Flag.fontFamily <|
2180 FontFamily (List.foldl renderFontClassName "font-" families)
2018 FontFamily (List.foldl renderFontClassName "font-" families)
@@ -2206,49 +2044,14 @@ renderFontClassName font current =
2206 |> String.toLower
2044 |> String.toLower
2207 |> String.words
2045 |> String.words
2208 |> String.join "-"
2046 |> String.join "-"
2210− FontWith { name } ->
2218renderFocusStyle :
2050renderFocusStyle :
2219 FocusStyle
2051 FocusStyle
2220− -> List Style
2052+ -> Style
2221renderFocusStyle focus =
2053renderFocusStyle 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, ")
2249− ++ (Internal.Style.dot classes.any ++ ".focusable:focus, ")
2054+ Style (Internal.Style.dot classes.any ++ ":focus .focusable, " ++ Internal.Style.dot classes.any ++ ".focusable:focus")
2250− ++ (".ui-slide-bar:focus + " ++ Internal.Style.dot classes.any ++ " .focusable-thumb")
2252 (List.filterMap identity
2055 (List.filterMap identity
2253 [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
2056 [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
2254 , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
2057 , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
@@ -2271,7 +2074,6 @@ renderFocusStyle focus =
2271 , Just <| Property "outline" "none"
2074 , Just <| Property "outline" "none"
2277focusDefaultStyle : { backgroundColor : Maybe Color, borderColor : Maybe Color, shadow : Maybe Shadow }
2079focusDefaultStyle : { backgroundColor : Maybe Color, borderColor : Maybe Color, shadow : Maybe Shadow }
@@ -2283,7 +2085,7 @@ focusDefaultStyle =
2283 { color =
2085 { color =
2284 Rgba (155 / 255) (203 / 255) 1 1
2086 Rgba (155 / 255) (203 / 255) 1 1
2285 , offset = ( 0, 0 )
2087 , offset = ( 0, 0 )
2286− , blur = 0
2088+ , blur = 3
2287 , size = 3
2089 , size = 3
@@ -2351,734 +2153,519 @@ optionsToRecord options =
2354−toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2156+renderFont : List Font -> String
2355−toStyleSheet options styleSheet =
2157+renderFont families =
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 =
2385− withImport font =
2159+ fontName font =
2386 case font of
2160 case font of
2387− ImportFont _ url ->
2161+ Serif ->
2388− Just ("@import url('" ++ url ++ "');")
2162+ "serif"
2390− -- FontWith with ->
2391− -- case with.url of
2393− -- Just ("@import url('" ++ x ++ "');")
2400− List.map Tuple.first rules
2402− fontImports ( name, typefaces ) =
2405− String.join "\n" (List.filterMap withImport typefaces)
2409− fontAdjustments ( name, typefaces ) =
2410− case typefaceAdjustment typefaces of
2413− (List.map (renderNullAdjustmentRule name) allNames)
2415− Just adjustment ->
2164+ SansSerif ->
2416− String.join ""
2165+ "sans-serif"
2417− (List.map (renderFontAdjustmentRule name adjustment) allNames)
2419− String.join "\n" (List.map fontImports rules)
2420− ++ String.join "\n" (List.map fontAdjustments rules)
2423−renderNullAdjustmentRule fontToAdjust otherFontName =
2170+ Typeface name ->
2424− let
2171+ "\"" ++ name ++ "\""
2426− if fontToAdjust == otherFontName then
2429− else
2173+ ImportFont name url ->
2430− otherFontName ++ " ." ++ fontToAdjust
2174+ "\"" ++ name ++ "\""
2177+ |> List.map fontName
2432− String.join " "
2178+ |> String.join ", "
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" )
2466−fontRule name modifier ( parentAdj, textAdjustment ) =
2181+toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2467− [ bracket
2182+toStyleSheet options styleSheet =
2468− ("."
2183+ VirtualDom.node "style" [] [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2485− ++ Internal.Style.classes.text
2491− ++ Internal.Style.classes.text
2497−renderFontAdjustmentRule fontToAdjust ( full, capital ) otherFontName =
2186+toStyleSheetString : OptionRecord -> List Style -> String
2187+toStyleSheetString options stylesheet =
2499− name =
2189+ renderTopLevels rule =
2500− if fontToAdjust == otherFontName then
2190+ case rule of
2501− fontToAdjust
2191+ FontFamily name typefaces ->
2503− else
2193+ getImports font =
2504− otherFontName ++ " ." ++ fontToAdjust
2194+ case font of
2505− in
2195+ ImportFont _ url ->
2506− String.join " "
2196+ Just ("@import url('" ++ url ++ "');")
2507− (fontRule name classes.sizeByCapital capital ++ fontRule name classes.fullSize full)
2510−bracket selector rules =
2198+ _ ->
2512− renderPair ( name, val ) =
2513− name ++ ": " ++ val ++ ";"
2515− selector ++ " {" ++ String.join "" (List.map renderPair rules) ++ "}"
2201+ typefaces
2202+ |> List.filterMap getImports
2203+ |> String.join "\n"
2518−fontAdjustmentRules converted =
2209+ renderProps force (Property key val) existing =
2519− ( [ ( "display", "block" )
2210+ if force then
2520− ]
2211+ existing ++ "\n " ++ key ++ ": " ++ val ++ " !important;"
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" )
2214+ existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
2529−typefaceAdjustment typefaces =
2216+ renderStyle maybePseudo selector props =
2532− case found of
2217+ case maybePseudo of
2533 Nothing ->
2218 Nothing ->
2534− case face of
2219+ selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}"
2536− case with.adjustment of
2542− ( fontAdjustmentRules
2543− (.full (convertAdjustment adjustment))
2544− , fontAdjustmentRules
2545− (.capital (convertAdjustment adjustment))
2224+ case options.hover of
2558−fontName font =
2228+ ForceHover ->
2559− case font of
2229+ selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}"
2570− "\"" ++ name ++ "\""
2572− ImportFont name url ->
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
2231+ AllowHover ->
2610−toStyleSheetString options stylesheet =
2232+ selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}"
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
2237+ List.foldl (renderProps False) "" props
2248+ ++ "-fs:not(.focus) {"
2258+ , ".focusable-parent:focus ~ "
2628−renderStyle : OptionRecord -> Maybe PseudoClass -> String -> List Property -> List String
2268+ Active ->
2629−renderStyle options maybePseudo selector props =
2630− case maybePseudo of
2632− [ selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2269+ selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}"
2637− case options.hover of
2641− ForceHover ->
2271+ renderStyleRule rule maybePseudo =
2642− [ selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}" ]
2272+ case rule of
2273+ Style selector props ->
2274+ renderStyle maybePseudo selector props
2644− AllowHover ->
2276+ Shadows name prop ->
2645− [ selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2277+ renderStyle
2280+ [ Property "box-shadow" prop
2647− Focus ->
2283+ Transparency name transparency ->
2649− renderedProps =
2285+ opacity =
2650− List.foldl (renderProps False) "" props
2286+ (1 - transparency)
2652− [ selector ++ "-fs:focus {" ++ renderedProps ++ "\n}"
2290+ renderStyle
2653− , ("." ++ classes.any ++ ":focus " ++ selector ++ "-fs {")
2291+ maybePseudo
2656− , (selector ++ "-fs:focus-within {")
2659− , (".ui-slide-bar:focus + " ++ Internal.Style.dot classes.any ++ " .focusable-thumb" ++ selector ++ "-fs {")
2665− [ selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2668−renderStyleRule : OptionRecord -> Style -> Maybe PseudoClass -> List String
2669−renderStyleRule options rule maybePseudo =
2671− Style selector props ->
2672− renderStyle options maybePseudo selector props
2674− Shadows name prop ->
2675− renderStyle options
2677− ("." ++ name)
2292+ ("." ++ name)
2678− [ Property "box-shadow" prop
2681− Transparency name transparency ->
2688− renderStyle options
2691− [ Property "opacity" (String.fromFloat opacity)
2293+ [ Property "opacity" (String.fromFloat opacity)
2694− FontSize i ->
2296+ FontSize i ->
2695− renderStyle options
2297+ renderStyle
2696− maybePseudo
2298+ maybePseudo
2697− (".font-size-" ++ String.fromInt i)
2299+ (".font-size-" ++ String.fromInt i)
2698− [ Property "font-size" (String.fromInt i ++ "px")
2300+ [ Property "font-size" (String.fromInt i ++ "px")
2701− FontFamily name typefaces ->
2303+ FontFamily name typefaces ->
2702− let
2304+ renderStyle
2703− features =
2305+ maybePseudo
2704− typefaces
2306+ ("." ++ name)
2705− |> List.filterMap renderVariants
2706− |> String.join ", "
2709− [ Property "font-family"
2307+ [ Property "font-family" (renderFont typefaces)
2711− |> List.map fontName
2712− |> String.join ", "
2714− , Property "font-feature-settings" features
2715− , Property "font-variant"
2716− (if List.any hasSmallCaps typefaces then
2719− else
2310+ Single class prop val ->
2724− renderStyle options
2311+ renderStyle
2725− maybePseudo
2312+ maybePseudo
2726− ("." ++ name)
2313+ ("." ++ class)
2727− families
2314+ [ Property prop val
2729− Single class prop val ->
2317+ Colored class prop color ->
2730− renderStyle options
2318+ renderStyle
2731− maybePseudo
2319+ maybePseudo
2732− ("." ++ class)
2320+ ("." ++ class)
2733− [ Property prop val
2321+ [ Property prop (formatColor color)
2736− Colored class prop color ->
2324+ SpacingStyle cls x y ->
2737− renderStyle options
2325+ let
2738− maybePseudo
2326+ class =
2739− ("." ++ class)
2327+ "." ++ cls
2740− [ Property prop (formatColor color)
2743− SpacingStyle cls x y ->
2329+ xPx =
2744− let
2330+ String.fromInt x ++ "px"
2749− String.fromFloat (toFloat x / 2) ++ "px"
2333+ String.fromInt y ++ "px"
2752− String.fromFloat (toFloat y / 2) ++ "px"
2336+ "." ++ Internal.Style.classes.row
2754− xPx =
2338+ wrappedRow =
2755− String.fromInt x ++ "px"
2339+ "." ++ Internal.Style.classes.wrapped ++ row
2757− yPx =
2341+ column =
2758− String.fromInt y ++ "px"
2342+ "." ++ Internal.Style.classes.column
2761− "." ++ Internal.Style.classes.row
2345+ "." ++ Internal.Style.classes.page
2763− wrappedRow =
2347+ paragraph =
2764− "." ++ Internal.Style.classes.wrapped ++ row
2348+ "." ++ Internal.Style.classes.paragraph
2766− column =
2350+ left =
2767− "." ++ Internal.Style.classes.column
2351+ "." ++ Internal.Style.classes.alignLeft
2769− page =
2353+ right =
2770− "." ++ Internal.Style.classes.page
2354+ "." ++ Internal.Style.classes.alignRight
2772− paragraph =
2356+ any =
2773− "." ++ Internal.Style.classes.paragraph
2357+ "." ++ Internal.Style.classes.any
2775− left =
2359+ single =
2776− "." ++ Internal.Style.classes.alignLeft
2360+ "." ++ Internal.Style.classes.single
2363+ [ renderStyle maybePseudo (class ++ row ++ " > " ++ any) [ Property "margin-right" xPx ]
2778− right =
2365+ -- margins don't apply to last element of normal, unwrapped rows
2779− "." ++ Internal.Style.classes.alignRight
2366+ , renderStyle maybePseudo (class ++ row ++ " > " ++ any ++ ":last-child") [ Property "margin" "0" ]
2781− any =
2368+ -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2782− "." ++ Internal.Style.classes.any
2369+ , renderStyle maybePseudo
2370+ (class ++ wrappedRow ++ " > " ++ any)
2371+ [ Property "margin" ("0 " ++ xPx ++ " " ++ yPx ++ " 0")
2373+ , renderStyle maybePseudo
2374+ (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2375+ [ Property "margin-right" "0"
2784− single =
2378+ -- columns
2785− "." ++ Internal.Style.classes.single
2788− [ renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ " + " ++ any) [ Property "margin-left" xPx ]
2379+ , renderStyle maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2789−
2380+ , renderStyle maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2790− -- margins don't apply to last element of normal, unwrapped rows
2791− -- , renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ ":first-child") [ Property "margin" "0" ]
2381+ , renderStyle maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2792− -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2382+ , renderStyle maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2793− , renderStyle options
2383+ , renderStyle
2794− maybePseudo
2384+ maybePseudo
2795− (class ++ wrappedRow ++ " > " ++ any)
2385+ (class ++ paragraph)
2796− [ Property "margin" (halfY ++ " " ++ halfX)
2386+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2390+ ("textarea" ++ class)
2391+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2799− -- , renderStyle options maybePseudo
2394+ -- , renderStyle
2800− -- (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2395+ -- maybePseudo
2396+ -- (class ++ paragraph ++ " > " ++ any)
2801− -- [ Property "margin-right" "0"
2397+ -- [ Property "margin-right" xPx
2802− -- ]
2398+ -- , Property "margin-bottom" yPx
2803− -- columns
2399+ -- ]
2804− , renderStyle options maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2400+ , renderStyle
2805− , renderStyle options maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2401+ maybePseudo
2402+ (class ++ paragraph ++ " > " ++ left)
2403+ [ Property "margin-right" xPx
2407+ (class ++ paragraph ++ " > " ++ right)
2806− , renderStyle options maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2408+ [ Property "margin-left" xPx
2807− , renderStyle options maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2409+ ]
2808− , renderStyle options
2410+ , renderStyle
2809− maybePseudo
2411+ maybePseudo
2810− (class ++ paragraph)
2412+ (class ++ paragraph ++ "::after")
2413+ [ Property "content" "''"
2414+ , Property "display" "block"
2415+ , Property "height" "0"
2416+ , Property "width" "0"
2811− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2417+ , Property "margin-top" (String.fromInt (-1 * (y // 2)) ++ "px")
2813− , renderStyle options
2419+ , renderStyle
2814− maybePseudo
2420+ maybePseudo
2815− ("textarea" ++ any ++ class)
2421+ (class ++ paragraph ++ "::before")
2816− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2422+ [ Property "content" "''"
2423+ , Property "display" "block"
2424+ , Property "height" "0"
2425+ , Property "width" "0"
2817− , Property "height" ("calc(100% + " ++ String.fromInt y ++ "px)")
2426+ , Property "margin-bottom" (String.fromInt (-1 * (y // 2)) ++ "px")
2820− -- , renderStyle options
2430+ PaddingStyle cls top right bottom left ->
2821− -- maybePseudo
2431+ let
2822− -- (class ++ paragraph ++ " > " ++ any)
2823− -- [ Property "margin-right" xPx
2824− -- , Property "margin-bottom" yPx
2826− , renderStyle options
2828− (class ++ paragraph ++ " > " ++ left)
2432+ class =
2829− [ Property "margin-right" xPx
2433+ "."
2831− , renderStyle options
2435+ in
2833− (class ++ paragraph ++ " > " ++ right)
2834− [ Property "margin-left" xPx
2836− , renderStyle options
2436+ renderStyle
2837− maybePseudo
2437+ maybePseudo
2838− (class ++ paragraph ++ "::after")
2438+ class
2839− [ Property "content" "''"
2439+ [ Property "padding"
2840− , Property "display" "block"
2841− , Property "height" "0"
2842− , Property "width" "0"
2843− , Property "margin-top" (String.fromInt (-1 * (y // 2)) ++ "px")
2440+ (String.fromInt top
2845− , renderStyle options
2442+ ++ String.fromInt right
2846− maybePseudo
2443+ ++ "px "
2847− (class ++ paragraph ++ "::before")
2444+ ++ String.fromInt bottom
2848− [ Property "content" "''"
2445+ ++ "px "
2849− , Property "display" "block"
2850− , Property "height" "0"
2851− , Property "width" "0"
2852− , Property "margin-bottom" (String.fromInt (-1 * (y // 2)) ++ "px")
2446+ ++ String.fromInt left
2856− PaddingStyle cls top right bottom left ->
2451+ BorderWidth cls top right bottom left ->
2858− class =
2453+ class =
2862− renderStyle options
2457+ renderStyle
2863− maybePseudo
2458+ maybePseudo
2865− [ Property "padding"
2460+ [ Property "border-width"
2866− (String.fromFloat top
2461+ (String.fromInt top
2867− ++ "px "
2462+ ++ "px "
2868− ++ String.fromFloat right
2463+ ++ String.fromInt right
2869− ++ "px "
2464+ ++ "px "
2870− ++ String.fromFloat bottom
2465+ ++ String.fromInt bottom
2871− ++ "px "
2466+ ++ "px "
2872− ++ String.fromFloat left
2467+ ++ String.fromInt left
2873− ++ "px"
2468+ ++ "px"
2877− BorderWidth cls top right bottom left ->
2472+ GridTemplateStyle template ->
2879− class =
2474+ class =
2880− "."
2475+ ".grid-rows-"
2881− ++ cls
2476+ ++ String.join "-" (List.map lengthClassName template.rows)
2478+ ++ String.join "-" (List.map lengthClassName template.columns)
2480+ ++ lengthClassName (Tuple.first template.spacing)
2482+ ++ lengthClassName (Tuple.second template.spacing)
2485+ toGridLength (Tuple.second template.spacing)
2488+ toGridLength (Tuple.first template.spacing)
2491+ toGridLengthHelper Nothing Nothing x
2493+ toGridLengthHelper minimum maximum x =
2496+ String.fromInt px ++ "px"
2499+ case ( minimum, maximum ) of
2500+ ( Nothing, Nothing ) ->
2503+ ( Just minSize, Nothing ) ->
2504+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ "max-content)"
2506+ ( Nothing, Just maxSize ) ->
2507+ "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2509+ ( Just minSize, Just maxSize ) ->
2510+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2513+ case ( minimum, maximum ) of
2514+ ( Nothing, Nothing ) ->
2515+ String.fromInt i ++ "fr"
2517+ ( Just minSize, Nothing ) ->
2518+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt i ++ "fr" ++ "fr)"
2520+ ( Nothing, Just maxSize ) ->
2521+ "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2523+ ( Just minSize, Just maxSize ) ->
2524+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2527+ toGridLengthHelper (Just m) maximum len
2530+ toGridLengthHelper minimum (Just m) len
2534+ |> List.map toGridLength
2535+ |> String.join ySpacing
2536+ |> (\x -> "-ms-grid-columns: " ++ x ++ ";")
2540+ |> List.map toGridLength
2541+ |> String.join ySpacing
2542+ |> (\x -> "-ms-grid-rows: " ++ x ++ ";")
2545+ class ++ "{" ++ msColumns ++ msRows ++ "}"
2549+ |> List.map toGridLength
2551+ |> (\x -> "grid-template-columns: " ++ x ++ ";")
2555+ |> List.map toGridLength
2557+ |> (\x -> "grid-template-rows: " ++ x ++ ";")
2560+ "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2563+ "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2566+ class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2569+ "@supports (display:grid) {" ++ modernGrid ++ "}"
2883− renderStyle options
2571+ base ++ supports
2886− [ Property "border-width"
2887− (String.fromInt top
2889− ++ String.fromInt right
2891− ++ String.fromInt bottom
2893− ++ String.fromInt left
2898− GridTemplateStyle template ->
2573+ GridPosition position ->
2900− class =
2575+ class =
2901− ".grid-rows-"
2576+ ".grid-pos-"
2902− ++ String.join "-" (List.map lengthClassName template.rows)
2577+ ++ String.fromInt position.row
2579+ ++ String.fromInt position.col
2903− ++ "-cols-"
2580+ ++ "-"
2904− ++ String.join "-" (List.map lengthClassName template.columns)
2581+ ++ String.fromInt position.width
2905− ++ "-space-x-"
2582+ ++ "-"
2906− ++ lengthClassName (Tuple.first template.spacing)
2583+ ++ String.fromInt position.height
2907− ++ "-space-y-"
2584+
2908− ++ lengthClassName (Tuple.second template.spacing)
2585+ msPosition =
2909−
2586+ String.join " "
2910− ySpacing =
2587+ [ "-ms-grid-row: "
2911− toGridLength (Tuple.second template.spacing)
2588+ ++ String.fromInt position.row
2913− xSpacing =
2590+ , "-ms-grid-row-span: "
2914− toGridLength (Tuple.first template.spacing)
2591+ ++ String.fromInt position.height
2916− toGridLength x =
2593+ , "-ms-grid-column: "
2917− toGridLengthHelper Nothing Nothing x
2594+ ++ String.fromInt position.col
2919− toGridLengthHelper minimum maximum x =
2596+ , "-ms-grid-column-span: "
2920− case x of
2597+ ++ String.fromInt position.width
2921− Px px ->
2598+ ++ ";"
2602+ class ++ "{" ++ msPosition ++ "}"
2922− String.fromInt px ++ "px"
2607+ ++ String.fromInt position.row
2924− Content ->
2609+ ++ String.fromInt (position.row + position.height)
2925− case ( minimum, maximum ) of
2610+ ++ ";"
2926− ( Nothing, Nothing ) ->
2611+ , "grid-column: "
2929− ( Just minSize, Nothing ) ->
2930− "minmax(" ++ String.fromInt minSize ++ "px, " ++ "max-content)"
2612+ ++ String.fromInt position.col
2932− ( Nothing, Just maxSize ) ->
2614+ ++ String.fromInt (position.col + position.width)
2933− "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2615+ ++ ";"
2935− ( Just minSize, Just maxSize ) ->
2617+
2936− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2618+ modernGrid =
2937−
2619+ class ++ "{" ++ modernPosition ++ "}"
2939− case ( minimum, maximum ) of
2621+ supports =
2940− ( Nothing, Nothing ) ->
2622+ "@supports (display:grid) {" ++ modernGrid ++ "}"
2941− String.fromInt i ++ "fr"
2623+ in
2942−
2624+ base ++ supports
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
2977− |> (\x -> "grid-template-columns: " ++ x ++ ";")
2979− rows =
2626+ PseudoSelector class styles ->
2980− template.rows
2627+ let
2981− |> List.map toGridLength
2628+ renderPseudoRule style =
2629+ renderStyleRule style (Just class)
2631+ List.map renderPseudoRule styles
2982 |> String.join " "
2632 |> String.join " "
2983− |> (\x -> "grid-template-rows: " ++ x ++ ";")
2986− "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2989− "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2992− class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2994− supports =
2634+ Transform transform ->
2995− "@supports (display:grid) {" ++ modernGrid ++ "}"
3001− GridPosition position ->
3004− ".grid-pos-"
2637+ transformValue transform
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 ++ "}"
3056− PseudoSelector class styles ->
2639+ class =
3057− let
2640+ transformClass transform
3058− renderPseudoRule style =
3059− renderStyleRule options style (Just class)
3061− List.concatMap renderPseudoRule styles
2642+ case ( class, val ) of
2643+ ( Just cls, Just v ) ->
2647+ [ Property "transform"
3063− Transform transform ->
2651+ _ ->
3066− transformValue transform
3068− class =
2654+ combine style rendered =
3069− transformClass transform
2655+ { rendered
3070− in
2656+ | rules = rendered.rules ++ renderStyleRule style Nothing
3071− case ( class, val ) of
2657+ , topLevel =
3072− ( Just cls, Just v ) ->
2658+ case renderTopLevels style of
3073− renderStyle options
2659+ Nothing ->
3074− maybePseudo
2660+ rendered.topLevel
3076− [ Property "transform"
3080− _ ->
2662+ Just topLevel ->
3081− []
2663+ rendered.topLevel ++ topLevel
2666+ case List.foldl combine { rules = "", topLevel = "" } stylesheet of
2667+ { topLevel, rules } ->
3084lengthClassName : Length -> String
2671lengthClassName : Length -> String
@@ -3118,12 +2705,12 @@ formatTextShadow shadow =
3121−textShadowClass shadow =
2708+textShadowName shadow =
3122 String.concat
2709 String.concat
3124− , floatClass (Tuple.first shadow.offset) ++ "px"
2711+ , String.fromFloat (Tuple.first shadow.offset) ++ "px"
3125− , floatClass (Tuple.second shadow.offset) ++ "px"
2712+ , String.fromFloat (Tuple.second shadow.offset) ++ "px"
3126− , floatClass shadow.blur ++ "px"
2713+ , String.fromFloat shadow.blur ++ "px"
3127 , formatColorClass shadow.color
2714 , formatColorClass shadow.color
@@ -3144,17 +2731,17 @@ formatBoxShadow shadow =
3147−boxShadowClass shadow =
2734+boxShadowName shadow =
3148 String.concat <|
2735 String.concat <|
3149 [ if shadow.inset then
2736 [ if shadow.inset then
3150 "box-inset"
2737 "box-inset"
3154− , floatClass (Tuple.first shadow.offset) ++ "px"
2741+ , String.fromFloat (Tuple.first shadow.offset) ++ "px"
3155− , floatClass (Tuple.second shadow.offset) ++ "px"
2742+ , String.fromFloat (Tuple.second shadow.offset) ++ "px"
3156− , floatClass shadow.blur ++ "px"
2743+ , String.fromFloat shadow.blur ++ "px"
3157− , floatClass shadow.size ++ "px"
2744+ , String.fromFloat shadow.size ++ "px"
3158 , formatColorClass shadow.color
2745 , formatColorClass shadow.color
@@ -3199,17 +2786,6 @@ paddingName top right bottom left =
3199 ++ String.fromInt left
2786 ++ String.fromInt left
3202−paddingNameFloat top right bottom left =
3206− ++ floatClass right
3208− ++ floatClass bottom
3213getStyleName : Style -> String
2789getStyleName : Style -> String
3214getStyleName style =
2790getStyleName style =
3215 case style of
2791 case style of
@@ -3475,76 +3051,3 @@ 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