Skip to content

Commit

Permalink
add breakpoint value support to maxWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
ansh-saini committed Jun 27, 2021
1 parent 45950ec commit 2c28a6d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/material-ui-system/src/sizing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import style from './style';
import compose from './compose';
import { handleBreakpoints } from './breakpoints';

function transform(value) {
return value <= 1 ? `${value * 100}%` : value;
Expand All @@ -10,10 +11,19 @@ export const width = style({
transform,
});

export const maxWidth = style({
prop: 'maxWidth',
transform,
});
export const maxWidth = (props) => {
if (props.maxWidth) {
const styleFromPropValue = (propValue) => {
const breakpoint = props.theme.breakpoints.values[propValue];
return {
maxWidth: breakpoint || transform(propValue),
};
};
return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
}
return null;
};
maxWidth.filterProps = ['maxWidth'];

export const minWidth = style({
prop: 'minWidth',
Expand Down

0 comments on commit 2c28a6d

Please sign in to comment.