diff --git a/Sources/CSS/Properties/Margin.swift b/Sources/CSS/Properties/Margin.swift index 1e7f17c..e14a7b0 100644 --- a/Sources/CSS/Properties/Margin.swift +++ b/Sources/CSS/Properties/Margin.swift @@ -56,27 +56,27 @@ public struct Margin: Property { /// Creates a `margin` declaration. /// Used by `StylesheetRenderer` when emitting CSS. /// - Parameters: - /// - horizontal: The horizontal value. /// - vertical: The vertical value. + /// - horizontal: The horizontal value. public init( - horizontal: Value, - vertical: Value + vertical: Value, + horizontal: Value ) { self.name = "margin" - self.value = horizontal.rawValue + " " + vertical.rawValue + self.value = vertical.rawValue + " " + horizontal.rawValue self.isImportant = false } /// Creates a `margin` declaration. /// Used by `StylesheetRenderer` when emitting CSS. /// - Parameters: - /// - horizontal: The horizontal value. /// - vertical: The vertical value. + /// - horizontal: The horizontal value. public init( - horizontal: UnitRepresentable = 0, - vertical: UnitRepresentable = 0 + vertical: UnitRepresentable = 0, + horizontal: UnitRepresentable = 0 ) { - self.init(horizontal: .length(horizontal), vertical: .length(vertical)) + self.init(vertical: .length(vertical), horizontal: .length(horizontal)) } /// Creates a `margin` declaration. diff --git a/Sources/CSS/Properties/Padding.swift b/Sources/CSS/Properties/Padding.swift index 3309a9b..faf6a24 100644 --- a/Sources/CSS/Properties/Padding.swift +++ b/Sources/CSS/Properties/Padding.swift @@ -52,27 +52,27 @@ public struct Padding: Property { /// Creates a `padding` declaration. /// Used by `StylesheetRenderer` when emitting CSS. /// - Parameters: - /// - horizontal: The horizontal value. /// - vertical: The vertical value. + /// - horizontal: The horizontal value. public init( - horizontal: Value, - vertical: Value + vertical: Value, + horizontal: Value ) { self.name = "padding" - self.value = horizontal.rawValue + " " + vertical.rawValue + self.value = vertical.rawValue + " " + horizontal.rawValue self.isImportant = false } /// Creates a `padding` declaration. /// Used by `StylesheetRenderer` when emitting CSS. /// - Parameters: - /// - horizontal: The horizontal value. /// - vertical: The vertical value. + /// - horizontal: The horizontal value. public init( - horizontal: UnitRepresentable = 0, - vertical: UnitRepresentable = 0 + vertical: UnitRepresentable = 0, + horizontal: UnitRepresentable = 0 ) { - self.init(horizontal: .length(horizontal), vertical: .length(vertical)) + self.init(vertical: .length(vertical), horizontal: .length(horizontal)) } /// Creates a `padding` declaration. diff --git a/Tests/CSSTests/Properties/MarginTestSuite.swift b/Tests/CSSTests/Properties/MarginTestSuite.swift index 2bd3ed1..3ae7489 100644 --- a/Tests/CSSTests/Properties/MarginTestSuite.swift +++ b/Tests/CSSTests/Properties/MarginTestSuite.swift @@ -39,7 +39,7 @@ struct MarginTests { @Test func values() { let single = Margin(12.px) - let axis = Margin(horizontal: 8.px, vertical: 16.px) + let axis = Margin(vertical: 8.px, horizontal: 16.px) let sides = Margin(top: 1.px, right: 2.px, bottom: 3.px, left: 4.px) let auto = Margin(.auto) let initial = Margin(.initial) diff --git a/Tests/CSSTests/Properties/PaddingTestSuite.swift b/Tests/CSSTests/Properties/PaddingTestSuite.swift index 2992ab0..19b8988 100644 --- a/Tests/CSSTests/Properties/PaddingTestSuite.swift +++ b/Tests/CSSTests/Properties/PaddingTestSuite.swift @@ -39,7 +39,7 @@ struct PaddingTests { @Test func values() { let single = Padding(12.px) - let axis = Padding(horizontal: 8.px, vertical: 16.px) + let axis = Padding(vertical: 8.px, horizontal: 16.px) let sides = Padding(top: 1.px, right: 2.px, bottom: 3.px, left: 4.px) let inherit = Padding(.inherit) diff --git a/Tests/CSSTests/SelectorTests.swift b/Tests/CSSTests/SelectorTests.swift index 5115928..e76cad4 100644 --- a/Tests/CSSTests/SelectorTests.swift +++ b/Tests/CSSTests/SelectorTests.swift @@ -55,8 +55,8 @@ struct SelectorTests { AllElements { Padding(0) Padding(8.rem) - Padding(horizontal: 8.px) - Padding(horizontal: .length(0), vertical: .inherit) + Padding(vertical: 8.px) + Padding(vertical: .length(0), horizontal: .inherit) } } } diff --git a/Tests/CSSTests/StylesheetRendererTests.swift b/Tests/CSSTests/StylesheetRendererTests.swift index 467a69b..910a22d 100644 --- a/Tests/CSSTests/StylesheetRendererTests.swift +++ b/Tests/CSSTests/StylesheetRendererTests.swift @@ -16,7 +16,7 @@ struct StylesheetRendererTests { let css = Stylesheet { Media { Class("badge") { - Padding(horizontal: 6.px, vertical: 2.px) + Padding(vertical: 6.px, horizontal: 2.px) BackgroundColor(.red) } } diff --git a/Tests/CSSTests/SwiftCSSTests.swift b/Tests/CSSTests/SwiftCSSTests.swift index 131f429..63926cb 100644 --- a/Tests/CSSTests/SwiftCSSTests.swift +++ b/Tests/CSSTests/SwiftCSSTests.swift @@ -17,14 +17,14 @@ struct SwiftCssTests { Charset("UTF-8") Media { Root { - Margin(horizontal: 8.5.px, vertical: 8.px) - Padding(horizontal: 8.px, vertical: 8.px) + Margin(vertical: 8.5.px, horizontal: 8.px) + Padding(vertical: 8.5.px, horizontal: 8.px) } } } #expect( StylesheetRenderer(minify: true, indent: 2).render(css) - == #"@charset "UTF-8";:root{margin:8.5px 8px;padding:8px 8px}"# + == #"@charset "UTF-8";:root{margin:8.5px 8px;padding:8.5px 8px}"# ) } @@ -34,8 +34,8 @@ struct SwiftCssTests { Charset("UTF-8") Media { Root { - Margin(horizontal: 8.5.px, vertical: 8.px) - Padding(horizontal: 8.px, vertical: 8.px) + Margin(vertical: 8.5.px, horizontal: 8.px) + Padding(vertical: 8.5.px, horizontal: 8.px) } } } @@ -45,7 +45,7 @@ struct SwiftCssTests { @charset "UTF-8"; :root { margin: 8.5px 8px; - padding: 8px 8px; + padding: 8.5px 8px; } """# ) @@ -58,8 +58,8 @@ struct SwiftCssTests { Media { Root { - Margin(horizontal: 8.5.px, vertical: 8.px) - Padding(horizontal: 8.px, vertical: 8.px) + Margin(vertical: 8.5.px, horizontal: 8.px) + Padding(vertical: 8.5.px, horizontal: 8.px) } } @@ -70,7 +70,7 @@ struct SwiftCssTests { } Media(.screen && .prefersColorScheme(.dark)) { Universal { - Margin(horizontal: 8.px, vertical: 8.px) + Margin(vertical: 8.5.px, horizontal: 8.px) } } @@ -86,7 +86,7 @@ struct SwiftCssTests { @charset "UTF-8"; :root { margin: 8.5px 8px; - padding: 8px 8px; + padding: 8.5px 8px; } @media screen and (min-width: 600px) { .button { @@ -95,7 +95,7 @@ struct SwiftCssTests { } @media screen and (prefers-color-scheme: dark) { * { - margin: 8px 8px; + margin: 8.5px 8px; } } @media screen and (display-mode: standalone) {