Skip to content

Commit

Permalink
Cater for mb shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongarciah committed Jul 22, 2024
1 parent 50bb4a7 commit e0cc8c7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ import { Typography as MyTypography } from '@mui/material';
<MyTypography paragraph={paragraph} className="my-class" />;
<Typography paragraph sx={{ marginBottom: "32px" }} />;
<MyTypography paragraph sx={{ marginBottom: "32px" }} />;
<Typography paragraph sx={{ mb: "32px" }} />;
<MyTypography paragraph sx={{ mb: "32px" }} />;
<Typography paragraph sx={{ color: "black" }} />;
<MyTypography paragraph sx={{ color: "black" }} />;
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { Typography as MyTypography } from '@mui/material';
}} />;
<Typography sx={{ marginBottom: "32px" }} />;
<MyTypography sx={{ marginBottom: "32px" }} />;
<Typography sx={{ mb: "32px" }} />;
<MyTypography sx={{ mb: "32px" }} />;
<Typography
sx={{
color: "black",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ fn({
},
},
});
fn({
MuiTypography: {
defaultProps: {
paragraph,
className: "my-class",
sx: {
mb: "32px",
},
},
},
});
fn({
MuiTypography: {
defaultProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ fn({
defaultProps: {
className: "my-class",

sx: {
mb: "32px",
}
},
},
});
fn({
MuiTypography: {
defaultProps: {
className: "my-class",

sx: {
color: "black",
marginBottom: "16px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export default function transformer(file, api, options) {
} else {
const hasMarginBottom = elementPath.node.openingElement.attributes[
sxIndex
].value.expression.properties.some((key) => key.key.name === 'marginBottom');
].value.expression.properties.some(
(key) => key.key.name === 'marginBottom' || key.key.name === 'mb',
);

if (!hasMarginBottom) {
assignObject(j, {
Expand Down Expand Up @@ -95,7 +97,7 @@ export default function transformer(file, api, options) {
);
} else {
const hasMarginBottom = defaultPropsObject.value.properties[sxIndex].value.properties.some(
(key) => key.key.name === 'marginBottom',
(key) => key.key.name === 'marginBottom' || key.key.name === 'mb',
);

if (!hasMarginBottom) {
Expand Down

0 comments on commit e0cc8c7

Please sign in to comment.