vcc-ui
Version:
A React library for building user interfaces at Volvo Cars
43 lines (42 loc) • 1.47 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import PropTypes from 'prop-types';
import React from 'react';
import { useFela } from 'react-fela';
const style = {
display: 'flex',
flexDirection: 'column',
flexGrow: 0,
flexShrink: 1,
flexBasis: 'auto',
alignSelf: 'stretch'
};
/**
* @deprecated This component is deprecated and can be recreated using CSS only. See [Flex](https://developer.volvocars.com/design-system/web/?path=/docs/layout-flex--docs)
*/
export const Flex = /*#__PURE__*/React.forwardRef((_ref, ref) => {
let {
children,
className,
as: As = 'div',
extend,
...props
} = _ref;
const {
css
} = useFela(props);
return /*#__PURE__*/React.createElement(As, _extends({}, props, {
ref: ref,
className: css(style, extend) + (className ? ' ' + className : '')
}), children);
});
Flex.displayName = 'Flex';
Flex.propTypes = {
/** Any valid React element, function, or a string specifying a name for an HTML element */
as: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.elementType, PropTypes.func]),
/** An object containing valid CSS style declarations */
extend: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.array]),
/** A JSX node */
children: PropTypes.node,
/** Add an additional custom className to element. Warning: make sure it doesn't collide with the classNames being generated for the atomic CSS **/
className: PropTypes.string
};