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][Accordion] Replace hardcoded classes with constants in demos #44453

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 8 additions & 6 deletions docs/data/material/components/accordion/AccordionTransition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react';
import Accordion from '@mui/material/Accordion';
import Accordion, { accordionClasses } from '@mui/material/Accordion';
import AccordionSummary from '@mui/material/AccordionSummary';
import AccordionDetails from '@mui/material/AccordionDetails';
import AccordionDetails, {
accordionDetailsClasses,
} from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import Fade from '@mui/material/Fade';
Expand All @@ -23,18 +25,18 @@ export default function AccordionTransition() {
sx={[
expanded
? {
'& .MuiAccordion-region': {
[`& .${accordionClasses.region}`]: {
height: 'auto',
},
'& .MuiAccordionDetails-root': {
[`& .${accordionDetailsClasses.root}`]: {
display: 'block',
},
}
: {
'& .MuiAccordion-region': {
[`& .${accordionClasses.region}`]: {
height: 0,
},
'& .MuiAccordionDetails-root': {
[`& .${accordionDetailsClasses.root}`]: {
display: 'none',
},
},
Expand Down
17 changes: 11 additions & 6 deletions docs/data/material/components/accordion/AccordionTransition.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as React from 'react';
import Accordion, { AccordionSlots } from '@mui/material/Accordion';
import Accordion, {
AccordionSlots,
accordionClasses,
} from '@mui/material/Accordion';
import AccordionSummary from '@mui/material/AccordionSummary';
import AccordionDetails from '@mui/material/AccordionDetails';
import AccordionDetails, {
accordionDetailsClasses,
} from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import Fade from '@mui/material/Fade';
Expand All @@ -23,18 +28,18 @@ export default function AccordionTransition() {
sx={[
expanded
? {
'& .MuiAccordion-region': {
[`& .${accordionClasses.region}`]: {
height: 'auto',
},
'& .MuiAccordionDetails-root': {
[`& .${accordionDetailsClasses.root}`]: {
display: 'block',
},
}
: {
'& .MuiAccordion-region': {
[`& .${accordionClasses.region}`]: {
height: 0,
},
'& .MuiAccordionDetails-root': {
[`& .${accordionDetailsClasses.root}`]: {
display: 'none',
},
},
Expand Down
13 changes: 8 additions & 5 deletions docs/data/material/components/accordion/CustomizedAccordions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import * as React from 'react';
import { styled } from '@mui/material/styles';
import ArrowForwardIosSharpIcon from '@mui/icons-material/ArrowForwardIosSharp';
import MuiAccordion from '@mui/material/Accordion';
import MuiAccordionSummary from '@mui/material/AccordionSummary';
import MuiAccordionSummary, {
accordionSummaryClasses,
} from '@mui/material/AccordionSummary';
import MuiAccordionDetails from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography';

Expand All @@ -26,10 +28,11 @@ const AccordionSummary = styled((props) => (
))(({ theme }) => ({
backgroundColor: 'rgba(0, 0, 0, .03)',
flexDirection: 'row-reverse',
'& .MuiAccordionSummary-expandIconWrapper.Mui-expanded': {
transform: 'rotate(90deg)',
},
'& .MuiAccordionSummary-content': {
[`& .${accordionSummaryClasses.expandIconWrapper}.${accordionSummaryClasses.expanded}`]:
{
transform: 'rotate(90deg)',
},
[`& .${accordionSummaryClasses.content}`]: {
marginLeft: theme.spacing(1),
},
...theme.applyStyles('dark', {
Expand Down
10 changes: 6 additions & 4 deletions docs/data/material/components/accordion/CustomizedAccordions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ArrowForwardIosSharpIcon from '@mui/icons-material/ArrowForwardIosSharp';
import MuiAccordion, { AccordionProps } from '@mui/material/Accordion';
import MuiAccordionSummary, {
AccordionSummaryProps,
accordionSummaryClasses,
} from '@mui/material/AccordionSummary';
import MuiAccordionDetails from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography';
Expand All @@ -28,10 +29,11 @@ const AccordionSummary = styled((props: AccordionSummaryProps) => (
))(({ theme }) => ({
backgroundColor: 'rgba(0, 0, 0, .03)',
flexDirection: 'row-reverse',
'& .MuiAccordionSummary-expandIconWrapper.Mui-expanded': {
transform: 'rotate(90deg)',
},
'& .MuiAccordionSummary-content': {
[`& .${accordionSummaryClasses.expandIconWrapper}.${accordionSummaryClasses.expanded}`]:
{
transform: 'rotate(90deg)',
},
[`& .${accordionSummaryClasses.content}`]: {
marginLeft: theme.spacing(1),
},
...theme.applyStyles('dark', {
Expand Down