@@ -16,7 +16,6 @@ module Internal.Model exposing
1616 , LayoutContext(..)
1717 , Length(..)
1818 , Location(..)
19− , NearbyChildren(..)
2019 , NodeName(..)
2120 , Option(..)
2221 , OptionRecord
@@ -30,7 +29,6 @@ module Internal.Model exposing
3029 , TransformComponent(..)
3130 , Transformation(..)
3231 , VAlign(..)
33− , Variant(..)
3432 , XYZ
3533 , addNodeName
3634 , addWhen
@@ -42,7 +40,7 @@ module Internal.Model exposing
4240 , asParagraph
4341 , asRow
4442 , asTextColumn
45− , boxShadowClass
43+ , boxShadowName
4644 , columnClass
4745 , composeTransformation
4846 , contextClasses
@@ -70,7 +68,6 @@ module Internal.Model exposing
7068 , getWidth
7169 , gridClass
7270 , htmlClass
73− , isContent
7471 , lengthClassName
7572 , map
7673 , mapAttr
@@ -79,30 +76,41 @@ module Internal.Model exposing
7976 , onlyStyles
8077 , optionsToRecord
8178 , paddingName
82− , paddingNameFloat
8379 , pageClass
8480 , paragraphClass
8581 , reduceRecursive
82+ , reduceRecursiveCalcName
8683 , reduceStyles
8784 , reduceStylesRecursive
8885 , removeNever
86+ , renderFocusStyle
87+ , renderFont
8988 , renderFontClassName
9089 , renderHeight
9190 , renderRoot
92− , renderVariant
9391 , renderWidth
9492 , rootStyle
9593 , rowClass
9694 , singleClass
95+ , skippable
96+ , sortedReduce
9797 , spacingName
98+ , staticRoot
9899 , tag
99− , textShadowClass
100+ , textElement
101+ , textElementFill
102+ , textShadowName
100103 , toHtml
101104 , toStyleSheet
105+ , toStyleSheetString
102106 , transformClass
107+ , transformValue
108+ , unit
103109 , unstyled
110+ , untransformed
104111 , unwrapDecorations
105− , variantName
112+ , unwrapDecsHelper
113+ , isContent
106114 )
107115
108116{-| -}
@@ -112,7 +120,7 @@ import Html.Attributes
112120import Html.Keyed
113121import Internal.Flag as Flag exposing (Flag)
114122import Internal.Style exposing (classes, dot)
115−import Json.Encode as Encode
123+import Json.Encode as Json
116124import Set exposing (Set)
117125import VirtualDom
118126
@@ -173,8 +181,7 @@ type Style
173181 | Single String String String
174182 | Colored String String Color
175183 | SpacingStyle String Int Int
176− | BorderWidth String Int Int Int Int
177− | PaddingStyle String Float Float Float Float
184+ | PaddingStyle String Int Int Int Int
178185 | GridTemplateStyle
179186 { spacing : ( Length, Length )
180187 , columns : List Length
@@ -205,86 +212,12 @@ type PseudoClass
205212 | Active
206213
207214
208−{-| -}
209−type alias Adjustment =
210− { capital : Float
211− , lowercase : Float
212− , baseline : Float
213− , descender : Float
214− }
215−
216−
217215type Font
218216 = Serif
219217 | SansSerif
220218 | Monospace
221219 | Typeface String
222220 | ImportFont String String
223− | FontWith
224− { name : String
225− , adjustment : Maybe Adjustment
226− , variants : List Variant
227− }
228−
229−
230−type Variant
231− = VariantActive String
232− | VariantOff String
233− | VariantIndexed String Int
234−
235−
236−renderVariant var =
237− case var of
238− VariantActive name ->
239− "\"" ++ name ++ "\""
240−
241− VariantOff name ->
242− "\"" ++ name ++ "\" 0"
243−
244− VariantIndexed name index ->
245− "\"" ++ name ++ "\" " ++ String.fromInt index
246−
247−
248−variantName var =
249− case var of
250− VariantActive name ->
251− name
252−
253− VariantOff name ->
254− name ++ "-0"
255−
256− VariantIndexed name index ->
257− name ++ "-" ++ String.fromInt index
258−
259−
260−renderVariants typeface =
261− case typeface of
262− FontWith font ->
263− Just (String.join ", " (List.map renderVariant font.variants))
264−
265− _ ->
266− Nothing
267−
268−
269−isSmallCaps var =
270− case var of
271− VariantActive name ->
272− name == "smcp"
273−
274− VariantOff name ->
275− False
276−
277− VariantIndexed name index ->
278− name == "smcp" && index == 1
279−
280−
281−hasSmallCaps typeface =
282− case typeface of
283− FontWith font ->
284− List.any isSmallCaps font.variants
285−
286− _ ->
287− False
288221
289222
290223type Property
@@ -372,13 +305,6 @@ type NodeName
372305 | Embedded String String
373306
374307
375−type NearbyChildren msg
376− = NoNearbyChildren
377− | ChildrenBehind (List (Html.Html msg))
378− | ChildrenInFront (List (Html.Html msg))
379− | ChildrenBehindAndInFront (List (Html.Html msg)) (List (Html.Html msg))
380−
381−
382308div =
383309 Generic
384310
@@ -387,7 +313,7 @@ type alias Gathered msg =
387313 { node : NodeName
388314 , attributes : List (VirtualDom.Attribute msg)
389315 , styles : List Style
390− , children : NearbyChildren msg
316+ , children : List (VirtualDom.Node msg)
391317 , has : Flag.Field
392318 }
393319
@@ -455,10 +381,7 @@ finalizeNode has node attributes children embedMode parentContext =
455381 Embedded nodeName internal ->
456382 VirtualDom.node nodeName
457383 attributes
458− [ createNode internal
459− [ Html.Attributes.class
460− (classes.any ++ " " ++ classes.single)
461− ]
384+ [ createNode internal [ Html.Attributes.class (classes.any ++ " " ++ classes.single) ]
462385 ]
463386 in
464387 case parentContext of
@@ -535,45 +458,49 @@ finalizeNode has node attributes children embedMode parentContext =
535458
536459
537460embedWith static opts styles children =
538− let
539− dynamicStyleSheet =
540− styles
541− |> List.foldl reduceStyles ( Set.empty, renderFocusStyle opts.focus )
542− |> Tuple.second
543− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
544− -- |> sortedReduce
545− |> toStyleSheet opts
546− in
547461 if static then
548− staticRoot opts
549− :: dynamicStyleSheet
462+ staticRoot
463+ :: (styles
464+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
465+ |> Tuple.second
466+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
467+ -- |> sortedReduce
468+ |> toStyleSheet opts
469+ )
550470 :: children
551471
552472 else
553− dynamicStyleSheet
473+ (styles
474+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
475+ |> Tuple.second
476+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
477+ -- |> sortedReduce
478+ |> toStyleSheet opts
479+ )
554480 :: children
555481
556482
557483embedKeyed static opts styles children =
558− let
559− dynamicStyleSheet =
560− styles
561− |> List.foldl reduceStyles ( Set.empty, renderFocusStyle opts.focus )
562− |> Tuple.second
563− -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
564− -- |> sortedReduce
565− |> toStyleSheet opts
566− in
567484 if static then
568− ( "static-stylesheet", staticRoot opts )
485+ ( "static-stylesheet", staticRoot )
569486 :: ( "dynamic-stylesheet"
570− , dynamicStyleSheet
487+ , styles
488+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
489+ |> Tuple.second
490+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
491+ -- |> sortedReduce
492+ |> toStyleSheet opts
571493 )
572494 :: children
573495
574496 else
575497 ( "dynamic-stylesheet"
576− , dynamicStyleSheet
498+ , styles
499+ |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
500+ |> Tuple.second
501+ -- |> reduceStylesRecursive Set.empty [ ]) --renderFocusStyle opts.focus ]
502+ -- |> sortedReduce
503+ |> toStyleSheet opts
577504 )
578505 :: children
579506
@@ -889,16 +816,7 @@ skippable flag style =
889816 False
890817
891818
892−gatherAttrRecursive :
893− String
894− -> NodeName
895− -> Flag.Field
896− -> Transformation
897− -> List Style
898− -> List (VirtualDom.Attribute msg)
899− -> NearbyChildren msg
900− -> List (Attribute aligned msg)
901− -> Gathered msg
819+gatherAttrRecursive : String -> NodeName -> Flag.Field -> Transformation -> List Style -> List (VirtualDom.Attribute msg) -> List (VirtualDom.Node msg) -> List (Attribute aligned msg) -> Gathered msg
902820gatherAttrRecursive classes node has transform styles attrs children elementAttrs =
903821 case elementAttrs of
904822 [] ->
@@ -1032,7 +950,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1032950 in
1033951 gatherAttrRecursive (classes ++ " " ++ newClass)
1034952 node
1035− (Flag.merge addToFlags (Flag.add Flag.width has))
953+ (Flag.merge addToFlags has)
1036954 transform
1037955 (newStyles ++ styles)
1038956 attrs
@@ -1053,7 +971,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1053971 name =
1054972 "height-px-" ++ val
1055973 in
1056− gatherAttrRecursive (Internal.Style.classes.heightExact ++ " " ++ name ++ " " ++ classes)
974+ gatherAttrRecursive (name ++ " " ++ classes)
1057975 node
1058976 (Flag.add Flag.height has)
1059977 transform
@@ -1110,7 +1028,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
11101028 in
11111029 gatherAttrRecursive (classes ++ " " ++ newClass)
11121030 node
1113− (Flag.merge addToFlags (Flag.add Flag.height has))
1031+ (Flag.merge addToFlags has)
11141032 transform
11151033 (newStyles ++ styles)
11161034 attrs
@@ -1142,15 +1060,20 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
11421060 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
11431061
11441062 Paragraph ->
1145− -- previously we rendered a <p> tag, though apparently this invalidates the html if it has <div>s inside.
1146− -- Since we can't guaranteee that there are no divs, we need another strategy.
1147− -- While it's not documented in many places, there apparently is a paragraph aria role
1148− -- https://github.com/w3c/aria/blob/11f85f41a5b621fdbe85fc9bcdcd270e653a48ba/common/script/roleInfo.js
1149− -- Though we'll need to wait till it gets released in an official wai-aria spec to use it.
1150− -- If it's used at the moment, then Lighthouse complains (likely rightfully) that role paragraph is not recognized.
1151− gatherAttrRecursive
1152− classes
1153− node
1063+ let
1064+ newNode =
1065+ case node of
1066+ Generic ->
1067+ NodeName "p"
1068+
1069+ NodeName name ->
1070+ NodeName name
1071+
1072+ Embedded x y ->
1073+ Embedded x y
1074+ in
1075+ gatherAttrRecursive classes
1076+ newNode
11541077 has
11551078 transform
11561079 styles
@@ -1185,16 +1108,75 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
11851108
11861109 Styled styled ->
11871110 styles ++ styled.styles
1111+
1112+ nearbyElement =
1113+ Html.div
1114+ [ Html.Attributes.class <|
1115+ case location of
1116+ Above ->
1117+ String.join " "
1118+ [ Internal.Style.classes.nearby
1119+ , Internal.Style.classes.single
1120+ , Internal.Style.classes.above
1121+ ]
1122+
1123+ Below ->
1124+ String.join " "
1125+ [ Internal.Style.classes.nearby
1126+ , Internal.Style.classes.single
1127+ , Internal.Style.classes.below
1128+ ]
1129+
1130+ OnRight ->
1131+ String.join " "
1132+ [ Internal.Style.classes.nearby
1133+ , Internal.Style.classes.single
1134+ , Internal.Style.classes.onRight
1135+ ]
1136+
1137+ OnLeft ->
1138+ String.join " "
1139+ [ Internal.Style.classes.nearby
1140+ , Internal.Style.classes.single
1141+ , Internal.Style.classes.onLeft
1142+ ]
1143+
1144+ InFront ->
1145+ String.join " "
1146+ [ Internal.Style.classes.nearby
1147+ , Internal.Style.classes.single
1148+ , Internal.Style.classes.inFront
1149+ ]
1150+
1151+ Behind ->
1152+ String.join " "
1153+ [ Internal.Style.classes.nearby
1154+ , Internal.Style.classes.single
1155+ , Internal.Style.classes.behind
1156+ ]
1157+ ]
1158+ [ case elem of
1159+ Empty ->
1160+ VirtualDom.text ""
1161+
1162+ Text str ->
1163+ textElement str
1164+
1165+ Unstyled html ->
1166+ html asEl
1167+
1168+ Styled styled ->
1169+ styled.html NoStyleSheet asEl
1170+ ]
1171+
1172+ newClasses =
1173+ if location == Behind then
1174+ Internal.Style.classes.hasBehind ++ " " ++ classes
1175+
1176+ else
1177+ classes
11881178 in
1189− gatherAttrRecursive
1190− classes
1191− node
1192− has
1193− transform
1194− newStyles
1195− attrs
1196− (addNearbyElement location elem children)
1197− remaining
1179+ gatherAttrRecursive newClasses node has transform newStyles attrs (nearbyElement :: children) remaining
11981180
11991181 AlignX x ->
12001182 if Flag.present Flag.xAlign has then
@@ -1250,106 +1232,6 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
12501232 remaining
12511233
12521234
1253−addNearbyElement location elem existing =
1254− let
1255− nearby =
1256− nearbyElement location elem
1257− in
1258− case existing of
1259− NoNearbyChildren ->
1260− case location of
1261− Behind ->
1262− ChildrenBehind [ nearby ]
1263−
1264− _ ->
1265− ChildrenInFront [ nearby ]
1266−
1267− ChildrenBehind existingBehind ->
1268− case location of
1269− Behind ->
1270− ChildrenBehind (nearby :: existingBehind)
1271−
1272− _ ->
1273− ChildrenBehindAndInFront existingBehind [ nearby ]
1274−
1275− ChildrenInFront existingInFront ->
1276− case location of
1277− Behind ->
1278− ChildrenBehindAndInFront [ nearby ] existingInFront
1279−
1280− _ ->
1281− ChildrenInFront (nearby :: existingInFront)
1282−
1283− ChildrenBehindAndInFront existingBehind existingInFront ->
1284− case location of
1285− Behind ->
1286− ChildrenBehindAndInFront (nearby :: existingBehind) existingInFront
1287−
1288− _ ->
1289− ChildrenBehindAndInFront existingBehind (nearby :: existingInFront)
1290−
1291−
1292−nearbyElement location elem =
1293− Html.div
1294− [ Html.Attributes.class <|
1295− case location of
1296− Above ->
1297− String.join " "
1298− [ Internal.Style.classes.nearby
1299− , Internal.Style.classes.single
1300− , Internal.Style.classes.above
1301− ]
1302−
1303− Below ->
1304− String.join " "
1305− [ Internal.Style.classes.nearby
1306− , Internal.Style.classes.single
1307− , Internal.Style.classes.below
1308− ]
1309−
1310− OnRight ->
1311− String.join " "
1312− [ Internal.Style.classes.nearby
1313− , Internal.Style.classes.single
1314− , Internal.Style.classes.onRight
1315− ]
1316−
1317− OnLeft ->
1318− String.join " "
1319− [ Internal.Style.classes.nearby
1320− , Internal.Style.classes.single
1321− , Internal.Style.classes.onLeft
1322− ]
1323−
1324− InFront ->
1325− String.join " "
1326− [ Internal.Style.classes.nearby
1327− , Internal.Style.classes.single
1328− , Internal.Style.classes.inFront
1329− ]
1330−
1331− Behind ->
1332− String.join " "
1333− [ Internal.Style.classes.nearby
1334− , Internal.Style.classes.single
1335− , Internal.Style.classes.behind
1336− ]
1337− ]
1338− [ case elem of
1339− Empty ->
1340− VirtualDom.text ""
1341−
1342− Text str ->
1343− textElement str
1344−
1345− Unstyled html ->
1346− html asEl
1347−
1348− Styled styled ->
1349− styled.html NoStyleSheet asEl
1350− ]
1351−
1352−
13531235renderWidth w =
13541236 case w of
13551237 Px px ->
@@ -1436,7 +1318,7 @@ renderHeight h =
14361318 "height-px-" ++ val
14371319 in
14381320 ( Flag.none
1439− , Internal.Style.classes.heightExact ++ " " ++ name
1321+ , name
14401322 , [ Single name "height" (val ++ "px") ]
14411323 )
14421324
@@ -1459,7 +1341,7 @@ renderHeight h =
14591341 , [ Single
14601342 (Internal.Style.classes.any
14611343 ++ "."
1462− ++ Internal.Style.classes.column
1344+ ++ Internal.Style.classes.row
14631345 ++ " > "
14641346 ++ (Internal.Style.dot <| "height-fill-" ++ String.fromInt portion)
14651347 )
@@ -1478,9 +1360,7 @@ renderHeight h =
14781360 Single
14791361 cls
14801362 "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")
1363+ (String.fromInt minSize ++ "px")
14841364
14851365 ( newFlag, newAttrs, newStyle ) =
14861366 renderHeight len
@@ -1558,7 +1438,7 @@ element : LayoutContext -> NodeName -> List (Attribute aligned msg) -> Children
15581438element context node attributes children =
15591439 attributes
15601440 |> List.reverse
1561− |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] NoNearbyChildren
1441+ |> gatherAttrRecursive (contextClasses context) node Flag.none untransformed [] [] []
15621442 |> createElement context children
15631443
15641444
@@ -1566,6 +1446,13 @@ untransformed =
15661446 Untransformed
15671447
15681448
1449+
1450+-- space =
1451+-- VirtualDom.text " "
1452+-- keyedSpace =
1453+-- ( " ", space )
1454+
1455+
15691456createElement : LayoutContext -> Children (Element msg) -> Gathered msg -> Element msg
15701457createElement context children rendered =
15711458 let
@@ -1607,33 +1494,36 @@ createElement context children rendered =
16071494 -- Same if it's a column or row with one child and width-content, height-content
16081495 -- interferes with css grid
16091496 -- 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.
1497+ -- however embedded style elements that are larger than the line height will overlap with exisitng text.
16111498 -- I don't think that's what we want.
1612− -- if
1613− -- context
1614− -- == asEl
1615− -- || context
1616− -- == asParagraph
1617− -- then
1618− -- ( VirtualDom.text
1619− -- (if context == asParagraph then
1620− -- str
1621− -- else
1622− -- str
1623− -- )
1624− -- :: htmls
1625− -- , existingStyles
1626− -- )
1627− -- else
1628− ( (if context == asEl then
1629− textElementFill str
1630−
1631− else
1632− textElement str
1633− )
1634− :: htmls
1635− , existingStyles
1636− )
1499+ if
1500+ context
1501+ == asEl
1502+ || context
1503+ == asParagraph
1504+ then
1505+ ( VirtualDom.text
1506+ (if context == asParagraph then
1507+ str ++ " "
1508+
1509+ else
1510+ str
1511+ )
1512+ :: htmls
1513+ , existingStyles
1514+ )
1515+
1516+ else
1517+ ( textElement
1518+ (if context == asParagraph then
1519+ str ++ " "
1520+
1521+ else
1522+ str
1523+ )
1524+ :: htmls
1525+ , existingStyles
1526+ )
16371527
16381528 Empty ->
16391529 ( htmls, existingStyles )
@@ -1675,30 +1565,38 @@ createElement context children rendered =
16751565 -- TEXT OPTIMIZATION
16761566 -- You can have raw text if the element is an el, and has `width-content` and `height-content`
16771567 -- Same if it's a column or row with one child and width-content, height-content
1678− -- if
1679− -- context
1680− -- == asEl
1681− -- || context
1682− -- == asParagraph
1683− -- then
1684− -- ( ( key
1685− -- , VirtualDom.text
1686− -- str
1687− -- )
1688− -- :: htmls
1689− -- , existingStyles
1690− -- )
1691− -- else
1692− ( ( key
1693− , if context == asEl then
1694− textElementFill str
1568+ if
1569+ context
1570+ == asEl
1571+ || context
1572+ == asParagraph
1573+ then
1574+ ( ( key
1575+ , VirtualDom.text
1576+ (if context == asParagraph then
1577+ str ++ " "
1578+
1579+ else
1580+ str
1581+ )
1582+ )
1583+ :: htmls
1584+ , existingStyles
1585+ )
16951586
1696− else
1697− textElement str
1698− )
1699− :: htmls
1700− , existingStyles
1701− )
1587+ else
1588+ ( ( key
1589+ , textElement
1590+ (if context == asParagraph then
1591+ str ++ " "
1592+
1593+ else
1594+ str
1595+ )
1596+ )
1597+ :: htmls
1598+ , existingStyles
1599+ )
17021600
17031601 Empty ->
17041602 ( htmls, existingStyles )
@@ -1721,9 +1619,7 @@ createElement context children rendered =
17211619 (finalizeNode rendered.has
17221620 rendered.node
17231621 rendered.attributes
1724− (Keyed
1725− (addKeyedChildren "nearby-element-pls" keyed rendered.children)
1726− )
1622+ (Keyed <| List.map (\x -> ( "nearby-elements-pls", x )) rendered.children ++ keyed)
17271623 NoStyleSheet
17281624 )
17291625
@@ -1731,13 +1627,7 @@ createElement context children rendered =
17311627 Styled
17321628 { styles = allStyles
17331629 , html =
1734− finalizeNode
1735− rendered.has
1736− rendered.node
1737− rendered.attributes
1738− (Keyed
1739− (addKeyedChildren "nearby-element-pls" keyed rendered.children)
1740− )
1630+ finalizeNode rendered.has rendered.node rendered.attributes (Keyed (List.map (\x -> ( "nearby-elements-pls", x )) rendered.children ++ keyed))
17411631 }
17421632
17431633 Unkeyed unkeyedChildren ->
@@ -1754,58 +1644,20 @@ createElement context children rendered =
17541644 case newStyles of
17551645 [] ->
17561646 Unstyled
1757− (finalizeNode
1758− rendered.has
1647+ (finalizeNode rendered.has
17591648 rendered.node
17601649 rendered.attributes
1761− (Unkeyed (addChildren unkeyed rendered.children))
1650+ (Unkeyed <| rendered.children ++ unkeyed)
17621651 NoStyleSheet
17631652 )
17641653
17651654 allStyles ->
17661655 Styled
17671656 { styles = allStyles
1768− , html =
1769− finalizeNode
1770− rendered.has
1771− rendered.node
1772− rendered.attributes
1773− (Unkeyed (addChildren unkeyed rendered.children))
1657+ , html = finalizeNode rendered.has rendered.node rendered.attributes (Unkeyed (rendered.children ++ unkeyed))
17741658 }
17751659
17761660
1777−addChildren existing nearbyChildren =
1778− case nearbyChildren of
1779− NoNearbyChildren ->
1780− existing
1781−
1782− ChildrenBehind behind ->
1783− behind ++ existing
1784−
1785− ChildrenInFront inFront ->
1786− existing ++ inFront
1787−
1788− ChildrenBehindAndInFront behind inFront ->
1789− behind ++ existing ++ inFront
1790−
1791−
1792−addKeyedChildren key existing nearbyChildren =
1793− case nearbyChildren of
1794− NoNearbyChildren ->
1795− existing
1796−
1797− ChildrenBehind behind ->
1798− List.map (\x -> ( key, x )) behind ++ existing
1799−
1800− ChildrenInFront inFront ->
1801− existing ++ List.map (\x -> ( key, x )) inFront
1802−
1803− ChildrenBehindAndInFront behind inFront ->
1804− List.map (\x -> ( key, x )) behind
1805− ++ existing
1806− ++ List.map (\x -> ( key, x )) inFront
1807−
1808−
18091661unit =
18101662 0
18111663
@@ -1817,20 +1669,8 @@ defaultOptions =
18171669 }
18181670
18191671
1820−staticRoot : OptionRecord -> VirtualDom.Node msg
1821−staticRoot opts =
1822− case opts.mode of
1823− Layout ->
1824− -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
1825− VirtualDom.node "div"
1826− []
1827− [ VirtualDom.node "style" [] [ VirtualDom.text Internal.Style.rules ] ]
1828−
1829− NoStaticStyleSheet ->
1830− VirtualDom.text ""
1831−
1832− WithVirtualCss ->
1833− VirtualDom.node "elm-ui-static-rules" [ VirtualDom.property "rules" (Encode.string Internal.Style.rules) ] []
1672+staticRoot =
1673+ VirtualDom.node "style" [] [ VirtualDom.text Internal.Style.rules ]
18341674
18351675
18361676addWhen ifThis x to =
@@ -1948,7 +1788,7 @@ type Spacing
19481788
19491789
19501790type Padding
1951− = Padding String Float Float Float Float
1791+ = Padding String Int Int Int Int
19521792
19531793
19541794extractSpacingAndPadding : List (Attribute aligned msg) -> ( Maybe Padding, Maybe Spacing )
@@ -2044,44 +1884,35 @@ getHeight attrs =
20441884 Nothing
20451885
20461886
2047−textElementClasses : String
2048−textElementClasses =
2049− classes.any
2050− ++ " "
2051− ++ classes.text
2052− ++ " "
2053− ++ classes.widthContent
2054− ++ " "
2055− ++ classes.heightContent
2056−
2057−
20581887textElement : String -> VirtualDom.Node msg
20591888textElement str =
20601889 Html.div
20611890 [ Html.Attributes.class
2062− textElementClasses
1891+ (String.join " "
1892+ [ classes.any
1893+ , classes.text
1894+ , classes.widthContent
1895+ , classes.heightContent
1896+ ]
1897+ )
20631898 ]
20641899 [ Html.text str ]
20651900
20661901
2067−textElementFillClasses : String
2068−textElementFillClasses =
2069− classes.any
2070− ++ " "
2071− ++ classes.text
2072− ++ " "
2073− ++ classes.widthFill
2074− ++ " "
2075− ++ classes.heightFill
2076−
2077−
20781902textElementFill : String -> VirtualDom.Node msg
20791903textElementFill str =
2080− Html.div
2081− [ Html.Attributes.class
2082− textElementFillClasses
1904+ VirtualDom.node "div"
1905+ [ VirtualDom.property "className"
1906+ (Json.string <|
1907+ String.join " "
1908+ [ classes.any
1909+ , classes.text
1910+ , classes.widthFill
1911+ , classes.heightFill
1912+ ]
1913+ )
20831914 ]
2084− [ Html.text str ]
1915+ [ VirtualDom.text str ]
20851916
20861917
20871918type Children x
@@ -2089,6 +1920,10 @@ type Children x
20891920 | Keyed (List ( String, x ))
20901921
20911922
1923+
1924+-- toHtml : OptionRecord -> Element msg -> VirtualDom.Node msg
1925+
1926+
20921927toHtml mode el =
20931928 case el of
20941929 Unstyled html ->
@@ -2124,7 +1959,8 @@ renderRoot optionList attributes child =
21241959
21251960
21261961type RenderMode
2127− = Layout
1962+ = Viewport
1963+ | Layout
21281964 | NoStaticStyleSheet
21291965 | WithVirtualCss
21301966
@@ -2173,8 +2009,8 @@ rootStyle =
21732009 , SansSerif
21742010 ]
21752011 in
2176− [ StyleClass Flag.bgColor (Colored ("bg-" ++ 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))
2012+ [ StyleClass Flag.bgColor (Colored ("bg-color-" ++ formatColorClass (Rgba 1 1 1 0)) "background-color" (Rgba 1 1 1 0))
2013+ , StyleClass Flag.fontColor (Colored ("font-color-" ++ formatColorClass (Rgba 0 0 0 1)) "color" (Rgba 0 0 0 1))
21782014 , StyleClass Flag.fontSize (FontSize 20)
21792015 , StyleClass Flag.fontFamily <|
21802016 FontFamily (List.foldl renderFontClassName "font-" families)
@@ -2206,49 +2042,14 @@ renderFontClassName font current =
22062042 |> String.toLower
22072043 |> String.words
22082044 |> String.join "-"
2209−
2210− FontWith { name } ->
2211− name
2212− |> String.toLower
2213− |> String.words
2214− |> String.join "-"
22152045 )
22162046
22172047
22182048renderFocusStyle :
22192049 FocusStyle
2220− -> List Style
2050+ -> Style
22212051renderFocusStyle 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
2226− , Maybe.map
2227− (\shadow ->
2228− Property "box-shadow"
2229− (formatBoxShadow
2230− { color = shadow.color
2231− , offset =
2232− shadow.offset
2233− |> Tuple.mapFirst toFloat
2234− |> Tuple.mapSecond toFloat
2235− , inset = False
2236− , blur =
2237− toFloat shadow.blur
2238− , size =
2239− toFloat shadow.size
2240− }
2241− )
2242− )
2243− focus.shadow
2244− , Just <| Property "outline" "none"
2245− ]
2246− )
2247− , Style
2248− ((Internal.Style.dot classes.any ++ ":focus .focusable, ")
2249− ++ (Internal.Style.dot classes.any ++ ".focusable:focus, ")
2250− ++ (".ui-slide-bar:focus + " ++ Internal.Style.dot classes.any ++ " .focusable-thumb")
2251− )
2052+ Style (Internal.Style.dot classes.any ++ ":focus .focusable, " ++ Internal.Style.dot classes.any ++ ".focusable:focus")
22522053 (List.filterMap identity
22532054 [ Maybe.map (\color -> Property "border-color" (formatColor color)) focus.borderColor
22542055 , Maybe.map (\color -> Property "background-color" (formatColor color)) focus.backgroundColor
@@ -2271,7 +2072,6 @@ renderFocusStyle focus =
22712072 , Just <| Property "outline" "none"
22722073 ]
22732074 )
2274− ]
22752075
22762076
22772077focusDefaultStyle : { backgroundColor : Maybe Color, borderColor : Maybe Color, shadow : Maybe Shadow }
@@ -2283,7 +2083,7 @@ focusDefaultStyle =
22832083 { color =
22842084 Rgba (155 / 255) (203 / 255) 1 1
22852085 , offset = ( 0, 0 )
2286− , blur = 0
2086+ , blur = 3
22872087 , size = 3
22882088 }
22892089 }
@@ -2351,734 +2151,498 @@ optionsToRecord options =
23512151 options
23522152
23532153
2354−toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2355−toStyleSheet options styleSheet =
2356− case options.mode of
2357− Layout ->
2358− -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
2359− VirtualDom.node "div"
2360− []
2361− [ VirtualDom.node "style"
2362− []
2363− [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2364− ]
2365−
2366− NoStaticStyleSheet ->
2367− -- wrap the style node in a div to prevent `Dark Reader` from blowin up the dom.
2368− VirtualDom.node "div"
2369− []
2370− [ VirtualDom.node "style"
2371− []
2372− [ VirtualDom.text (toStyleSheetString options styleSheet) ]
2373− ]
2374−
2375− WithVirtualCss ->
2376− VirtualDom.node "elm-ui-rules"
2377− [ VirtualDom.property "rules"
2378− (encodeStyles options styleSheet)
2379− ]
2380− []
2381−
2382−
2383−renderTopLevelValues rules =
2154+renderFont : List Font -> String
2155+renderFont families =
23842156 let
2385− withImport font =
2157+ fontName font =
23862158 case font of
2387− ImportFont _ url ->
2388− Just ("@import url('" ++ url ++ "');")
2389−
2390− -- FontWith with ->
2391− -- case with.url of
2392− -- Just x ->
2393− -- Just ("@import url('" ++ x ++ "');")
2394− -- Nothing ->
2395− -- Nothing
2396− _ ->
2397− Nothing
2398−
2399− allNames =
2400− List.map Tuple.first rules
2401−
2402− fontImports ( name, typefaces ) =
2403− let
2404− imports =
2405− String.join "\n" (List.filterMap withImport typefaces)
2406− in
2407− imports
2408−
2409− fontAdjustments ( name, typefaces ) =
2410− case typefaceAdjustment typefaces of
2411− Nothing ->
2412− String.join ""
2413− (List.map (renderNullAdjustmentRule name) allNames)
2159+ Serif ->
2160+ "serif"
24142161
2415− Just adjustment ->
2416− String.join ""
2417− (List.map (renderFontAdjustmentRule name adjustment) allNames)
2418− in
2419− String.join "\n" (List.map fontImports rules)
2420− ++ String.join "\n" (List.map fontAdjustments rules)
2162+ SansSerif ->
2163+ "sans-serif"
24212164
2165+ Monospace ->
2166+ "monospace"
24222167
2423−renderNullAdjustmentRule fontToAdjust otherFontName =
2424− let
2425− name =
2426− if fontToAdjust == otherFontName then
2427− fontToAdjust
2168+ Typeface name ->
2169+ "\"" ++ name ++ "\""
24282170
2429− else
2430− otherFontName ++ " ." ++ fontToAdjust
2171+ ImportFont name url ->
2172+ "\"" ++ name ++ "\""
24312173 in
2432− String.join " "
2433− [ bracket
2434− ("."
2435− ++ name
2436− ++ "."
2437− ++ classes.sizeByCapital
2438− ++ ", "
2439− ++ "."
2440− ++ name
2441− ++ " ."
2442− ++ classes.sizeByCapital
2443− )
2444− [ ( "line-height", "1" )
2445− ]
2446− , bracket
2447− ("."
2448− ++ name
2449− ++ "."
2450− ++ classes.sizeByCapital
2451− ++ "> ."
2452− ++ Internal.Style.classes.text
2453− ++ ", ."
2454− ++ name
2455− ++ " ."
2456− ++ classes.sizeByCapital
2457− ++ " > ."
2458− ++ Internal.Style.classes.text
2459− )
2460− [ ( "vertical-align", "0" )
2461− , ( "line-height", "1" )
2462− ]
2463− ]
2174+ families
2175+ |> List.map fontName
2176+ |> String.join ", "
24642177
24652178
2466−fontRule name modifier ( parentAdj, textAdjustment ) =
2467− [ bracket
2468− ("."
2469− ++ name
2470− ++ "."
2471− ++ modifier
2472− ++ ", "
2473− ++ "."
2474− ++ name
2475− ++ " ."
2476− ++ modifier
2477− )
2478− parentAdj
2479− , bracket
2480− ("."
2481− ++ name
2482− ++ "."
2483− ++ modifier
2484− ++ "> ."
2485− ++ Internal.Style.classes.text
2486− ++ ", ."
2487− ++ name
2488− ++ " ."
2489− ++ modifier
2490− ++ " > ."
2491− ++ Internal.Style.classes.text
2492− )
2493− textAdjustment
2494− ]
2179+toStyleSheet : OptionRecord -> List Style -> VirtualDom.Node msg
2180+toStyleSheet options styleSheet =
2181+ VirtualDom.node "style" [] [ VirtualDom.text (toStyleSheetString options styleSheet) ]
24952182
24962183
2497−renderFontAdjustmentRule fontToAdjust ( full, capital ) otherFontName =
2184+toStyleSheetString : OptionRecord -> List Style -> String
2185+toStyleSheetString options stylesheet =
24982186 let
2499− name =
2500− if fontToAdjust == otherFontName then
2501− fontToAdjust
2502−
2503− else
2504− otherFontName ++ " ." ++ fontToAdjust
2505− in
2506− String.join " "
2507− (fontRule name classes.sizeByCapital capital ++ fontRule name classes.fullSize full)
2508−
2187+ renderTopLevels rule =
2188+ case rule of
2189+ FontFamily name typefaces ->
2190+ let
2191+ getImports font =
2192+ case font of
2193+ ImportFont _ url ->
2194+ Just ("@import url('" ++ url ++ "');")
25092195
2510−bracket selector rules =
2511− let
2512− renderPair ( name, val ) =
2513− name ++ ": " ++ val ++ ";"
2514− in
2515− selector ++ " {" ++ String.join "" (List.map renderPair rules) ++ "}"
2196+ _ ->
2197+ Nothing
2198+ in
2199+ typefaces
2200+ |> List.filterMap getImports
2201+ |> String.join "\n"
2202+ |> Just
25162203
2204+ _ ->
2205+ Nothing
25172206
2518−fontAdjustmentRules converted =
2519− ( [ ( "display", "block" )
2520− ]
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" )
2525− ]
2526− )
2207+ renderProps force (Property key val) existing =
2208+ if force then
2209+ existing ++ "\n " ++ key ++ ": " ++ val ++ " !important;"
25272210
2211+ else
2212+ existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
25282213
2529−typefaceAdjustment typefaces =
2530− List.foldl
2531− (\face found ->
2532− case found of
2214+ renderStyle maybePseudo selector props =
2215+ case maybePseudo of
25332216 Nothing ->
2534− case face of
2535− FontWith with ->
2536− case with.adjustment of
2537− Nothing ->
2538− found
2539−
2540− Just adjustment ->
2541− Just
2542− ( fontAdjustmentRules
2543− (.full (convertAdjustment adjustment))
2544− , fontAdjustmentRules
2545− (.capital (convertAdjustment adjustment))
2546− )
2547−
2548− _ ->
2549− found
2217+ selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}"
25502218
2551− Just _ ->
2552− found
2553− )
2554− Nothing
2555− typefaces
2556−
2557−
2558−fontName font =
2559− case font of
2560− Serif ->
2561− "serif"
2562−
2563− SansSerif ->
2564− "sans-serif"
2565−
2566− Monospace ->
2567− "monospace"
2568−
2569− Typeface name ->
2570− "\"" ++ name ++ "\""
2571−
2572− ImportFont name url ->
2573− "\"" ++ name ++ "\""
2574−
2575− FontWith { name } ->
2576− "\"" ++ name ++ "\""
2577−
2578−
2579−topLevelValue rule =
2580− case rule of
2581− FontFamily name typefaces ->
2582− Just ( name, typefaces )
2583−
2584− _ ->
2585− Nothing
2586−
2587−
2588−renderProps force (Property key val) existing =
2589− if force then
2590− existing ++ "\n " ++ key ++ ": " ++ val ++ " !important;"
2591−
2592− else
2593− existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
2594−
2595−
2596−encodeStyles options stylesheet =
2597− stylesheet
2598− |> List.map
2599− (\style ->
2600− let
2601− styled =
2602− renderStyleRule options style Nothing
2603− in
2604− ( getStyleName style, Encode.list Encode.string styled )
2605− )
2606− |> Encode.object
2607−
2608−
2609−toStyleSheetString : OptionRecord -> List Style -> String
2610−toStyleSheetString options stylesheet =
2611− let
2612− combine style rendered =
2613− { rules = rendered.rules ++ renderStyleRule options style Nothing
2614− , topLevel =
2615− case topLevelValue style of
2616− Nothing ->
2617− rendered.topLevel
2219+ Just pseudo ->
2220+ case pseudo of
2221+ Hover ->
2222+ case options.hover of
2223+ NoHover ->
2224+ ""
26182225
2619− Just topLevel ->
2620− topLevel :: rendered.topLevel
2621− }
2622− in
2623− case List.foldl combine { topLevel = [], rules = [] } stylesheet of
2624− { topLevel, rules } ->
2625− renderTopLevelValues topLevel ++ String.concat rules
2226+ ForceHover ->
2227+ selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}"
26262228
2229+ AllowHover ->
2230+ selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}"
26272231
2628−renderStyle : OptionRecord -> Maybe PseudoClass -> String -> List Property -> List String
2629−renderStyle options maybePseudo selector props =
2630− case maybePseudo of
2631− Nothing ->
2632− [ selector ++ "{" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2232+ Focus ->
2233+ let
2234+ renderedProps =
2235+ List.foldl (renderProps False) "" props
2236+ in
2237+ String.join "\n"
2238+ [ selector
2239+ ++ "-fs:focus {"
2240+ ++ renderedProps
2241+ ++ "\n}"
2242+ , "."
2243+ ++ classes.any
2244+ ++ ":focus ~ "
2245+ ++ selector
2246+ ++ "-fs:not(.focus) {"
2247+ ++ renderedProps
2248+ ++ "\n}"
2249+ , "."
2250+ ++ classes.any
2251+ ++ ":focus "
2252+ ++ selector
2253+ ++ "-fs {"
2254+ ++ renderedProps
2255+ ++ "\n}"
2256+ , ".focusable-parent:focus ~ "
2257+ ++ "."
2258+ ++ classes.any
2259+ ++ " "
2260+ ++ selector
2261+ ++ "-fs {"
2262+ ++ renderedProps
2263+ ++ "\n}"
2264+ ]
26332265
2634− Just pseudo ->
2635− case pseudo of
2636− Hover ->
2637− case options.hover of
2638− NoHover ->
2639− []
2266+ Active ->
2267+ selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}"
26402268
2641− ForceHover ->
2642− [ selector ++ "-hv {" ++ List.foldl (renderProps True) "" props ++ "\n}" ]
2269+ renderStyleRule rule maybePseudo =
2270+ case rule of
2271+ Style selector props ->
2272+ renderStyle maybePseudo selector props
26432273
2644− AllowHover ->
2645− [ selector ++ "-hv:hover {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2274+ Shadows name prop ->
2275+ renderStyle
2276+ maybePseudo
2277+ ("." ++ name)
2278+ [ Property "box-shadow" prop
2279+ ]
26462280
2647− Focus ->
2281+ Transparency name transparency ->
26482282 let
2649− renderedProps =
2650− List.foldl (renderProps False) "" props
2283+ opacity =
2284+ (1 - transparency)
2285+ |> min 1
2286+ |> max 0
26512287 in
2652− [ selector ++ "-fs:focus {" ++ renderedProps ++ "\n}"
2653− , ("." ++ classes.any ++ ":focus " ++ selector ++ "-fs {")
2654− ++ renderedProps
2655− ++ "\n}"
2656− , (selector ++ "-fs:focus-within {")
2657− ++ renderedProps
2658− ++ "\n}"
2659− , (".ui-slide-bar:focus + " ++ Internal.Style.dot classes.any ++ " .focusable-thumb" ++ selector ++ "-fs {")
2660− ++ renderedProps
2661− ++ "\n}"
2662− ]
2663−
2664− Active ->
2665− [ selector ++ "-act:active {" ++ List.foldl (renderProps False) "" props ++ "\n}" ]
2666−
2667−
2668−renderStyleRule : OptionRecord -> Style -> Maybe PseudoClass -> List String
2669−renderStyleRule options rule maybePseudo =
2670− case rule of
2671− Style selector props ->
2672− renderStyle options maybePseudo selector props
2673−
2674− Shadows name prop ->
2675− renderStyle options
2676− maybePseudo
2677− ("." ++ name)
2678− [ Property "box-shadow" prop
2679− ]
2680−
2681− Transparency name transparency ->
2682− let
2683− opacity =
2684− (1 - transparency)
2685− |> min 1
2686− |> max 0
2687− in
2688− renderStyle options
2689− maybePseudo
2690− ("." ++ name)
2691− [ Property "opacity" (String.fromFloat opacity)
2692− ]
2693−
2694− FontSize i ->
2695− renderStyle options
2696− maybePseudo
2697− (".font-size-" ++ String.fromInt i)
2698− [ Property "font-size" (String.fromInt i ++ "px")
2699− ]
2288+ renderStyle
2289+ maybePseudo
2290+ ("." ++ name)
2291+ [ Property "opacity" (String.fromFloat opacity)
2292+ ]
27002293
2701− FontFamily name typefaces ->
2702− let
2703− features =
2704− typefaces
2705− |> List.filterMap renderVariants
2706− |> String.join ", "
2707−
2708− families =
2709− [ Property "font-family"
2710− (typefaces
2711− |> List.map fontName
2712− |> String.join ", "
2713− )
2714− , Property "font-feature-settings" features
2715− , Property "font-variant"
2716− (if List.any hasSmallCaps typefaces then
2717− "small-caps"
2294+ FontSize i ->
2295+ renderStyle
2296+ maybePseudo
2297+ (".font-size-" ++ String.fromInt i)
2298+ [ Property "font-size" (String.fromInt i ++ "px")
2299+ ]
27182300
2719− else
2720− "normal"
2721− )
2722− ]
2723− in
2724− renderStyle options
2725− maybePseudo
2726− ("." ++ name)
2727− families
2301+ FontFamily name typefaces ->
2302+ renderStyle
2303+ maybePseudo
2304+ ("." ++ name)
2305+ [ Property "font-family" (renderFont typefaces)
2306+ ]
27282307
2729− Single class prop val ->
2730− renderStyle options
2731− maybePseudo
2732− ("." ++ class)
2733− [ Property prop val
2734− ]
2308+ Single class prop val ->
2309+ renderStyle
2310+ maybePseudo
2311+ ("." ++ class)
2312+ [ Property prop val
2313+ ]
27352314
2736− Colored class prop color ->
2737− renderStyle options
2738− maybePseudo
2739− ("." ++ class)
2740− [ Property prop (formatColor color)
2741− ]
2315+ Colored class prop color ->
2316+ renderStyle
2317+ maybePseudo
2318+ ("." ++ class)
2319+ [ Property prop (formatColor color)
2320+ ]
27422321
2743− SpacingStyle cls x y ->
2744− let
2745− class =
2746− "." ++ cls
2322+ SpacingStyle cls x y ->
2323+ let
2324+ class =
2325+ "." ++ cls
27472326
2748− halfX =
2749− String.fromFloat (toFloat x / 2) ++ "px"
2327+ xPx =
2328+ String.fromInt x ++ "px"
27502329
2751− halfY =
2752− String.fromFloat (toFloat y / 2) ++ "px"
2330+ yPx =
2331+ String.fromInt y ++ "px"
27532332
2754− xPx =
2755− String.fromInt x ++ "px"
2333+ row =
2334+ "." ++ Internal.Style.classes.row
27562335
2757− yPx =
2758− String.fromInt y ++ "px"
2336+ wrappedRow =
2337+ "." ++ Internal.Style.classes.wrapped ++ row
27592338
2760− row =
2761− "." ++ Internal.Style.classes.row
2339+ column =
2340+ "." ++ Internal.Style.classes.column
27622341
2763− wrappedRow =
2764− "." ++ Internal.Style.classes.wrapped ++ row
2342+ page =
2343+ "." ++ Internal.Style.classes.page
27652344
2766− column =
2767− "." ++ Internal.Style.classes.column
2345+ paragraph =
2346+ "." ++ Internal.Style.classes.paragraph
27682347
2769− page =
2770− "." ++ Internal.Style.classes.page
2348+ left =
2349+ "." ++ Internal.Style.classes.alignLeft
27712350
2772− paragraph =
2773− "." ++ Internal.Style.classes.paragraph
2351+ right =
2352+ "." ++ Internal.Style.classes.alignRight
27742353
2775− left =
2776− "." ++ Internal.Style.classes.alignLeft
2354+ any =
2355+ "." ++ Internal.Style.classes.any
27772356
2778− right =
2779− "." ++ Internal.Style.classes.alignRight
2357+ single =
2358+ "." ++ Internal.Style.classes.single
2359+ in
2360+ String.concat
2361+ [ renderStyle maybePseudo (class ++ row ++ " > " ++ any) [ Property "margin-right" xPx ]
27802362
2781− any =
2782− "." ++ Internal.Style.classes.any
2363+ -- margins don't apply to last element of normal, unwrapped rows
2364+ , renderStyle maybePseudo (class ++ row ++ " > " ++ any ++ ":last-child") [ Property "margin" "0" ]
27832365
2784− single =
2785− "." ++ Internal.Style.classes.single
2786− in
2787− List.concat
2788− [ renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ " + " ++ any) [ Property "margin-left" xPx ]
2789−
2790− -- margins don't apply to last element of normal, unwrapped rows
2791− -- , renderStyle options maybePseudo (class ++ row ++ " > " ++ any ++ ":first-child") [ Property "margin" "0" ]
2792− -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2793− , renderStyle options
2794− maybePseudo
2795− (class ++ wrappedRow ++ " > " ++ any)
2796− [ Property "margin" (halfY ++ " " ++ halfX)
2797− ]
2366+ -- For wrapped rows, margins always apply because we handle "canceling out" the other margins manually in the element.
2367+ , renderStyle maybePseudo
2368+ (class ++ wrappedRow ++ " > " ++ any)
2369+ [ Property "margin" ("0 " ++ xPx ++ " " ++ yPx ++ " 0")
2370+ ]
2371+ , renderStyle maybePseudo
2372+ (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2373+ [ Property "margin-right" "0"
2374+ ]
27982375
2799− -- , renderStyle options maybePseudo
2800− -- (class ++ wrappedRow ++ " > " ++ any ++ ":last-child")
2801− -- [ Property "margin-right" "0"
2802− -- ]
2803− -- columns
2804− , renderStyle options maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2805− , renderStyle options maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2806− , renderStyle options maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2807− , renderStyle options maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2808− , renderStyle options
2809− maybePseudo
2810− (class ++ paragraph)
2811− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2812− ]
2813− , renderStyle options
2814− maybePseudo
2815− ("textarea" ++ any ++ class)
2816− [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2817− , Property "height" ("calc(100% + " ++ String.fromInt y ++ "px)")
2818− ]
2376+ -- columns
2377+ , renderStyle maybePseudo (class ++ column ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2378+ , renderStyle maybePseudo (class ++ page ++ " > " ++ any ++ " + " ++ any) [ Property "margin-top" yPx ]
2379+ , renderStyle maybePseudo (class ++ page ++ " > " ++ left) [ Property "margin-right" xPx ]
2380+ , renderStyle maybePseudo (class ++ page ++ " > " ++ right) [ Property "margin-left" xPx ]
2381+ , renderStyle
2382+ maybePseudo
2383+ (class ++ paragraph)
2384+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2385+ ]
2386+ , renderStyle
2387+ maybePseudo
2388+ ("textarea" ++ class)
2389+ [ Property "line-height" ("calc(1em + " ++ String.fromInt y ++ "px)")
2390+ ]
28192391
2820− -- , renderStyle options
2821− -- maybePseudo
2822− -- (class ++ paragraph ++ " > " ++ any)
2823− -- [ Property "margin-right" xPx
2824− -- , Property "margin-bottom" yPx
2825− -- ]
2826− , renderStyle options
2827− maybePseudo
2828− (class ++ paragraph ++ " > " ++ left)
2829− [ Property "margin-right" xPx
2830− ]
2831− , renderStyle options
2832− maybePseudo
2833− (class ++ paragraph ++ " > " ++ right)
2834− [ Property "margin-left" xPx
2835− ]
2836− , renderStyle options
2837− maybePseudo
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")
2844− ]
2845− , renderStyle options
2846− maybePseudo
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")
2853− ]
2854− ]
2392+ -- , renderStyle
2393+ -- maybePseudo
2394+ -- (class ++ paragraph ++ " > " ++ any)
2395+ -- [ Property "margin-right" xPx
2396+ -- , Property "margin-bottom" yPx
2397+ -- ]
2398+ , renderStyle
2399+ maybePseudo
2400+ (class ++ paragraph ++ " > " ++ left)
2401+ [ Property "margin-right" xPx
2402+ ]
2403+ , renderStyle
2404+ maybePseudo
2405+ (class ++ paragraph ++ " > " ++ right)
2406+ [ Property "margin-left" xPx
2407+ ]
2408+ , renderStyle
2409+ maybePseudo
2410+ (class ++ paragraph ++ "::after")
2411+ [ Property "content" "''"
2412+ , Property "display" "block"
2413+ , Property "height" "0"
2414+ , Property "width" "0"
2415+ , Property "margin-top" (String.fromInt (-1 * (y // 2)) ++ "px")
2416+ ]
2417+ , renderStyle
2418+ maybePseudo
2419+ (class ++ paragraph ++ "::before")
2420+ [ Property "content" "''"
2421+ , Property "display" "block"
2422+ , Property "height" "0"
2423+ , Property "width" "0"
2424+ , Property "margin-bottom" (String.fromInt (-1 * (y // 2)) ++ "px")
2425+ ]
2426+ ]
28552427
2856− PaddingStyle cls top right bottom left ->
2857− let
2858− class =
2859− "."
2860− ++ cls
2861− in
2862− renderStyle options
2863− maybePseudo
2864− class
2865− [ Property "padding"
2866− (String.fromFloat top
2867− ++ "px "
2868− ++ String.fromFloat right
2869− ++ "px "
2870− ++ String.fromFloat bottom
2871− ++ "px "
2872− ++ String.fromFloat left
2873− ++ "px"
2874− )
2875− ]
2428+ PaddingStyle cls top right bottom left ->
2429+ let
2430+ class =
2431+ "."
2432+ ++ cls
2433+ in
2434+ renderStyle
2435+ maybePseudo
2436+ class
2437+ [ Property "padding"
2438+ (String.fromInt top
2439+ ++ "px "
2440+ ++ String.fromInt right
2441+ ++ "px "
2442+ ++ String.fromInt bottom
2443+ ++ "px "
2444+ ++ String.fromInt left
2445+ ++ "px"
2446+ )
2447+ ]
28762448
2877− BorderWidth cls top right bottom left ->
2878− let
2879− class =
2880− "."
2881− ++ cls
2882− in
2883− renderStyle options
2884− maybePseudo
2885− class
2886− [ Property "border-width"
2887− (String.fromInt top
2888− ++ "px "
2889− ++ String.fromInt right
2890− ++ "px "
2891− ++ String.fromInt bottom
2892− ++ "px "
2893− ++ String.fromInt left
2894− ++ "px"
2895− )
2896− ]
2449+ GridTemplateStyle template ->
2450+ let
2451+ class =
2452+ ".grid-rows-"
2453+ ++ String.join "-" (List.map lengthClassName template.rows)
2454+ ++ "-cols-"
2455+ ++ String.join "-" (List.map lengthClassName template.columns)
2456+ ++ "-space-x-"
2457+ ++ lengthClassName (Tuple.first template.spacing)
2458+ ++ "-space-y-"
2459+ ++ lengthClassName (Tuple.second template.spacing)
2460+
2461+ ySpacing =
2462+ toGridLength (Tuple.second template.spacing)
2463+
2464+ xSpacing =
2465+ toGridLength (Tuple.first template.spacing)
2466+
2467+ toGridLength x =
2468+ toGridLengthHelper Nothing Nothing x
2469+
2470+ toGridLengthHelper minimum maximum x =
2471+ case x of
2472+ Px px ->
2473+ String.fromInt px ++ "px"
2474+
2475+ Content ->
2476+ case ( minimum, maximum ) of
2477+ ( Nothing, Nothing ) ->
2478+ "max-content"
2479+
2480+ ( Just minSize, Nothing ) ->
2481+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ "max-content)"
2482+
2483+ ( Nothing, Just maxSize ) ->
2484+ "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2485+
2486+ ( Just minSize, Just maxSize ) ->
2487+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2488+
2489+ Fill i ->
2490+ case ( minimum, maximum ) of
2491+ ( Nothing, Nothing ) ->
2492+ String.fromInt i ++ "fr"
2493+
2494+ ( Just minSize, Nothing ) ->
2495+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt i ++ "fr" ++ "fr)"
2496+
2497+ ( Nothing, Just maxSize ) ->
2498+ "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2499+
2500+ ( Just minSize, Just maxSize ) ->
2501+ "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2502+
2503+ Min m len ->
2504+ toGridLengthHelper (Just m) maximum len
2505+
2506+ Max m len ->
2507+ toGridLengthHelper minimum (Just m) len
2508+
2509+ msColumns =
2510+ template.columns
2511+ |> List.map toGridLength
2512+ |> String.join ySpacing
2513+ |> (\x -> "-ms-grid-columns: " ++ x ++ ";")
2514+
2515+ msRows =
2516+ template.columns
2517+ |> List.map toGridLength
2518+ |> String.join ySpacing
2519+ |> (\x -> "-ms-grid-rows: " ++ x ++ ";")
2520+
2521+ base =
2522+ class ++ "{" ++ msColumns ++ msRows ++ "}"
2523+
2524+ columns =
2525+ template.columns
2526+ |> List.map toGridLength
2527+ |> String.join " "
2528+ |> (\x -> "grid-template-columns: " ++ x ++ ";")
2529+
2530+ rows =
2531+ template.rows
2532+ |> List.map toGridLength
2533+ |> String.join " "
2534+ |> (\x -> "grid-template-rows: " ++ x ++ ";")
2535+
2536+ gapX =
2537+ "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2538+
2539+ gapY =
2540+ "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2541+
2542+ modernGrid =
2543+ class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2544+
2545+ supports =
2546+ "@supports (display:grid) {" ++ modernGrid ++ "}"
2547+ in
2548+ base ++ supports
28972549
2898− GridTemplateStyle template ->
2899− let
2900− class =
2901− ".grid-rows-"
2902− ++ String.join "-" (List.map lengthClassName template.rows)
2903− ++ "-cols-"
2904− ++ String.join "-" (List.map lengthClassName template.columns)
2905− ++ "-space-x-"
2906− ++ lengthClassName (Tuple.first template.spacing)
2907− ++ "-space-y-"
2908− ++ lengthClassName (Tuple.second template.spacing)
2909−
2910− ySpacing =
2911− toGridLength (Tuple.second template.spacing)
2912−
2913− xSpacing =
2914− toGridLength (Tuple.first template.spacing)
2915−
2916− toGridLength x =
2917− toGridLengthHelper Nothing Nothing x
2918−
2919− toGridLengthHelper minimum maximum x =
2920− case x of
2921− Px px ->
2922− String.fromInt px ++ "px"
2923−
2924− Content ->
2925− case ( minimum, maximum ) of
2926− ( Nothing, Nothing ) ->
2927− "max-content"
2928−
2929− ( Just minSize, Nothing ) ->
2930− "minmax(" ++ String.fromInt minSize ++ "px, " ++ "max-content)"
2931−
2932− ( Nothing, Just maxSize ) ->
2933− "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2934−
2935− ( Just minSize, Just maxSize ) ->
2936− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2937−
2938− Fill i ->
2939− case ( minimum, maximum ) of
2940− ( Nothing, Nothing ) ->
2941− String.fromInt i ++ "fr"
2942−
2943− ( Just minSize, Nothing ) ->
2944− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt i ++ "fr" ++ "fr)"
2945−
2946− ( Nothing, Just maxSize ) ->
2947− "minmax(max-content, " ++ String.fromInt maxSize ++ "px)"
2948−
2949− ( Just minSize, Just maxSize ) ->
2950− "minmax(" ++ String.fromInt minSize ++ "px, " ++ String.fromInt maxSize ++ "px)"
2951−
2952− Min m len ->
2953− toGridLengthHelper (Just m) maximum len
2954−
2955− Max m len ->
2956− toGridLengthHelper minimum (Just m) len
2957−
2958− msColumns =
2959− template.columns
2960− |> List.map toGridLength
2961− |> String.join ySpacing
2962− |> (\x -> "-ms-grid-columns: " ++ x ++ ";")
2963−
2964− msRows =
2965− template.columns
2966− |> List.map toGridLength
2967− |> String.join ySpacing
2968− |> (\x -> "-ms-grid-rows: " ++ x ++ ";")
2969−
2970− base =
2971− class ++ "{" ++ msColumns ++ msRows ++ "}"
2972−
2973− columns =
2974− template.columns
2975− |> List.map toGridLength
2976− |> String.join " "
2977− |> (\x -> "grid-template-columns: " ++ x ++ ";")
2550+ GridPosition position ->
2551+ let
2552+ class =
2553+ ".grid-pos-"
2554+ ++ String.fromInt position.row
2555+ ++ "-"
2556+ ++ String.fromInt position.col
2557+ ++ "-"
2558+ ++ String.fromInt position.width
2559+ ++ "-"
2560+ ++ String.fromInt position.height
2561+
2562+ msPosition =
2563+ String.join " "
2564+ [ "-ms-grid-row: "
2565+ ++ String.fromInt position.row
2566+ ++ ";"
2567+ , "-ms-grid-row-span: "
2568+ ++ String.fromInt position.height
2569+ ++ ";"
2570+ , "-ms-grid-column: "
2571+ ++ String.fromInt position.col
2572+ ++ ";"
2573+ , "-ms-grid-column-span: "
2574+ ++ String.fromInt position.width
2575+ ++ ";"
2576+ ]
2577+
2578+ base =
2579+ class ++ "{" ++ msPosition ++ "}"
2580+
2581+ modernPosition =
2582+ String.join " "
2583+ [ "grid-row: "
2584+ ++ String.fromInt position.row
2585+ ++ " / "
2586+ ++ String.fromInt (position.row + position.height)
2587+ ++ ";"
2588+ , "grid-column: "
2589+ ++ String.fromInt position.col
2590+ ++ " / "
2591+ ++ String.fromInt (position.col + position.width)
2592+ ++ ";"
2593+ ]
2594+
2595+ modernGrid =
2596+ class ++ "{" ++ modernPosition ++ "}"
2597+
2598+ supports =
2599+ "@supports (display:grid) {" ++ modernGrid ++ "}"
2600+ in
2601+ base ++ supports
29782602
2979− rows =
2980− template.rows
2981− |> List.map toGridLength
2603+ PseudoSelector class styles ->
2604+ let
2605+ renderPseudoRule style =
2606+ renderStyleRule style (Just class)
2607+ in
2608+ List.map renderPseudoRule styles
29822609 |> String.join " "
2983− |> (\x -> "grid-template-rows: " ++ x ++ ";")
2984−
2985− gapX =
2986− "grid-column-gap:" ++ toGridLength (Tuple.first template.spacing) ++ ";"
2987−
2988− gapY =
2989− "grid-row-gap:" ++ toGridLength (Tuple.second template.spacing) ++ ";"
2990−
2991− modernGrid =
2992− class ++ "{" ++ columns ++ rows ++ gapX ++ gapY ++ "}"
2993−
2994− supports =
2995− "@supports (display:grid) {" ++ modernGrid ++ "}"
2996− in
2997− [ base
2998− , supports
2999− ]
30002610
3001− GridPosition position ->
3002− let
3003− class =
3004− ".grid-pos-"
3005− ++ String.fromInt position.row
3006− ++ "-"
3007− ++ String.fromInt position.col
3008− ++ "-"
3009− ++ String.fromInt position.width
3010− ++ "-"
3011− ++ String.fromInt position.height
3012−
3013− msPosition =
3014− String.join " "
3015− [ "-ms-grid-row: "
3016− ++ String.fromInt position.row
3017− ++ ";"
3018− , "-ms-grid-row-span: "
3019− ++ String.fromInt position.height
3020− ++ ";"
3021− , "-ms-grid-column: "
3022− ++ String.fromInt position.col
3023− ++ ";"
3024− , "-ms-grid-column-span: "
3025− ++ String.fromInt position.width
3026− ++ ";"
3027− ]
3028−
3029− base =
3030− class ++ "{" ++ msPosition ++ "}"
3031−
3032− modernPosition =
3033− String.join " "
3034− [ "grid-row: "
3035− ++ String.fromInt position.row
3036− ++ " / "
3037− ++ String.fromInt (position.row + position.height)
3038− ++ ";"
3039− , "grid-column: "
3040− ++ String.fromInt position.col
3041− ++ " / "
3042− ++ String.fromInt (position.col + position.width)
3043− ++ ";"
3044− ]
3045−
3046− modernGrid =
3047− class ++ "{" ++ modernPosition ++ "}"
3048−
3049− supports =
3050− "@supports (display:grid) {" ++ modernGrid ++ "}"
3051− in
3052− [ base
3053− , supports
3054− ]
2611+ Transform transform ->
2612+ let
2613+ val =
2614+ transformValue transform
30552615
3056− PseudoSelector class styles ->
3057− let
3058− renderPseudoRule style =
3059− renderStyleRule options style (Just class)
3060− in
3061− List.concatMap renderPseudoRule styles
2616+ class =
2617+ transformClass transform
2618+ in
2619+ case ( class, val ) of
2620+ ( Just cls, Just v ) ->
2621+ renderStyle
2622+ maybePseudo
2623+ ("." ++ cls)
2624+ [ Property "transform"
2625+ v
2626+ ]
30622627
3063− Transform transform ->
3064− let
3065− val =
3066− transformValue transform
2628+ _ ->
2629+ ""
30672630
3068− class =
3069− transformClass transform
3070− in
3071− case ( class, val ) of
3072− ( Just cls, Just v ) ->
3073− renderStyle options
3074− maybePseudo
3075− ("." ++ cls)
3076− [ Property "transform"
3077− v
3078− ]
2631+ combine style rendered =
2632+ { rendered
2633+ | rules = rendered.rules ++ renderStyleRule style Nothing
2634+ , topLevel =
2635+ case renderTopLevels style of
2636+ Nothing ->
2637+ rendered.topLevel
30792638
3080− _ ->
3081− []
2639+ Just topLevel ->
2640+ rendered.topLevel ++ topLevel
2641+ }
2642+ in
2643+ case List.foldl combine { rules = "", topLevel = "" } stylesheet of
2644+ { topLevel, rules } ->
2645+ topLevel ++ rules
30822646
30832647
30842648lengthClassName : Length -> String
@@ -3118,12 +2682,12 @@ formatTextShadow shadow =
31182682 ]
31192683
31202684
3121−textShadowClass shadow =
2685+textShadowName shadow =
31222686 String.concat
31232687 [ "txt"
3124− , floatClass (Tuple.first shadow.offset) ++ "px"
3125− , floatClass (Tuple.second shadow.offset) ++ "px"
3126− , floatClass shadow.blur ++ "px"
2688+ , String.fromFloat (Tuple.first shadow.offset) ++ "px"
2689+ , String.fromFloat (Tuple.second shadow.offset) ++ "px"
2690+ , String.fromFloat shadow.blur ++ "px"
31272691 , formatColorClass shadow.color
31282692 ]
31292693
@@ -3144,17 +2708,17 @@ formatBoxShadow shadow =
31442708 ]
31452709
31462710
3147−boxShadowClass shadow =
2711+boxShadowName shadow =
31482712 String.concat <|
31492713 [ if shadow.inset then
31502714 "box-inset"
31512715
31522716 else
31532717 "box-"
3154− , floatClass (Tuple.first shadow.offset) ++ "px"
3155− , floatClass (Tuple.second shadow.offset) ++ "px"
3156− , floatClass shadow.blur ++ "px"
3157− , floatClass shadow.size ++ "px"
2718+ , String.fromFloat (Tuple.first shadow.offset) ++ "px"
2719+ , String.fromFloat (Tuple.second shadow.offset) ++ "px"
2720+ , String.fromFloat shadow.blur ++ "px"
2721+ , String.fromFloat shadow.size ++ "px"
31582722 , formatColorClass shadow.color
31592723 ]
31602724
@@ -3199,17 +2763,6 @@ paddingName top right bottom left =
31992763 ++ String.fromInt left
32002764
32012765
3202−paddingNameFloat top right bottom left =
3203− "pad-"
3204− ++ floatClass top
3205− ++ "-"
3206− ++ floatClass right
3207− ++ "-"
3208− ++ floatClass bottom
3209− ++ "-"
3210− ++ floatClass left
3211−
3212−
32132766getStyleName : Style -> String
32142767getStyleName style =
32152768 case style of
@@ -3240,9 +2793,6 @@ getStyleName style =
32402793 PaddingStyle cls top right bottom left ->
32412794 cls
32422795
3243− BorderWidth cls top right bottom left ->
3244− cls
3245−
32462796 GridTemplateStyle template ->
32472797 "grid-rows-"
32482798 ++ String.join "-" (List.map lengthClassName template.rows)
@@ -3475,76 +3025,3 @@ onlyStyles attr =
34753025
34763026 _ ->
34773027 Nothing
3478−
3479−
3480−
3481−{- Font Adjustments -}
3482−
3483−
3484−convertAdjustment adjustment =
3485− let
3486− lineHeight =
3487− 1.5
3488−
3489− base =
3490− lineHeight
3491−
3492− normalDescender =
3493− (lineHeight - 1)
3494− / 2
3495−
3496− oldMiddle =
3497− lineHeight / 2
3498−
3499− newCapitalMiddle =
3500− ((ascender - newBaseline) / 2) + newBaseline
3501−
3502− newFullMiddle =
3503− ((ascender - descender) / 2) + descender
3504−
3505− lines =
3506− [ adjustment.capital
3507− , adjustment.baseline
3508− , adjustment.descender
3509− , adjustment.lowercase
3510− ]
3511−
3512− ascender =
3513− Maybe.withDefault adjustment.capital (List.maximum lines)
3514−
3515− descender =
3516− Maybe.withDefault adjustment.descender (List.minimum lines)
3517−
3518− newBaseline =
3519− lines
3520− |> List.filter (\x -> x /= descender)
3521− |> List.minimum
3522− |> Maybe.withDefault adjustment.baseline
3523−
3524− capitalVertical =
3525− 1 - ascender
3526−
3527− capitalSize =
3528− 1 / (ascender - newBaseline)
3529−
3530− fullSize =
3531− 1 / (ascender - descender)
3532−
3533− fullVertical =
3534− 1 - ascender
3535−
3536− -- (oldMiddle - newFullMiddle) * 2
3537− in
3538− { full =
3539− adjust fullSize (ascender - descender) fullVertical
3540− , capital =
3541− adjust capitalSize (ascender - newBaseline) capitalVertical
3542− }
3543−
3544−
3545−adjust size height vertical =
3546− { vertical = vertical
3547− , height =
3548− height / size
3549− , size = size
3550− }