-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[system] Add container queries utility #41674
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
05bc425
add container queries
siriwatknp ca0d779
add containerQueries
siriwatknp 6682098
pnpm extract-error-codes
siriwatknp 35e2a07
reexport cssContainerQueries
siriwatknp c66c031
add demo
siriwatknp 235a5c3
remove cq prefix
siriwatknp 1ae42b4
make container queries as default
siriwatknp 4aa9b01
Merge branch 'next' of https://github.com/mui/material-ui into system…
siriwatknp 2602d28
simplify logic
siriwatknp 7a88670
add containerQueries to Joy theme
siriwatknp e77155d
add more tests
siriwatknp af3b7a1
Merge branch 'next' of https://github.com/mui/material-ui into system…
siriwatknp 4493ee9
add cq field to test
siriwatknp a1aa6d6
Merge branch 'next' of https://github.com/mui/material-ui into system…
siriwatknp 07907de
pnpm extract-error-codes
siriwatknp 7677ad0
change `cq` to `containerQueries`
siriwatknp 885caa5
Merge branch 'next' of https://github.com/mui/material-ui into system…
siriwatknp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add demo
- Loading branch information
commit c66c031b7f9954e7dc260667c5f7003c94d14b7c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
docs/data/system/getting-started/usage/ContainerQueries.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import * as React from 'react'; | ||
| import Box from '@mui/material/Box'; | ||
|
|
||
| export default function ContainerQueries() { | ||
| return ( | ||
| <Box | ||
| sx={{ | ||
| overflow: 'auto', | ||
| resize: 'horizontal', | ||
| width: 400, | ||
| maxWidth: '80%', | ||
| containerType: 'inline-size', | ||
| }} | ||
| > | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| flexDirection: { xs: 'column', 'cq@350': 'row' }, | ||
| bgcolor: 'background.default', | ||
| border: '1px solid', | ||
| borderColor: 'divider', | ||
| borderRadius: 2, | ||
| overflow: 'clip', | ||
| }} | ||
| > | ||
| <Box | ||
| component="img" | ||
| sx={{ | ||
| alignSelf: 'stretch', | ||
| aspectRatio: '16 / 9', | ||
| objectFit: 'cover', | ||
| width: '100%', | ||
| maxWidth: { 'cq@350': '36%', 'cq@500': 240 }, | ||
| }} | ||
| alt="The house from the offer." | ||
| src="https://images.unsplash.com/photo-1512917774080-9991f1c4c750?auto=format&w=350&dpr=2" | ||
| /> | ||
| <Box | ||
| sx={{ | ||
| p: { xs: 2, 'cq@500': 3 }, | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| gap: 1, | ||
| }} | ||
| > | ||
| <div> | ||
| <Box | ||
| component="span" | ||
| sx={{ fontSize: '0.875rem', color: 'text.secondary' }} | ||
| > | ||
| 123 Main St, Phoenix AZ | ||
| </Box> | ||
| <Box | ||
| sx={{ | ||
| color: 'primary.main', | ||
| fontSize: '1.125rem', | ||
| fontWeight: 'bold', | ||
| }} | ||
| > | ||
| $280,000 — $310,000 | ||
| </Box> | ||
| </div> | ||
| <Box | ||
| sx={{ | ||
| width: 'fit-content', | ||
| py: 0.5, | ||
| px: 1, | ||
| backgroundColor: 'rgba(46, 125, 50, 0.1)', | ||
| borderRadius: 10, | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: 0.5, | ||
| border: '1px solid', | ||
| borderColor: 'rgba(46, 125, 50, 0.1)', | ||
| fontSize: '0.7rem', | ||
| fontWeight: 'bold', | ||
| letterSpacing: '.05rem', | ||
| textTransform: 'uppercase', | ||
| color: 'success.main', | ||
| }} | ||
| > | ||
| Confidence score: 85% | ||
| </Box> | ||
| </Box> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| } |
88 changes: 88 additions & 0 deletions
88
docs/data/system/getting-started/usage/ContainerQueries.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import * as React from 'react'; | ||
| import Box from '@mui/material/Box'; | ||
|
|
||
| export default function ContainerQueries() { | ||
| return ( | ||
| <Box | ||
| sx={{ | ||
| overflow: 'auto', | ||
| resize: 'horizontal', | ||
| width: 400, | ||
| maxWidth: '80%', | ||
| containerType: 'inline-size', | ||
| }} | ||
| > | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| flexDirection: { xs: 'column', 'cq@350': 'row' }, | ||
| bgcolor: 'background.default', | ||
| border: '1px solid', | ||
| borderColor: 'divider', | ||
| borderRadius: 2, | ||
| overflow: 'clip', | ||
| }} | ||
| > | ||
| <Box | ||
| component="img" | ||
| sx={{ | ||
| alignSelf: 'stretch', | ||
| aspectRatio: '16 / 9', | ||
| objectFit: 'cover', | ||
| width: '100%', | ||
| maxWidth: { 'cq@350': '36%', 'cq@500': 240 }, | ||
| }} | ||
| alt="The house from the offer." | ||
| src="https://images.unsplash.com/photo-1512917774080-9991f1c4c750?auto=format&w=350&dpr=2" | ||
| /> | ||
| <Box | ||
| sx={{ | ||
| p: { xs: 2, 'cq@500': 3 }, | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| gap: 1, | ||
| }} | ||
| > | ||
| <div> | ||
| <Box | ||
| component="span" | ||
| sx={{ fontSize: '0.875rem', color: 'text.secondary' }} | ||
| > | ||
| 123 Main St, Phoenix AZ | ||
| </Box> | ||
| <Box | ||
| sx={{ | ||
| color: 'primary.main', | ||
| fontSize: '1.125rem', | ||
| fontWeight: 'bold', | ||
| }} | ||
| > | ||
| $280,000 — $310,000 | ||
| </Box> | ||
| </div> | ||
| <Box | ||
| sx={{ | ||
| width: 'fit-content', | ||
| py: 0.5, | ||
| px: 1, | ||
| backgroundColor: 'rgba(46, 125, 50, 0.1)', | ||
| borderRadius: 10, | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| gap: 0.5, | ||
| border: '1px solid', | ||
| borderColor: 'rgba(46, 125, 50, 0.1)', | ||
| fontSize: '0.7rem', | ||
| fontWeight: 'bold', | ||
| letterSpacing: '.05rem', | ||
| textTransform: 'uppercase', | ||
| color: 'success.main', | ||
| }} | ||
| > | ||
| Confidence score: 85% | ||
| </Box> | ||
| </Box> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this function only used for the
xs,sm,md,lg, andxlqueries?I'm wondering as it only supports
min-widthdeclarations.Uh oh!
There was an error while loading. Please reload this page.
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.
No, it supports valid CSS units like
40emor300pxbut it requires all fields to use the same unit.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.
But it only supports
min-widthones, right? So, for example,theme.cq.down, which outputs@container (max-width:...)won't be sorted correctly.I want to better understand this function's use case. Is it internal or also for users?
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 sorting only happens for the
sxprop (happens internally, the function isn't meant for users) similar to theme breakpoints shorthand.