Skip to content

Commit

Permalink
Add less generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lancehudson committed Apr 18, 2014
1 parent 2a5eabe commit 302f359
Show file tree
Hide file tree
Showing 6 changed files with 1,766 additions and 0 deletions.
54 changes: 54 additions & 0 deletions builder/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
FONTS_FOLDER_PATH = os.path.join(ROOT_PATH, 'fonts')
CSS_FOLDER_PATH = os.path.join(ROOT_PATH, 'css')
SCSS_FOLDER_PATH = os.path.join(ROOT_PATH, 'scss')
LESS_FOLDER_PATH = os.path.join(ROOT_PATH, 'less')


def main():
Expand All @@ -17,6 +18,7 @@ def main():

rename_svg_glyph_names(data)
generate_scss(data)
generate_less(data)
generate_cheatsheet(data)
generate_component_json(data)
generate_composer_json(data)
Expand Down Expand Up @@ -46,6 +48,58 @@ def rename_svg_glyph_names(data):
svg_file.close()


def generate_less(data):
print "Generate LESS"
font_name = data['name']
font_version = data['version']
css_prefix = data['prefix']
variables_file_path = os.path.join(LESS_FOLDER_PATH, '_ionicons-variables.less')
icons_file_path = os.path.join(LESS_FOLDER_PATH, '_ionicons-icons.less')

d = []
d.append('/*!');
d.append('Ionicons, v%s' % (font_version) );
d.append('Created by Ben Sperry for the Ionic Framework, http://ionicons.com/');
d.append('https://twitter.com/benjsperry https://twitter.com/ionicframework');
d.append('MIT License: https://github.com/driftyco/ionicons');
d.append('*/');
d.append('// Ionicons Variables')
d.append('// --------------------------\n')
d.append('@ionicons-font-path: "../fonts";')
d.append('@ionicons-font-family: "%s";' % (font_name) )
d.append('@ionicons-version: "%s";' % (font_version) )
d.append('@ionicons-prefix: %s;' % (css_prefix) )
d.append('')
for ionicon in data['icons']:
chr_code = ionicon['code'].replace('0x', '\\')
d.append('@ionicon-var-%s: "%s";' % (ionicon['name'], chr_code) )
f = open(variables_file_path, 'w')
f.write( '\n'.join(d) )
f.close()

d = []
d.append('// Ionicons Icons')
d.append('// --------------------------\n')

group = [ '.%s' % (data['name'].lower()) ]
for ionicon in data['icons']:
group.append('.@{ionicons-prefix}%s' % (ionicon['name']) )

d.append( ',\n'.join(group) )

d.append('{')
d.append(' &:extend(.ion);')
d.append('}')

for ionicon in data['icons']:
chr_code = ionicon['code'].replace('0x', '\\')
d.append('.@{ionicons-prefix}%s:before { content: @ionicon-var-%s; }' % (ionicon['name'], ionicon['name']) )

f = open(icons_file_path, 'w')
f.write( '\n'.join(d) )
f.close()


def generate_scss(data):
print "Generate SCSS"
font_name = data['name']
Expand Down
85 changes: 85 additions & 0 deletions less/_ionicons-animation.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Animation Icons
// --------------------------

.spin() {
-webkit-animation: spin 1s infinite linear;
-moz-animation: spin 1s infinite linear;
-o-animation: spin 1s infinite linear;
animation: spin 1s infinite linear;
}

.@{ionicons-prefix}loading-a,
.@{ionicons-prefix}loading-b,
.@{ionicons-prefix}loading-c,
.@{ionicons-prefix}loading-d,
.@{ionicons-prefix}looping,
.@{ionicons-prefix}refreshing,
.@{ionicons-prefix}ios7-reloading {
&:extend(.ion);
}

.@{ionicons-prefix}spin,
.@{ionicons-prefix}loading-a,
.@{ionicons-prefix}loading-b,
.@{ionicons-prefix}loading-c,
.@{ionicons-prefix}loading-d,
.@{ionicons-prefix}looping,
.@{ionicons-prefix}refreshing,
.@{ionicons-prefix}ios7-reloading {
.spin()
}

@-moz-keyframes spin {
0% { -moz-transform: rotate(0deg); }
100% { -moz-transform: rotate(359deg); }
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(359deg); }
}
@-o-keyframes spin {
0% { -o-transform: rotate(0deg); }
100% { -o-transform: rotate(359deg); }
}
@-ms-keyframes spin {
0% { -ms-transform: rotate(0deg); }
100% { -ms-transform: rotate(359deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(359deg); }
}

.@{ionicons-prefix}loading-a {
-webkit-animation-timing-function: steps(8, start);
-moz-animation-timing-function: steps(8, start);
animation-timing-function: steps(8, start);
}

.@{ionicons-prefix}loading-a:before {
&:extend(.@{ionicons-prefix}load-a:before);
}

.@{ionicons-prefix}loading-b:before {
&:extend(.@{ionicons-prefix}load-b:before);
}

.@{ionicons-prefix}loading-c:before {
&:extend(.@{ionicons-prefix}load-c:before);
}

.@{ionicons-prefix}loading-d:before {
&:extend(.@{ionicons-prefix}load-d:before);
}

.@{ionicons-prefix}looping:before {
&:extend(.@{ionicons-prefix}loop:before);
}

.@{ionicons-prefix}refreshing:before {
&:extend(.@{ionicons-prefix}refresh:before);
}

.@{ionicons-prefix}ios7-reloading:before {
&:extend(.@{ionicons-prefix}ios7-reload:before);
}
27 changes: 27 additions & 0 deletions less/_ionicons-font.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Ionicons Font Path
// --------------------------

@font-face {
font-family: @ionicons-font-family;
src:url("@{ionicons-font-path}/ionicons.eot?v=@{ionicons-version}");
src:url("@{ionicons-font-path}/ionicons.eot?v=@{ionicons-version}#iefix") format("embedded-opentype"),
url("@{ionicons-font-path}/ionicons.ttf?v=@{ionicons-version}") format("truetype"),
url("@{ionicons-font-path}/ionicons.woff?v=@{ionicons-version}") format("woff"),
url("@{ionicons-font-path}/ionicons.svg?v=@{ionicons-version}#Ionicons") format("svg");
font-weight: normal;
font-style: normal;
}

.ion {
display: inline-block;
font-family: @ionicons-font-family;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
text-rendering: auto;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Loading

0 comments on commit 302f359

Please sign in to comment.