Skip to content

Commit

Permalink
[core] Ensure component class keys aren't missing
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed May 10, 2021
1 parent 8cb115b commit 6ace5a0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 46 deletions.
18 changes: 2 additions & 16 deletions packages/material-ui/src/Accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SxProps } from '@material-ui/system';
import { InternalStandardProps as StandardProps, Theme } from '..';
import { TransitionProps } from '../transitions/transition';
import { PaperProps } from '../Paper';
import { AccordionClasses } from './accordionClasses';

export interface AccordionProps extends StandardProps<PaperProps, 'onChange'> {
/**
Expand All @@ -12,20 +13,7 @@ export interface AccordionProps extends StandardProps<PaperProps, 'onChange'> {
/**
* Override or extend the styles applied to the component.
*/
classes?: {
/** Styles applied to the root element. */
root?: string;
/** Styles applied to the root element unless `square={true}`. */
rounded?: string;
/** Pseudo-class applied to the root element if `expanded={true}`. */
expanded?: string;
/** Pseudo-class applied to the root element if `disabled={true}`. */
disabled?: string;
/** Styles applied to the root element unless `disableGutters={true}`. */
gutters?: string;
/** Styles applied to the region element, the container of the children. */
region?: string;
};
classes?: Partial<AccordionClasses>;
/**
* If `true`, expands the accordion by default.
* @default false
Expand Down Expand Up @@ -72,8 +60,6 @@ export interface AccordionProps extends StandardProps<PaperProps, 'onChange'> {
TransitionProps?: TransitionProps;
}

export type AccordionClassKey = keyof NonNullable<AccordionProps['classes']>;

/**
*
* Demos:
Expand Down
5 changes: 0 additions & 5 deletions packages/material-ui/src/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const AccordionRoot = experimentalStyled(
};

return {
/* Styles applied to the root element. */
position: 'relative',
transition: theme.transitions.create(['margin'], transition),
overflowAnchor: 'none', // Keep the same scrolling position
Expand All @@ -73,7 +72,6 @@ const AccordionRoot = experimentalStyled(
display: 'none',
},
},
/* Styles applied to the root element if `expanded={true}`. */
[`&.${accordionClasses.expanded}`]: {
'&:before': {
opacity: 0,
Expand All @@ -90,14 +88,12 @@ const AccordionRoot = experimentalStyled(
},
},
},
/* Styles applied to the root element if `disabled={true}`. */
[`&.${accordionClasses.disabled}`]: {
backgroundColor: theme.palette.action.disabledBackground,
},
};
},
({ theme, styleProps }) => ({
/* Styles applied to the root element unless `square={true}`. */
...(!styleProps.square && {
borderRadius: 0,
'&:first-of-type': {
Expand All @@ -114,7 +110,6 @@ const AccordionRoot = experimentalStyled(
},
},
}),
/* Styles applied to the root element unless `disableGutters={true}`. */
...(!styleProps.disableGutters && {
[`&.${accordionClasses.expanded}`]: {
margin: '16px 0',
Expand Down
9 changes: 0 additions & 9 deletions packages/material-ui/src/Accordion/accordionClasses.d.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/material-ui/src/Accordion/accordionClasses.js

This file was deleted.

33 changes: 33 additions & 0 deletions packages/material-ui/src/Accordion/accordionClasses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { generateUtilityClass, generateUtilityClasses } from '@material-ui/unstyled';

export interface AccordionClasses {
/** Styles applied to the root element. */
root: string;
/** Styles applied to the root element unless `square={true}`. */
rounded: string;
/** Pseudo-class applied to the root element if `expanded={true}`. */
expanded: string;
/** Pseudo-class applied to the root element if `disabled={true}`. */
disabled: string;
/** Styles applied to the root element unless `disableGutters={true}`. */
gutters: string;
/** Styles applied to the region element, the container of the children. */
region: string;
}

export type AccordionClassKey = keyof AccordionClasses;

export function getAccordionUtilityClass(slot: string): string {
return generateUtilityClass('MuiAccordion', slot);
}

const accordionClasses: AccordionClasses = generateUtilityClasses('MuiAccordion', [
'root',
'rounded',
'expanded',
'disabled',
'gutters',
'region',
]);

export default accordionClasses;

0 comments on commit 6ace5a0

Please sign in to comment.