Skip to content

Commit

Permalink
Add gridCellRows modifier. (#197)
Browse files Browse the repository at this point in the history
Part of #51.
  • Loading branch information
jverkoey authored Sep 15, 2024
1 parent 0452b87 commit 40c2869
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Tailwind utility | Slipstream modifier
[Grid Template Columns](https://tailwindcss.com/docs/grid-template-columns) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51)
[Grid Column Start / End](https://tailwindcss.com/docs/grid-column) | ``View/gridCellColumns(_:condition:)``, ``View/gridCellColumns(_:condition:)-2tedw``
[Grid Template Rows](https://tailwindcss.com/docs/grid-template-rows) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51)
[Grid Row Start / End](https://tailwindcss.com/docs/grid-row) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51)
[Grid Row Start / End](https://tailwindcss.com/docs/grid-row) | ``View/gridCellRows(_:condition:)``, ``View/gridCellRows(_:condition:)-75orh``
[Grid Auto Flow](https://tailwindcss.com/docs/grid-auto-flow) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51)
[Grid Auto Columns](https://tailwindcss.com/docs/grid-auto-columns) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51)
[Grid Auto Rows](https://tailwindcss.com/docs/grid-auto-rows) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51)
Expand Down
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``
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
)
)
}
}
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>"#)
}
}

0 comments on commit 40c2869

Please sign in to comment.