styled-components / vue-styled-components

Visual primitives for the component age. A simple port for Vue of styled-components 💅
MIT License
1.39k stars 99 forks source link

Can't seem to reference other components in SASS? #131

Closed IntusFacultas closed 3 years ago

IntusFacultas commented 3 years ago

Hi there, I was wondering if support for this feature in React styled-components will be implemented soon. In particular:

export const StyledButton = styled('button', props)`
  /** some styling here */
`;

export const ButtonGroup = styled.div`
  display: flex;
  ${StyledButton} + ${StyledButton} {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin-left: -2px;
  }
`;

Currently, doing this results in the following CSS being produced after compile for ButtonGroup:

    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    ): ;
    return resolvedAttrs: ;

which isn't valid. I know I can technically do

export const ButtonGroup = styled.div`
  display: flex;
  button + button {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-left: -2px;
  }
`;

But ideally I'd like to use the components so that the rendered css references a css rule both by element and the compiled hashed class name.

IntusFacultas commented 3 years ago

Hi, I've realized this is a clone of #97 so I'm going to close this.