xylabs/sdk-react

View on GitHub
packages/shared/src/calcSpacing.ts

Summary

Maintainability
A
35 mins
Test Coverage
import { BoxProps, Theme } from '@mui/material'

export const calcSpacing = (theme: Theme, values: BoxProps['margin'][]) => {
  for (const value of values) {
    if (value !== undefined) {
      if (typeof value === 'string') {
        return value
      } else if (typeof value === 'number') {
        return theme.spacing(value)
      }
    }
  }
}