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
docs(variants): Clearly explain variant notation #1494
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/systemui/theme-ui/fpgy38nht |
Looks great! I'm not sure how useful any of this would be useful for documentation but I'd like to clarify - styles are applied and overridden in this order:
const CustomButton = ({ children, className }) => (
<Button
className={className}
variant="primary"
sx={{ borderColor: "purple" }}
>
{children} (but custom)
</Button>
)
// sx is converted to className
<CustomButton sx={{p: 5}}>Big Button</ CustomButton> Finally, within the I'm also wondering if there are any identified anti-patterns - In the example above radical departures like adding link styles to a button don't seem to work, and I've also found that there is always a balance to strike as far as what belongs isolated in a theme file vs declared where it is used or where some defaults are applied. Another thought i'd be willing to take on - it would be nice to add doc comments for default theme keys to the custom components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement, folks.
I'm approving both the current addition and any changes / more content based on Erik's comment.
Thanks @erikdstock! I added a section about |
Variants inside the `styles` object, while usable through the same mechanisms as regular variants, | ||
are also used for other Theme UI APIs. | ||
|
||
- The entire [`styles` object](/theme-spec#styles) can style child HTML elements or MDX content, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lachlanjc, I'm not sure if this bullet doesn't "conflict" with the last one.
BaseStyles is used to style embedded HTML content, but MDX is styled with Themed
(i.e. ##
maps to Themed.h2
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Using Next.js that's not the case (MDX is treated the same as HTML children, so you need BaseStyles), so I've never experienced that. I guess we can just remove the MDX reference for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MDX is treated the same as HTML children
That MDXProvider rendered by our ThemeProvider doesn't work in Next? (We pass an object with components through context)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope: #1130
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't a new version of MDX packages specified in resolutions solve that issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps! Forgot about that & have never tried it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can just remove the MDX reference for now?
Yeah, this sound like a good idea :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks yall, this is great! |
At @erikdstock’s excellent suggestion, clarifying how the notation for accessing variants works.