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

TypeError when passing a style object with default variants or of type CSS #405

Closed
jorenrui opened this issue Feb 17, 2021 · 1 comment
Closed

Comments

@jorenrui
Copy link

Bug report

TypeError when passing a style object with default variants or of type CSS

Describe the bug

1. When a style object has a defaultVariants, it shows a type error.

const smallChipStyles = {
  display: "inline-block",
  padding: "8px",
  borderWidth: "1px",
  borderStyle: "solid",

  variants: {
    color: {
      blue: {
        color: "blue",
        borderColor: "blue"
      }
    }
  },
  // Adding default variants to a style object
  // shows a type error.
  // Remove this then the error goes away.
+  defaultVariants: {
+    color: 'blue',
+  },
};

image

2. Variants is lost when you use CSS for the style object's type

+ const bigChipStyles: CSS = {
  display: "inline-block",
  padding: "8px",
  borderWidth: "1px",
  borderStyle: "solid",

  variants: {
    color: {
      blue: {
        color: "blue",
        borderColor: "blue"
      }
    }
  },
  defaultVariants: {
    color: 'blue',
  },
};

image

image

To Reproduce

CodeSandbox: https://codesandbox.io/s/festive-bell-jn5de?file=/src/App.tsx

System information

  • OS: macOs
  • Version of Stitches: 0.1.0-canary.6
  • Version of Node.js: v14.15.4

Additional context

My use-case for this was using Radix then using the styles of an existing component.

Example:

export const StyledButton = styled('button', BUTTON_STYLES);

// Dialog.Trigger from Radix
export const StyledTrigger = styled(Dialog.Trigger, BUTTON_STYLES);

In this example, the Dialog's Trigger and the styled Button have the same styles.

@peduarte
Copy link
Contributor

Fixed in V1. Please refer to migration guide and changelog

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

No branches or pull requests

2 participants