WEB APP: Стили в примерах для разработчика (MUI)

This commit is contained in:
Mikhail Chechnev 2023-12-21 20:34:20 +03:00
parent 24585ba6b2
commit 60af1cf05f
2 changed files with 56 additions and 46 deletions

View File

@ -22,7 +22,10 @@ import { ApplicationСtx } from "../../context/application"; //Контекст
const STYLES = { const STYLES = {
CONTAINER: { textAlign: "center", paddingTop: "20px" }, CONTAINER: { textAlign: "center", paddingTop: "20px" },
TITLE: { paddingBottom: "15px" }, TITLE: { paddingBottom: "15px" },
LIST: { width: "100%", maxWidth: "600px", bgcolor: "background.paper" } GRID_CONTAINER: { maxWidth: "500px" },
GRID_TEM: { width: "100%" },
LIST_CONTAINER: { marginTop: "10pt", maxHeight: "60vh", overflow: "auto", width: "100%" },
LIST: { width: "100%", bgcolor: "background.paper" }
}; };
//----------- //-----------
@ -109,8 +112,9 @@ const Mui = ({ title }) => {
<Typography sx={STYLES.TITLE} variant={"h6"}> <Typography sx={STYLES.TITLE} variant={"h6"}>
{title} {title}
</Typography> </Typography>
<Grid container spacing={0} direction="column" alignItems="center"> <Box display="flex" justifyContent="center" alignItems="center">
<Grid item xs={12}> <Grid container spacing={0} direction="column" alignItems="center" justifyContent="center" sx={STYLES.GRID_CONTAINER}>
<Grid item xs={12} sx={STYLES.GRID_TEM}>
<TextField <TextField
name="agnAbbr" name="agnAbbr"
label="Мнемокод" label="Мнемокод"
@ -132,6 +136,9 @@ const Mui = ({ title }) => {
Добавить контрагента Добавить контрагента
</Button> </Button>
</Box> </Box>
</Grid>
<Grid item xs={12} sx={STYLES.GRID_TEM}>
<Box sx={STYLES.LIST_CONTAINER}>
<List sx={STYLES.LIST}> <List sx={STYLES.LIST}>
{agents.map(a => ( {agents.map(a => (
<ListItem <ListItem
@ -149,8 +156,10 @@ const Mui = ({ title }) => {
</ListItem> </ListItem>
))} ))}
</List> </List>
</Box>
</Grid> </Grid>
</Grid> </Grid>
</Box>
</div> </div>
); );
}; };

View File

@ -35,6 +35,7 @@ const MODES = {
//Стили //Стили
const STYLES = { const STYLES = {
ROOT: { height: "calc(100vh - 64px)" },
CONTAINER: { textAlign: "center", paddingTop: "20px" }, CONTAINER: { textAlign: "center", paddingTop: "20px" },
BACK_BUTTON: { position: "absolute", left: "20px", marginTop: "20px" } BACK_BUTTON: { position: "absolute", left: "20px", marginTop: "20px" }
}; };
@ -46,19 +47,19 @@ const STYLES = {
//Примеры //Примеры
const Samples = () => { const Samples = () => {
//Собственное состояние //Собственное состояние
const [mode, setMode] = useState(""); const [mode, setMode] = useState("MUI");
//Генерация содержимого //Генерация содержимого
return ( return (
<div> <div style={STYLES.ROOT}>
{mode ? ( {mode ? (
<div> <>
<Fab variant="extended" sx={STYLES.BACK_BUTTON} onClick={() => setMode("")}> <Fab variant="extended" sx={STYLES.BACK_BUTTON} onClick={() => setMode("")}>
<Icon>arrow_back_ios</Icon> <Icon>arrow_back_ios</Icon>
{BUTTONS.NAVIGATE_BACK} {BUTTONS.NAVIGATE_BACK}
</Fab> </Fab>
{React.createElement(MODES[mode]?.component || (() => {}), { title: MODES[mode]?.caption })} {React.createElement(MODES[mode]?.component || (() => {}), { title: MODES[mode]?.caption })}
</div> </>
) : ( ) : (
<div style={STYLES.CONTAINER}> <div style={STYLES.CONTAINER}>
{Object.entries(MODES).map(m => ( {Object.entries(MODES).map(m => (