@@ -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
@@ -77,31 +79,30 @@ module Internal.Model exposing
77 , onlyStyles
79 , onlyStyles
78 , optionsToRecord
80 , optionsToRecord
79 , paddingName
81 , paddingName
80 , pageClass
83 , pageClass
81 , paragraphClass
84 , paragraphClass
82 , reduceRecursive
85 , reduceRecursive
83 , reduceStyles
86 , reduceStyles
84 , reduceStylesRecursive
87 , reduceStylesRecursive
85 , removeNever
88 , removeNever
89 , renderFontClassName
89 , renderFontClassName
90 , renderHeight
90 , renderHeight
91 , renderRoot
91 , renderRoot
92 , renderWidth
93 , renderWidth
93 , rootStyle
94 , rootStyle
94 , rowClass
95 , rowClass
95 , singleClass
96 , singleClass
96 , spacingName
97 , spacingName
99− , textShadowName
99+ , textShadowClass
101 , toStyleSheet
101 , toStyleSheet
102 , transformClass
102 , transformClass
103 , unstyled
103 , unstyled
104 , unwrapDecorations
104 , unwrapDecorations
@@ -111,7 +112,7 @@ import Html.Attributes
111import Html.Keyed
112import Html.Keyed
112import Internal.Flag as Flag exposing (Flag)
113import Internal.Flag as Flag exposing (Flag)
113import Internal.Style exposing (classes, dot)
114import Internal.Style exposing (classes, dot)
114−import Json.Encode as Json
115+import Json.Encode as Encode
115import Set exposing (Set)
116import Set exposing (Set)
116import VirtualDom
117import VirtualDom
@@ -173,7 +174,7 @@ type Style
173 | Colored String String Color
174 | Colored String String Color
174 | SpacingStyle String Int Int
175 | SpacingStyle String Int Int
175 | BorderWidth String Int Int Int Int
176 | BorderWidth String Int Int Int Int
176− | PaddingStyle String Int Int Int Int
177+ | PaddingStyle String Float Float Float Float
177 | GridTemplateStyle
178 | GridTemplateStyle
178 { spacing : ( Length, Length )
179 { spacing : ( Length, Length )
179 , columns : List Length
180 , columns : List Length
@@ -221,11 +222,71 @@ type Font
221 | ImportFont String String
222 | ImportFont String String
222 | FontWith
223 | FontWith
223 { name : String
224 { name : String
224− , url : Maybe String
225− , adjustment : Adjustment
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
229type Property
290type Property
230 = Property String String
291 = Property String String
@@ -311,6 +372,13 @@ type NodeName
311 | 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))
@@ -319,7 +387,7 @@ type alias Gathered msg =
319 { node : NodeName
387 { node : NodeName
320 , attributes : List (VirtualDom.Attribute msg)
388 , attributes : List (VirtualDom.Attribute msg)
321 , styles : List Style
389 , styles : List Style
322− , children : List (VirtualDom.Node msg)
390+ , children : NearbyChildren msg
323 , has : Flag.Field
391 , has : Flag.Field
@@ -387,7 +455,10 @@ finalizeNode has node attributes children embedMode parentContext =
387 Embedded nodeName internal ->
455 Embedded nodeName internal ->
388 VirtualDom.node nodeName
456 VirtualDom.node nodeName
389 attributes
457 attributes
458+ [ createNode internal
459+ [ Html.Attributes.class
390− [ createNode internal [ Html.Attributes.class (classes.any ++ " " ++ classes.single) ]
460+ (classes.any ++ " " ++ classes.single)
393 case parentContext of
464 case parentContext of
@@ -464,49 +535,45 @@ finalizeNode has node attributes children embedMode parentContext =
466embedWith 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
467 if static then
547 if static then
468− staticRoot
548+ staticRoot opts
469− :: (styles
549+ :: dynamicStyleSheet
470− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
472− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
474− |> toStyleSheet opts
476 :: children
550 :: children
479− (styles
553+ dynamicStyleSheet
480− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
482− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
484− |> toStyleSheet opts
486 :: children
554 :: children
489embedKeyed 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
490 if static then
567 if static then
491− ( "static-stylesheet", staticRoot )
568+ ( "static-stylesheet", staticRoot opts )
492 :: ( "dynamic-stylesheet"
569 :: ( "dynamic-stylesheet"
493− , styles
570+ , dynamicStyleSheet
494− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
496− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
498− |> toStyleSheet opts
500 :: children
572 :: children
503 ( "dynamic-stylesheet"
575 ( "dynamic-stylesheet"
504− , styles
576+ , dynamicStyleSheet
505− |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
507− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
509− |> toStyleSheet opts
511 :: children
578 :: children
@@ -822,7 +889,16 @@ skippable flag style =
825−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)
826gatherAttrRecursive classes node has transform styles attrs children elementAttrs =
902gatherAttrRecursive classes node has transform styles attrs children elementAttrs =
827 case elementAttrs of
903 case elementAttrs of
@@ -956,7 +1032,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
957 gatherAttrRecursive (classes ++ " " ++ newClass)
1033 gatherAttrRecursive (classes ++ " " ++ newClass)
959− (Flag.merge addToFlags has)
1035+ (Flag.merge addToFlags (Flag.add Flag.width has))
960 transform
1036 transform
961 (newStyles ++ styles)
1037 (newStyles ++ styles)
@@ -977,7 +1053,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
978 "height-px-" ++ val
1054 "height-px-" ++ val
980− gatherAttrRecursive (name ++ " " ++ classes)
1056+ gatherAttrRecursive (Internal.Style.classes.heightExact ++ " " ++ name ++ " " ++ classes)
982 (Flag.add Flag.height has)
1058 (Flag.add Flag.height has)
983 transform
1059 transform
@@ -1034,7 +1110,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1035 gatherAttrRecursive (classes ++ " " ++ newClass)
1111 gatherAttrRecursive (classes ++ " " ++ newClass)
1037− (Flag.merge addToFlags has)
1113+ (Flag.merge addToFlags (Flag.add Flag.height has))
1038 transform
1114 transform
1039 (newStyles ++ styles)
1115 (newStyles ++ styles)
@@ -1066,20 +1142,15 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1066 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
1142 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
1068 Paragraph ->
1144 Paragraph ->
1069− let
1145+ -- previously we rendered a <p> tag, though apparently this invalidates the html if it has <div>s inside.
1070− newNode =
1146+ -- Since we can't guaranteee that there are no divs, we need another strategy.
1071− case node of
1147+ -- While it's not documented in many places, there apparently is a paragraph aria role
1072− Generic ->
1148+ -- https://github.com/w3c/aria/blob/11f85f41a5b621fdbe85fc9bcdcd270e653a48ba/common/script/roleInfo.js
1073− NodeName "p"
1149+ -- Though we'll need to wait till it gets released in an official wai-aria spec to use it.
1074−
1150+ -- If it's used at the moment, then Lighthouse complains (likely rightfully) that role paragraph is not recognized.
1081− gatherAttrRecursive classes
1151+ gatherAttrRecursive
1082− newNode
1152+ classes
1084 transform
1155 transform
@@ -1114,75 +1185,16 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1115 Styled styled ->
1186 Styled styled ->
1116 styles ++ styled.styles
1187 styles ++ styled.styles
1120− [ Html.Attributes.class <|
1124− [ Internal.Style.classes.nearby
1125− , Internal.Style.classes.single
1126− , Internal.Style.classes.above
1131− [ Internal.Style.classes.nearby
1132− , Internal.Style.classes.single
1133− , Internal.Style.classes.below
1138− [ Internal.Style.classes.nearby
1139− , Internal.Style.classes.single
1140− , Internal.Style.classes.onRight
1145− [ Internal.Style.classes.nearby
1146− , Internal.Style.classes.single
1147− , Internal.Style.classes.onLeft
1152− [ Internal.Style.classes.nearby
1153− , Internal.Style.classes.single
1154− , Internal.Style.classes.inFront
1159− [ Internal.Style.classes.nearby
1160− , Internal.Style.classes.single
1161− , Internal.Style.classes.behind
1175− styled.html NoStyleSheet asEl
1179− if location == Behind then
1180− Internal.Style.classes.hasBehind ++ " " ++ classes
1185− gatherAttrRecursive newClasses node has transform newStyles attrs (nearbyElement :: children) remaining
1189+ gatherAttrRecursive
1196+ (addNearbyElement location elem children)
1187 AlignX x ->
1199 AlignX x ->
1188 if Flag.present Flag.xAlign has then
1200 if Flag.present Flag.xAlign has then
@@ -1238,6 +1250,106 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1238 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
1241renderWidth w =
1353renderWidth w =
1242 case w of
1354 case w of
1243 Px px ->
1355 Px px ->
@@ -1324,7 +1436,7 @@ renderHeight h =
1324 "height-px-" ++ val
1436 "height-px-" ++ val
1326 ( Flag.none
1438 ( Flag.none
1327− , name
1439+ , Internal.Style.classes.heightExact ++ " " ++ name
1328 , [ Single name "height" (val ++ "px") ]
1440 , [ Single name "height" (val ++ "px") ]
@@ -1347,7 +1459,7 @@ renderHeight h =
1347 , [ Single
1459 , [ Single
1348 (Internal.Style.classes.any
1460 (Internal.Style.classes.any
1350− ++ Internal.Style.classes.row
1462+ ++ Internal.Style.classes.column
1351 ++ " > "
1463 ++ " > "
1352 ++ (Internal.Style.dot <| "height-fill-" ++ String.fromInt portion)
1464 ++ (Internal.Style.dot <| "height-fill-" ++ String.fromInt portion)
@@ -1366,7 +1478,9 @@ renderHeight h =
1368 "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.
1369− (String.fromInt minSize ++ "px")
1483+ (String.fromInt minSize ++ "px !important")
1371 ( newFlag, newAttrs, newStyle ) =
1485 ( newFlag, newAttrs, newStyle ) =
1372 renderHeight len
1486 renderHeight len
@@ -1444,7 +1558,7 @@ element : LayoutContext -> NodeName -> List (Attribute aligned msg) -> Children
1444element context node attributes children =
1558element context node attributes children =
1445 attributes
1559 attributes
1446 |> List.reverse
1560 |> List.reverse
1447− |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] []
1561+ |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] NoNearbyChildren
1448 |> createElement context children
1562 |> createElement context children
@@ -1511,13 +1625,12 @@ createElement context children rendered =
1511 -- , existingStyles
1625 -- , existingStyles
1515− (if context == asParagraph then
1628+ ( (if context == asEl then
1516− str
1629+ textElementFill str
1519− str
1632+ textElement str
1521 :: htmls
1634 :: htmls
1522 , existingStyles
1635 , existingStyles
@@ -1577,8 +1690,11 @@ createElement context children rendered =
1693+ , if context == asEl then
1694+ textElementFill str
1580− , textElement
1697+ textElement str
1583 :: htmls
1699 :: htmls
1584 , existingStyles
1700 , existingStyles
@@ -1605,13 +1721,8 @@ createElement context children rendered =
1605 (finalizeNode rendered.has
1721 (finalizeNode rendered.has
1606 rendered.node
1722 rendered.node
1607 rendered.attributes
1723 rendered.attributes
1608− (Keyed <|
1724+ (Keyed
1612− ( "nearby-elements-pls", x )
1614− rendered.children
1725+ (addKeyedChildren "nearby-element-pls" keyed rendered.children)
1616 NoStyleSheet
1727 NoStyleSheet
@@ -1625,13 +1736,7 @@ createElement context children rendered =
1625 rendered.node
1736 rendered.node
1626 rendered.attributes
1737 rendered.attributes
1631− ( "nearby-elements-pls", x )
1633− rendered.children
1739+ (addKeyedChildren "nearby-element-pls" keyed rendered.children)
@@ -1653,7 +1758,7 @@ createElement context children rendered =
1653 rendered.has
1758 rendered.has
1654 rendered.node
1759 rendered.node
1655 rendered.attributes
1760 rendered.attributes
1656− (Unkeyed <| unkeyed ++ rendered.children)
1761+ (Unkeyed (addChildren unkeyed rendered.children))
1657 NoStyleSheet
1762 NoStyleSheet
@@ -1665,10 +1770,42 @@ createElement context children rendered =
1665 rendered.has
1770 rendered.has
1666 rendered.node
1771 rendered.node
1667 rendered.attributes
1772 rendered.attributes
1668− (Unkeyed (unkeyed ++ rendered.children))
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
@@ -1680,8 +1817,20 @@ defaultOptions =
1683−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"
1684− 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) ] []
1687addWhen ifThis x to =
1836addWhen ifThis x to =
@@ -1799,7 +1948,7 @@ type Spacing
1801type Padding
1950type Padding
1802− = Padding String Int Int Int Int
1951+ = Padding String Float Float Float Float
1805extractSpacingAndPadding : List (Attribute aligned msg) -> ( Maybe Padding, Maybe Spacing )
1954extractSpacingAndPadding : List (Attribute aligned msg) -> ( Maybe Padding, Maybe Spacing )
@@ -1895,35 +2044,44 @@ getHeight attrs =
2047+textElementClasses : String
2048+textElementClasses =
2053+ ++ classes.widthContent
2055+ ++ classes.heightContent
1898textElement : String -> VirtualDom.Node msg
2058textElement : String -> VirtualDom.Node msg
1899textElement str =
2059textElement str =
1900 Html.div
2060 Html.div
1901 [ Html.Attributes.class
2061 [ Html.Attributes.class
1902− (String.join " "
2062+ textElementClasses
1905− , classes.widthContent
1906− , classes.heightContent
1910 [ Html.text str ]
2064 [ Html.text str ]
2067+textElementFillClasses : String
2068+textElementFillClasses =
2073+ ++ classes.widthFill
2075+ ++ classes.heightFill
1913textElementFill : String -> VirtualDom.Node msg
2078textElementFill : String -> VirtualDom.Node msg
1914textElementFill str =
2079textElementFill str =
1915− VirtualDom.node "div"
2080+ Html.div
1916− [ VirtualDom.property "className"
2081+ [ Html.Attributes.class
1917− (Json.string <|
2082+ textElementFillClasses
1921− , classes.widthFill
1922− , classes.heightFill
1926− [ VirtualDom.text str ]
2084+ [ Html.text str ]
1929type Children x
2087type Children x
@@ -1931,10 +2089,6 @@ type Children x
1931 | Keyed (List ( String, x ))
2089 | Keyed (List ( String, x ))
1935−-- toHtml : OptionRecord -> Element msg -> VirtualDom.Node msg
1938toHtml mode el =
2092toHtml mode el =
1939 case el of
2093 case el of
1940 Unstyled html ->
2094 Unstyled html ->
@@ -1970,8 +2124,7 @@ renderRoot optionList attributes child =
1972type RenderMode
2126type RenderMode
1974− | Layout
2127+ = Layout
1975 | NoStaticStyleSheet
2128 | NoStaticStyleSheet
1976 | WithVirtualCss
2129 | WithVirtualCss
@@ -2020,8 +2173,8 @@ rootStyle =
2020 , SansSerif
2173 , SansSerif
2023− [ 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))
2024− , 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))
2025 , StyleClass Flag.fontSize (FontSize 20)
2178 , StyleClass Flag.fontSize (FontSize 20)
2026 , StyleClass Flag.fontFamily <|
2179 , StyleClass Flag.fontFamily <|
2027 FontFamily (List.foldl renderFontClassName "font-" families)
2180 FontFamily (List.foldl renderFontClassName "font-" families)
@@ -2064,9 +2217,38 @@ renderFontClassName font current =
2065renderFocusStyle :
2218renderFocusStyle :
2066 FocusStyle
2219 FocusStyle
2067− -> Style
2220+ -> List Style
2068renderFocusStyle 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, ")
2069− 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")
2070 (List.filterMap identity
2252 (List.filterMap identity
2071 [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
2253 [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
2072 , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
2254 , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
@@ -2089,6 +2271,7 @@ renderFocusStyle focus =
2089 , Just <| Property "outline" "none"
2271 , Just <| Property "outline" "none"
2094focusDefaultStyle : { backgroundColor : Maybe Color, borderColor : Maybe Color, shadow : Maybe Shadow }
2277focusDefaultStyle : { backgroundColor : Maybe Color, borderColor : Maybe Color, shadow : Maybe Shadow }
@@ -2100,7 +2283,7 @@ focusDefaultStyle =
2100 { color =
2283 { color =
2101 Rgba (155 / 255) (203 / 255) 1 1
2284 Rgba (155 / 255) (203 / 255) 1 1
2102 , offset = ( 0, 0 )
2285 , offset = ( 0, 0 )
2103− , blur = 3
2286+ , blur = 0
2104 , size = 3
2287 , size = 3
@@ -2170,68 +2353,31 @@ optionsToRecord options =
2171toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2354toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2172toStyleSheet options styleSheet =
2355toStyleSheet 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"
2173− VirtualDom.node "style" [] [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2363+ [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2176−
2366+ NoStaticStyleSheet ->
2177−-- case typefaceAdjustment typefaces of
2367+ -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
2178−-- Nothing ->
2368+ VirtualDom.node "div"
2180−-- Just ( parentAdj, textAdjustment ) ->
2370+ [ VirtualDom.node "style"
2181−-- String.join " "
2371+ []
2182−-- [ renderStyle
2372+ [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2183−-- maybePseudo
2373+ ]
2185−-- ++ name
2375+ WithVirtualCss ->
2186−-- ++ "."
2376+ VirtualDom.node "elm-ui-rules"
2187−-- ++ classes.sizeByCapital
2377+ [ VirtualDom.property "rules"
2188−-- ++ ", "
2378+ (encodeStyles options styleSheet)
2192−-- ++ classes.sizeByCapital
2200−-- ++ classes.sizeByCapital
2202−-- ++ Internal.Style.classes.text
2206−-- ++ classes.sizeByCapital
2208−-- ++ Internal.Style.classes.text
2212−-- renderTopLevels rule =
2214−-- FontFamily name typefaces ->
2216−-- getImports font =
2218−-- ImportFont _ url ->
2219−-- Just ("@import url('" ++ url ++ "');")
2220−-- FontWith { url } ->
2223−-- Just ("@import url('" ++ x ++ "');")
2230−-- |> List.filterMap getImports
2231−-- |> String.join "\n"
2237renderTopLevelValues rules =
2383renderTopLevelValues rules =
@@ -2241,14 +2387,12 @@ renderTopLevelValues rules =
2241 ImportFont _ url ->
2387 ImportFont _ url ->
2242 Just ("@import url('" ++ url ++ "');")
2388 Just ("@import url('" ++ url ++ "');")
2244− FontWith with ->
2390+ -- FontWith with ->
2245− case with.url of
2391+ -- case with.url of
2246− Just x ->
2392+ -- Just x ->
2247− Just ("@import url('" ++ x ++ "');")
2393+ -- Just ("@import url('" ++ x ++ "');")
2249− Nothing ->
2394+ -- Nothing ->
2250− Nothing
2395+ -- Nothing
@@ -2319,7 +2463,38 @@ renderNullAdjustmentRule fontToAdjust otherFontName =
2466+fontRule name modifier ( parentAdj, textAdjustment ) =
2485+ ++ Internal.Style.classes.text
2491+ ++ Internal.Style.classes.text
2322−renderFontAdjustmentRule fontToAdjust ( parentAdj, textAdjustment ) otherFontName =
2497+renderFontAdjustmentRule fontToAdjust ( full, capital ) otherFontName =
2325 if fontToAdjust == otherFontName then
2500 if fontToAdjust == otherFontName then
@@ -2329,34 +2504,7 @@ renderFontAdjustmentRule fontToAdjust ( parentAdj, textAdjustment ) otherFontNam
2329 otherFontName ++ " ." ++ fontToAdjust
2504 otherFontName ++ " ." ++ fontToAdjust
2331 String.join " "
2506 String.join " "
2336− ++ classes.sizeByCapital
2341− ++ classes.sizeByCapital
2507+ (fontRule name classes.sizeByCapital capital ++ fontRule name classes.fullSize full)
2348− ++ classes.sizeByCapital
2350− ++ Internal.Style.classes.text
2354− ++ classes.sizeByCapital
2356− ++ Internal.Style.classes.text
2362bracket selector rules =
2510bracket selector rules =
@@ -2369,11 +2517,11 @@ bracket selector rules =
2370fontAdjustmentRules converted =
2518fontAdjustmentRules converted =
2371 ( [ ( "display", "block" )
2519 ( [ ( "display", "block" )
2372− , ( "line-height", String.fromFloat converted.height )
2374 , [ ( "display", "inline-block" )
2521 , [ ( "display", "inline-block" )
2375 , ( "line-height", String.fromFloat converted.height )
2522 , ( "line-height", String.fromFloat converted.height )
2376 , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2523 , ( "vertical-align", String.fromFloat converted.vertical ++ "em" )
2524+ , ( "font-size", String.fromFloat converted.size ++ "em" )
@@ -2385,10 +2533,17 @@ typefaceAdjustment typefaces =
2385 Nothing ->
2533 Nothing ->
2386 case face of
2534 case face of
2387 FontWith with ->
2535 FontWith with ->
2389− (fontAdjustmentRules
2390− (.capital (convertAdjustment with.adjustment))
2536+ case with.adjustment of
2542+ ( fontAdjustmentRules
2543+ (.full (convertAdjustment adjustment))
2544+ , fontAdjustmentRules
2545+ (.capital (convertAdjustment adjustment))
@@ -2438,470 +2593,492 @@ renderProps force (Property key val) existing =
2438 existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
2593 existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
2596+encodeStyles options stylesheet =
2602+ renderStyleRule options style Nothing
2604+ ( getStyleName style, Encode.list Encode.string styled )
2441toStyleSheetString : OptionRecord -> List Style -> String
2609toStyleSheetString : OptionRecord -> List Style -> String
2442toStyleSheetString options stylesheet =
2610toStyleSheetString options stylesheet =
2444− renderStyle maybePseudo selector props =
2612+ combine style rendered =
2445− case maybePseudo of
2613+ { rules = rendered.rules ++ renderStyleRule options style Nothing
2446− Nothing ->
2614+ , topLevel =
2447− selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}"
2615+ case topLevelValue style of
2449− Just pseudo ->
2617+ rendered.topLevel
2452− case options.hover of
2456− ForceHover ->
2619+ Just topLevel ->
2457− selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}"
2620+ topLevel :: rendered.topLevel
2623+ case List.foldl combine { topLevel = [], rules = [] } stylesheet of
2624+ { topLevel, rules } ->
2625+ renderTopLevelValues topLevel ++ String.concat rules
2460− selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}"
2462− Focus ->
2628+renderStyle : OptionRecord -> Maybe PseudoClass -> String -> List Property -> List String
2463− let
2629+renderStyle options maybePseudo selector props =
2464− renderedProps =
2630+ case maybePseudo of
2465− List.foldl (renderProps False) "" props
2632+ [ selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2476− ++ "-fs:not(.focus) {"
2486− , ".focusable-parent:focus ~ "
2496− Active ->
2634+ Just pseudo ->
2497− selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}"
2635+ case pseudo of
2637+ case options.hover of
2499− renderStyleRule rule maybePseudo =
2641+ ForceHover ->
2500− case rule of
2642+ [ selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}" ]
2501− Style selector props ->
2502− renderStyle maybePseudo selector props
2504− Shadows name prop ->
2644+ AllowHover ->
2505− renderStyle
2645+ [ selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2508− [ Property "box-shadow" prop
2511− Transparency name transparency ->
2647+ Focus ->
2513− opacity =
2649+ renderedProps =
2514− (1 - transparency)
2650+ List.foldl (renderProps False) "" props
2518− renderStyle
2652+ [ selector ++ "-fs:focus {" ++ renderedProps ++ "\n}"
2519− maybePseudo
2653+ , ("." ++ classes.any ++ ":focus " ++ selector ++ "-fs {")
2520− ("." ++ name)
2654+ ++ renderedProps
2521− [ 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 {")
2524− FontSize i ->
2664+ Active ->
2525− renderStyle
2665+ [ selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2527− (".font-size-" ++ String.fromInt i)
2528− [ Property "font-size" (String.fromInt i ++ "px")
2531− FontFamily name typefaces ->
2534− Property "font-family"
2536− |> List.map fontName
2537− |> String.join ", "
2547− Single class prop val ->
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 ->
2548− renderStyle
2675+ renderStyle options
2549− maybePseudo
2676+ maybePseudo
2550− ("." ++ class)
2677+ ("." ++ name)
2551− [ Property prop val
2678+ [ Property "box-shadow" prop
2554− Colored class prop color ->
2681+ Transparency name transparency ->
2555− renderStyle
2688+ renderStyle options
2556− maybePseudo
2689+ maybePseudo
2557− ("." ++ class)
2690+ ("." ++ name)
2558− [ Property prop (formatColor color)
2691+ [ Property "opacity" (String.fromFloat opacity)
2561− SpacingStyle cls x y ->
2694+ FontSize i ->
2562− let
2695+ renderStyle options
2563− class =
2696+ maybePseudo
2564− "." ++ cls
2697+ (".font-size-" ++ String.fromInt i)
2698+ [ Property "font-size" (String.fromInt i ++ "px")
2566− xPx =
2701+ FontFamily name typefaces ->
2705+ |> List.filterMap renderVariants
2706+ |> String.join ", "
2709+ [ Property "font-family"
2711+ |> List.map fontName
2567− String.fromInt x ++ "px"
2712+ |> String.join ", "
2714+ , Property "font-feature-settings" features
2715+ , Property "font-variant"
2716+ (if List.any hasSmallCaps typefaces then
2570− String.fromInt y ++ "px"
2720+ "normal"
2724+ renderStyle options
2572− row =
2729+ Single class prop val ->
2573− "." ++ Internal.Style.classes.row
2730+ renderStyle options
2733+ [ Property prop val
2575− wrappedRow =
2736+ Colored class prop color ->
2576− "." ++ Internal.Style.classes.wrapped ++ row
2737+ renderStyle options
2740+ [ Property prop (formatColor color)
2578− column =
2743+ SpacingStyle cls x y ->
2579− "." ++ Internal.Style.classes.column
2744+ let
2581− page =
2748+ halfX =
2582− "." ++ Internal.Style.classes.page
2749+ String.fromFloat (toFloat x / 2) ++ "px"
2584− paragraph =
2751+ halfY =
2585− "." ++ Internal.Style.classes.paragraph
2752+ String.fromFloat (toFloat y / 2) ++ "px"
2588− "." ++ Internal.Style.classes.alignLeft
2755+ String.fromInt x ++ "px"
2591− "." ++ Internal.Style.classes.alignRight
2758+ String.fromInt y ++ "px"
2594− "." ++ Internal.Style.classes.any
2761+ "." ++ Internal.Style.classes.row
2596− single =
2763+ wrappedRow =
2597− "." ++ Internal.Style.classes.single
2764+ "." ++ Internal.Style.classes.wrapped ++ row
2600− [ renderStyle maybePseudo (class ++ row ++ " > " ++ any) [ Property "margin-right" xPx ]
2602− -- margins don't apply to last element of normal, unwrapped rows
2766+ column =
2603− , renderStyle maybePseudo (class ++ row ++ " > " ++ any ++ ":last-child") [ Property "margin" "0" ]
2767+ "." ++ Internal.Style.classes.column
2605− -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2769+ page =
2606− , renderStyle maybePseudo
2770+ "." ++ Internal.Style.classes.page
2607− (class ++ wrappedRow ++ " > " ++ any)
2608− [ Property "margin" ("0 " ++ xPx ++ " " ++ yPx ++ " 0")
2610− , renderStyle maybePseudo
2611− (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2612− [ Property "margin-right" "0"
2616− , renderStyle maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2617− , renderStyle maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2618− , renderStyle maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2619− , renderStyle maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2622− (class ++ paragraph)
2772+ paragraph =
2623− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2773+ "." ++ Internal.Style.classes.paragraph
2627− ("textarea" ++ class)
2628− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2631− -- , renderStyle
2775+ left =
2632− -- maybePseudo
2776+ "." ++ Internal.Style.classes.alignLeft
2633− -- (class ++ paragraph ++ " > " ++ any)
2634− -- [ Property "margin-right" xPx
2635− -- , Property "margin-bottom" yPx
2639− (class ++ paragraph ++ " > " ++ left)
2640− [ Property "margin-right" xPx
2644− (class ++ paragraph ++ " > " ++ right)
2645− [ Property "margin-left" xPx
2649− (class ++ paragraph ++ "::after")
2650− [ Property "content" "''"
2651− , Property "display" "block"
2652− , Property "height" "0"
2653− , Property "width" "0"
2654− , Property "margin-top" (String.fromInt (-1 * (y // 2)) ++ "px")
2658− (class ++ paragraph ++ "::before")
2659− [ Property "content" "''"
2660− , Property "display" "block"
2661− , Property "height" "0"
2662− , Property "width" "0"
2663− , Property "margin-bottom" (String.fromInt (-1 * (y // 2)) ++ "px")
2667− PaddingStyle cls top right bottom left ->
2778+ right =
2668− let
2779+ "." ++ Internal.Style.classes.alignRight
2676− [ Property "padding"
2677− (String.fromInt top
2679− ++ String.fromInt right
2681− ++ String.fromInt bottom
2683− ++ String.fromInt left
2688− BorderWidth cls top right bottom left ->
2781+ any =
2689− let
2782+ "." ++ Internal.Style.classes.any
2697− [ Property "border-width"
2698− (String.fromInt top
2700− ++ String.fromInt right
2702− ++ String.fromInt bottom
2704− ++ String.fromInt left
2709− GridTemplateStyle template ->
2784+ single =
2710− let
2785+ "." ++ Internal.Style.classes.single
2712− ".grid-rows-"
2787+ List.concat
2713− ++ String.join "-" (List.map lengthClassName template.rows)
2788+ [ renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ " + " ++ any) [ Property "margin-left" xPx ]
2715− ++ String.join "-" (List.map lengthClassName template.columns)
2790+ -- margins don't apply to last element of normal, unwrapped rows
2716− ++ "-space-x-"
2791+ -- , renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ ":first-child") [ Property "margin" "0" ]
2717− ++ lengthClassName (Tuple.first template.spacing)
2792+ -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2718− ++ "-space-y-"
2793+ , renderStyle options
2719− ++ lengthClassName (Tuple.second template.spacing)
2794+ maybePseudo
2720−
2795+ (class ++ wrappedRow ++ " > " ++ any)
2721− ySpacing =
2796+ [ Property "margin" (halfY ++ " " ++ halfX)
2722− toGridLength (Tuple.second template.spacing)
2797+ ]
2725− toGridLength (Tuple.first template.spacing)
2728− toGridLengthHelper Nothing Nothing x
2730− toGridLengthHelper minimum maximum x =
2733− String.fromInt px ++ "px"
2736− case ( minimum, maximum ) of
2737− ( Nothing, Nothing ) ->
2740− ( Just minSize, Nothing ) ->
2741− "minmax(" ++ String.fromInt minSize ++ "px, " ++ "max-content)"
2743− ( Nothing, Just maxSize ) ->
2744− "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2746− ( Just minSize, Just maxSize ) ->
2747− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2750− case ( minimum, maximum ) of
2751− ( Nothing, Nothing ) ->
2752− String.fromInt i ++ "fr"
2754− ( Just minSize, Nothing ) ->
2755− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt i ++ "fr" ++ "fr)"
2757− ( Nothing, Just maxSize ) ->
2758− "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2760− ( Just minSize, Just maxSize ) ->
2761− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2764− toGridLengthHelper (Just m) maximum len
2767− toGridLengthHelper minimum (Just m) len
2771− |> List.map toGridLength
2772− |> String.join ySpacing
2773− |> (\x -> "-ms-grid-columns: " ++ x ++ ";")
2777− |> List.map toGridLength
2778− |> String.join ySpacing
2779− |> (\x -> "-ms-grid-rows: " ++ x ++ ";")
2782− class ++ "{" ++ msColumns ++ msRows ++ "}"
2786− |> List.map toGridLength
2788− |> (\x -> "grid-template-columns: " ++ x ++ ";")
2792− |> List.map toGridLength
2794− |> (\x -> "grid-template-rows: " ++ x ++ ";")
2797− "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2800− "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2803− class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2806− "@supports (display:grid) {" ++ modernGrid ++ "}"
2810− GridPosition position ->
2799+ -- , renderStyle options maybePseudo
2811− let
2800+ -- (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2812− class =
2801+ -- [ Property "margin-right" "0"
2813− ".grid-pos-"
2802+ -- ]
2814− ++ String.fromInt position.row
2803+ -- columns
2815− ++ "-"
2804+ , renderStyle options maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2816− ++ String.fromInt position.col
2805+ , renderStyle options maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2817− ++ "-"
2806+ , renderStyle options maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2818− ++ String.fromInt position.width
2807+ , renderStyle options maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2819− ++ "-"
2808+ , renderStyle options
2820− ++ String.fromInt position.height
2809+ maybePseudo
2821−
2810+ (class ++ paragraph)
2822− msPosition =
2811+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2823− String.join " "
2812+ ]
2824− [ "-ms-grid-row: "
2813+ , renderStyle options
2825− ++ String.fromInt position.row
2814+ maybePseudo
2826− ++ ";"
2815+ ("textarea" ++ any ++ class)
2827− , "-ms-grid-row-span: "
2816+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2828− ++ String.fromInt position.height
2817+ , Property "height" ("calc(100% + " ++ String.fromInt y ++ "px)")
2830− , "-ms-grid-column: "
2831− ++ String.fromInt position.col
2833− , "-ms-grid-column-span: "
2834− ++ String.fromInt position.width
2839− class ++ "{" ++ msPosition ++ "}"
2844− ++ String.fromInt position.row
2846− ++ String.fromInt (position.row + position.height)
2849− ++ String.fromInt position.col
2851− ++ String.fromInt (position.col + position.width)
2856− class ++ "{" ++ modernPosition ++ "}"
2859− "@supports (display:grid) {" ++ modernGrid ++ "}"
2863− PseudoSelector class styles ->
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 ->
2865− renderPseudoRule style =
2879+ class =
2866− renderStyleRule style (Just class)
2880+ "."
2868− 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
2869 |> String.join " "
2976 |> String.join " "
2977+ |> (\x -> "grid-template-columns: " ++ x ++ ";")
2871− Transform transform ->
2979+ rows =
2872− let
2980+ template.rows
2873− val =
2981+ |> List.map toGridLength
2874− transformValue transform
2982+ |> String.join " "
2983+ |> (\x -> "grid-template-rows: " ++ x ++ ";")
2876− class =
2985+ gapX =
2877− transformClass transform
2986+ "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2879− case ( class, val ) of
2880− ( Just cls, Just v ) ->
2884− [ Property "transform"
2889− ""
2989+ "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2891− combine style rendered =
2991+ modernGrid =
2892− { rules = rendered.rules ++ renderStyleRule style Nothing
2992+ class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2894− case topLevelValue style of
2898− Just topLevel ->
2994+ supports =
2899− topLevel :: rendered.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 ++ "}"
2902− case List.foldl combine { topLevel = [], rules = "" } stylesheet of
3052+ [ base
2903− { topLevel, rules } ->
3053+ , supports
2904− renderTopLevelValues 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"
2907lengthClassName : Length -> String
3084lengthClassName : Length -> String
@@ -2941,12 +3118,12 @@ formatTextShadow shadow =
2944−textShadowName shadow =
3121+textShadowClass shadow =
2945 String.concat
3122 String.concat
2947− , String.fromFloat (Tuple.first shadow.offset) ++ "px"
3124+ , floatClass (Tuple.first shadow.offset) ++ "px"
2948− , String.fromFloat (Tuple.second shadow.offset) ++ "px"
3125+ , floatClass (Tuple.second shadow.offset) ++ "px"
2949− , String.fromFloat shadow.blur ++ "px"
3126+ , floatClass shadow.blur ++ "px"
2950 , formatColorClass shadow.color
3127 , formatColorClass shadow.color
@@ -2967,17 +3144,17 @@ formatBoxShadow shadow =
2970−boxShadowName shadow =
3147+boxShadowClass shadow =
2971 String.concat <|
3148 String.concat <|
2972 [ if shadow.inset then
3149 [ if shadow.inset then
2973 "box-inset"
3150 "box-inset"
2977− , String.fromFloat (Tuple.first shadow.offset) ++ "px"
3154+ , floatClass (Tuple.first shadow.offset) ++ "px"
2978− , String.fromFloat (Tuple.second shadow.offset) ++ "px"
3155+ , floatClass (Tuple.second shadow.offset) ++ "px"
2979− , String.fromFloat shadow.blur ++ "px"
3156+ , floatClass shadow.blur ++ "px"
2980− , String.fromFloat shadow.size ++ "px"
3157+ , floatClass shadow.size ++ "px"
2981 , formatColorClass shadow.color
3158 , formatColorClass shadow.color
@@ -3022,6 +3199,17 @@ paddingName top right bottom left =
3022 ++ String.fromInt left
3199 ++ String.fromInt left
3202+paddingNameFloat top right bottom left =
3206+ ++ floatClass right
3208+ ++ floatClass bottom
3025getStyleName : Style -> String
3213getStyleName : Style -> String
3026getStyleName style =
3214getStyleName style =
3027 case style of
3215 case style of
@@ -3334,19 +3522,29 @@ convertAdjustment adjustment =
3334 |> Maybe.withDefault adjustment.baseline
3522 |> Maybe.withDefault adjustment.baseline
3336 capitalVertical =
3524 capitalVertical =
3337− (oldMiddle - newCapitalMiddle) * 2
3525+ 1 - ascender
3528+ 1 / (ascender - newBaseline)
3531+ 1 / (ascender - descender)
3339 fullVertical =
3533 fullVertical =
3340− (oldMiddle - newFullMiddle) * 2
3536+ -- (oldMiddle - newFullMiddle) * 2
3342 { full =
3538 { full =
3343− { vertical = fullVertical
3345− (ascender - descender)
3539+ adjust fullSize (ascender - descender) fullVertical
3348 , capital =
3540 , capital =
3349− { vertical = capitalVertical
3350− , height = (ascender - newBaseline) - abs capitalVertical
3541+ adjust capitalSize (ascender - newBaseline) capitalVertical
3545+adjust size height vertical =
3546+ { vertical = vertical