-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
781 additions
and
138 deletions.
There are no files selected for viewing
This file contains 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,14 @@ | ||
import * as React from 'react'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import { Box, Container } from '@mui/system'; | ||
|
||
export default function FixedContainer() { | ||
return ( | ||
<React.Fragment> | ||
<CssBaseline /> | ||
<Container fixed> | ||
<Box sx={{ bgcolor: '#cfe8fc', height: '100vh' }} /> | ||
</Container> | ||
</React.Fragment> | ||
); | ||
} |
This file contains 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,14 @@ | ||
import * as React from 'react'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import { Box, Container } from '@mui/system'; | ||
|
||
export default function FixedContainer() { | ||
return ( | ||
<React.Fragment> | ||
<CssBaseline /> | ||
<Container fixed> | ||
<Box sx={{ bgcolor: '#cfe8fc', height: '100vh' }} /> | ||
</Container> | ||
</React.Fragment> | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
docs/data/system/components/container/FixedContainer.tsx.preview
This file contains 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,6 @@ | ||
<React.Fragment> | ||
<CssBaseline /> | ||
<Container fixed> | ||
<Box sx={{ bgcolor: '#cfe8fc', height: '100vh' }} /> | ||
</Container> | ||
</React.Fragment> |
This file contains 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,14 @@ | ||
import * as React from 'react'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import { Box, Container } from '@mui/system'; | ||
|
||
export default function SimpleContainer() { | ||
return ( | ||
<React.Fragment> | ||
<CssBaseline /> | ||
<Container maxWidth="sm"> | ||
<Box sx={{ bgcolor: '#cfe8fc', height: '100vh' }} /> | ||
</Container> | ||
</React.Fragment> | ||
); | ||
} |
This file contains 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,14 @@ | ||
import * as React from 'react'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import { Box, Container } from '@mui/system'; | ||
|
||
export default function SimpleContainer() { | ||
return ( | ||
<React.Fragment> | ||
<CssBaseline /> | ||
<Container maxWidth="sm"> | ||
<Box sx={{ bgcolor: '#cfe8fc', height: '100vh' }} /> | ||
</Container> | ||
</React.Fragment> | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
docs/data/system/components/container/SimpleContainer.tsx.preview
This file contains 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,6 @@ | ||
<React.Fragment> | ||
<CssBaseline /> | ||
<Container maxWidth="sm"> | ||
<Box sx={{ bgcolor: '#cfe8fc', height: '100vh' }} /> | ||
</Container> | ||
</React.Fragment> |
This file contains 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,35 @@ | ||
--- | ||
product: system | ||
title: React Container component | ||
components: Container | ||
githubLabel: 'component: Container' | ||
--- | ||
|
||
# Container | ||
|
||
<p class="description">The container centers your content horizontally. It's the most basic layout element.</p> | ||
|
||
While containers can be nested, most layouts do not require a nested container. | ||
|
||
{{"component": "modules/components/ComponentLinkHeader.js", "design": false}} | ||
|
||
## Fluid | ||
|
||
A fluid container width is bounded by the `maxWidth` prop value. | ||
|
||
{{"demo": "SimpleContainer.js", "iframe": true, "defaultCodeOpen": false}} | ||
|
||
```jsx | ||
<Container maxWidth="sm"> | ||
``` | ||
|
||
## Fixed | ||
|
||
If you prefer to design for a fixed set of sizes instead of trying to accommodate a fully fluid viewport, you can set the `fixed` prop. | ||
The max-width matches the min-width of the current breakpoint. | ||
|
||
{{"demo": "FixedContainer.js", "iframe": true, "defaultCodeOpen": false}} | ||
|
||
```jsx | ||
<Container fixed> | ||
``` |
This file contains 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 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 |
---|---|---|
@@ -1 +1,4 @@ | ||
module.exports = [{ pathname: '/system/api/box' }]; | ||
module.exports = [ | ||
{ pathname: '/system/api/box' }, | ||
{ pathname: '/system/api/container' }, | ||
]; |
This file contains 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 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,19 @@ | ||
import * as React from 'react'; | ||
import ApiPage from 'docs/src/modules/components/ApiPage'; | ||
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations'; | ||
import jsonPageContent from './container.json'; | ||
|
||
export default function Page(props) { | ||
const { descriptions, pageContent } = props; | ||
return <ApiPage descriptions={descriptions} pageContent={pageContent} />; | ||
} | ||
|
||
Page.getInitialProps = () => { | ||
const req = require.context('docs/translations/api-docs/container', false, /container.*.json$/); | ||
const descriptions = mapApiPageTranslations(req); | ||
|
||
return { | ||
descriptions, | ||
pageContent: jsonPageContent, | ||
}; | ||
}; |
This file contains 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,41 @@ | ||
{ | ||
"props": { | ||
"classes": { "type": { "name": "object" } }, | ||
"component": { "type": { "name": "elementType" } }, | ||
"disableGutters": { "type": { "name": "bool" } }, | ||
"fixed": { "type": { "name": "bool" } }, | ||
"maxWidth": { | ||
"type": { | ||
"name": "union", | ||
"description": "'xs'<br>| 'sm'<br>| 'md'<br>| 'lg'<br>| 'xl'<br>| false<br>| string" | ||
} | ||
}, | ||
"sx": { | ||
"type": { | ||
"name": "union", | ||
"description": "Array<func<br>| object<br>| bool><br>| func<br>| object" | ||
} | ||
} | ||
}, | ||
"name": "Container", | ||
"styles": { | ||
"classes": [ | ||
"root", | ||
"disableGutters", | ||
"fixed", | ||
"maxWidthXs", | ||
"maxWidthSm", | ||
"maxWidthMd", | ||
"maxWidthLg", | ||
"maxWidthXl" | ||
], | ||
"globalClasses": {}, | ||
"name": "MuiContainer" | ||
}, | ||
"spread": true, | ||
"forwardsRefTo": "HTMLElement", | ||
"filename": "/packages/mui-system/src/Container/Container.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/material-ui/react-container/\">Container (Material UI)</a></li>\n<li><a href=\"/system/react-container/\">Container (MUI System)</a></li></ul>", | ||
"cssComponent": false | ||
} |
This file contains 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,11 @@ | ||
import * as React from 'react'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; | ||
import { | ||
demos, | ||
docs, | ||
demoComponents, | ||
} from 'docs/data/system/components/container/container.md?@mui/markdown'; | ||
|
||
export default function Page() { | ||
return <MarkdownDocs demos={demos} docs={docs} demoComponents={demoComponents} />; | ||
} |
This file contains 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 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 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 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 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,33 @@ | ||
import * as React from 'react'; | ||
import { expect } from 'chai'; | ||
import { describeConformance, createRenderer } from 'test/utils'; | ||
import Container, { containerClasses as classes } from '@mui/joy/Container'; | ||
|
||
describe('<Container />', () => { | ||
const { render } = createRenderer(); | ||
|
||
const defaultProps = { | ||
children: <div />, | ||
}; | ||
|
||
describeConformance(<Container {...defaultProps} />, () => ({ | ||
classes, | ||
inheritComponent: 'div', | ||
render, | ||
refInstanceof: window.HTMLElement, | ||
muiName: 'MuiContainer', | ||
skip: ['componentsProp'], | ||
testVariantProps: { fixed: true }, | ||
})); | ||
|
||
describe('prop: maxWidth', () => { | ||
it('should support different maxWidth values', () => { | ||
const { container: firstContainer } = render(<Container {...defaultProps} />); | ||
expect(firstContainer.firstChild).to.have.class(classes.maxWidthLg); | ||
const { container: secondsContainre } = render( | ||
<Container {...defaultProps} maxWidth={false} />, | ||
); | ||
expect(secondsContainre.firstChild).not.to.have.class(classes.maxWidthLg); | ||
}); | ||
}); | ||
}); |
This file contains 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,66 @@ | ||
/* eslint-disable material-ui/mui-name-matches-component-name */ | ||
import { createContainer } from '@mui/system'; | ||
import PropTypes from 'prop-types'; | ||
import { OverridableComponent } from '@mui/types'; | ||
import { ContainerTypeMap } from './ContainerProps'; | ||
import { Theme } from '../styles/types/theme'; | ||
import styled from '../styles/styled'; | ||
import { useThemeProps } from '../styles'; | ||
|
||
const Container = createContainer<Theme>({ | ||
createStyledComponent: styled('div', { | ||
name: 'MuiContainer', | ||
slot: 'Root', | ||
overridesResolver: (props, styles) => styles.root, | ||
}), | ||
useThemeProps: (inProps) => useThemeProps({ props: inProps, name: 'MuiContainer' }), | ||
}) as OverridableComponent<ContainerTypeMap>; | ||
|
||
Container.propTypes /* remove-proptypes */ = { | ||
// ----------------------------- Warning -------------------------------- | ||
// | These PropTypes are generated from the TypeScript type definitions | | ||
// | To update them edit TypeScript types and run "yarn proptypes" | | ||
// ---------------------------------------------------------------------- | ||
/** | ||
* @ignore | ||
*/ | ||
children: PropTypes.node, | ||
/** | ||
* The component used for the root node. | ||
* Either a string to use a HTML element or a component. | ||
*/ | ||
component: PropTypes.elementType, | ||
/** | ||
* If `true`, the left and right padding is removed. | ||
* @default false | ||
*/ | ||
disableGutters: PropTypes.bool, | ||
/** | ||
* Set the max-width to match the min-width of the current breakpoint. | ||
* This is useful if you'd prefer to design for a fixed set of sizes | ||
* instead of trying to accommodate a fully fluid viewport. | ||
* It's fluid by default. | ||
* @default false | ||
*/ | ||
fixed: PropTypes.bool, | ||
/** | ||
* Determine the max-width of the container. | ||
* The container width grows with the size of the screen. | ||
* Set to `false` to disable `maxWidth`. | ||
* @default 'lg' | ||
*/ | ||
maxWidth: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ | ||
PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), | ||
PropTypes.string, | ||
]), | ||
/** | ||
* The system prop that allows defining system overrides as well as additional CSS styles. | ||
*/ | ||
sx: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), | ||
PropTypes.func, | ||
PropTypes.object, | ||
]), | ||
} as any; | ||
|
||
export default Container; |
This file contains 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,40 @@ | ||
import * as React from 'react'; | ||
import { OverrideProps } from '@mui/types'; | ||
import { Breakpoint } from '@mui/system'; | ||
import { SxProps } from '../styles/types'; | ||
|
||
export interface ContainerTypeMap<P = {}, D extends React.ElementType = 'div'> { | ||
props: P & { | ||
children?: React.ReactNode; | ||
/** | ||
* If `true`, the left and right padding is removed. | ||
* @default false | ||
*/ | ||
disableGutters?: boolean; | ||
/** | ||
* Set the max-width to match the min-width of the current breakpoint. | ||
* This is useful if you'd prefer to design for a fixed set of sizes | ||
* instead of trying to accommodate a fully fluid viewport. | ||
* It's fluid by default. | ||
* @default false | ||
*/ | ||
fixed?: boolean; | ||
/** | ||
* Determine the max-width of the container. | ||
* The container width grows with the size of the screen. | ||
* Set to `false` to disable `maxWidth`. | ||
* @default 'lg' | ||
*/ | ||
maxWidth?: Breakpoint | false; | ||
/** | ||
* The system prop that allows defining system overrides as well as additional CSS styles. | ||
*/ | ||
sx?: SxProps; | ||
}; | ||
defaultComponent: D; | ||
} | ||
|
||
export type ContainerProps< | ||
D extends React.ElementType = ContainerTypeMap['defaultComponent'], | ||
P = {}, | ||
> = OverrideProps<ContainerTypeMap<P, D>, D>; |
Oops, something went wrong.