styled-components and Glamorous support
See original GitHub issueFurther to this discussion https://github.com/styleguidist/react-styleguidist/issues/37
If you are using styled-components, you may have a component similar to:
import styled, { css } from "styled-components";
import PropTypes from "prop-types";
const Button = styled.a`
background: transparent;
color: white;
${({primary}) =>
!!primary &&
css`
background: white;
color: palevioletred;
`};
`;
Button.propTypes = {
primary: PropTypes.bool
};
export default Button;
or, with Glamorous:
import glamorous from "glamorous";
import PropTypes from "prop-types";
const Button = glamorous.button({
background: "transparent",
color: "white"
},
({ primary }) => (!!primary && {
background: "white",
color: "palevioletred"
})
);
Button.propTypes = {
primary: PropTypes.bool
};
This doesn’t import React, so afaik is why the react-docgen resolver does not pick it up as a valid component.
No suitable component definition found.
Is there an existing way to get this to work e.g. with a custom resolver? Or is a bugfix/new feature needed?
#195 looks like it resolves this, and is marked as closed as the feature in v3. I’ve installed react-docgen@3.0.0-beta11
but still get the issue with the above 2 examples.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:6
Top Results From Across the Web
Glamorous vs styled-components | What are the differences?
Glamorous is React component styling solved with an elegant (inspired) API, small footprint (<5kb gzipped), and great performance (via glamor). It has a...
Read more >glamorous - React component styling solved
Maintainable CSS with React ... Made with by PayPal and contributors.
Read more >Styling React Components Using glamorous - DigitalOcean
glamorous is a flavor of CSS-in-JS. In this post, you'll see how you can style your components with it.
Read more >Introducing glamorous - Kent C. Dodds
A styled-components and jsxstyle inspired solution for styling ⚛️ React Components from PayPal.
Read more >Why We Use Styled Components at Decisiv | by Alan B Smith
I'm not saying Styled Components is better than Radium, Aphrodite, Glamor, Glamorous, Emotion, or any of the other CSS-in-JS libraries.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
if anyone is interested this is what we came up with for css-literal-loader, but the syntax is the same for styled components or emotion, so this should work for them as well:
https://gist.github.com/jquense/c2a92f1c909552f295bb7953fcd2ce4d
I am seeing this issue as well using styled-components (through styled-system’s
system
function).