Skip to content

Instantly share code, notes, and snippets.

@davidtheclark
Created August 28, 2013 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidtheclark/6366838 to your computer and use it in GitHub Desktop.
Save davidtheclark/6366838 to your computer and use it in GitHub Desktop.
grunt-webfont SCSS template outputting classes that utilize an @extend placeholder, and accompanying demo HTML template.
/* Generated by grunt-webfont */
<% if (fontfaceStyles) { %>@font-face {
font-family:"<%= fontBaseName %>";<% if (eot) { %>
src:<%= fontSrc1 %>;<% }%>
src:<%= fontSrc2 %>;
font-weight:normal;
font-style:normal;
}
<% } %>
<% if (baseStyles) { if (stylesheet !== 'scss') { %>.icon<% } else if (stylesheet === 'scss') { %>%icon-base<% } %> {
font-family:"<%= fontBaseName %>";
display:inline-block;
font-style:normal;
speak:none;
-webkit-font-smoothing:antialiased;
b {
display: block;
height: 0;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
}
<% } %>
<% if (iconsStyles && (stylesheet === 'less' || stylesheet === 'scss')) { %>/* Classes */<% for (var glyphIdx = 0; glyphIdx < glyphs.length; glyphIdx++) { %>
.icon-<%= glyphs[glyphIdx] %> {
<% if (baseStyles && stylesheet === 'scss') { %>@extend %icon-base;
<% } %>&:before {
content:"\<%= (61696+glyphIdx).toString(16) %>";
}
}<% } %><% } %>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><%= fontBaseName %></title>
<style>
body {
background:#fff;
color:#222;
}
h1, div, footer {
font-family:'Helvetica Neue', Arial, sans-serif;
}
h1 {
font-size:18px;
}
.icons {
-webkit-column-count:5;
-moz-column-count:5;
column-count:5;
-webkit-column-gap:20px;
-moz-column-gap:20px;
column-gap:20px;
}
.icons__item,
.icons__item i {
line-height:2em;
cursor:pointer;
}
.icons__item:hover {
color:#800;
}
.icons__item i {
display:inline-block;
width:32px;
text-align:center;
}
.icons__item:hover i {
-webkit-transform:scale(1.5);
-moz-transform:scale(1.5);
-ms-transform:scale(1.5);
-o-transform:scale(1.5);
transform:scale(1.5);
}
footer {
margin-top:2em;
font-size:14px;
color:#999;
}
</style>
<link rel="stylesheet" href="icon.css">
</head>
<body>
<h1><%= fontBaseName %></h1>
<div class="icons" id="icons">
<% for (var glyphIdx = 0; glyphIdx < glyphs.length; glyphIdx++) { var glyph = glyphs[glyphIdx] %>
<div class="icons__item" data-name="<%= glyph %>"><i class="icon-<%= glyphs[glyphIdx] %>"></i> icon-<%= glyphs[glyphIdx] %></div>
<% } %>
</div>
<h1>Usage</h1>
<pre><code>&lt;i class=&quot;icon-<span id="name">name</span>&quot;&gt;&lt;/i&gt;</code></pre>
<footer>Generated by <a href="https://github.com/sapegin/grunt-webfont">grunt-webfont</a>.</footer>
<script>
(function() {
document.getElementById('icons').onclick = function(e) {
e = e || window.event;
document.getElementById('name').innerHTML = e.target.getAttribute('data-name') || e.target.parentNode.getAttribute('data-name');
}
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment