forked from eustasy/Colors.css
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.js
More file actions
29 lines (29 loc) · 1015 Bytes
/
Copy pathgenerator.js
File metadata and controls
29 lines (29 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*global $*/
$(function() {
$.getJSON('colors.json', function( data ) {
var css = '/*! Colors.css 1.9.0 | MIT License | https://github.com/eustasy/colors.css */\n'
//console.log(data)
$.each( data, function( group, list ) {
//console.log(group + ': ' + list)
css += '/* $$ ' + group + ' */\n'
if ( group == 'Baseline' ) {
group = ''
} else {
group = group.replace(/\s+/g, '').toLowerCase() + '-'
}
var typeIndex
var types = ['background', 'color', 'fill']
for (typeIndex = 0; typeIndex < types.length; ++typeIndex) {
css += '/* $ ' + types[typeIndex].charAt(0).toUpperCase() + types[typeIndex].slice(1) + 's */\n'
$.each( list, function( key, val ) {
//console.log(key + ': ' + val)
// .color-elementary-orange
css += '.' + types[typeIndex] + '-' + group + key.replace(/\s+/g, '-').toLowerCase()
// { color: #f37329; }
css += ' { ' + types[typeIndex] + ': ' + val.toLowerCase() + '; }\n'
})
}
})
$('#js-target-css').val(css)
})
})