-
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
5 changed files
with
61 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
...umentation.docc/TailwindCSS/FlexboxAndGrid/FlexboxAndGrid-GridColumnStartEnd.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/gridCellColumns(_:condition:)`` | ||
- ``View/gridCellColumns(_:condition:)-2tedw`` | ||
|
||
### Supporting types | ||
|
||
- ``GridSpan`` |
27 changes: 27 additions & 0 deletions
27
Sources/Slipstream/TailwindCSS/FlexboxAndGrid/View+gridCellColumns.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 columns. | ||
/// | ||
/// - SeeAlso: Tailwind CSS' [grid-column](https://tailwindcss.com/docs/grid-column) documentation. | ||
@available(iOS 17.0, macOS 14.0, *) | ||
public func gridCellColumns(_ count: Int, condition: Condition? = nil) -> some View { | ||
return modifier( | ||
TailwindClassModifier( | ||
add: "col-span-\(count)", | ||
condition: condition | ||
) | ||
) | ||
} | ||
|
||
/// Tells a view that acts as a cell in a grid to span the specified number of columns. | ||
/// | ||
/// - SeeAlso: Tailwind CSS' [grid-column](https://tailwindcss.com/docs/grid-column) documentation. | ||
@available(iOS 17.0, macOS 14.0, *) | ||
public func gridCellColumns(_ span: GridSpan, condition: Condition? = nil) -> some View { | ||
return modifier( | ||
TailwindClassModifier( | ||
add: "col-span-" + span.rawValue, | ||
condition: condition | ||
) | ||
) | ||
} | ||
} |
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,5 @@ | ||
/// A generic representation of a span in a grid. | ||
@available(iOS 17.0, macOS 14.0, *) | ||
public enum GridSpan: String { | ||
case full | ||
} |
14 changes: 14 additions & 0 deletions
14
Tests/SlipstreamTests/TailwindCSS/FlexboxAndGrid/GridCellColumnsTests.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 GridCellColumnsTests { | ||
@Test func columns() throws { | ||
try #expect(renderHTML(Div {}.gridCellColumns(1)) == #"<div class="col-span-1"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellColumns(2)) == #"<div class="col-span-2"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellColumns(3)) == #"<div class="col-span-3"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellColumns(4)) == #"<div class="col-span-4"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellColumns(5)) == #"<div class="col-span-5"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellColumns(6)) == #"<div class="col-span-6"></div>"#) | ||
try #expect(renderHTML(Div {}.gridCellColumns(.full)) == #"<div class="col-span-full"></div>"#) | ||
} | ||
} |