-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
483 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const LAYOUT = { | ||
label: { | ||
xs: 1, | ||
sm: 1, | ||
md: 1 | ||
}, | ||
form: { | ||
xs: 4, | ||
sm: 4, | ||
md: 2 | ||
} | ||
}; | ||
const SIZES = ['xs', 'sm', 'md']; | ||
|
||
/** | ||
* class BSColumnsManager - helps to keep track on the BS grid usage. | ||
* | ||
* @return {type} description | ||
*/ | ||
export default class BSColumnsManager { | ||
constructor() { | ||
this.columnCounter = { xs: 0, sm: 0, md: 0 }; | ||
} | ||
|
||
/** | ||
* Calculates the element column width by iterating over its size settings | ||
* in the LAYOUT object. | ||
* returns a class string, E.G: 'col-xs-2 col-sm-4 col-md-4'. | ||
* @param {String} elementName | ||
* @return {string} | ||
*/ | ||
getElementColumnsClass = (elementName, props) => | ||
SIZES.map(size => { | ||
if (elementName !== 'slider') { | ||
const numberOfColumns = LAYOUT[elementName][size]; | ||
this.columnCounter[size] += numberOfColumns; | ||
return `col-${size}-${numberOfColumns}`; | ||
} | ||
const demoCounter = { xs: 0, sm: 0, md: 0 }; | ||
|
||
if (props.input || props.selectList) { | ||
demoCounter[size] += LAYOUT.form[size]; | ||
} | ||
|
||
if (props.icon || props.label) { | ||
demoCounter[size] += LAYOUT.label[size]; | ||
} | ||
|
||
return `col-${size}-${12 - demoCounter[size]}`; | ||
}).join(' '); | ||
|
||
resetColumnsCount = () => { | ||
this.columnCounter = { xs: 0, sm: 0, md: 0 }; | ||
}; | ||
} |
Oops, something went wrong.