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

fix: type support for props supplied in .attrs() #25

Merged
merged 5 commits into from
Oct 23, 2024

Conversation

sparten11740
Copy link
Contributor

@sparten11740 sparten11740 commented Oct 23, 2024

This makes properties passed into attrs() optional on the resulting component.

E.g. a component LinearGradient that requires the colors prop, can be wrapped as follows:

const DefaultGradient = styled(LinearGradient, { attrs: { colors: ['red', 'blue'] })()
// or
const ErrorGradient = styled(LinearGradient)().attrs({ colors: ['red', 'orange'] })

They won't require consumers to pass the required colors prop

@sparten11740 sparten11740 self-assigned this Oct 23, 2024
@sparten11740 sparten11740 force-pushed the sparten11740/feat/typesupport-for-attrs branch from 6bfa09e to 518db3a Compare October 23, 2024 11:24
Comment on lines -33 to -42
type ComponentFactory<P extends object, S extends object> = <SP extends object>(
componentStyle: ComponentStyle<P, SP, S>
) => StyledComponent<P & SP, S> | (() => StyledComponent<P, S>);

export interface StyledFunction{
<P extends object, S extends object>(
Comp: React.ComponentType<P>,
config?: Config<P>
): ComponentFactory<P, S>;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed these as they were unused

@sparten11740 sparten11740 changed the title feat: add type support for props supplied in .attrs() fix: type support for props supplied in .attrs() Oct 23, 2024
Copy link
Contributor

@headfire94 headfire94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK thanks

@sparten11740 sparten11740 merged commit fe53111 into master Oct 23, 2024
3 checks passed
@sparten11740 sparten11740 deleted the sparten11740/feat/typesupport-for-attrs branch October 23, 2024 11:34
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.

2 participants