-
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
49 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
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,23 @@ | ||
/// A representation of the CSS properties that should transition. | ||
public enum Transition: String { | ||
/// Transitions nothing. | ||
case none = "-none" | ||
|
||
/// Transitions all CSS properties that can be transformed. | ||
case all = "-all" | ||
|
||
/// Transitions color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, and backdrop-filter. | ||
case `default` = "" | ||
|
||
/// Transitions color, background-color, border-color, text-decoration-color, fill, and stroke. | ||
case colors = "-colors" | ||
|
||
/// Transitions opacity. | ||
case opacity = "-opacity" | ||
|
||
/// Transitions box-shadow. | ||
case shadow = "-shadow" | ||
|
||
/// Transitions transform. | ||
case transform = "-transform" | ||
} |
11 changes: 11 additions & 0 deletions
11
Sources/Slipstream/TailwindCSS/TransitionsAndAnimations/View+transition.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,11 @@ | ||
import Foundation | ||
|
||
extension View { | ||
/// Indicates which properties should transition when they change. | ||
/// | ||
/// - SeeAlso: Tailwind CSS' [transition](https://tailwindcss.com/docs/transition-property) documentation. | ||
@available(iOS 17.0, macOS 14.0, *) | ||
public func transition(_ transition: Transition, condition: Condition? = nil) -> some View { | ||
return modifier(TailwindClassModifier(add: "transition" + transition.rawValue, condition: condition)) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Tests/SlipstreamTests/TailwindCSS/TransitionsAndAnimations/TransitionTests.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 TransitionTests { | ||
@Test func properties() throws { | ||
try #expect(renderHTML(Div {}.transition(.none)) == #"<div class="transition-none"></div>"#) | ||
try #expect(renderHTML(Div {}.transition(.all)) == #"<div class="transition-all"></div>"#) | ||
try #expect(renderHTML(Div {}.transition(.default)) == #"<div class="transition"></div>"#) | ||
try #expect(renderHTML(Div {}.transition(.colors)) == #"<div class="transition-colors"></div>"#) | ||
try #expect(renderHTML(Div {}.transition(.opacity)) == #"<div class="transition-opacity"></div>"#) | ||
try #expect(renderHTML(Div {}.transition(.shadow)) == #"<div class="transition-shadow"></div>"#) | ||
try #expect(renderHTML(Div {}.transition(.transform)) == #"<div class="transition-transform"></div>"#) | ||
} | ||
} |