diff --git a/Sources/Slipstream/Documentation.docc/Guides/SlipstreamForTailwindCSSDevelopers.md b/Sources/Slipstream/Documentation.docc/Guides/SlipstreamForTailwindCSSDevelopers.md index 6088ce3..e2806f5 100644 --- a/Sources/Slipstream/Documentation.docc/Guides/SlipstreamForTailwindCSSDevelopers.md +++ b/Sources/Slipstream/Documentation.docc/Guides/SlipstreamForTailwindCSSDevelopers.md @@ -185,7 +185,7 @@ Tailwind utility | Slipstream modifier [Drop Shadow](https://tailwindcss.com/docs/drop-shadow) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51) [Grayscale](https://tailwindcss.com/docs/grayscale) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51) [Hue Rotate](https://tailwindcss.com/docs/hue-rotate) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51) -[Invert](https://tailwindcss.com/docs/invert) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51) +[Invert](https://tailwindcss.com/docs/invert) | ``View/colorInvert(condition:)`` [Saturate](https://tailwindcss.com/docs/saturate) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51) [Sepia](https://tailwindcss.com/docs/sepia) | [Not implemented yet](https://github.com/jverkoey/slipstream/issues/51) [Backdrop Blur](https://tailwindcss.com/docs/backdrop-blur) | ``View/background(_:condition:)-89gyc`` diff --git a/Sources/Slipstream/Documentation.docc/Guides/SlipstreamforSwiftUIDevelopers.md b/Sources/Slipstream/Documentation.docc/Guides/SlipstreamforSwiftUIDevelopers.md index 0ef7aed..0b22ae4 100644 --- a/Sources/Slipstream/Documentation.docc/Guides/SlipstreamforSwiftUIDevelopers.md +++ b/Sources/Slipstream/Documentation.docc/Guides/SlipstreamforSwiftUIDevelopers.md @@ -105,6 +105,19 @@ struct MyView: View { } ``` +## Filters + +SwiftUI and Slipstream both provide the ability to invert colors. + +### Offset + +```swift +var body: some View { + Text("Inverted text") + .colorInvert() +} +``` + ## Layout SwiftUI and Slipstream both provide the ability to affect the layout of views. diff --git a/Sources/Slipstream/Documentation.docc/TailwindCSS/TailwindCSS-Utilities.md b/Sources/Slipstream/Documentation.docc/TailwindCSS/TailwindCSS-Utilities.md index 834c101..675f0d1 100644 --- a/Sources/Slipstream/Documentation.docc/TailwindCSS/TailwindCSS-Utilities.md +++ b/Sources/Slipstream/Documentation.docc/TailwindCSS/TailwindCSS-Utilities.md @@ -60,6 +60,7 @@ Slipstream implementations of Tailwind CSS's utility classes. ### Filters - +- ``View/colorInvert(condition:)`` ### Transitions and animations diff --git a/Sources/Slipstream/TailwindCSS/Filters/View+colorInvert.swift b/Sources/Slipstream/TailwindCSS/Filters/View+colorInvert.swift new file mode 100644 index 0000000..4bb1503 --- /dev/null +++ b/Sources/Slipstream/TailwindCSS/Filters/View+colorInvert.swift @@ -0,0 +1,11 @@ +extension View { + /// Inverts all of the colors in a view so that each color displays as its complementary color. + /// + /// For example, blue converts to yellow, and white converts to black. + /// + /// - SeeAlso: Tailwind CSS' [invert](https://tailwindcss.com/docs/invert) documentation. + @available(iOS 17.0, macOS 14.0, *) + public func colorInvert(condition: Condition? = nil) -> some View { + return modifier(TailwindClassModifier(add: "invert", condition: condition)) + } +} diff --git a/Tests/SlipstreamTests/TailwindCSS/Filters/ColorInvertTests.swift b/Tests/SlipstreamTests/TailwindCSS/Filters/ColorInvertTests.swift new file mode 100644 index 0000000..15789c0 --- /dev/null +++ b/Tests/SlipstreamTests/TailwindCSS/Filters/ColorInvertTests.swift @@ -0,0 +1,8 @@ +import Testing +import Slipstream + +struct ColorInvertTests { + @Test func applies() throws { + try #expect(renderHTML(Div {}.colorInvert()) == #"
"#) + } +}