Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style Protocol Redux: Introducing a reimagined Style protocol for generating custom CSS classes #222

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

JPToroDev
Copy link
Collaborator

@JPToroDev JPToroDev commented Jan 4, 2025

This implementation draws inspiration from SwiftUI's ShapeStyle, offering a declarative approach to generating custom CSS classes:

struct MyStyle: Style {
   func style(content: StyledHTML, environment: EnvironmentConditions) -> StyledHTML {
       if environment.orientation == .portrait {
           content
               .foregroundStyle(.red)
       } else {
           content
               .foregroundStyle(.blue)
       }
   }
}

Styles can be applied using the new style() modifier:

Text("My Dynamic Text")
   .style(MyTestStyle())

I'm submitting this alongside my other changes to ensure we have a complete view of all remaining work for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant