Basic navs and auth pages working·
This commit is contained in:
parent
33e8a9f384
commit
3ef6f3c80b
20 changed files with 222 additions and 33 deletions
111
imports/ui/components/Col/Col.js
Normal file
111
imports/ui/components/Col/Col.js
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import classNames from 'classnames';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import elementType from 'prop-types-extra/lib/elementType';
|
||||
|
||||
import { bsClass, prefix, splitBsProps } from 'react-bootstrap/lib/utils/bootstrapUtils';
|
||||
import { DEVICE_SIZES } from 'react-bootstrap/lib/utils/StyleConfig';
|
||||
|
||||
const column = PropTypes.oneOfType([
|
||||
PropTypes.oneOf(['auto']),
|
||||
PropTypes.number,
|
||||
]);
|
||||
|
||||
const propTypes = {
|
||||
componentClass: elementType,
|
||||
|
||||
/**
|
||||
* The number of columns you wish to span
|
||||
*
|
||||
* for Extra small devices Phones (<576px)
|
||||
*
|
||||
* class-prefix `col-`
|
||||
*/
|
||||
xs: column,
|
||||
|
||||
/**
|
||||
* The number of columns you wish to span
|
||||
*
|
||||
* for Small devices Tablets (≥576px)
|
||||
*
|
||||
* class-prefix `col-sm-`
|
||||
*/
|
||||
sm: column,
|
||||
|
||||
/**
|
||||
* The number of columns you wish to span
|
||||
*
|
||||
* for Medium devices Desktops (≥768px)
|
||||
*
|
||||
* class-prefix `col-md-`
|
||||
*/
|
||||
md: column,
|
||||
|
||||
/**
|
||||
* The number of columns you wish to span
|
||||
*
|
||||
* for Large devices Desktops (≥992px)
|
||||
*
|
||||
* class-prefix `col-lg-`
|
||||
*/
|
||||
lg: column,
|
||||
|
||||
/**
|
||||
* The number of columns you wish to span
|
||||
*
|
||||
* for Large devices Desktops (≥1200px)
|
||||
*
|
||||
* class-prefix `col-xl-`
|
||||
*/
|
||||
xl: column,
|
||||
};
|
||||
|
||||
const defaultProps = {
|
||||
componentClass: 'div',
|
||||
};
|
||||
|
||||
class Col extends React.Component {
|
||||
render() {
|
||||
const { componentClass: Component, className, ...props } = this.props;
|
||||
const [bsProps, elementProps] = splitBsProps(props);
|
||||
|
||||
const classes = [];
|
||||
|
||||
DEVICE_SIZES.forEach((size) => {
|
||||
const propValue = elementProps[size];
|
||||
|
||||
if (propValue == null) return;
|
||||
|
||||
if (size === 'xs') {
|
||||
// col and col-4
|
||||
classes.push(propValue === true ?
|
||||
bsProps.bsClass :
|
||||
prefix(bsProps, `${propValue}`),
|
||||
);
|
||||
} else {
|
||||
// col-md-3
|
||||
classes.push(
|
||||
prefix(bsProps, `${size}-${propValue}`),
|
||||
);
|
||||
}
|
||||
|
||||
delete elementProps[size];
|
||||
});
|
||||
|
||||
if (!classes.length) {
|
||||
classes.push(bsProps.bsClass); // plain 'col'
|
||||
}
|
||||
|
||||
return (
|
||||
<Component
|
||||
{...elementProps}
|
||||
className={classNames(className, classes)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Col.propTypes = propTypes;
|
||||
Col.defaultProps = defaultProps;
|
||||
|
||||
export default bsClass('col', Col);
|
||||
Loading…
Add table
Add a link
Reference in a new issue