Skip to content

Commit 302f359

Browse files
committed
Add less generation
1 parent 2a5eabe commit 302f359

6 files changed

+1766
-0
lines changed

builder/generate.py

+54
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
FONTS_FOLDER_PATH = os.path.join(ROOT_PATH, 'fonts')
99
CSS_FOLDER_PATH = os.path.join(ROOT_PATH, 'css')
1010
SCSS_FOLDER_PATH = os.path.join(ROOT_PATH, 'scss')
11+
LESS_FOLDER_PATH = os.path.join(ROOT_PATH, 'less')
1112

1213

1314
def main():
@@ -17,6 +18,7 @@ def main():
1718

1819
rename_svg_glyph_names(data)
1920
generate_scss(data)
21+
generate_less(data)
2022
generate_cheatsheet(data)
2123
generate_component_json(data)
2224
generate_composer_json(data)
@@ -46,6 +48,58 @@ def rename_svg_glyph_names(data):
4648
svg_file.close()
4749

4850

51+
def generate_less(data):
52+
print "Generate LESS"
53+
font_name = data['name']
54+
font_version = data['version']
55+
css_prefix = data['prefix']
56+
variables_file_path = os.path.join(LESS_FOLDER_PATH, '_ionicons-variables.less')
57+
icons_file_path = os.path.join(LESS_FOLDER_PATH, '_ionicons-icons.less')
58+
59+
d = []
60+
d.append('/*!');
61+
d.append('Ionicons, v%s' % (font_version) );
62+
d.append('Created by Ben Sperry for the Ionic Framework, http://ionicons.com/');
63+
d.append('https://twitter.com/benjsperry https://twitter.com/ionicframework');
64+
d.append('MIT License: https://github.com/driftyco/ionicons');
65+
d.append('*/');
66+
d.append('// Ionicons Variables')
67+
d.append('// --------------------------\n')
68+
d.append('@ionicons-font-path: "../fonts";')
69+
d.append('@ionicons-font-family: "%s";' % (font_name) )
70+
d.append('@ionicons-version: "%s";' % (font_version) )
71+
d.append('@ionicons-prefix: %s;' % (css_prefix) )
72+
d.append('')
73+
for ionicon in data['icons']:
74+
chr_code = ionicon['code'].replace('0x', '\\')
75+
d.append('@ionicon-var-%s: "%s";' % (ionicon['name'], chr_code) )
76+
f = open(variables_file_path, 'w')
77+
f.write( '\n'.join(d) )
78+
f.close()
79+
80+
d = []
81+
d.append('// Ionicons Icons')
82+
d.append('// --------------------------\n')
83+
84+
group = [ '.%s' % (data['name'].lower()) ]
85+
for ionicon in data['icons']:
86+
group.append('.@{ionicons-prefix}%s' % (ionicon['name']) )
87+
88+
d.append( ',\n'.join(group) )
89+
90+
d.append('{')
91+
d.append(' &:extend(.ion);')
92+
d.append('}')
93+
94+
for ionicon in data['icons']:
95+
chr_code = ionicon['code'].replace('0x', '\\')
96+
d.append('.@{ionicons-prefix}%s:before { content: @ionicon-var-%s; }' % (ionicon['name'], ionicon['name']) )
97+
98+
f = open(icons_file_path, 'w')
99+
f.write( '\n'.join(d) )
100+
f.close()
101+
102+
49103
def generate_scss(data):
50104
print "Generate SCSS"
51105
font_name = data['name']

less/_ionicons-animation.less

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Animation Icons
2+
// --------------------------
3+
4+
.spin() {
5+
-webkit-animation: spin 1s infinite linear;
6+
-moz-animation: spin 1s infinite linear;
7+
-o-animation: spin 1s infinite linear;
8+
animation: spin 1s infinite linear;
9+
}
10+
11+
.@{ionicons-prefix}loading-a,
12+
.@{ionicons-prefix}loading-b,
13+
.@{ionicons-prefix}loading-c,
14+
.@{ionicons-prefix}loading-d,
15+
.@{ionicons-prefix}looping,
16+
.@{ionicons-prefix}refreshing,
17+
.@{ionicons-prefix}ios7-reloading {
18+
&:extend(.ion);
19+
}
20+
21+
.@{ionicons-prefix}spin,
22+
.@{ionicons-prefix}loading-a,
23+
.@{ionicons-prefix}loading-b,
24+
.@{ionicons-prefix}loading-c,
25+
.@{ionicons-prefix}loading-d,
26+
.@{ionicons-prefix}looping,
27+
.@{ionicons-prefix}refreshing,
28+
.@{ionicons-prefix}ios7-reloading {
29+
.spin()
30+
}
31+
32+
@-moz-keyframes spin {
33+
0% { -moz-transform: rotate(0deg); }
34+
100% { -moz-transform: rotate(359deg); }
35+
}
36+
@-webkit-keyframes spin {
37+
0% { -webkit-transform: rotate(0deg); }
38+
100% { -webkit-transform: rotate(359deg); }
39+
}
40+
@-o-keyframes spin {
41+
0% { -o-transform: rotate(0deg); }
42+
100% { -o-transform: rotate(359deg); }
43+
}
44+
@-ms-keyframes spin {
45+
0% { -ms-transform: rotate(0deg); }
46+
100% { -ms-transform: rotate(359deg); }
47+
}
48+
@keyframes spin {
49+
0% { transform: rotate(0deg); }
50+
100% { transform: rotate(359deg); }
51+
}
52+
53+
.@{ionicons-prefix}loading-a {
54+
-webkit-animation-timing-function: steps(8, start);
55+
-moz-animation-timing-function: steps(8, start);
56+
animation-timing-function: steps(8, start);
57+
}
58+
59+
.@{ionicons-prefix}loading-a:before {
60+
&:extend(.@{ionicons-prefix}load-a:before);
61+
}
62+
63+
.@{ionicons-prefix}loading-b:before {
64+
&:extend(.@{ionicons-prefix}load-b:before);
65+
}
66+
67+
.@{ionicons-prefix}loading-c:before {
68+
&:extend(.@{ionicons-prefix}load-c:before);
69+
}
70+
71+
.@{ionicons-prefix}loading-d:before {
72+
&:extend(.@{ionicons-prefix}load-d:before);
73+
}
74+
75+
.@{ionicons-prefix}looping:before {
76+
&:extend(.@{ionicons-prefix}loop:before);
77+
}
78+
79+
.@{ionicons-prefix}refreshing:before {
80+
&:extend(.@{ionicons-prefix}refresh:before);
81+
}
82+
83+
.@{ionicons-prefix}ios7-reloading:before {
84+
&:extend(.@{ionicons-prefix}ios7-reload:before);
85+
}

less/_ionicons-font.less

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Ionicons Font Path
2+
// --------------------------
3+
4+
@font-face {
5+
font-family: @ionicons-font-family;
6+
src:url("@{ionicons-font-path}/ionicons.eot?v=@{ionicons-version}");
7+
src:url("@{ionicons-font-path}/ionicons.eot?v=@{ionicons-version}#iefix") format("embedded-opentype"),
8+
url("@{ionicons-font-path}/ionicons.ttf?v=@{ionicons-version}") format("truetype"),
9+
url("@{ionicons-font-path}/ionicons.woff?v=@{ionicons-version}") format("woff"),
10+
url("@{ionicons-font-path}/ionicons.svg?v=@{ionicons-version}#Ionicons") format("svg");
11+
font-weight: normal;
12+
font-style: normal;
13+
}
14+
15+
.ion {
16+
display: inline-block;
17+
font-family: @ionicons-font-family;
18+
speak: none;
19+
font-style: normal;
20+
font-weight: normal;
21+
font-variant: normal;
22+
text-transform: none;
23+
text-rendering: auto;
24+
line-height: 1;
25+
-webkit-font-smoothing: antialiased;
26+
-moz-osx-font-smoothing: grayscale;
27+
}

0 commit comments

Comments
 (0)