vcc-ui
Version:
VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.
48 lines (43 loc) • 970 B
JavaScript
import PropTypes from "prop-types";
import React from "react";
import { useFela } from "react-fela";
const style = {
display: "block"
};
export function Block({
children,
className,
innerRef,
as: As = "div",
extend,
...props
}) {
const { css } = useFela(props);
return (
<As
{...props}
ref={innerRef}
className={css(style, extend) + (className ? " " + className : "")}
>
{children}
</As>
);
}
Block.propTypes = {
/** Any valid React element, function, or a string specifying a name for an HTML element */
as: PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
PropTypes.func
]),
/** An object containing valid CSS style declarations */
extend: PropTypes.oneOfType([
PropTypes.object,
PropTypes.func,
PropTypes.array
]),
/** A JSX node */
children: PropTypes.node,
/** React DOM ref object or fn to be passed through to the DOM element **/
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
};