All files / src/material-toolbox/layout-grid Cell.js

100% Statements 3/3
100% Branches 13/13
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                          37x   37x                     183x                                    
// @flow strict
import React from 'react';
import cx from 'classnames';
 
import type { ElementType } from 'react';
 
type phoneCols = 1 | 2 | 3 | 4;
type tabletCols = phoneCols | 5 | 6 | 7 | 8;
type desktopCols = tabletCols | 9 | 10 | 11 | 12;
 
type Props = {
  align?: 'top' | 'middle' | 'bottom',
  className?: string,
  span?: desktopCols,
  order?: desktopCols,
  phone?: phoneCols,
  tablet?: tabletCols,
  desktop?: desktopCols,
  as?: ElementType,
};
 
const BASE = 'mdc-layout-grid__cell';
 
const Cell = ({
  align,
  className,
  span,
  order,
  phone,
  tablet,
  desktop,
  as: Component = 'div',
  ...rest
}: Props) => (
  <Component
    {...(rest: mixed)}
    className={cx(
      BASE,
      {
        [`${BASE}--span-${span || ''}`]: span,
        [`${BASE}--span-${tablet || ''}-tablet`]: tablet,
        [`${BASE}--span-${phone || ''}-phone`]: phone,
        [`${BASE}--span-${desktop || ''}-desktop`]: desktop,
        [`${BASE}--order-${order || ''}`]: order,
        [`${BASE}--align-${align || ''}`]: align,
      },
      className,
    )}
  />
);
 
export default Cell;