UNPKG

@mui/system

Version:

MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.

68 lines (67 loc) 1.9 kB
import style from "../style/index.mjs"; import compose from "../compose/index.mjs"; import { handleBreakpoints } from "../breakpoints/index.mjs"; import * as breakpointsModule from "../breakpoints/index.mjs"; const breakpointsValues = breakpointsModule.values; /** @internal */ export function sizingTransform(value) { return value <= 1 && value !== 0 ? `${value * 100}%` : value; } export const width = style({ prop: 'width', transform: sizingTransform }); export const maxWidth = props => { if (props.maxWidth !== undefined && props.maxWidth !== null) { const styleFromPropValue = propValue => { const breakpoint = props.theme?.breakpoints?.values?.[propValue] || breakpointsValues[propValue]; if (!breakpoint) { return { maxWidth: sizingTransform(propValue) }; } if (props.theme?.breakpoints?.unit !== 'px') { return { maxWidth: `${breakpoint}${props.theme.breakpoints.unit}` }; } return { maxWidth: breakpoint }; }; return handleBreakpoints(props, props.maxWidth, styleFromPropValue); } return null; }; maxWidth.filterProps = ['maxWidth']; export const minWidth = style({ prop: 'minWidth', transform: sizingTransform }); export const height = style({ prop: 'height', transform: sizingTransform }); export const maxHeight = style({ prop: 'maxHeight', transform: sizingTransform }); export const minHeight = style({ prop: 'minHeight', transform: sizingTransform }); export const sizeWidth = style({ prop: 'size', cssProperty: 'width', transform: sizingTransform }); export const sizeHeight = style({ prop: 'size', cssProperty: 'height', transform: sizingTransform }); export const boxSizing = style({ prop: 'boxSizing' }); const sizing = compose(width, maxWidth, minWidth, height, maxHeight, minHeight, boxSizing); export default sizing;