Skip to content
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

[docs][Joy] Add documentation for Joy Stack component #35373

Merged
merged 22 commits into from
Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/data/joy/components/stack/BasicStack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';

const Item = styled(Sheet)(({ theme }) => ({
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.vars.palette.text.tertiary,
}));

export default function BasicStack() {
return (
<Stack spacing={2} sx={{ width: '100%' }}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
);
}
21 changes: 21 additions & 0 deletions docs/data/joy/components/stack/BasicStack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';

const Item = styled(Sheet)(({ theme }) => ({
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.vars.palette.text.tertiary,
}));

export default function BasicStack() {
return (
<Stack spacing={2} sx={{ width: '100%' }}>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
);
}
3 changes: 3 additions & 0 deletions docs/data/joy/components/stack/BasicStack.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
26 changes: 26 additions & 0 deletions docs/data/joy/components/stack/DirectionStack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';

const Item = styled(Sheet)(({ theme }) => ({
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.vars.palette.text.tertiary,
}));

export default function DirectionStack() {
return (
<Stack
direction="row"
spacing={2}
justifyContent="center"
sx={{ width: '100%' }}
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
);
}
26 changes: 26 additions & 0 deletions docs/data/joy/components/stack/DirectionStack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';

const Item = styled(Sheet)(({ theme }) => ({
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.vars.palette.text.tertiary,
}));

export default function DirectionStack() {
return (
<Stack
direction="row"
spacing={2}
justifyContent="center"
sx={{ width: '100%' }}
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
);
}
3 changes: 3 additions & 0 deletions docs/data/joy/components/stack/DirectionStack.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
28 changes: 28 additions & 0 deletions docs/data/joy/components/stack/DividerStack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from 'react';
import Divider from '@mui/joy/Divider';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';

const Item = styled(Sheet)(({ theme }) => ({
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.vars.palette.text.tertiary,
}));

export default function DividerStack() {
return (
<Stack
direction="row"
divider={<Divider orientation="vertical" />}
spacing={2}
justifyContent="center"
sx={{ width: '100%' }}
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
);
}
28 changes: 28 additions & 0 deletions docs/data/joy/components/stack/DividerStack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from 'react';
import Divider from '@mui/joy/Divider';
import Sheet from '@mui/joy/Sheet';
import Stack from '@mui/joy/Stack';
import { styled } from '@mui/joy/styles';

const Item = styled(Sheet)(({ theme }) => ({
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'center',
color: theme.vars.palette.text.tertiary,
}));

export default function DividerStack() {
return (
<Stack
direction="row"
divider={<Divider orientation="vertical" />}
spacing={2}
justifyContent="center"
sx={{ width: '100%' }}
>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Stack>
);
}
3 changes: 3 additions & 0 deletions docs/data/joy/components/stack/DividerStack.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
145 changes: 145 additions & 0 deletions docs/data/joy/components/stack/InteractiveStack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import * as React from 'react';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import Grid from '@mui/joy/Grid';
import BrandingProvider from 'docs/src/BrandingProvider';
import HighlightedCode from 'docs/src/modules/components/HighlightedCode';
import Sheet from '@mui/joy/Sheet';
import RadioGroup from '@mui/joy/RadioGroup';
import Radio from '@mui/joy/Radio';
import Stack from '@mui/joy/Stack';

export default function InteractiveStack() {
const [direction, setDirection] = React.useState('row');
const [justifyContent, setJustifyContent] = React.useState('center');
const [alignItems, setAlignItems] = React.useState('center');
const [spacing, setSpacing] = React.useState(2);

const jsx = `
<Stack
direction="${direction}"
justifyContent="${justifyContent}"
alignItems="${alignItems}"
spacing={${spacing}}
>
`;

return (
<Stack sx={{ flexGrow: 1 }}>
<Stack
direction={direction}
justifyContent={justifyContent}
alignItems={alignItems}
spacing={spacing}
sx={{ height: 300, pt: 2, pb: 2 }}
>
{[0, 1, 2].map((value) => (
<Sheet
key={value}
sx={{
p: 2,
pt: value + 1,
pb: value + 1,
typography: 'body2',
}}
>
{`Item ${value + 1}`}
</Sheet>
))}
</Stack>
<Sheet sx={{ p: 2 }}>
<Grid container spacing={3}>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 1.5 }}>direction</FormLabel>
<RadioGroup
row
name="direction"
aria-label="direction"
value={direction}
onChange={(event) => {
setDirection(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="row" value="row" />
<Radio label="row-reverse" value="row-reverse" />
<Radio label="column" value="column" />
<Radio label="column-reverse" value="column-reverse" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 1.5 }}>alignItems</FormLabel>
<RadioGroup
row
name="alignItems"
aria-label="align items"
value={alignItems}
onChange={(event) => {
setAlignItems(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="flex-start" value="flex-start" />
<Radio label="center" value="center" />
<Radio label="flex-end" value="flex-end" />
<Radio label="stretch" value="stretch" />
<Radio label="baseline" value="baseline" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 1.5 }}>justifyContent</FormLabel>
<RadioGroup
row
name="justifyContent"
aria-label="justifyContent"
value={justifyContent}
onChange={(event) => {
setJustifyContent(event.target.value);
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
<Radio label="flex-start" value="flex-start" />
<Radio label="center" value="center" />
<Radio label="flex-end" value="flex-end" />
<Radio label="space-between" value="space-between" />
<Radio label="space-around" value="space-around" />
<Radio label="space-evenly" value="space-evenly" />
</RadioGroup>
</FormControl>
</Grid>
<Grid xs={12}>
<FormControl>
<FormLabel sx={{ mb: 1.5 }}>spacing</FormLabel>
<RadioGroup
row
name="spacing"
aria-label="spacing"
value={spacing.toString()}
onChange={(event) => {
setSpacing(Number(event.target.value));
}}
sx={{ flexWrap: 'wrap', gap: 2, '--RadioGroup-gap': '0px' }}
>
{[0, 0.5, 1, 2, 3, 4, 8, 12].map((value) => (
<Radio
key={value}
label={value.toString()}
value={value.toString()}
/>
))}
</RadioGroup>
</FormControl>
</Grid>
</Grid>
</Sheet>
<BrandingProvider mode="dark">
<HighlightedCode code={jsx} language="jsx" />
</BrandingProvider>
</Stack>
);
}
Loading