@@ -1,4 +1,4 @@
1−module Internal.Model exposing (..)
1+module Internal.Model exposing (Aligned(..), Angle, Attribute(..), Axis(..), Children(..), Color(..), Description(..), Element(..), EmbedStyle(..), FocusStyle, Font(..), Gathered, HAlign(..), HoverSetting(..), LayoutContext(..), Length(..), Location(..), NodeName(..), Option(..), OptionRecord, Padding(..), Property(..), PseudoClass(..), RenderMode(..), Shadow, Spacing(..), Style(..), TransformComponent(..), Transformation(..), VAlign(..), XYZ, addNodeName, addWhen, alignXName, alignYName, asColumn, asEl, asGrid, asParagraph, asRow, asTextColumn, boxShadowName, columnClass, composeTransformation, contextClasses, createElement, defaultOptions, div, element, embedKeyed, embedWith, extractSpacingAndPadding, filter, finalizeNode, floatClass, focusDefaultStyle, formatBoxShadow, formatColor, formatColorClass, formatDropShadow, formatTextShadow, gatherAttrRecursive, get, getHeight, getSpacing, getStyleName, getWidth, gridClass, htmlClass, lengthClassName, map, mapAttr, mapAttrFromStyle, noStyleSheet, onlyStyles, optionsToRecord, paddingName, pageClass, paragraphClass, reduceRecursive, reduceRecursiveCalcName, reduceStyles, reduceStylesRecursive, removeNever, renderFocusStyle, renderFont, renderFontClassName, renderHeight, renderRoot, renderWidth, rootStyle, rowClass, singleClass, skippable, sortedReduce, spacingName, staticRoot, tag, textElement, textElementFill, textShadowName, toHtml, toStyleSheet, toStyleSheetString, transformClass, transformValue, unit, unstyled, untransformed, unwrapDecorations, unwrapDecsHelper)
@@ -275,6 +275,7 @@ finalizeNode has node attributes children embedMode parentContext =
276 if Flag.present Flag.widthFill has && not (Flag.present Flag.widthBetween has) then
276 if Flag.present Flag.widthFill has && not (Flag.present Flag.widthBetween has) then
278 else if Flag.present Flag.alignRight has then
279 else if Flag.present Flag.alignRight has then
280 [ Html.Attributes.class
281 [ Html.Attributes.class
@@ -288,6 +289,7 @@ finalizeNode has node attributes children embedMode parentContext =
291 else if Flag.present Flag.centerX has then
293 else if Flag.present Flag.centerX has then
293 [ Html.Attributes.class
295 [ Html.Attributes.class
@@ -301,12 +303,14 @@ finalizeNode has node attributes children embedMode parentContext =
307 AsColumn ->
310 AsColumn ->
308 if Flag.present Flag.heightFill has && not (Flag.present Flag.heightBetween has) then
311 if Flag.present Flag.heightFill has && not (Flag.present Flag.heightBetween has) then
310 else if Flag.present Flag.centerY has then
314 else if Flag.present Flag.centerY has then
312 [ Html.Attributes.class
316 [ Html.Attributes.class
@@ -319,6 +323,7 @@ finalizeNode has node attributes children embedMode parentContext =
322 else if Flag.present Flag.alignBottom has then
327 else if Flag.present Flag.alignBottom has then
324 [ Html.Attributes.class
329 [ Html.Attributes.class
@@ -331,6 +336,7 @@ finalizeNode has node attributes children embedMode parentContext =
@@ -349,6 +355,7 @@ embedWith static opts styles children =
349 |> toStyleSheet opts
355 |> toStyleSheet opts
351 :: children
357 :: children
354 |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
361 |> List.foldl reduceStyles ( Set.empty, [ renderFocusStyle opts.focus ] )
@@ -372,6 +379,7 @@ embedKeyed static opts styles children =
372 |> toStyleSheet opts
379 |> toStyleSheet opts
374 :: children
381 :: children
376 ( "dynamic-stylesheet"
384 ( "dynamic-stylesheet"
@@ -397,6 +405,7 @@ reduceStylesRecursive cache found styles =
398 if Set.member styleName cache then
406 if Set.member styleName cache then
399 reduceStylesRecursive cache found remaining
407 reduceStylesRecursive cache found remaining
401 reduceStylesRecursive (Set.insert styleName cache) (head :: found) remaining
410 reduceStylesRecursive (Set.insert styleName cache) (head :: found) remaining
@@ -409,6 +418,7 @@ reduceStyles style (( cache, existing ) as nevermind) =
410 if Set.member styleName cache then
419 if Set.member styleName cache then
411 nevermind
420 nevermind
413 ( Set.insert styleName cache
423 ( Set.insert styleName cache
414 , style :: existing
424 , style :: existing
@@ -434,6 +444,7 @@ reduceRecursiveCalcName found styles =
434 headOfList :: other :: remaining ->
444 headOfList :: other :: remaining ->
435 if headOfList /= other then
445 if headOfList /= other then
436 reduceRecursiveCalcName (headOfList :: found) (other :: remaining)
446 reduceRecursiveCalcName (headOfList :: found) (other :: remaining)
438 reduceRecursiveCalcName found (other :: remaining)
449 reduceRecursiveCalcName found (other :: remaining)
@@ -450,6 +461,7 @@ reduceRecursive found styles =
450 ( headOfListName, headOfList ) :: ( otherName, other ) :: remaining ->
461 ( headOfListName, headOfList ) :: ( otherName, other ) :: remaining ->
451 if headOfListName /= otherName then
462 if headOfListName /= otherName then
452 reduceRecursive (headOfList :: found) (( otherName, other ) :: remaining)
463 reduceRecursive (headOfList :: found) (( otherName, other ) :: remaining)
454 reduceRecursive found (( otherName, other ) :: remaining)
466 reduceRecursive found (( otherName, other ) :: remaining)
@@ -674,6 +686,7 @@ skippable flag style =
678 case style of
691 case style of
679 FontSize i ->
692 FontSize i ->
@@ -719,6 +732,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
719 Class flag exactClassName ->
732 Class flag exactClassName ->
720 if Flag.present flag has then
733 if Flag.present flag has then
721 gatherAttrRecursive classes node has transform styles attrs children remaining
734 gatherAttrRecursive classes node has transform styles attrs children remaining
723 gatherAttrRecursive (exactClassName ++ " " ++ classes) node (Flag.add flag has) transform styles attrs children remaining
737 gatherAttrRecursive (exactClassName ++ " " ++ classes) node (Flag.add flag has) transform styles attrs children remaining
@@ -728,6 +742,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
728 StyleClass flag style ->
742 StyleClass flag style ->
729 if Flag.present flag has then
743 if Flag.present flag has then
730 gatherAttrRecursive classes node has transform styles attrs children remaining
744 gatherAttrRecursive classes node has transform styles attrs children remaining
731 else if skippable flag style then
746 else if skippable flag style then
732 gatherAttrRecursive (getStyleName style ++ " " ++ classes)
747 gatherAttrRecursive (getStyleName style ++ " " ++ classes)
@@ -737,6 +752,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
739 remaining
754 remaining
741 gatherAttrRecursive (getStyleName style ++ " " ++ classes)
757 gatherAttrRecursive (getStyleName style ++ " " ++ classes)
@@ -760,6 +776,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
760 Width width ->
776 Width width ->
761 if Flag.present Flag.width has then
777 if Flag.present Flag.width has then
762 gatherAttrRecursive classes node has transform styles attrs children remaining
778 gatherAttrRecursive classes node has transform styles attrs children remaining
764 case width of
781 case width of
@@ -792,6 +809,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
794 remaining
811 remaining
796 gatherAttrRecursive (classes ++ " " ++ Internal.Style.classes.widthFillPortion ++ " width-fill-" ++ String.fromInt portion)
814 gatherAttrRecursive (classes ++ " " ++ Internal.Style.classes.widthFillPortion ++ " width-fill-" ++ String.fromInt portion)
@@ -829,6 +847,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
829 Height height ->
847 Height height ->
830 if Flag.present Flag.height has then
848 if Flag.present Flag.height has then
831 gatherAttrRecursive classes node has transform styles attrs children remaining
849 gatherAttrRecursive classes node has transform styles attrs children remaining
833 case height of
852 case height of
@@ -868,6 +887,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
870 remaining
889 remaining
872 gatherAttrRecursive (classes ++ " " ++ (Internal.Style.classes.heightFillPortion ++ " height-fill-" ++ String.fromInt portion))
892 gatherAttrRecursive (classes ++ " " ++ (Internal.Style.classes.heightFillPortion ++ " height-fill-" ++ String.fromInt portion))
@@ -919,8 +939,10 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
919 Heading i ->
939 Heading i ->
920 if i <= 1 then
940 if i <= 1 then
921 gatherAttrRecursive classes (addNodeName "h1" node) has transform styles attrs children remaining
941 gatherAttrRecursive classes (addNodeName "h1" node) has transform styles attrs children remaining
922 else if i < 7 then
943 else if i < 7 then
923 gatherAttrRecursive classes (addNodeName ("h" ++ String.fromInt i) node) has transform styles attrs children remaining
944 gatherAttrRecursive classes (addNodeName ("h" ++ String.fromInt i) node) has transform styles attrs children remaining
925 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
947 gatherAttrRecursive classes (addNodeName "h6" node) has transform styles attrs children remaining
@@ -1037,6 +1059,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1037 newClasses =
1059 newClasses =
1038 if location == Behind then
1060 if location == Behind then
1039 Internal.Style.classes.hasBehind ++ " " ++ classes
1061 Internal.Style.classes.hasBehind ++ " " ++ classes
@@ -1045,6 +1068,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1045 AlignX x ->
1068 AlignX x ->
1046 if Flag.present Flag.xAlign has then
1069 if Flag.present Flag.xAlign has then
1047 gatherAttrRecursive classes node has transform styles attrs children remaining
1070 gatherAttrRecursive classes node has transform styles attrs children remaining
1049 gatherAttrRecursive (alignXName x ++ " " ++ classes)
1073 gatherAttrRecursive (alignXName x ++ " " ++ classes)
@@ -1071,6 +1095,7 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
1071 AlignY y ->
1095 AlignY y ->
1072 if Flag.present Flag.yAlign has then
1096 if Flag.present Flag.yAlign has then
1073 gatherAttrRecursive classes node has transform styles attrs children remaining
1097 gatherAttrRecursive classes node has transform styles attrs children remaining
1075 gatherAttrRecursive (alignYName y ++ " " ++ classes)
1100 gatherAttrRecursive (alignYName y ++ " " ++ classes)
@@ -1114,6 +1139,7 @@ renderWidth w =
1114 , Internal.Style.classes.widthFill
1139 , Internal.Style.classes.widthFill
1118 ( Flag.add Flag.widthFill Flag.none
1144 ( Flag.add Flag.widthFill Flag.none
1119 , Internal.Style.classes.widthFillPortion ++ " width-fill-" ++ String.fromInt portion
1145 , Internal.Style.classes.widthFillPortion ++ " width-fill-" ++ String.fromInt portion
@@ -1195,6 +1221,7 @@ renderHeight h =
1195 , Internal.Style.classes.heightFill
1221 , Internal.Style.classes.heightFill
1199 ( Flag.add Flag.heightFill Flag.none
1226 ( Flag.add Flag.heightFill Flag.none
1200 , Internal.Style.classes.heightFillPortion ++ " height-fill-" ++ String.fromInt portion
1227 , Internal.Style.classes.heightFillPortion ++ " height-fill-" ++ String.fromInt portion
@@ -1323,6 +1350,7 @@ createElement context children rendered =
1323 ( html context :: htmls
1350 ( html context :: htmls
1324 , existingStyles
1351 , existingStyles
1327 ( html context :: htmls
1355 ( html context :: htmls
1328 , existingStyles
1356 , existingStyles
@@ -1333,13 +1361,16 @@ createElement context children rendered =
1333 ( styled.html NoStyleSheet context :: htmls
1361 ( styled.html NoStyleSheet context :: htmls
1334 , if List.isEmpty existingStyles then
1362 , if List.isEmpty existingStyles then
1335 styled.styles
1363 styled.styles
1337 styled.styles ++ existingStyles
1366 styled.styles ++ existingStyles
1340 ( styled.html NoStyleSheet context :: htmls
1370 ( styled.html NoStyleSheet context :: htmls
1341 , if List.isEmpty existingStyles then
1371 , if List.isEmpty existingStyles then
1342 styled.styles
1372 styled.styles
1344 styled.styles ++ existingStyles
1375 styled.styles ++ existingStyles
@@ -1361,16 +1392,19 @@ createElement context children rendered =
1361 ( VirtualDom.text
1392 ( VirtualDom.text
1362 (if context == asParagraph then
1393 (if context == asParagraph then
1363 str ++ " "
1394 str ++ " "
1367 :: htmls
1399 :: htmls
1368 , existingStyles
1400 , existingStyles
1371 ( textElement
1404 ( textElement
1372 (if context == asParagraph then
1405 (if context == asParagraph then
1373 str ++ " "
1406 str ++ " "
@@ -1388,6 +1422,7 @@ createElement context children rendered =
1388 ( ( key, html context ) :: htmls
1422 ( ( key, html context ) :: htmls
1389 , existingStyles
1423 , existingStyles
1392 ( ( key, html context ) :: htmls
1427 ( ( key, html context ) :: htmls
1393 , existingStyles
1428 , existingStyles
@@ -1399,13 +1434,16 @@ createElement context children rendered =
1399 :: htmls
1434 :: htmls
1400 , if List.isEmpty existingStyles then
1435 , if List.isEmpty existingStyles then
1401 styled.styles
1436 styled.styles
1403 styled.styles ++ existingStyles
1439 styled.styles ++ existingStyles
1406 ( ( key, styled.html NoStyleSheet context ) :: htmls
1443 ( ( key, styled.html NoStyleSheet context ) :: htmls
1407 , if List.isEmpty existingStyles then
1444 , if List.isEmpty existingStyles then
1408 styled.styles
1445 styled.styles
1410 styled.styles ++ existingStyles
1448 styled.styles ++ existingStyles
@@ -1424,6 +1462,7 @@ createElement context children rendered =
1424 , VirtualDom.text
1462 , VirtualDom.text
1425 (if context == asParagraph then
1463 (if context == asParagraph then
1426 str ++ " "
1464 str ++ " "
@@ -1431,11 +1470,13 @@ createElement context children rendered =
1431 :: htmls
1470 :: htmls
1432 , existingStyles
1471 , existingStyles
1436 , textElement
1476 , textElement
1437 (if context == asParagraph then
1477 (if context == asParagraph then
1438 str ++ " "
1478 str ++ " "
@@ -1455,6 +1496,7 @@ createElement context children rendered =
1455 newStyles =
1496 newStyles =
1456 if List.isEmpty styles then
1497 if List.isEmpty styles then
1457 rendered.styles
1498 rendered.styles
1459 rendered.styles ++ styles
1501 rendered.styles ++ styles
@@ -1482,6 +1524,7 @@ createElement context children rendered =
1482 newStyles =
1524 newStyles =
1483 if List.isEmpty styles then
1525 if List.isEmpty styles then
1484 rendered.styles
1526 rendered.styles
1486 rendered.styles ++ styles
1529 rendered.styles ++ styles
@@ -1520,6 +1563,7 @@ staticRoot =
1520addWhen ifThis x to =
1563addWhen ifThis x to =
1521 if ifThis then
1564 if ifThis then
@@ -1550,18 +1594,21 @@ filter attrs =
1550 Width width ->
1594 Width width ->
1551 if Set.member "width" has then
1595 if Set.member "width" has then
1552 ( found, has )
1596 ( found, has )
1554 ( x :: found, Set.insert "width" has )
1599 ( x :: found, Set.insert "width" has )
1556 Height height ->
1601 Height height ->
1557 if Set.member "height" has then
1602 if Set.member "height" has then
1558 ( found, has )
1603 ( found, has )
1560 ( x :: found, Set.insert "height" has )
1606 ( x :: found, Set.insert "height" has )
1562 Describe description ->
1608 Describe description ->
1563 if Set.member "described" has then
1609 if Set.member "described" has then
1564 ( found, has )
1610 ( found, has )
1566 ( x :: found, Set.insert "described" has )
1613 ( x :: found, Set.insert "described" has )
@@ -1571,18 +1618,21 @@ filter attrs =
1571 AlignX _ ->
1618 AlignX _ ->
1572 if Set.member "align-x" has then
1619 if Set.member "align-x" has then
1573 ( found, has )
1620 ( found, has )
1575 ( x :: found, Set.insert "align-x" has )
1623 ( x :: found, Set.insert "align-x" has )
1577 AlignY _ ->
1625 AlignY _ ->
1578 if Set.member "align-y" has then
1626 if Set.member "align-y" has then
1579 ( found, has )
1627 ( found, has )
1581 ( x :: found, Set.insert "align-y" has )
1630 ( x :: found, Set.insert "align-y" has )
1583 TransformComponent _ _ ->
1632 TransformComponent _ _ ->
1584 if Set.member "transform" has then
1633 if Set.member "transform" has then
1585 ( found, has )
1634 ( found, has )
1587 ( x :: found, Set.insert "transform" has )
1637 ( x :: found, Set.insert "transform" has )
@@ -1598,6 +1648,7 @@ get attrs isAttr =
1598 (\x found ->
1648 (\x found ->
1599 if isAttr x then
1649 if isAttr x then
1600 x :: found
1650 x :: found
@@ -2030,6 +2081,7 @@ toStyleSheetString options stylesheet =
2030 renderProps force (Property key val) existing =
2081 renderProps force (Property key val) existing =
2031 if force then
2082 if force then
2032 existing ++ "\n " ++ key ++ ": " ++ val ++ " !important;"
2083 existing ++ "\n " ++ key ++ ": " ++ val ++ " !important;"
2034 existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
2086 existing ++ "\n " ++ key ++ ": " ++ val ++ ";"
@@ -2519,6 +2571,7 @@ formatBoxShadow shadow =
2519 List.filterMap identity
2571 List.filterMap identity
2520 [ if shadow.inset then
2572 [ if shadow.inset then
2521 Just "inset"
2573 Just "inset"
2524 , Just <| String.fromFloat (Tuple.first shadow.offset) ++ "px"
2577 , Just <| String.fromFloat (Tuple.first shadow.offset) ++ "px"
@@ -2533,6 +2586,7 @@ boxShadowName shadow =
2533 String.concat <|
2586 String.concat <|
2534 [ if shadow.inset then
2587 [ if shadow.inset then
2535 "box-inset"
2588 "box-inset"
2538 , String.fromFloat (Tuple.first shadow.offset) ++ "px"
2592 , String.fromFloat (Tuple.first shadow.offset) ++ "px"