-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
icons script which creates sass list of icons
- Loading branch information
1 parent
f4972e2
commit 2a0bb2e
Showing
3 changed files
with
57 additions
and
1 deletion.
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,39 @@ | ||
#!/usr/bin/env node | ||
// Builds a .scss file with all site icons | ||
var glob = require('glob') | ||
var fs = require('fs') | ||
var path = require('path') | ||
var format = require('util').format | ||
|
||
var sets = ['calcite', 'calcite-large', 'vecticons'] | ||
|
||
function comma (index, array) { | ||
var needsComma = index !== array.length - 1 | ||
return needsComma ? ',' : '' | ||
} | ||
|
||
function formatLine (files, i) { | ||
var icon = path.basename(files[i], '.svg') | ||
return format('\n "%s"%s', icon, comma(i, files)) | ||
} | ||
|
||
function parseFiles (setName, index) { | ||
var files = glob.sync(format('lib/img/icons/%s/*.svg', setName)) | ||
var sassStream = fs.createWriteStream(format('lib/sass/calcite-web/icons/sets/%s.scss', setName), 'utf8') | ||
|
||
dataStream.write(format('\n "%s": [', setName)) | ||
sassStream.write(format('$%s-icons:', setName)) | ||
|
||
files.forEach(function (file, i) { | ||
var line = formatLine(files, i) | ||
dataStream.write(line) | ||
sassStream.write(line) | ||
}) | ||
sassStream.end(';') | ||
dataStream.write(format('\n ]%s', comma(index, sets))) | ||
} | ||
|
||
var dataStream = fs.createWriteStream('docs/source/icons.json', 'utf8') | ||
dataStream.write('{') | ||
sets.forEach(parseFiles) | ||
dataStream.end('\n}') |
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