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

Extend variants while composing components #333

Closed
schonert opened this issue Feb 1, 2021 · 4 comments
Closed

Extend variants while composing components #333

schonert opened this issue Feb 1, 2021 · 4 comments
Labels
feature New feature

Comments

@schonert
Copy link

schonert commented Feb 1, 2021

Is your feature request related to a problem? Please describe.
Creating a base component library with the goal of being easily customisable and extendable. In this case i'd like the ability to extend the parent components variants rather then overwrite them.

Describe the solution you'd like
The component library exports a Button component handling size, type, disabled, icons etc. By importing and using this Button to compose your own button with custom styling - variants are not overwritten.

In the example below the entire primary and link types are overwritten in FancyButton

const StyledButton = styled("button", {
  variants: {
    type: {
      primary: {
        backgroundColor: "$accent",
        color: "#fff",
      },
      link: {
        backgroundColor: "transparent",
        color: "$accent",
      },
    },
  },
});

const FancyButton = styled(StyledButton, {
  variants: {
    type: {
      primary: {
        backgroundColor: "pink",
      },
    },
  },
});

export const Button = ({ type = "primary", ...rest }: ButtonProps) => (
  <FancyButton type={type} {...rest} />
);
@peduarte
Copy link
Contributor

peduarte commented Feb 1, 2021

@schonert thanks for this 💯 Something we've talked about. Will see if we can fit that in the next beta release.

/cc @jonathantneal

@peduarte peduarte added the feature New feature label Feb 1, 2021
@peduarte
Copy link
Contributor

peduarte commented Feb 1, 2021

@schonert This has been implemented in beta.

@LexSwed
Copy link

LexSwed commented Feb 1, 2021

omg this next release is nuts 🤯

@peduarte
Copy link
Contributor

peduarte commented Feb 12, 2021

We've published a pre-release of Stitches beta 🚀

Core:

npm install @stitches/[email protected]

React:

npm install @stitches/[email protected]

This issue should have been resolved in the beta version. We'd appreciate it if you could verify it.

⚠️ Please refer to this migration guide as there are some breaking changes.

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

No branches or pull requests

3 participants