-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of #51.
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...Documentation.docc/TailwindCSS/FlexboxAndGrid/FlexboxAndGrid-GridRowStartEnd.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Grid column start / end | ||
|
||
Utilities for controlling how views are sized and placed across grid columns. | ||
|
||
## Topics | ||
|
||
### Modifiers | ||
|
||
- ``View/gridCellRows(_:condition:)`` | ||
- ``View/gridCellRows(_:condition:)-75orh`` | ||
|
||
### Supporting types | ||
|
||
- ``GridSpan`` |
27 changes: 27 additions & 0 deletions
27
Sources/Slipstream/TailwindCSS/FlexboxAndGrid/View+gridCellRows.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extension View { | ||
/// Tells a view that acts as a cell in a grid to span the specified number of rows. | ||
/// | ||
/// - SeeAlso: Tailwind CSS' [grid-row](https://tailwindcss.com/docs/grid-row) documentation. | ||
@available(iOS 17.0, macOS 14.0, *) | ||
public func gridCellRows(_ count: Int, condition: Condition? = nil) -> some View { | ||
return modifier( | ||
TailwindClassModifier( | ||
add: "row-span-\(count)", | ||
condition: condition | ||
) | ||
) | ||
} | ||
|
||
/// Tells a view that acts as a cell in a grid to span the specified number of rows. | ||
/// | ||
/// - SeeAlso: Tailwind CSS' [grid-row](https://tailwindcss.com/docs/grid-row) documentation. | ||
@available(iOS 17.0, macOS 14.0, *) | ||
public func gridCellRows(_ span: GridSpan, condition: Condition? = nil) -> some View { | ||
return modifier( | ||
TailwindClassModifier( | ||
add: "row-span-" + span.rawValue, | ||
condition: condition | ||
) | ||
) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Tests/SlipstreamTests/TailwindCSS/FlexboxAndGrid/GridCellRowsTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Testing | ||
import Slipstream | ||
|
||
struct GridCellRowsTests { | ||
@Test func rows() throws { | ||
try #expect(renderHTML(Div {}.gridCellRows(1)) == #"<div class="row-span-1"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellRows(2)) == #"<div class="row-span-2"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellRows(3)) == #"<div class="row-span-3"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellRows(4)) == #"<div class="row-span-4"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellRows(5)) == #"<div class="row-span-5"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellRows(6)) == #"<div class="row-span-6"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellRows(.full)) == #"<div class="row-span-full"></div>"#) | ||
} | ||
} |