Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Sources/CSS/Properties/Margin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions Sources/CSS/Properties/Padding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Tests/CSSTests/Properties/MarginTestSuite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Tests/CSSTests/Properties/PaddingTestSuite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions Tests/CSSTests/SelectorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/CSSTests/StylesheetRendererTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
22 changes: 11 additions & 11 deletions Tests/CSSTests/SwiftCSSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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}"#
)
}

Expand All @@ -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)
}
}
}
Expand All @@ -45,7 +45,7 @@ struct SwiftCssTests {
@charset "UTF-8";
:root {
margin: 8.5px 8px;
padding: 8px 8px;
padding: 8.5px 8px;
}
"""#
)
Expand All @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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 {
Expand All @@ -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) {
Expand Down
Loading