All files / atom/panel/src index.js

100% Statements 4/4
100% Branches 6/6
100% Functions 1/1
100% Lines 4/4

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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91            1x                   13x                             1x   1x                                                                                                                  
import PropTypes from 'prop-types'
 
import ColorPanel from './ColorPanel.js'
import {ALPHA, BORDER_RADIUS, COLORS, ELEVATION, isImagePanel} from './constants.js'
import ImagePanel, {HORIZONTAL_ALIGNMENTS, VERTICAL_ALIGNMENTS} from './ImagePanel.js'
 
const AtomPanel = function ({
  alpha,
  color,
  elevation = ELEVATION.NONE,
  horizontalAlign = HORIZONTAL_ALIGNMENTS.CENTER,
  rounded = BORDER_RADIUS.NONE,
  src,
  verticalAlign = VERTICAL_ALIGNMENTS.CENTER,
  ...props
}) {
  return isImagePanel({src}) ? (
    <ImagePanel
      color={color}
      elevation={elevation}
      horizontalAlign={horizontalAlign}
      rounded={rounded}
      src={src}
      verticalAlign={verticalAlign}
      {...props}
    />
  ) : (
    <ColorPanel alpha={alpha} color={color} elevation={elevation} rounded={rounded} {...props} />
  )
}
 
AtomPanel.displayName = 'AtomPanel'
 
AtomPanel.propTypes = {
  children: PropTypes.node.isRequired,
  /**
   * Background image
   */
  src: PropTypes.string,
  /**
   * Specify the type of alignment vertically
   */
  verticalAlign: PropTypes.oneOf(Object.values(VERTICAL_ALIGNMENTS)),
  /**
   * Specify the type of alignment horizontally
   */
  horizontalAlign: PropTypes.oneOf(Object.values(HORIZONTAL_ALIGNMENTS)),
  /**
   * Specify the border-radius of the panel
   */
  rounded: PropTypes.oneOf(Object.values(BORDER_RADIUS)),
  /**
   * Specify the box-shadow of the panel
   */
  elevation: PropTypes.oneOf(Object.values(ELEVATION)),
  /**
   * Specify the background-color
   */
  color: PropTypes.oneOf(Object.values(COLORS)),
  /**
   * Specify the opacity
   */
  alpha: PropTypes.oneOf(Object.values(ALPHA)),
  /**
   * Specify the HTML tag element or component to render in the DOM.
   */
  as: PropTypes.elementType,
  /**
   * Specify the element id
   */
  id: PropTypes.string,
  /**
   * Sets the element's width to 100%
   */
  isFullWidth: PropTypes.bool,
  /**
   * Sets the element's height to 100%
   */
  isFullHeight: PropTypes.bool
}
 
export default AtomPanel
export {
  HORIZONTAL_ALIGNMENTS as atomPanelHorizontalAlign,
  VERTICAL_ALIGNMENTS as atomPanelVerticalAlign,
  COLORS as atomPanelColors,
  ALPHA as atomPanelAlpha,
  BORDER_RADIUS as atomPanelRounded,
  ELEVATION as atomPanelElevation
}