-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CardHeader] Deprecate
*TypographyProps
and complete slots
, `slot…
…Props` (#44729)
- Loading branch information
1 parent
088bfa8
commit 11b3889
Showing
13 changed files
with
490 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/mui-codemod/src/deprecations/card-header-props/card-header-props.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import movePropIntoSlotProps from '../utils/movePropIntoSlotProps'; | ||
|
||
/** | ||
* @param {import('jscodeshift').FileInfo} file | ||
* @param {import('jscodeshift').API} api | ||
*/ | ||
export default function transformer(file, api, options) { | ||
const j = api.jscodeshift; | ||
const root = j(file.source); | ||
const printOptions = options.printOptions; | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'CardHeader', | ||
propName: 'titleTypographyProps', | ||
slotName: 'title', | ||
}); | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'CardHeader', | ||
propName: 'subheaderTypographyProps', | ||
slotName: 'subheader', | ||
}); | ||
|
||
return root.toSource(printOptions); | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/mui-codemod/src/deprecations/card-header-props/card-header-props.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { describeJscodeshiftTransform } from '../../../testUtils'; | ||
import transform from './card-header-props'; | ||
|
||
describe('@mui/codemod', () => { | ||
describe('deprecations', () => { | ||
describeJscodeshiftTransform({ | ||
transform, | ||
transformName: 'tooltip-props', | ||
dirname: __dirname, | ||
testCases: [{ actual: '/test-cases/actual.js', expected: '/test-cases/expected.js' }], | ||
}); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/mui-codemod/src/deprecations/card-header-props/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './card-header-props'; |
26 changes: 26 additions & 0 deletions
26
packages/mui-codemod/src/deprecations/card-header-props/test-cases/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import CardHeader from '@mui/material/CardHeader'; | ||
import { CardHeader as MyCardHeader } from '@mui/material'; | ||
|
||
<CardHeader | ||
titleTypographyProps={{ variant: 'h6' }} | ||
subheaderTypographyProps={{ variant: 'body2' }} | ||
/>; | ||
<CardHeader | ||
titleTypographyProps={{ variant: 'h6' }} | ||
subheaderTypographyProps={{ variant: 'body2' }} | ||
slotProps={{ title: { variant: 'h1' }, subheader: { variant: 'h2' } }} | ||
/>; | ||
<CardHeader | ||
titleTypographyProps={{ variant: 'h6' }} | ||
subheaderTypographyProps={{ variant: 'body2' }} | ||
slotProps={{ title: { sx: { color: 'red' } }, subheader: { sx: { color: 'red' } } }} | ||
/>; | ||
<MyCardHeader | ||
titleTypographyProps={{ variant: 'h6' }} | ||
subheaderTypographyProps={{ variant: 'body2' }} | ||
/>; | ||
|
||
<CustomCardHeader | ||
titleTypographyProps={{ variant: 'h6' }} | ||
subheaderTypographyProps={{ variant: 'body2' }} | ||
/>; |
34 changes: 34 additions & 0 deletions
34
packages/mui-codemod/src/deprecations/card-header-props/test-cases/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import CardHeader from '@mui/material/CardHeader'; | ||
import { CardHeader as MyCardHeader } from '@mui/material'; | ||
|
||
<CardHeader | ||
slotProps={{ | ||
title: { variant: 'h6' }, | ||
subheader: { variant: 'body2' } | ||
}} />; | ||
<CardHeader | ||
slotProps={{ title: { | ||
...{ variant: 'h6' }, | ||
...{ variant: 'h1' } | ||
}, subheader: { | ||
...{ variant: 'body2' }, | ||
...{ variant: 'h2' } | ||
} }} />; | ||
<CardHeader | ||
slotProps={{ title: { | ||
...{ variant: 'h6' }, | ||
...{ sx: { color: 'red' } } | ||
}, subheader: { | ||
...{ variant: 'body2' }, | ||
...{ sx: { color: 'red' } } | ||
} }} />; | ||
<MyCardHeader | ||
slotProps={{ | ||
title: { variant: 'h6' }, | ||
subheader: { variant: 'body2' } | ||
}} />; | ||
|
||
<CustomCardHeader | ||
titleTypographyProps={{ variant: 'h6' }} | ||
subheaderTypographyProps={{ variant: 'body2' }} | ||
/>; |
Oops, something went wrong.