-
Notifications
You must be signed in to change notification settings - Fork 671
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
Responsive values is variant styles override sx styles #720
Comments
Thanks! I'm not sure I understand the issue here. Would you mind creating a Code Sandbox to demonstrate what's happening? |
Pretty sure I’m having the same issue: My |
@lachlanjc if that's the same thing happening in the issue description, then yeah, that's a known issue without a clear solution, but I suspect the example above might be pointing to something else?? |
Yeah, it’s the same issue. Thanks for a better explanation @lachlanjc |
Just start using theme-ui and hit the same issue It seems related to the Box. The system props styles of In other words, e.g. whatever media queries generated in If I twist the code a bit as following, does it make sense? const aliases = {
bg: "backgroundColor",
m: "margin",
mt: "marginTop",
mr: "marginRight",
mb: "marginBottom",
ml: "marginLeft",
mx: "marginX",
my: "marginY",
p: "padding",
pt: "paddingTop",
pr: "paddingRight",
pb: "paddingBottom",
pl: "paddingLeft",
px: "paddingX",
py: "paddingY"
};
const keys = Object.keys;
const toString = Object.prototype.toString;
const isObject = arg => toString.call(arg) === "[object Object]";
// replace the aliases
const normalize = arg =>
!arg
? {}
: keys(arg).reduce((acc, curr) => {
const key = curr in aliases ? aliases[curr] : curr;
const value = arg[curr];
return {
...acc,
// recursive for hover, focus etc.
[key]: isObject(value) ? normalize(value) : value
};
}, {});
const variant = ({ theme, variant, __themeKey = "variants" }) =>
get(theme, __themeKey + "." + variant, get(theme, variant));
// apply css ONCE
const merged = css({
// base
...normalize(props.__css),
// variant
...normalize(variant(props)),
// sx
...normalize(props.sx)
})(props.theme); |
Saw this in the v1 roadmap and wanted to +1. Our |
Responsive values in variant styles override
sx
styles.To Reproduce
Expected behavior
sx
prop styles should always override variant styles.The text was updated successfully, but these errors were encountered: