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

[material-ui][docs] Simplify components styling on templates #41845

Merged
merged 9 commits into from
Apr 16, 2024
101 changes: 50 additions & 51 deletions docs/data/material/getting-started/templates/checkout/PaymentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';

import Alert from '@mui/material/Alert';
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import { Card as MuiCard } from '@mui/material';
import CardActionArea from '@mui/material/CardActionArea';
import CardContent from '@mui/material/CardContent';
import Checkbox from '@mui/material/Checkbox';
Expand All @@ -14,12 +14,56 @@ import RadioGroup from '@mui/material/RadioGroup';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';

import { styled } from '@mui/material/styles';

import AccountBalanceRoundedIcon from '@mui/icons-material/AccountBalanceRounded';
import CreditCardRoundedIcon from '@mui/icons-material/CreditCardRounded';
import SimCardRoundedIcon from '@mui/icons-material/SimCardRounded';
import WarningRoundedIcon from '@mui/icons-material/WarningRounded';

import { styled } from '@mui/system';
const Card = styled(MuiCard)(({ theme }) => ({
border: '1px solid',
borderColor: theme.palette.divider,
width: '100%',
'&:hover': {
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.5) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
borderColor: theme.palette.mode === 'light' ? 'primary.light' : 'primary.dark',
boxShadow:
theme.palette.mode === 'light'
? '0px 2px 8px hsla(0, 0%, 0%, 0.1)'
: '0px 1px 8px hsla(210, 100%, 25%, 0.5) ',
},
[theme.breakpoints.up('md')]: {
flexGrow: 1,
maxWidth: `calc(50% - ${theme.spacing(1)})`,
},
}));

const PaymentContainer = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
width: '100%',
height: 375,
padding: theme.spacing(3),
borderRadius: '20px',
border: '1px solid ',
borderColor: theme.palette.divider,
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.3) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
boxShadow: '0px 4px 8px hsla(210, 0%, 0%, 0.05)',
[theme.breakpoints.up('xs')]: {
height: 300,
},
[theme.breakpoints.up('sm')]: {
height: 350,
},
}));

const FormGrid = styled('div')(() => ({
display: 'flex',
Expand Down Expand Up @@ -68,28 +112,13 @@ export default function PaymentForm() {
value={paymentType}
onChange={handlePaymentTypeChange}
sx={{
flexDirection: { sm: 'column', md: 'row' },
display: 'flex',
flexDirection: { xs: 'column', sm: 'row' },
gap: 2,
}}
>
<Card
sx={(theme) => ({
maxWidth: { sm: '100%', md: '50%' },
flexGrow: 1,
border: '1px solid',
borderColor: 'divider',
'&:hover': {
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.5) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
borderColor:
theme.palette.mode === 'light' ? 'primary.light' : 'primary.dark',
boxShadow:
theme.palette.mode === 'light'
? '0px 2px 8px hsla(0, 0%, 0%, 0.1)'
: '0px 1px 8px hsla(210, 100%, 25%, 0.5) ',
},
...(paymentType === 'creditCard' && {
backgroundColor: 'action.selected',
borderColor:
Expand Down Expand Up @@ -124,22 +153,6 @@ export default function PaymentForm() {
</Card>
<Card
sx={(theme) => ({
maxWidth: { sm: '100%', md: '50%' },
flexGrow: 1,
border: '1px solid',
borderColor: 'divider',
'&:hover': {
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.5) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
borderColor:
theme.palette.mode === 'light' ? 'primary.light' : 'primary.dark',
boxShadow:
theme.palette.mode === 'light'
? '0px 2px 8px hsla(0, 0%, 0%, 0.1)'
: '0px 1px 8px hsla(210, 100%, 25%, 0.5) ',
},
...(paymentType === 'bankTransfer' && {
backgroundColor: 'action.selected',
borderColor:
Expand Down Expand Up @@ -182,21 +195,7 @@ export default function PaymentForm() {
gap: 2,
}}
>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
p: 3,
height: { xs: 300, sm: 350, md: 375 },
width: '100%',
borderRadius: '20px',
border: '1px solid ',
borderColor: 'divider',
backgroundColor: 'background.paper',
boxShadow: '0px 4px 8px hsla(210, 0%, 0%, 0.05)',
}}
>
<PaymentContainer>
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="subtitle2">Credit card</Typography>
<CreditCardRoundedIcon sx={{ color: 'text.secondary' }} />
Expand Down Expand Up @@ -269,7 +268,7 @@ export default function PaymentForm() {
/>
</FormGrid>
</Box>
</Box>
</PaymentContainer>
<FormControlLabel
control={<Checkbox name="saveCard" />}
label="Remember credit card details for next time"
Expand Down
102 changes: 51 additions & 51 deletions docs/data/material/getting-started/templates/checkout/PaymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';

import Alert from '@mui/material/Alert';
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import { Card as MuiCard } from '@mui/material';
import CardActionArea from '@mui/material/CardActionArea';
import CardContent from '@mui/material/CardContent';
import Checkbox from '@mui/material/Checkbox';
Expand All @@ -14,12 +14,57 @@ import RadioGroup from '@mui/material/RadioGroup';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';

import { styled } from '@mui/material/styles';

import AccountBalanceRoundedIcon from '@mui/icons-material/AccountBalanceRounded';
import CreditCardRoundedIcon from '@mui/icons-material/CreditCardRounded';
import SimCardRoundedIcon from '@mui/icons-material/SimCardRounded';
import WarningRoundedIcon from '@mui/icons-material/WarningRounded';

import { styled } from '@mui/system';
const Card = styled(MuiCard)(({ theme }) => ({
border: '1px solid',
borderColor: theme.palette.divider,
width: '100%',
'&:hover': {
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.5) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
borderColor: theme.palette.mode === 'light' ? 'primary.light' : 'primary.dark',
boxShadow:
theme.palette.mode === 'light'
? '0px 2px 8px hsla(0, 0%, 0%, 0.1)'
: '0px 1px 8px hsla(210, 100%, 25%, 0.5) ',
},

[theme.breakpoints.up('md')]: {
flexGrow: 1,
maxWidth: `calc(50% - ${theme.spacing(1)})`,
},
}));

const PaymentContainer = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
width: '100%',
height: 375,
padding: theme.spacing(3),
borderRadius: '20px',
border: '1px solid ',
borderColor: theme.palette.divider,
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.3) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
boxShadow: '0px 4px 8px hsla(210, 0%, 0%, 0.05)',
[theme.breakpoints.up('xs')]: {
height: 300,
},
[theme.breakpoints.up('sm')]: {
height: 350,
},
}));

const FormGrid = styled('div')(() => ({
display: 'flex',
Expand Down Expand Up @@ -70,28 +115,13 @@ export default function PaymentForm() {
value={paymentType}
onChange={handlePaymentTypeChange}
sx={{
flexDirection: { sm: 'column', md: 'row' },
display: 'flex',
flexDirection: { xs: 'column', sm: 'row' },
gap: 2,
}}
>
<Card
sx={(theme) => ({
maxWidth: { sm: '100%', md: '50%' },
flexGrow: 1,
border: '1px solid',
borderColor: 'divider',
'&:hover': {
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.5) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
borderColor:
theme.palette.mode === 'light' ? 'primary.light' : 'primary.dark',
boxShadow:
theme.palette.mode === 'light'
? '0px 2px 8px hsla(0, 0%, 0%, 0.1)'
: '0px 1px 8px hsla(210, 100%, 25%, 0.5) ',
},
...(paymentType === 'creditCard' && {
backgroundColor: 'action.selected',
borderColor:
Expand Down Expand Up @@ -126,22 +156,6 @@ export default function PaymentForm() {
</Card>
<Card
sx={(theme) => ({
maxWidth: { sm: '100%', md: '50%' },
flexGrow: 1,
border: '1px solid',
borderColor: 'divider',
'&:hover': {
background:
theme.palette.mode === 'light'
? 'linear-gradient(to bottom right, hsla(210, 100%, 97%, 0.5) 25%, hsla(210, 100%, 90%, 0.3) 100%)'
: 'linear-gradient(to right bottom, hsla(210, 100%, 12%, 0.2) 25%, hsla(210, 100%, 16%, 0.2) 100%)',
borderColor:
theme.palette.mode === 'light' ? 'primary.light' : 'primary.dark',
boxShadow:
theme.palette.mode === 'light'
? '0px 2px 8px hsla(0, 0%, 0%, 0.1)'
: '0px 1px 8px hsla(210, 100%, 25%, 0.5) ',
},
...(paymentType === 'bankTransfer' && {
backgroundColor: 'action.selected',
borderColor:
Expand Down Expand Up @@ -184,21 +198,7 @@ export default function PaymentForm() {
gap: 2,
}}
>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
p: 3,
height: { xs: 300, sm: 350, md: 375 },
width: '100%',
borderRadius: '20px',
border: '1px solid ',
borderColor: 'divider',
backgroundColor: 'background.paper',
boxShadow: '0px 4px 8px hsla(210, 0%, 0%, 0.05)',
}}
>
<PaymentContainer>
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
<Typography variant="subtitle2">Credit card</Typography>
<CreditCardRoundedIcon sx={{ color: 'text.secondary' }} />
Expand Down Expand Up @@ -271,7 +271,7 @@ export default function PaymentForm() {
/>
</FormGrid>
</Box>
</Box>
</PaymentContainer>
<FormControlLabel
control={<Checkbox name="saveCard" />}
label="Remember credit card details for next time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import * as React from 'react';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
import Card from '@mui/material/Card';
import Chip from '@mui/material/Chip';
import { Chip as MuiChip } from '@mui/material';
import Container from '@mui/material/Container';
import Grid from '@mui/material/Grid';
import Link from '@mui/material/Link';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';

import { styled } from '@mui/material/styles';

import ChevronRightRoundedIcon from '@mui/icons-material/ChevronRightRounded';
import DevicesRoundedIcon from '@mui/icons-material/DevicesRounded';
import EdgesensorHighRoundedIcon from '@mui/icons-material/EdgesensorHighRounded';
Expand Down Expand Up @@ -40,6 +43,21 @@ const items = [
},
];

const Chip = styled(MuiChip)(({ theme, selected }) => ({
...(selected && {
borderColor:
theme.palette.mode === 'light'
? theme.palette.primary.light
: theme.palette.primary.dark,
background:
'linear-gradient(to bottom right, hsl(210, 98%, 48%), hsl(210, 98%, 35%))',
color: 'hsl(0, 0%, 100%)',
'& .MuiChip-label': {
color: 'hsl(0, 0%, 100%)',
},
}),
}));

export default function Features() {
const [selectedItemIndex, setSelectedItemIndex] = React.useState(0);

Expand Down Expand Up @@ -73,20 +91,7 @@ export default function Features() {
key={index}
label={title}
onClick={() => handleItemClick(index)}
sx={(theme) => ({
...(selectedItemIndex === index && {
borderColor:
theme.palette.mode === 'light'
? 'primary.light'
: 'primary.dark',
background:
'linear-gradient(to bottom right, hsl(210, 98%, 48%), hsl(210, 98%, 35%))',
color: 'hsl(0, 0%, 100%)',
'& .MuiChip-label': {
color: 'hsl(0, 0%, 100%)',
},
}),
})}
selected={selectedItemIndex === index}
/>
))}
</Grid>
Expand Down
Loading
Loading