1- import React from 'react' ;
2- import PropTypes from 'prop-types' ;
3- import classNames from 'classnames' ;
4- import { tagPropType } from '../utils/helper.js' ;
1+ import React from 'react'
2+ import PropTypes from 'prop-types'
3+ import classNames from 'classnames'
4+ import { tagPropType } from '../utils/helper.js'
55
6- const colWidths = [ 'xs' , 'sm' , 'md' , 'lg' , 'xl' ] ;
7- const stringOrNumberProp = PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ;
6+
7+ const stringOrNumberProp = PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] )
88const columnProps = PropTypes . oneOfType ( [
99 PropTypes . bool ,
1010 PropTypes . number ,
@@ -14,19 +14,19 @@ const columnProps = PropTypes.oneOfType([
1414 order : stringOrNumberProp ,
1515 offset : stringOrNumberProp
1616 } )
17- ] ) ;
17+ ] )
18+
1819const getColumnSizeClass = ( isXs , colWidth , colSize ) => {
1920 if ( colSize === true || colSize === '' ) {
20- return isXs ? 'col' : `col-${ colWidth } ` ;
21+ return isXs ? 'col' : `col-${ colWidth } `
2122 } else if ( colSize === 'auto' ) {
22- return isXs ? 'col-auto' : `col-${ colWidth } -auto` ;
23+ return isXs ? 'col-auto' : `col-${ colWidth } -auto`
2324 }
24- return isXs ? `col-${ colSize } ` : `col-${ colWidth } -${ colSize } ` ;
25+ return isXs ? `col-${ colSize } ` : `col-${ colWidth } -${ colSize } `
2526} ;
2627
2728//component - CoreUI / CCol
28-
29- const CCol = props => {
29+ const CCol = props => {
3030
3131 const {
3232 tag : Tag ,
@@ -35,46 +35,45 @@ const CCol = props=>{
3535 innerRef,
3636 widths,
3737 ...attributes
38- } = props ;
38+ } = props
3939
4040 //render
4141
42- const colClasses = [ ] ;
43-
42+ const colClasses = [ ]
4443 widths . forEach ( ( colWidth , i ) => {
45- let columnProp = props [ colWidth ] ;
46- delete attributes [ colWidth ] ;
44+ let columnProp = props [ colWidth ]
45+ delete attributes [ colWidth ]
4746 if ( ! columnProp && columnProp !== '' ) {
48- return ;
47+ return
4948 }
50- const isXs = ! i ;
49+ const isXs = ! i
5150 if ( typeof columnProp === 'object' ) {
52- const colSizeInterfix = isXs ? '-' : `-${ colWidth } -` ;
53- const colClass = getColumnSizeClass ( isXs , colWidth , columnProp . size ) ;
51+ const colSizeInterfix = isXs ? '-' : `-${ colWidth } -`
52+ const colClass = getColumnSizeClass ( isXs , colWidth , columnProp . size )
5453
5554 colClasses . push ( classNames ( {
5655 [ colClass ] : columnProp . size || columnProp . size === '' ,
5756 [ `order${ colSizeInterfix } ${ columnProp . order } ` ] : columnProp . order || columnProp . order === 0 ,
5857 [ `offset${ colSizeInterfix } ${ columnProp . offset } ` ] : columnProp . offset || columnProp . offset === 0
59- } ) ) ;
58+ } ) )
6059 } else {
61- const colClass = getColumnSizeClass ( isXs , colWidth , columnProp ) ;
62- colClasses . push ( colClass ) ;
60+ const colClass = getColumnSizeClass ( isXs , colWidth , columnProp )
61+ colClasses . push ( colClass )
6362 }
64- } ) ;
63+ } )
6564
6665 if ( ! colClasses . length ) {
67- colClasses . push ( 'col' ) ;
66+ colClasses . push ( 'col' )
6867 }
6968
7069 const classes = classNames (
7170 className ,
7271 colClasses
73- ) ;
72+ )
7473
7574 return (
7675 < Tag { ...attributes } className = { classes } ref = { innerRef } />
77- ) ;
76+ )
7877
7978}
8079
@@ -88,12 +87,13 @@ CCol.propTypes = {
8887 md : columnProps ,
8988 lg : columnProps ,
9089 xl : columnProps ,
90+ xxl : columnProps ,
9191 widths : PropTypes . array
92- } ;
92+ }
9393
9494CCol . defaultProps = {
9595 tag : 'div' ,
96- widths : colWidths ,
97- } ;
96+ widths : [ 'xs' , 'sm' , 'md' , 'lg' , 'xl' , 'xxl' ]
97+ }
9898
99- export default CCol ;
99+ export default CCol
0 commit comments