Replies: 9 comments
-
Cool with me too 👌 |
Beta Was this translation helpful? Give feedback.
-
I like how this simplifies things but are we sure that we only want to support |
Beta Was this translation helpful? Give feedback.
-
@jjenzz Agreed, but I think it should be enough for launch at least. Then we have more time to think through in more depth, and see what users want/need |
Beta Was this translation helpful? Give feedback.
-
UPDATEUtils will support media queries when the inline media query work is merged: https://codesandbox.io/s/romantic-colden-c61i8 To summarise our Slack discussion... I really think our focus should be to allow const { styled } = createStyled({
tokens: {
'$red': 'tomato'
},
breakpoints: {
'@short': rule => `@media(max-height: 300px) { ${rule} }`,
},
utils: {
_motion: config => value => ({
'@media (prefers-reduced-motion)': value,
}),
_hover: config => value => ({
'@media(hover: hover)': {
':hover': value,
}
}),
}
});
const Button = styled('button', {
color: 'blue',
_hover: { color: '$red' },
'@short': { /* whatever */ }
}); Then we just document recommendations:
|
Beta Was this translation helpful? Give feedback.
-
Here is an update on where this one is headed:
This outputs min-width: breakpoints: {
1: '200px'
} Or you can do a full one breakpoints: {
1: { minWidth: '200px', maxHeight: '400px' }
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for the update @hadihallak |
Beta Was this translation helpful? Give feedback.
-
Sorry to jump into the discussion but I guess that now everything is open! 😅 I was going to open a new issue/request asking if we couldn't simplify the breakpoints API as it seems a bit redundant to always have to include the At the same time I realised that doing something like this would also work: breakpoints: {
bp1: (rule) => `@media (min-width: 520px) { ${rule} }`,
bp2: (rule) => `@media (min-width: 900px) { ${rule} }`,
noGridSupport: (rule) => `@supports not (display: grid) { ${rule}}`
} So the From @hadihallak comment I assume that going forward you're planning on changing the breakpoints API to something like: breakpoints: {
1: { minWidth: '200px', maxHeight: '400px' }
} I think this has a couple of issues:
So, have you considered deprecating Something like this: queries: {
bp1: `@media (min-width: 520px)`,
bp2: `@media (min-width: 900px) and (max-width: 1280px)`,
noGridSupport: `@supports not (display: grid)`
} This would consolidate all cases instead of splitting them between For most this would just be used for breakpoints definition but it could have any other at-rules for more advanced uses. Just something for you to consider, hope you don't mind! 😬 |
Beta Was this translation helpful? Give feedback.
-
@braposo Thanks for your input on this. I believe what you suggest should already work, however, we treat the entries in The discussion around reworking @hadihallak @christianalfoni I'm curious if it's an issue to have other at-rules moved into this new style tag too though? I had also hoped for the API proposed by @braposo during our internal discussions so I'm curious if it's worth revisiting. We've made lots of changes since our original discussions. |
Beta Was this translation helpful? Give feedback.
-
hey @jjenzz thanks for the reply! I must admit that it felt a bit weird to comment on this as I'm sure lots has been discussed outside of this issue so thanks for shedding some light into the decisions behind this. It makes sense to separate breakpoints to give them a "special treatment" comparing with the other at-rules. I don't think this was very clear from the docs, which is completely expected at this point btw, so my initial question was more to understand the reasoning behind isolating the breakpoints. One thing that is still confusing to me (and you mentioned that as well) is why does it have to be a completely different syntax from the "traditional" media queries declaration, especially when it seems that it doesn't provide the same features and it will need to be converted to a CSS media query anyway at some point. Hopefully @hadihallak @christianalfoni can give a bit more info on that! |
Beta Was this translation helpful? Give feedback.
-
Myself, @hadihallak, and @StephenHaney were chatting about Modulz having to parse
mediaQueries
and ignore non-breakpoint media queries.We eventually decided it's no big deal.
But it made me realise that non-breakpoint media queries don't belong in the
tokens
object. Tokens are for abstracting logic like300px
orhsl(208,100%,50%)
.So I suggested moving them to
utils
. @hadihallak said they don't belong there either, becauseutils
should output CSS properties.So we eventually agreed it makes sense to split them into 3 separate objects.
This also allows us to simplify the breakpoint syntax by only supporting
min-width
breakpoints.Beta Was this translation helpful? Give feedback.
All reactions