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

Warn if user is using an attribute Modifier inside a ComponentStyle #7

Open
bitspittle opened this issue Jan 19, 2024 · 0 comments
Open
Labels
IDE: Action An IDE action (something a user might tie to a keyboard shortcut) IDE: Inspection Some information that should be surfaced to the user (tooltip, notification, lint warning)
Milestone

Comments

@bitspittle
Copy link
Contributor

Warn if a user is using an attribute modifer within a component style (and offer assistance to extract it to the extraModifiers parameter)

// Before
val SomeStyle by ComponentStyle.base {
   Modifier.id("id").size(...)
            ^^
            "id" is an attribute modifier and not valid inside a ComponentStyle, which can only reference style modifiers
}

// After refactoring
val SomeStyle by ComponentStyle.base(extraModifiers = { Modifier.id("id") }) {
   Modifier.size(...)
}

Also support alt base syntax:

// Before
val SomeStyle by ComponentStyle {
   base { Modifier.id("id") }
}

// After refactoring
val SomeStyle by ComponentStyle(extraModifiers = { Modifier.id("id") }) {
   base { Modifier.size(...) }
}

For attribute modifiers that AREN'T in the base block, do NOT offer to refactor. Just show the warning.

val SomeStyle by ComponentStyle {
   hover { Modifier.id("id").size(...) }
                    ^^
}
@bitspittle bitspittle added IDE: Action An IDE action (something a user might tie to a keyboard shortcut) IDE: Inspection Some information that should be surfaced to the user (tooltip, notification, lint warning) labels Jan 19, 2024
@bitspittle bitspittle added this to the 1.0 milestone Jan 19, 2024
@bitspittle bitspittle modified the milestones: 1.0, Next release Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE: Action An IDE action (something a user might tie to a keyboard shortcut) IDE: Inspection Some information that should be surfaced to the user (tooltip, notification, lint warning)
Projects
None yet
Development

No branches or pull requests

1 participant