Created
September 10, 2019 14:06
-
-
Save DWboutin/867ff43e42be691ed472d0f5df364973 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import PropTypes from 'prop-types' | |
import classNames from 'classnames' | |
import omit from 'omit.js' | |
class Col extends React.Component { | |
colClasses(col, size) { | |
const classes = {} | |
classes[`col-${size}-${col.span}`] = col.span | |
classes[`col-${size}-offset-${col.offset}`] = col.offset | |
classes[`first-${size}`] = col.first | |
classes[`last-${size}`] = col.last | |
classes[`start-${size}`] = col.start | |
classes[`center-${size}`] = col.center | |
classes[`end-${size}`] = col.end | |
classes[`top-${size}`] = col.top | |
classes[`middle-${size}`] = col.middle | |
classes[`bottom-${size}`] = col.bottom | |
classes[`around-${size}`] = col.around | |
classes[`between-${size}`] = col.between | |
classes[`hidden-${size}`] = col.hidden | |
return classes | |
} | |
buildClasses() { | |
const { | |
className, | |
fullHeight, | |
alignMiddle, | |
reverse, | |
xs, | |
sm, | |
md, | |
lg, | |
xl, | |
} = this.props | |
const xsProps = typeof xs === 'object' ? this.colClasses(xs, 'xs') : {} | |
const smProps = typeof sm === 'object' ? this.colClasses(sm, 'sm') : {} | |
const mdProps = typeof md === 'object' ? this.colClasses(md, 'md') : {} | |
const lgProps = typeof lg === 'object' ? this.colClasses(lg, 'lg') : {} | |
const xlProps = typeof xl === 'object' ? this.colClasses(xl, 'xl') : {} | |
const classes = classNames({ | |
col: true, | |
'col-xs': !xs, | |
'full-height': fullHeight, | |
'align-middle': alignMiddle, | |
reverse: reverse, | |
...xsProps, | |
...smProps, | |
...mdProps, | |
...lgProps, | |
...xlProps, | |
[`${className}`]: className, | |
}) | |
return classes | |
} | |
render() { | |
const { children } = this.props | |
const classes = this.buildClasses() | |
const componentProps = omit(this.props, [ | |
'children', | |
'className', | |
'fullHeight', | |
'alignMiddle', | |
'reverse', | |
'xs', | |
'sm', | |
'md', | |
'lg', | |
'xl', | |
]) | |
return ( | |
<div className={classes} {...componentProps}> | |
{children} | |
</div> | |
) | |
} | |
} | |
const sizePropTypes = PropTypes.shape({ | |
span: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | |
offset: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | |
first: PropTypes.bool, | |
last: PropTypes.bool, | |
start: PropTypes.bool, | |
center: PropTypes.bool, | |
end: PropTypes.bool, | |
top: PropTypes.bool, | |
middle: PropTypes.bool, | |
bottom: PropTypes.bool, | |
around: PropTypes.bool, | |
between: PropTypes.bool, | |
hidden: PropTypes.bool, | |
}) | |
Col.defaultProps = { | |
fullHeight: false, | |
alignMiddle: false, | |
reverse: false, | |
} | |
Col.propTypes = { | |
children: PropTypes.node.isRequired, | |
className: PropTypes.string, | |
fullHeight: PropTypes.bool, | |
alignMiddle: PropTypes.bool, | |
reverse: PropTypes.bool, | |
xs: sizePropTypes, | |
sm: sizePropTypes, | |
md: sizePropTypes, | |
lg: sizePropTypes, | |
xl: sizePropTypes, | |
} | |
export default Col |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BASED ON http://flexboxgrid.com/ | |
@import '../_base/variables'; | |
@import '../_base/functions'; | |
.to-grid{ | |
&.container-full-height { | |
height: 100%; | |
.row { | |
height: 100%; | |
} | |
} | |
&.container-fluid, | |
&.container { | |
margin-right: auto; | |
margin-left: auto; | |
padding-right: sizeToRem(20); | |
padding-left: sizeToRem(20); | |
} | |
&.container-fluid { | |
padding-right: sizeToRem(20); | |
padding-left: sizeToRem(20); | |
} | |
.row { | |
box-sizing: border-box; | |
display: -webkit-box; | |
display: -ms-flexbox; | |
display: flex; | |
-webkit-box-flex: 0; | |
-ms-flex: 0 1 auto; | |
flex: 0 1 auto; | |
-webkit-box-orient: horizontal; | |
-webkit-box-direction: normal; | |
-ms-flex-direction: row; | |
flex-direction: row; | |
-ms-flex-wrap: wrap; | |
flex-wrap: wrap; | |
margin-right: sizeToRem(-20); | |
margin-left: sizeToRem(-20); | |
} | |
.row.reverse { | |
-webkit-box-orient: horizontal; | |
-webkit-box-direction: reverse; | |
-ms-flex-direction: row-reverse; | |
flex-direction: row-reverse; | |
} | |
[class^="col"].full-height { | |
height: 100%; | |
} | |
[class*="col"].align-middle { | |
display: flex; | |
position: relative; | |
align-items: center; | |
} | |
.col.reverse { | |
-webkit-box-orient: vertical; | |
-webkit-box-direction: reverse; | |
-ms-flex-direction: column-reverse; | |
flex-direction: column-reverse; | |
} | |
.col-xs, | |
.col-xs-1, | |
.col-xs-2, | |
.col-xs-3, | |
.col-xs-4, | |
.col-xs-5, | |
.col-xs-6, | |
.col-xs-7, | |
.col-xs-8, | |
.col-xs-9, | |
.col-xs-10, | |
.col-xs-11, | |
.col-xs-12, | |
.col-xs-offset-0, | |
.col-xs-offset-1, | |
.col-xs-offset-2, | |
.col-xs-offset-3, | |
.col-xs-offset-4, | |
.col-xs-offset-5, | |
.col-xs-offset-6, | |
.col-xs-offset-7, | |
.col-xs-offset-8, | |
.col-xs-offset-9, | |
.col-xs-offset-10, | |
.col-xs-offset-11, | |
.col-xs-offset-12 { | |
box-sizing: border-box; | |
-webkit-box-flex: 0; | |
-ms-flex: 0 0 auto; | |
flex: 0 0 auto; | |
padding-right: sizeToRem(20); | |
padding-left: sizeToRem(20); | |
} | |
.col-xs { | |
-webkit-box-flex: 1; | |
-ms-flex-positive: 1; | |
flex-grow: 1; | |
-ms-flex-preferred-size: 0; | |
flex-basis: 0; | |
max-width: 100%; | |
} | |
.col-xs-1 { | |
-ms-flex-preferred-size: 8.33333333%; | |
flex-basis: 8.33333333%; | |
max-width: 8.33333333%; | |
} | |
.col-xs-2 { | |
-ms-flex-preferred-size: 16.66666667%; | |
flex-basis: 16.66666667%; | |
max-width: 16.66666667%; | |
} | |
.col-xs-3 { | |
-ms-flex-preferred-size: 25%; | |
flex-basis: 25%; | |
max-width: 25%; | |
} | |
.col-xs-4 { | |
-ms-flex-preferred-size: 33.33333333%; | |
flex-basis: 33.33333333%; | |
max-width: 33.33333333%; | |
} | |
.col-xs-5 { | |
-ms-flex-preferred-size: 41.66666667%; | |
flex-basis: 41.66666667%; | |
max-width: 41.66666667%; | |
} | |
.col-xs-6 { | |
-ms-flex-preferred-size: 50%; | |
flex-basis: 50%; | |
max-width: 50%; | |
} | |
.col-xs-7 { | |
-ms-flex-preferred-size: 58.33333333%; | |
flex-basis: 58.33333333%; | |
max-width: 58.33333333%; | |
} | |
.col-xs-8 { | |
-ms-flex-preferred-size: 66.66666667%; | |
flex-basis: 66.66666667%; | |
max-width: 66.66666667%; | |
} | |
.col-xs-9 { | |
-ms-flex-preferred-size: 75%; | |
flex-basis: 75%; | |
max-width: 75%; | |
} | |
.col-xs-10 { | |
-ms-flex-preferred-size: 83.33333333%; | |
flex-basis: 83.33333333%; | |
max-width: 83.33333333%; | |
} | |
.col-xs-11 { | |
-ms-flex-preferred-size: 91.66666667%; | |
flex-basis: 91.66666667%; | |
max-width: 91.66666667%; | |
} | |
.col-xs-12 { | |
-ms-flex-preferred-size: 100%; | |
flex-basis: 100%; | |
max-width: 100%; | |
} | |
.col-xs-offset-0 { | |
margin-left: 0; | |
} | |
.col-xs-offset-1 { | |
margin-left: 8.33333333%; | |
} | |
.col-xs-offset-2 { | |
margin-left: 16.66666667%; | |
} | |
.col-xs-offset-3 { | |
margin-left: 25%; | |
} | |
.col-xs-offset-4 { | |
margin-left: 33.33333333%; | |
} | |
.col-xs-offset-5 { | |
margin-left: 41.66666667%; | |
} | |
.col-xs-offset-6 { | |
margin-left: 50%; | |
} | |
.col-xs-offset-7 { | |
margin-left: 58.33333333%; | |
} | |
.col-xs-offset-8 { | |
margin-left: 66.66666667%; | |
} | |
.col-xs-offset-9 { | |
margin-left: 75%; | |
} | |
.col-xs-offset-10 { | |
margin-left: 83.33333333%; | |
} | |
.col-xs-offset-11 { | |
margin-left: 91.66666667%; | |
} | |
.start-xs { | |
-webkit-box-pack: start; | |
-ms-flex-pack: start; | |
justify-content: flex-start; | |
text-align: start; | |
} | |
.center-xs { | |
-webkit-box-pack: center; | |
-ms-flex-pack: center; | |
justify-content: center; | |
} | |
.end-xs { | |
-webkit-box-pack: end; | |
-ms-flex-pack: end; | |
justify-content: flex-end; | |
text-align: end; | |
} | |
.top-xs { | |
-webkit-box-align: start; | |
-ms-flex-align: start; | |
align-items: flex-start; | |
} | |
.middle-xs { | |
-webkit-box-align: center; | |
-ms-flex-align: center; | |
align-items: center; | |
} | |
.bottom-xs { | |
-webkit-box-align: end; | |
-ms-flex-align: end; | |
align-items: flex-end; | |
} | |
.around-xs { | |
-ms-flex-pack: distribute; | |
justify-content: space-around; | |
} | |
.between-xs { | |
-webkit-box-pack: justify; | |
-ms-flex-pack: justify; | |
justify-content: space-between; | |
} | |
.first-xs { | |
-webkit-box-ordinal-group: 0; | |
-ms-flex-order: -1; | |
order: -1; | |
} | |
.last-xs { | |
-webkit-box-ordinal-group: 2; | |
-ms-flex-order: 1; | |
order: 1; | |
} | |
} | |
@media (max-width: $screen-sm) { | |
.to-grid{ | |
.hidden-xs { | |
display: none !important; | |
} | |
} | |
} | |
@media (min-width: $screen-sm) and (max-width: $screen-md - 1) { | |
.to-grid{ | |
&.container { | |
max-width: 100%; | |
} | |
.col-sm, | |
.col-sm-1, | |
.col-sm-2, | |
.col-sm-3, | |
.col-sm-4, | |
.col-sm-5, | |
.col-sm-6, | |
.col-sm-7, | |
.col-sm-8, | |
.col-sm-9, | |
.col-sm-10, | |
.col-sm-11, | |
.col-sm-12, | |
.col-sm-offset-0, | |
.col-sm-offset-1, | |
.col-sm-offset-2, | |
.col-sm-offset-3, | |
.col-sm-offset-4, | |
.col-sm-offset-5, | |
.col-sm-offset-6, | |
.col-sm-offset-7, | |
.col-sm-offset-8, | |
.col-sm-offset-9, | |
.col-sm-offset-10, | |
.col-sm-offset-11, | |
.col-sm-offset-12 { | |
box-sizing: border-box; | |
-webkit-box-flex: 0; | |
-ms-flex: 0 0 auto; | |
flex: 0 0 auto; | |
padding-right: sizeToRem(20); | |
padding-left: sizeToRem(20); | |
} | |
.col-sm { | |
-webkit-box-flex: 1; | |
-ms-flex-positive: 1; | |
flex-grow: 1; | |
-ms-flex-preferred-size: 0; | |
flex-basis: 0; | |
max-width: 100%; | |
} | |
.col-sm-1 { | |
-ms-flex-preferred-size: 8.33333333%; | |
flex-basis: 8.33333333%; | |
max-width: 8.33333333%; | |
} | |
.col-sm-2 { | |
-ms-flex-preferred-size: 16.66666667%; | |
flex-basis: 16.66666667%; | |
max-width: 16.66666667%; | |
} | |
.col-sm-3 { | |
-ms-flex-preferred-size: 25%; | |
flex-basis: 25%; | |
max-width: 25%; | |
} | |
.col-sm-4 { | |
-ms-flex-preferred-size: 33.33333333%; | |
flex-basis: 33.33333333%; | |
max-width: 33.33333333%; | |
} | |
.col-sm-5 { | |
-ms-flex-preferred-size: 41.66666667%; | |
flex-basis: 41.66666667%; | |
max-width: 41.66666667%; | |
} | |
.col-sm-6 { | |
-ms-flex-preferred-size: 50%; | |
flex-basis: 50%; | |
max-width: 50%; | |
} | |
.col-sm-7 { | |
-ms-flex-preferred-size: 58.33333333%; | |
flex-basis: 58.33333333%; | |
max-width: 58.33333333%; | |
} | |
.col-sm-8 { | |
-ms-flex-preferred-size: 66.66666667%; | |
flex-basis: 66.66666667%; | |
max-width: 66.66666667%; | |
} | |
.col-sm-9 { | |
-ms-flex-preferred-size: 75%; | |
flex-basis: 75%; | |
max-width: 75%; | |
} | |
.col-sm-10 { | |
-ms-flex-preferred-size: 83.33333333%; | |
flex-basis: 83.33333333%; | |
max-width: 83.33333333%; | |
} | |
.col-sm-11 { | |
-ms-flex-preferred-size: 91.66666667%; | |
flex-basis: 91.66666667%; | |
max-width: 91.66666667%; | |
} | |
.col-sm-12 { | |
-ms-flex-preferred-size: 100%; | |
flex-basis: 100%; | |
max-width: 100%; | |
} | |
.col-sm-offset-0 { | |
margin-left: 0; | |
} | |
.col-sm-offset-1 { | |
margin-left: 8.33333333%; | |
} | |
.col-sm-offset-2 { | |
margin-left: 16.66666667%; | |
} | |
.col-sm-offset-3 { | |
margin-left: 25%; | |
} | |
.col-sm-offset-4 { | |
margin-left: 33.33333333%; | |
} | |
.col-sm-offset-5 { | |
margin-left: 41.66666667%; | |
} | |
.col-sm-offset-6 { | |
margin-left: 50%; | |
} | |
.col-sm-offset-7 { | |
margin-left: 58.33333333%; | |
} | |
.col-sm-offset-8 { | |
margin-left: 66.66666667%; | |
} | |
.col-sm-offset-9 { | |
margin-left: 75%; | |
} | |
.col-sm-offset-10 { | |
margin-left: 83.33333333%; | |
} | |
.col-sm-offset-11 { | |
margin-left: 91.66666667%; | |
} | |
.start-sm { | |
-webkit-box-pack: start; | |
-ms-flex-pack: start; | |
justify-content: flex-start; | |
text-align: start; | |
} | |
.center-sm { | |
-webkit-box-pack: center; | |
-ms-flex-pack: center; | |
justify-content: center; | |
} | |
.end-sm { | |
-webkit-box-pack: end; | |
-ms-flex-pack: end; | |
justify-content: flex-end; | |
text-align: end; | |
} | |
.top-sm { | |
-webkit-box-align: start; | |
-ms-flex-align: start; | |
align-items: flex-start; | |
} | |
.middle-sm { | |
-webkit-box-align: center; | |
-ms-flex-align: center; | |
align-items: center; | |
} | |
.bottom-sm { | |
-webkit-box-align: end; | |
-ms-flex-align: end; | |
align-items: flex-end; | |
} | |
.around-sm { | |
-ms-flex-pack: distribute; | |
justify-content: space-around; | |
} | |
.between-sm { | |
-webkit-box-pack: justify; | |
-ms-flex-pack: justify; | |
justify-content: space-between; | |
} | |
.first-sm { | |
-webkit-box-ordinal-group: 0; | |
-ms-flex-order: -1; | |
order: -1; | |
} | |
.last-sm { | |
-webkit-box-ordinal-group: 2; | |
-ms-flex-order: 1; | |
order: 1; | |
} | |
.hidden-sm { | |
display: none !important; | |
} | |
} | |
} | |
@media (min-width: $screen-md) and (max-width: $screen-lg - 1) { | |
.to-grid{ | |
&.container { | |
max-width: 100%; | |
} | |
.col-md, | |
.col-md-1, | |
.col-md-2, | |
.col-md-3, | |
.col-md-4, | |
.col-md-5, | |
.col-md-6, | |
.col-md-7, | |
.col-md-8, | |
.col-md-9, | |
.col-md-10, | |
.col-md-11, | |
.col-md-12, | |
.col-md-offset-0, | |
.col-md-offset-1, | |
.col-md-offset-2, | |
.col-md-offset-3, | |
.col-md-offset-4, | |
.col-md-offset-5, | |
.col-md-offset-6, | |
.col-md-offset-7, | |
.col-md-offset-8, | |
.col-md-offset-9, | |
.col-md-offset-10, | |
.col-md-offset-11, | |
.col-md-offset-12 { | |
box-sizing: border-box; | |
-webkit-box-flex: 0; | |
-ms-flex: 0 0 auto; | |
flex: 0 0 auto; | |
padding-right: sizeToRem(20); | |
padding-left: sizeToRem(20); | |
} | |
.col-md { | |
-webkit-box-flex: 1; | |
-ms-flex-positive: 1; | |
flex-grow: 1; | |
-ms-flex-preferred-size: 0; | |
flex-basis: 0; | |
max-width: 100%; | |
} | |
.col-md-1 { | |
-ms-flex-preferred-size: 8.33333333%; | |
flex-basis: 8.33333333%; | |
max-width: 8.33333333%; | |
} | |
.col-md-2 { | |
-ms-flex-preferred-size: 16.66666667%; | |
flex-basis: 16.66666667%; | |
max-width: 16.66666667%; | |
} | |
.col-md-3 { | |
-ms-flex-preferred-size: 25%; | |
flex-basis: 25%; | |
max-width: 25%; | |
} | |
.col-md-4 { | |
-ms-flex-preferred-size: 33.33333333%; | |
flex-basis: 33.33333333%; | |
max-width: 33.33333333%; | |
} | |
.col-md-5 { | |
-ms-flex-preferred-size: 41.66666667%; | |
flex-basis: 41.66666667%; | |
max-width: 41.66666667%; | |
} | |
.col-md-6 { | |
-ms-flex-preferred-size: 50%; | |
flex-basis: 50%; | |
max-width: 50%; | |
} | |
.col-md-7 { | |
-ms-flex-preferred-size: 58.33333333%; | |
flex-basis: 58.33333333%; | |
max-width: 58.33333333%; | |
} | |
.col-md-8 { | |
-ms-flex-preferred-size: 66.66666667%; | |
flex-basis: 66.66666667%; | |
max-width: 66.66666667%; | |
} | |
.col-md-9 { | |
-ms-flex-preferred-size: 75%; | |
flex-basis: 75%; | |
max-width: 75%; | |
} | |
.col-md-10 { | |
-ms-flex-preferred-size: 83.33333333%; | |
flex-basis: 83.33333333%; | |
max-width: 83.33333333%; | |
} | |
.col-md-11 { | |
-ms-flex-preferred-size: 91.66666667%; | |
flex-basis: 91.66666667%; | |
max-width: 91.66666667%; | |
} | |
.col-md-12 { | |
-ms-flex-preferred-size: 100%; | |
flex-basis: 100%; | |
max-width: 100%; | |
} | |
.col-md-offset-0 { | |
margin-left: 0; | |
} | |
.col-md-offset-1 { | |
margin-left: 8.33333333%; | |
} | |
.col-md-offset-2 { | |
margin-left: 16.66666667%; | |
} | |
.col-md-offset-3 { | |
margin-left: 25%; | |
} | |
.col-md-offset-4 { | |
margin-left: 33.33333333%; | |
} | |
.col-md-offset-5 { | |
margin-left: 41.66666667%; | |
} | |
.col-md-offset-6 { | |
margin-left: 50%; | |
} | |
.col-md-offset-7 { | |
margin-left: 58.33333333%; | |
} | |
.col-md-offset-8 { | |
margin-left: 66.66666667%; | |
} | |
.col-md-offset-9 { | |
margin-left: 75%; | |
} | |
.col-md-offset-10 { | |
margin-left: 83.33333333%; | |
} | |
.col-md-offset-11 { | |
margin-left: 91.66666667%; | |
} | |
.start-md { | |
-webkit-box-pack: start; | |
-ms-flex-pack: start; | |
justify-content: flex-start; | |
text-align: start; | |
} | |
.center-md { | |
-webkit-box-pack: center; | |
-ms-flex-pack: center; | |
justify-content: center; | |
} | |
.end-md { | |
-webkit-box-pack: end; | |
-ms-flex-pack: end; | |
justify-content: flex-end; | |
text-align: end; | |
} | |
.top-md { | |
-webkit-box-align: start; | |
-ms-flex-align: start; | |
align-items: flex-start; | |
} | |
.middle-md { | |
-webkit-box-align: center; | |
-ms-flex-align: center; | |
align-items: center; | |
} | |
.bottom-md { | |
-webkit-box-align: end; | |
-ms-flex-align: end; | |
align-items: flex-end; | |
} | |
.around-md { | |
-ms-flex-pack: distribute; | |
justify-content: space-around; | |
} | |
.between-md { | |
-webkit-box-pack: justify; | |
-ms-flex-pack: justify; | |
justify-content: space-between; | |
} | |
.first-md { | |
-webkit-box-ordinal-group: 0; | |
-ms-flex-order: -1; | |
order: -1; | |
} | |
.last-md { | |
-webkit-box-ordinal-group: 2; | |
-ms-flex-order: 1; | |
order: 1; | |
} | |
.hidden-md { | |
display: none !important; | |
} | |
} | |
} | |
@media (min-width: $screen-lg) and (max-width: $screen-xl - 1) { | |
.to-grid{ | |
&.container { | |
max-width: $screen-lg; | |
} | |
.col-lg, | |
.col-lg-1, | |
.col-lg-2, | |
.col-lg-3, | |
.col-lg-4, | |
.col-lg-5, | |
.col-lg-6, | |
.col-lg-7, | |
.col-lg-8, | |
.col-lg-9, | |
.col-lg-10, | |
.col-lg-11, | |
.col-lg-12, | |
.col-lg-offset-0, | |
.col-lg-offset-1, | |
.col-lg-offset-2, | |
.col-lg-offset-3, | |
.col-lg-offset-4, | |
.col-lg-offset-5, | |
.col-lg-offset-6, | |
.col-lg-offset-7, | |
.col-lg-offset-8, | |
.col-lg-offset-9, | |
.col-lg-offset-10, | |
.col-lg-offset-11, | |
.col-lg-offset-12 { | |
box-sizing: border-box; | |
-webkit-box-flex: 0; | |
-ms-flex: 0 0 auto; | |
flex: 0 0 auto; | |
padding-right: sizeToRem(20); | |
padding-left: sizeToRem(20); | |
} | |
.col-lg { | |
-webkit-box-flex: 1; | |
-ms-flex-positive: 1; | |
flex-grow: 1; | |
-ms-flex-preferred-size: 0; | |
flex-basis: 0; | |
max-width: 100%; | |
} | |
.col-lg-1 { | |
-ms-flex-preferred-size: 8.33333333%; | |
flex-basis: 8.33333333%; | |
max-width: 8.33333333%; | |
} | |
.col-lg-2 { | |
-ms-flex-preferred-size: 16.66666667%; | |
flex-basis: 16.66666667%; | |
max-width: 16.66666667%; | |
} | |
.col-lg-3 { | |
-ms-flex-preferred-size: 25%; | |
flex-basis: 25%; | |
max-width: 25%; | |
} | |
.col-lg-4 { | |
-ms-flex-preferred-size: 33.33333333%; | |
flex-basis: 33.33333333%; | |
max-width: 33.33333333%; | |
} | |
.col-lg-5 { | |
-ms-flex-preferred-size: 41.66666667%; | |
flex-basis: 41.66666667%; | |
max-width: 41.66666667%; | |
} | |
.col-lg-6 { | |
-ms-flex-preferred-size: 50%; | |
flex-basis: 50%; | |
max-width: 50%; | |
} | |
.col-lg-7 { | |
-ms-flex-preferred-size: 58.33333333%; | |
flex-basis: 58.33333333%; | |
max-width: 58.33333333%; | |
} | |
.col-lg-8 { | |
-ms-flex-preferred-size: 66.66666667%; | |
flex-basis: 66.66666667%; | |
max-width: 66.66666667%; | |
} | |
.col-lg-9 { | |
-ms-flex-preferred-size: 75%; | |
flex-basis: 75%; | |
max-width: 75%; | |
} | |
.col-lg-10 { | |
-ms-flex-preferred-size: 83.33333333%; | |
flex-basis: 83.33333333%; | |
max-width: 83.33333333%; | |
} | |
.col-lg-11 { | |
-ms-flex-preferred-size: 91.66666667%; | |
flex-basis: 91.66666667%; | |
max-width: 91.66666667%; | |
} | |
.col-lg-12 { | |
-ms-flex-preferred-size: 100%; | |
flex-basis: 100%; | |
max-width: 100%; | |
} | |
.col-lg-offset-0 { | |
margin-left: 0; | |
} | |
.col-lg-offset-1 { | |
margin-left: 8.33333333%; | |
} | |
.col-lg-offset-2 { | |
margin-left: 16.66666667%; | |
} | |
.col-lg-offset-3 { | |
margin-left: 25%; | |
} | |
.col-lg-offset-4 { | |
margin-left: 33.33333333%; | |
} | |
.col-lg-offset-5 { | |
margin-left: 41.66666667%; | |
} | |
.col-lg-offset-6 { | |
margin-left: 50%; | |
} | |
.col-lg-offset-7 { | |
margin-left: 58.33333333%; | |
} | |
.col-lg-offset-8 { | |
margin-left: 66.66666667%; | |
} | |
.col-lg-offset-9 { | |
margin-left: 75%; | |
} | |
.col-lg-offset-10 { | |
margin-left: 83.33333333%; | |
} | |
.col-lg-offset-11 { | |
margin-left: 91.66666667%; | |
} | |
.start-lg { | |
-webkit-box-pack: start; | |
-ms-flex-pack: start; | |
justify-content: flex-start; | |
text-align: start; | |
} | |
.center-lg { | |
-webkit-box-pack: center; | |
-ms-flex-pack: center; | |
justify-content: center; | |
} | |
.end-lg { | |
-webkit-box-pack: end; | |
-ms-flex-pack: end; | |
justify-content: flex-end; | |
text-align: end; | |
} | |
.top-lg { | |
-webkit-box-align: start; | |
-ms-flex-align: start; | |
align-items: flex-start; | |
} | |
.middle-lg { | |
-webkit-box-align: center; | |
-ms-flex-align: center; | |
align-items: center; | |
} | |
.bottom-lg { | |
-webkit-box-align: end; | |
-ms-flex-align: end; | |
align-items: flex-end; | |
} | |
.around-lg { | |
-ms-flex-pack: distribute; | |
justify-content: space-around; | |
} | |
.between-lg { | |
-webkit-box-pack: justify; | |
-ms-flex-pack: justify; | |
justify-content: space-between; | |
} | |
.first-lg { | |
-webkit-box-ordinal-group: 0; | |
-ms-flex-order: -1; | |
order: -1; | |
} | |
.last-lg { | |
-webkit-box-ordinal-group: 2; | |
-ms-flex-order: 1; | |
order: 1; | |
} | |
.hidden-lg { | |
display: none !important; | |
} | |
} | |
} | |
@media (min-width: $screen-xl) { | |
.to-grid{ | |
&.container { | |
max-width: $screen-xl; | |
} | |
.col-xl, | |
.col-xl-1, | |
.col-xl-2, | |
.col-xl-3, | |
.col-xl-4, | |
.col-xl-5, | |
.col-xl-6, | |
.col-xl-7, | |
.col-xl-8, | |
.col-xl-9, | |
.col-xl-10, | |
.col-xl-11, | |
.col-xl-12, | |
.col-xl-offset-0, | |
.col-xl-offset-1, | |
.col-xl-offset-2, | |
.col-xl-offset-3, | |
.col-xl-offset-4, | |
.col-xl-offset-5, | |
.col-xl-offset-6, | |
.col-xl-offset-7, | |
.col-xl-offset-8, | |
.col-xl-offset-9, | |
.col-xl-offset-10, | |
.col-xl-offset-11, | |
.col-xl-offset-12 { | |
box-sizing: border-box; | |
-webkit-box-flex: 0; | |
-ms-flex: 0 0 auto; | |
flex: 0 0 auto; | |
padding-right: sizeToRem(20); | |
padding-left: sizeToRem(20); | |
} | |
.col-xl { | |
-webkit-box-flex: 1; | |
-ms-flex-positive: 1; | |
flex-grow: 1; | |
-ms-flex-preferred-size: 0; | |
flex-basis: 0; | |
max-width: 100%; | |
} | |
.col-xl-1 { | |
-ms-flex-preferred-size: 8.33333333%; | |
flex-basis: 8.33333333%; | |
max-width: 8.33333333%; | |
} | |
.col-xl-2 { | |
-ms-flex-preferred-size: 16.66666667%; | |
flex-basis: 16.66666667%; | |
max-width: 16.66666667%; | |
} | |
.col-xl-3 { | |
-ms-flex-preferred-size: 25%; | |
flex-basis: 25%; | |
max-width: 25%; | |
} | |
.col-xl-4 { | |
-ms-flex-preferred-size: 33.33333333%; | |
flex-basis: 33.33333333%; | |
max-width: 33.33333333%; | |
} | |
.col-xl-5 { | |
-ms-flex-preferred-size: 41.66666667%; | |
flex-basis: 41.66666667%; | |
max-width: 41.66666667%; | |
} | |
.col-xl-6 { | |
-ms-flex-preferred-size: 50%; | |
flex-basis: 50%; | |
max-width: 50%; | |
} | |
.col-xl-7 { | |
-ms-flex-preferred-size: 58.33333333%; | |
flex-basis: 58.33333333%; | |
max-width: 58.33333333%; | |
} | |
.col-xl-8 { | |
-ms-flex-preferred-size: 66.66666667%; | |
flex-basis: 66.66666667%; | |
max-width: 66.66666667%; | |
} | |
.col-xl-9 { | |
-ms-flex-preferred-size: 75%; | |
flex-basis: 75%; | |
max-width: 75%; | |
} | |
.col-xl-10 { | |
-ms-flex-preferred-size: 83.33333333%; | |
flex-basis: 83.33333333%; | |
max-width: 83.33333333%; | |
} | |
.col-xl-11 { | |
-ms-flex-preferred-size: 91.66666667%; | |
flex-basis: 91.66666667%; | |
max-width: 91.66666667%; | |
} | |
.col-xl-12 { | |
-ms-flex-preferred-size: 100%; | |
flex-basis: 100%; | |
max-width: 100%; | |
} | |
.col-xl-offset-0 { | |
margin-left: 0; | |
} | |
.col-xl-offset-1 { | |
margin-left: 8.33333333%; | |
} | |
.col-xl-offset-2 { | |
margin-left: 16.66666667%; | |
} | |
.col-xl-offset-3 { | |
margin-left: 25%; | |
} | |
.col-xl-offset-4 { | |
margin-left: 33.33333333%; | |
} | |
.col-xl-offset-5 { | |
margin-left: 41.66666667%; | |
} | |
.col-xl-offset-6 { | |
margin-left: 50%; | |
} | |
.col-xl-offset-7 { | |
margin-left: 58.33333333%; | |
} | |
.col-xl-offset-8 { | |
margin-left: 66.66666667%; | |
} | |
.col-xl-offset-9 { | |
margin-left: 75%; | |
} | |
.col-xl-offset-10 { | |
margin-left: 83.33333333%; | |
} | |
.col-xl-offset-11 { | |
margin-left: 91.66666667%; | |
} | |
.start-xl { | |
-webkit-box-pack: start; | |
-ms-flex-pack: start; | |
justify-content: flex-start; | |
text-align: start; | |
} | |
.center-xl { | |
-webkit-box-pack: center; | |
-ms-flex-pack: center; | |
justify-content: center; | |
} | |
.end-xl { | |
-webkit-box-pack: end; | |
-ms-flex-pack: end; | |
justify-content: flex-end; | |
text-align: end; | |
} | |
.top-xl { | |
-webkit-box-align: start; | |
-ms-flex-align: start; | |
align-items: flex-start; | |
} | |
.middle-xl { | |
-webkit-box-align: center; | |
-ms-flex-align: center; | |
align-items: center; | |
} | |
.bottom-xl { | |
-webkit-box-align: end; | |
-ms-flex-align: end; | |
align-items: flex-end; | |
} | |
.around-xl { | |
-ms-flex-pack: distribute; | |
justify-content: space-around; | |
} | |
.between-xl { | |
-webkit-box-pack: justify; | |
-ms-flex-pack: justify; | |
justify-content: space-between; | |
} | |
.first-xl { | |
-webkit-box-ordinal-group: 0; | |
-ms-flex-order: -1; | |
order: -1; | |
} | |
.last-xl { | |
-webkit-box-ordinal-group: 2; | |
-ms-flex-order: 1; | |
order: 1; | |
} | |
.hidden-xl { | |
display: none; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import PropTypes from 'prop-types' | |
import classNames from 'classnames' | |
import omit from 'omit.js' | |
class Grid extends React.Component { | |
constructor(props) { | |
super(props) | |
this.classesPrefix = 'to-grid' | |
} | |
render() { | |
const { children, className, fluid, fullHeight } = this.props | |
const classes = classNames({ | |
[this.classesPrefix]: true, | |
container: !fluid, | |
'container-fluid': fluid, | |
'container-full-height': fullHeight, | |
[`${className}`]: className, | |
}) | |
const componentProps = omit(this.props, [ | |
'children', | |
'className', | |
'fluid', | |
'fullHeight', | |
]) | |
return ( | |
<div className={classes} {...componentProps}> | |
{children} | |
</div> | |
) | |
} | |
} | |
Grid.defaultProps = { | |
fluid: false, | |
fullHeight: false, | |
} | |
Grid.propTypes = { | |
children: PropTypes.node.isRequired, | |
className: PropTypes.string, | |
fluid: PropTypes.bool, | |
fullHeight: PropTypes.bool, | |
} | |
export default Grid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import PropTypes from 'prop-types' | |
import classNames from 'classnames' | |
import omit from 'omit.js' | |
class Row extends React.Component { | |
constructor(props) { | |
super(props) | |
this.classesPrefix = 'row' | |
} | |
rowClasses(row, size) { | |
const classes = {} | |
classes[`${row.alignement}-${size}`] = row.alignement | |
classes[`${row.distribution}-${size}`] = row.distribution | |
return classes | |
} | |
buildClasses() { | |
const { className, xs, sm, md, lg, xl, reverse } = this.props | |
const xsProps = typeof xs === 'object' ? this.rowClasses(xs, 'xs') : {} | |
const smProps = typeof sm === 'object' ? this.rowClasses(sm, 'sm') : {} | |
const mdProps = typeof md === 'object' ? this.rowClasses(md, 'md') : {} | |
const lgProps = typeof lg === 'object' ? this.rowClasses(lg, 'lg') : {} | |
const xlProps = typeof xl === 'object' ? this.rowClasses(xl, 'xl') : {} | |
const classes = classNames({ | |
[this.classesPrefix]: true, | |
[`${className}`]: className, | |
reverse: reverse, | |
...xsProps, | |
...smProps, | |
...mdProps, | |
...lgProps, | |
...xlProps, | |
}) | |
return classes | |
} | |
render() { | |
const { children } = this.props | |
const classes = this.buildClasses() | |
const componentProps = omit(this.props, [ | |
'children', | |
'className', | |
'reverse', | |
'xs', | |
'sm', | |
'md', | |
'lg', | |
'xl', | |
]) | |
return ( | |
<div className={classes} {...componentProps}> | |
{children} | |
</div> | |
) | |
} | |
} | |
const sizePropTypes = PropTypes.shape({ | |
alignement: PropTypes.oneOf([ | |
'start', | |
'center', | |
'end', | |
'top', | |
'middle', | |
'bottom', | |
]), | |
distribution: PropTypes.oneOf(['around', 'between']), | |
}) | |
Row.propTypes = { | |
children: PropTypes.node.isRequired, | |
className: PropTypes.string, | |
reverse: PropTypes.bool, | |
xs: sizePropTypes, | |
sm: sizePropTypes, | |
md: sizePropTypes, | |
lg: sizePropTypes, | |
xl: sizePropTypes, | |
} | |
export default Row |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment