-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added 'position' css generator.
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
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,35 @@ | ||
/** | ||
* position.js | ||
* | ||
* Generates `position` property classes (`.x-position-absolute` etc.). | ||
*/ | ||
const fs = require('fs'), | ||
path = require('path'), | ||
{log, error} = console, | ||
|
||
genPositionCss = () => { | ||
const fileName = 'position.css', | ||
outputFilePath = path.join(__dirname, `../../src/css/modules/${fileName}`); | ||
const out = [ | ||
'static', | ||
'relative', | ||
'absolute', | ||
'sticky', | ||
'fixed', | ||
].map(k => `.x-position-${k} { | ||
position: ${k}; | ||
}`); | ||
|
||
const content = | ||
`/** | ||
* ${fileName} | ||
*/ | ||
${out.join('\n\n')}\n`; | ||
return fs.promises.writeFile(outputFilePath, content) | ||
.then( | ||
() => log(`file ${fileName} written successfully`), | ||
error | ||
); | ||
}; | ||
|
||
module.exports = {genPositionCss}; |
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,34 @@ | ||
/** | ||
* justify-content.js | ||
* | ||
* Generates `justify-content` property classes (`.x-justify-space-between, .x-jc-space-between` etc.). | ||
*/ | ||
const fs = require('fs'), | ||
path = require('path'), | ||
{log, error} = console; | ||
|
||
/** | ||
* Writes property values as css classes, for given `propName` - | ||
* Resulting content is written to given filePath | ||
*/ | ||
const genCssPropClasses = (propName, values, outputFilePath) => { | ||
const out = values.reduce((agg, k) => agg + `.x-${propName}-${k} { | ||
${propName}: ${k}; | ||
}\n`, ''); | ||
const content = | ||
`/** | ||
* ${outputFilePath} | ||
*/ | ||
${out.join('\n\n')}\n` | ||
; | ||
return fs.promises.writeFile(outputFilePath, content) | ||
.then( | ||
() => log(`file ${outputFilePath} written successfully`), | ||
error | ||
); | ||
}; | ||
|
||
module.exports = { | ||
genCssPropClasses | ||
} |