-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Q: Exposing props to allow for easier UI abstraction #348
Labels
Comments
I'm a big fan of having a utility that behaves similarly to interface ButtonProps {
children: React.ReactNode;
}
const Button = styled<ButtonProps>(x.button, {
type: 'button',
color: 'white',
transition: true
bg: { _: 'emerald-500', hover: 'emerald-800' }
})``;
const DangerButton = styled<ButtonProps>(Button, {
bg: { _: 'red-500', hover: 'red-800' }
})``; ps.: You can already use this pattern with |
@StuartMorris0 maybe the approach in #224 could help you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
💬 Questions and Help
Firstly, the project looks awesome, having come from a heavily
styled-components
andstyled-system
background.My first question, is around how you might expose props for creating UI components. Often with projects, we tend to abstract the UI components such as Button, Input and so on, into more reusable components with strict Typescript interfaces.
In essence, we would take something like this....
Into it's own Button component and expose props such as
variant
which may then further style the component.This removes the requirement to always pass a bunch of reused props every time the primary button is needed. It also removes the
@xstyled...
calls from all pages and into less components, should the need to change arise.Previously with
styled-system
we used to generate/build prop types (interfaces) so that we could further expose those props should we wish. For the above example, we might want to exposebg
but everything else be behind the scenes. What would be the recommended approach for this?Furthermore, is there any documentation around creating variants? I read that some of the variants part was deprecated as it was confusing. But interested to learn more around what approach might be best. In the above example, just creating variants for buttons that are predefined by the actual
Button
component, rather than exposingx.button
everywhere.Thanks!
The text was updated successfully, but these errors were encountered: