use styled for custom button
This commit is contained in:
parent
ae418bb26a
commit
8bcd396795
@ -1,32 +1,19 @@
|
|||||||
import { Button as DefaultButton } from "@mui/material";
|
import { Button as DefaultButton, styled } from "@mui/material";
|
||||||
|
import { ButtonProps } from "@mui/material/Button";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
fullWidth?: boolean;
|
|
||||||
backgroundColor?: string;
|
backgroundColor?: string;
|
||||||
color?: string;
|
textColor?: string;
|
||||||
variant: "outlined" | "contained";
|
|
||||||
children: React.ReactNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Button({ fullWidth = false, backgroundColor, color, variant, children }: Props) {
|
export default styled(DefaultButton)<ButtonProps & Props>(props => ({
|
||||||
|
paddingLeft: "41.5px",
|
||||||
return (
|
paddingRight: "41.5px",
|
||||||
<div>
|
paddingTop: "9px",
|
||||||
<DefaultButton
|
paddingBottom: "9px",
|
||||||
fullWidth={fullWidth}
|
|
||||||
variant={variant}
|
|
||||||
sx={{
|
|
||||||
backgroundColor,
|
|
||||||
color,
|
|
||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
px: "41.5px",
|
backgroundColor: props.backgroundColor,
|
||||||
py: "9px",
|
color: props.textColor,
|
||||||
boxShadow: "none",
|
boxShadow: "none",
|
||||||
}}
|
}));
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</DefaultButton>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
@ -74,7 +74,7 @@ export default function Section1() {
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
backgroundColor={theme.palette.custom.brightPurple.main}
|
backgroundColor={theme.palette.custom.brightPurple.main}
|
||||||
color={theme.palette.primary.main}
|
textColor={theme.palette.primary.main}
|
||||||
>Подробнее</Button>
|
>Подробнее</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</SectionWrapper>
|
</SectionWrapper>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Box, Typography, useTheme } from "@mui/material";
|
import { Box, Typography, useTheme } from "@mui/material";
|
||||||
import Button from "../Button";
|
import CustomButton from "../Button";
|
||||||
import SectionWrapper from "../SectionWrapper";
|
import SectionWrapper from "../SectionWrapper";
|
||||||
|
|
||||||
|
|
||||||
@ -36,14 +36,14 @@ export default function Section5() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/** extract buttons as components */}
|
{/** extract buttons as components */}
|
||||||
<Button
|
<CustomButton
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
>Подробнее</Button>
|
>Подробнее</CustomButton>
|
||||||
<Button
|
<CustomButton
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="contained"
|
variant="contained"
|
||||||
>Подробнее</Button>
|
>Подробнее</CustomButton>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
|
Loading…
Reference in New Issue
Block a user