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

remove property when it is used as variant #99

Closed
seeden opened this issue Feb 15, 2020 · 2 comments
Closed

remove property when it is used as variant #99

seeden opened this issue Feb 15, 2020 · 2 comments

Comments

@seeden
Copy link

seeden commented Feb 15, 2020

This feature is little bit connected with #69

Here is small example

const Test = styled(Box)`
  ${variant({
      key: 'container',
      default: 'md',
      prop: 'size',
  }))
`;

Theme

  ....
  sizes:  {
    sm: 540,
    md: 720,
    lg: 960,
    xl: 1140,
    xs: 30,
  },
  container: {
   sm: css`
    width: 320px;
  `
  }
  ...

When you render It will render with size property but also it will try to use size property inside Box and it will create another css and override width 320px with width: 540 and height 540px as well.

Can you remove property when it is used as variant and do not forward it to extended component?

@seeden
Copy link
Author

seeden commented Feb 15, 2020

maybe it is related to styled-components/styled-components#3006

@gregberge
Copy link
Collaborator

forwardedProps are the business of styled-components, not xstyled.

For size you have a solution, create your own Box component without size: https://xstyled.dev/docs/style-using-props/#avoid-undesired-props

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

No branches or pull requests

2 participants