Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
202 lines
6.4 KiB
TypeScript
202 lines
6.4 KiB
TypeScript
import * as React from 'react';
|
|
import FormControl from '@mui/material/FormControl';
|
|
import FormLabel from '@mui/material/FormLabel';
|
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
import Grid from '@mui/material/Grid';
|
|
import Paper from '@mui/material/Paper';
|
|
import RadioGroup from '@mui/material/RadioGroup';
|
|
import Radio from '@mui/material/Radio';
|
|
import Stack, { StackProps } from '@mui/material/Stack';
|
|
import { HighlightedCode } from '@mui/docs/HighlightedCode';
|
|
|
|
export default function InteractiveStack() {
|
|
const [direction, setDirection] = React.useState<StackProps['direction']>('row');
|
|
const [justifyContent, setJustifyContent] = React.useState('center');
|
|
const [alignItems, setAlignItems] = React.useState('center');
|
|
const [spacing, setSpacing] = React.useState(2);
|
|
|
|
const jsx = `
|
|
<Stack
|
|
direction="${direction}"
|
|
spacing={${spacing}}
|
|
sx={{
|
|
justifyContent: "${justifyContent}",
|
|
alignItems: "${alignItems}",
|
|
}}
|
|
>
|
|
`;
|
|
|
|
return (
|
|
<Stack sx={{ flexGrow: 1 }}>
|
|
<Stack
|
|
direction={direction}
|
|
spacing={spacing}
|
|
sx={{ justifyContent, alignItems, height: 240 }}
|
|
>
|
|
{[0, 1, 2].map((value) => (
|
|
<Paper
|
|
key={value}
|
|
sx={(theme) => ({
|
|
p: 2,
|
|
pt: value + 1,
|
|
pb: value + 1,
|
|
color: 'text.secondary',
|
|
typography: 'body2',
|
|
backgroundColor: '#fff',
|
|
...theme.applyStyles('dark', {
|
|
backgroundColor: '#1A2027',
|
|
}),
|
|
})}
|
|
>
|
|
{`Item ${value + 1}`}
|
|
</Paper>
|
|
))}
|
|
</Stack>
|
|
<Paper sx={{ p: 2 }}>
|
|
<Grid container spacing={3}>
|
|
<Grid size={12}>
|
|
<FormControl component="fieldset">
|
|
<FormLabel component="legend">direction</FormLabel>
|
|
<RadioGroup
|
|
row
|
|
name="direction"
|
|
aria-label="direction"
|
|
value={direction}
|
|
onChange={(event) => {
|
|
setDirection(event.target.value as StackProps['direction']);
|
|
}}
|
|
>
|
|
<FormControlLabel value="row" control={<Radio />} label="row" />
|
|
<FormControlLabel
|
|
value="row-reverse"
|
|
control={<Radio />}
|
|
label="row-reverse"
|
|
/>
|
|
<FormControlLabel
|
|
value="column"
|
|
control={<Radio />}
|
|
label="column"
|
|
/>
|
|
<FormControlLabel
|
|
value="column-reverse"
|
|
control={<Radio />}
|
|
label="column-reverse"
|
|
/>
|
|
</RadioGroup>
|
|
</FormControl>
|
|
</Grid>
|
|
<Grid size={12}>
|
|
<FormControl component="fieldset">
|
|
<FormLabel component="legend">alignItems</FormLabel>
|
|
<RadioGroup
|
|
row
|
|
name="alignItems"
|
|
aria-label="align items"
|
|
value={alignItems}
|
|
onChange={(event) => {
|
|
setAlignItems(event.target.value);
|
|
}}
|
|
>
|
|
<FormControlLabel
|
|
value="flex-start"
|
|
control={<Radio />}
|
|
label="flex-start"
|
|
/>
|
|
<FormControlLabel
|
|
value="center"
|
|
control={<Radio />}
|
|
label="center"
|
|
/>
|
|
<FormControlLabel
|
|
value="flex-end"
|
|
control={<Radio />}
|
|
label="flex-end"
|
|
/>
|
|
<FormControlLabel
|
|
value="stretch"
|
|
control={<Radio />}
|
|
label="stretch"
|
|
/>
|
|
<FormControlLabel
|
|
value="baseline"
|
|
control={<Radio />}
|
|
label="baseline"
|
|
/>
|
|
</RadioGroup>
|
|
</FormControl>
|
|
</Grid>
|
|
<Grid size={12}>
|
|
<FormControl component="fieldset">
|
|
<FormLabel component="legend">justifyContent</FormLabel>
|
|
<RadioGroup
|
|
row
|
|
name="justifyContent"
|
|
aria-label="justifyContent"
|
|
value={justifyContent}
|
|
onChange={(event) => {
|
|
setJustifyContent(event.target.value);
|
|
}}
|
|
>
|
|
<FormControlLabel
|
|
value="flex-start"
|
|
control={<Radio />}
|
|
label="flex-start"
|
|
/>
|
|
<FormControlLabel
|
|
value="center"
|
|
control={<Radio />}
|
|
label="center"
|
|
/>
|
|
<FormControlLabel
|
|
value="flex-end"
|
|
control={<Radio />}
|
|
label="flex-end"
|
|
/>
|
|
<FormControlLabel
|
|
value="space-between"
|
|
control={<Radio />}
|
|
label="space-between"
|
|
/>
|
|
<FormControlLabel
|
|
value="space-around"
|
|
control={<Radio />}
|
|
label="space-around"
|
|
/>
|
|
<FormControlLabel
|
|
value="space-evenly"
|
|
control={<Radio />}
|
|
label="space-evenly"
|
|
/>
|
|
</RadioGroup>
|
|
</FormControl>
|
|
</Grid>
|
|
<Grid size={12}>
|
|
<FormControl component="fieldset">
|
|
<FormLabel component="legend">spacing</FormLabel>
|
|
<RadioGroup
|
|
row
|
|
name="spacing"
|
|
aria-label="spacing"
|
|
value={spacing.toString()}
|
|
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
setSpacing(Number((event.target as HTMLInputElement).value));
|
|
}}
|
|
>
|
|
{[0, 0.5, 1, 2, 3, 4, 8, 12].map((value) => (
|
|
<FormControlLabel
|
|
key={value}
|
|
value={value.toString()}
|
|
control={<Radio />}
|
|
label={value}
|
|
/>
|
|
))}
|
|
</RadioGroup>
|
|
</FormControl>
|
|
</Grid>
|
|
</Grid>
|
|
</Paper>
|
|
<HighlightedCode code={jsx} language="jsx" />
|
|
</Stack>
|
|
);
|
|
}
|