Skip to content

Commit

Permalink
[material-ui][AppBar] Support all default palette colors in TypeScript (
Browse files Browse the repository at this point in the history
  • Loading branch information
BreakBB committed Oct 11, 2023
1 parent abe61bf commit e417dcf
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
8 changes: 6 additions & 2 deletions docs/pages/material-ui/api/app-bar.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"color": {
"type": {
"name": "union",
"description": "'default'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'transparent'<br>&#124;&nbsp;string"
"description": "'default'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'transparent'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
Expand Down Expand Up @@ -42,7 +42,11 @@
"colorPrimary",
"colorSecondary",
"colorInherit",
"colorTransparent"
"colorTransparent",
"colorError",
"colorInfo",
"colorSuccess",
"colorWarning"
],
"globalClasses": {},
"name": "MuiAppBar"
Expand Down
20 changes: 20 additions & 0 deletions docs/translations/api-docs/app-bar/app-bar.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"transparent\"</code>"
},
"colorError": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"error\"</code>"
},
"colorInfo": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"info\"</code>"
},
"colorSuccess": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"success\"</code>"
},
"colorWarning": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"warning\"</code>"
}
}
}
5 changes: 4 additions & 1 deletion packages/mui-material/src/AppBar/AppBar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export interface AppBarOwnProps {
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* @default 'primary'
*/
color?: OverridableStringUnion<PropTypes.Color | 'transparent', AppBarPropsColorOverrides>;
color?: OverridableStringUnion<
PropTypes.Color | 'transparent' | 'error' | 'info' | 'success' | 'warning',
AppBarPropsColorOverrides
>;
/**
* If true, the `color` prop is applied in dark mode.
* @default false
Expand Down
12 changes: 11 additions & 1 deletion packages/mui-material/src/AppBar/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,17 @@ AppBar.propTypes /* remove-proptypes */ = {
* @default 'primary'
*/
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary', 'transparent']),
PropTypes.oneOf([
'default',
'inherit',
'primary',
'secondary',
'transparent',
'error',
'info',
'success',
'warning',
]),
PropTypes.string,
]),
/**
Expand Down
11 changes: 11 additions & 0 deletions packages/mui-material/src/AppBar/AppBar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ function AppBarTest() {
</div>
);
}

// `color`
<AppBar color="inherit" />;
<AppBar color="primary" />;
<AppBar color="secondary" />;
<AppBar color="default" />;
<AppBar color="transparent" />;
<AppBar color="error" />;
<AppBar color="success" />;
<AppBar color="info" />;
<AppBar color="warning" />;
12 changes: 12 additions & 0 deletions packages/mui-material/src/AppBar/appBarClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export interface AppBarClasses {
colorInherit: string;
/** Styles applied to the root element if `color="transparent"`. */
colorTransparent: string;
/** Styles applied to the root element if `color="error"`. */
colorError: string;
/** Styles applied to the root element if `color="info"`. */
colorInfo: string;
/** Styles applied to the root element if `color="success"`. */
colorSuccess: string;
/** Styles applied to the root element if `color="warning"`. */
colorWarning: string;
}

export type AppBarClassKey = keyof AppBarClasses;
Expand All @@ -44,6 +52,10 @@ const appBarClasses: AppBarClasses = generateUtilityClasses('MuiAppBar', [
'colorSecondary',
'colorInherit',
'colorTransparent',
'colorError',
'colorInfo',
'colorSuccess',
'colorWarning',
]);

export default appBarClasses;

0 comments on commit e417dcf

Please sign in to comment.