-
Notifications
You must be signed in to change notification settings - Fork 672
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
fix: Allow overriding Paragraph margins via theme #1775
fix: Allow overriding Paragraph margins via theme #1775
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/systemui/theme-ui/47JD5Y5pEcvNmyvyW9autuBcwSij |
Thanks for the PR @bernharduw! |
Doesn't this break the scenario when users depend on margin being set to 0 by default? (See snapshot in the diff.) |
@@ -1097,7 +1097,6 @@ exports[`Paragraph renders 1`] = ` | |||
font-family: body; |
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.
The snapshot still has margin: 0
in it, but at the very beginning.
I think that way the effective margin on paragraphs is still 0, but can be overridden by any styling method, regardless of theme, styled-system-style or direct sx overrides. The tests still all pass, only the duplicate margin: 0 is reduced to a single occurrence. The margin:0 in line 1095 comes from the Box which sets margin:0 as a default, so we should be safe here. |
Thanks! Yup, I can see that first |
🚀 PR was released in |
WD for removing duplication. I, however, struggle to understand the purpose of Box's default margin: 0... which causes troubles when parent intends to set inner Boxes' margin via |
@sergeylukin I believe it's just a reset, since elements like form fields & lists often have margin applied by the default browser stylesheet. Happy to accept better solutions to that problem, though! |
This fixes #1774 - I found that margin: 0 is set by default (coming from Box maybe? Not 100% sure).
So if we don't set the margin for Paragraph manually, the specificity issues disappear.
I also added two tests using a theme override - the other two cases are already covered by the existing tests.
Version
Published prerelease version:
v0.9.1-develop.0
Changelog
🐛 Bug Fix
@theme-ui/components
Authors: 1