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][PaginationItem] Deprecate composed classes for v6 #40673

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 20 additions & 4 deletions docs/pages/material-ui/api/pagination-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@
"import { PaginationItem } from '@mui/material';"
],
"classes": [
{
"key": "colorPrimary",
"className": "MuiPaginationItem-colorPrimary",
"description": "Styles applied to the root element if `color=\"primary\"`.",
"isGlobal": false
},
{
"key": "colorSecondary",
"className": "MuiPaginationItem-colorSecondary",
"description": "Styles applied to the root element if `color=\"secondary\"`.",
"isGlobal": false
},
{
"key": "disabled",
"className": "Mui-disabled",
Expand Down Expand Up @@ -105,13 +117,15 @@
"key": "outlinedPrimary",
"className": "MuiPaginationItem-outlinedPrimary",
"description": "Styles applied to the root element if `variant=\"outlined\"` and `color=\"primary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "outlinedSecondary",
"className": "MuiPaginationItem-outlinedSecondary",
"description": "Styles applied to the root element if `variant=\"outlined\"` and `color=\"secondary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "page",
Expand Down Expand Up @@ -165,13 +179,15 @@
"key": "textPrimary",
"className": "MuiPaginationItem-textPrimary",
"description": "Styles applied to the root element if `variant=\"text\"` and `color=\"primary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "textSecondary",
"className": "MuiPaginationItem-textSecondary",
"description": "Styles applied to the root element if `variant=\"text\"` and `color=\"secondary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
}
],
"spread": true,
Expand Down
22 changes: 18 additions & 4 deletions docs/translations/api-docs/pagination-item/pagination-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
"variant": { "description": "The variant to use." }
},
"classDescriptions": {
"colorPrimary": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"primary\"</code>"
},
"colorSecondary": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"secondary\"</code>"
},
"disabled": {
"description": "State class applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
Expand Down Expand Up @@ -55,12 +65,14 @@
"outlinedPrimary": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>variant=\"outlined\"</code> and <code>color=\"primary\"</code>"
"conditions": "<code>variant=\"outlined\"</code> and <code>color=\"primary\"</code>",
"deprecationInfo": "Combine the <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-outlined\">.MuiPaginationItem-outlined</a> and <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-colorPrimary\">.MuiPaginationItem-colorPrimary</a> classes instead."
},
"outlinedSecondary": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>variant=\"outlined\"</code> and <code>color=\"secondary\"</code>"
"conditions": "<code>variant=\"outlined\"</code> and <code>color=\"secondary\"</code>",
"deprecationInfo": "Combine the <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-outlined\">.MuiPaginationItem-outlined</a> and <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-colorSecondary\">.MuiPaginationItem-colorSecondary</a> classes instead."
},
"page": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
Expand Down Expand Up @@ -101,12 +113,14 @@
"textPrimary": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>variant=\"text\"</code> and <code>color=\"primary\"</code>"
"conditions": "<code>variant=\"text\"</code> and <code>color=\"primary\"</code>",
"deprecationInfo": "Combine the <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-text\">.MuiPaginationItem-text</a> and <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-colorPrimary\">.MuiPaginationItem-colorPrimary</a> classes instead."
},
"textSecondary": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>variant=\"text\"</code> and <code>color=\"secondary\"</code>"
"conditions": "<code>variant=\"text\"</code> and <code>color=\"secondary\"</code>",
"deprecationInfo": "Combine the <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-text\">.MuiPaginationItem-text</a> and <a href=\"/material-ui/api/pagination-item/#pagination-item-classes-colorSecondary\">.MuiPaginationItem-colorSecondary</a> classes instead."
}
}
}
1 change: 1 addition & 0 deletions packages/mui-material/src/PaginationItem/PaginationItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const useUtilityClasses = (ownerState) => {
`size${capitalize(size)}`,
variant,
shape,
['primary', 'secondary'].includes(color) && `color${capitalize(color)}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do

Suggested change
['primary', 'secondary'].includes(color) && `color${capitalize(color)}`,
color !== 'standard' && `color${capitalize(color)}`,

As the logic is "add a color* class for all color values except the default"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it!! fixed in this commit 84f7045

color !== 'standard' && `${variant}${capitalize(color)}`,
disabled && 'disabled',
selected && 'selected',
Expand Down
12 changes: 12 additions & 0 deletions packages/mui-material/src/PaginationItem/PaginationItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ describe('<PaginationItem />', () => {
expect(getByRole('button')).to.have.class(classes.selected);
});

it('should add the `colorPrimary` class to the root element if `color="primary"`', () => {
const { getByRole } = render(<PaginationItem color="primary" />);

expect(getByRole('button')).to.have.class(classes.colorPrimary);
});

it('should add the `colorSecondary` class to the root element if `color="secondary"`', () => {
const { getByRole } = render(<PaginationItem color="secondary" />);

expect(getByRole('button')).to.have.class(classes.colorSecondary);
});

describe('prop: disabled', () => {
it('should add the `disabled` class to the root element if `disabled={true}`', () => {
const { getByRole } = render(<PaginationItem disabled />);
Expand Down
26 changes: 22 additions & 4 deletions packages/mui-material/src/PaginationItem/paginationItemClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ export interface PaginationItemClasses {
sizeLarge: string;
/** Styles applied to the root element if `variant="text"`. */
text: string;
/** Styles applied to the root element if `variant="text"` and `color="primary"`. */
/** Styles applied to the root element if `variant="text"` and `color="primary"`.
* @deprecated Combine the [.MuiPaginationItem-text](/material-ui/api/pagination-item/#pagination-item-classes-text)
* and [.MuiPaginationItem-colorPrimary](/material-ui/api/pagination-item/#pagination-item-classes-colorPrimary) classes instead.
*/
textPrimary: string;
/** Styles applied to the root element if `variant="text"` and `color="secondary"`. */
/** Styles applied to the root element if `variant="text"` and `color="secondary"`.
* @deprecated Combine the [.MuiPaginationItem-text](/material-ui/api/pagination-item/#pagination-item-classes-text)
* and [.MuiPaginationItem-colorSecondary](/material-ui/api/pagination-item/#pagination-item-classes-colorSecondary) classes instead.
*/
textSecondary: string;
/** Styles applied to the root element if `variant="outlined"`. */
outlined: string;
/** Styles applied to the root element if `variant="outlined"` and `color="primary"`. */
/** Styles applied to the root element if `variant="outlined"` and `color="primary"`.
* @deprecated Combine the [.MuiPaginationItem-outlined](/material-ui/api/pagination-item/#pagination-item-classes-outlined)
* and [.MuiPaginationItem-colorPrimary](/material-ui/api/pagination-item/#pagination-item-classes-colorPrimary) classes instead.
*/
outlinedPrimary: string;
/** Styles applied to the root element if `variant="outlined"` and `color="secondary"`. */
/** Styles applied to the root element if `variant="outlined"` and `color="secondary"`.
* @deprecated Combine the [.MuiPaginationItem-outlined](/material-ui/api/pagination-item/#pagination-item-classes-outlined)
* and [.MuiPaginationItem-colorSecondary](/material-ui/api/pagination-item/#pagination-item-classes-colorSecondary) classes instead.
*/
outlinedSecondary: string;
/** Styles applied to the root element if `rounded="true"`. */
rounded: string;
Expand All @@ -38,6 +50,10 @@ export interface PaginationItemClasses {
selected: string;
/** Styles applied to the icon to display. */
icon: string;
/** Styles applied to the root element if `color="primary"`. */
colorPrimary: string;
/** Styles applied to the root element if `color="secondary"`. */
colorSecondary: string;
}

export type PaginationItemClassKey = keyof PaginationItemClasses;
Expand Down Expand Up @@ -65,6 +81,8 @@ const paginationItemClasses: PaginationItemClasses = generateUtilityClasses('Mui
'disabled',
'selected',
'icon',
'colorPrimary',
'colorSecondary',
]);

export default paginationItemClasses;
Loading