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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | 1x 17x 17x 1x 1x | import {forwardRef} from 'react'
import PropTypes from 'prop-types'
import ColorPanel from './ColorPanel.js'
import {
ALPHA,
BORDER_RADIUS,
COLORS,
ELEVATION,
DEFAULT_ELEVATION,
DEFAULT_BORDER_RADIUS,
HORIZONTAL_ALIGNMENTS,
VERTICAL_ALIGNMENTS,
isImagePanel
} from './settings.js'
import ImagePanel from './ImagePanel.js'
const AtomPanel = forwardRef(
(
{
alpha,
color,
elevation = DEFAULT_ELEVATION,
horizontalAlign,
verticalAlign,
rounded = DEFAULT_BORDER_RADIUS,
src,
className,
...props
},
forwardedRef
) => {
const [Component, componentProps] = isImagePanel({src})
? [ImagePanel, {src, horizontalAlign, verticalAlign}]
: [ColorPanel, {alpha}]
return (
<Component
ref={forwardedRef}
className={className}
color={color}
elevation={elevation}
rounded={rounded}
{...componentProps}
{...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,
/**
* Additional classes
*/
className: PropTypes.string
}
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
}
|