Skip to content

Commit 2bd919c

Browse files
committed
init gruntjs
1 parent 20049c3 commit 2bd919c

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

gruntfile.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var fontName = 'fonterrific';
2+
var fontClass = 'ft';
3+
var fontClassPrefix = 'ft-';
4+
5+
module.exports = function(grunt) {
6+
grunt.initConfig({
7+
webfont: {
8+
icons: {
9+
src: 'icons/svg/*.svg',
10+
dest: 'build/font',
11+
destCss: 'build/',
12+
options: {
13+
fontBaseName: fontName,
14+
fontFilename: fontName,
15+
template: 'templates/fonterrific.css',
16+
htmlDemoTemplate: 'templates/fonterrific.html',
17+
templateOptions: {
18+
fontBaseName: fontName,
19+
baseClass: fontClass,
20+
classPrefix: fontClassPrefix
21+
}
22+
}
23+
}
24+
}
25+
});
26+
27+
grunt.loadNpmTasks('grunt-webfont');
28+
29+
grunt.registerTask('default', ['webfont']);
30+
};

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@
2323
"bugs": {
2424
"url": "https://github.com/stefanmeschke/fonterrific/issues"
2525
},
26-
"homepage": "https://github.com/stefanmeschke/fonterrific#readme"
26+
"homepage": "https://github.com/stefanmeschke/fonterrific#readme",
27+
"devDependencies": {
28+
"grunt": "^1.0.1",
29+
"grunt-webfont": "^1.6.0"
30+
}
2731
}

templates/fonterrific.css

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<% if (fontfaceStyles) { %>
2+
@font-face {
3+
font-family: "<%= fontBaseName %>";
4+
<% if (fontSrc1) { %>src: <%= fontSrc1 %>;<% }%>
5+
<% if (fontSrc2) { %>src: <%= fontSrc2 %>;<% }%>
6+
font-weight: normal;
7+
font-style: normal;
8+
}
9+
<% } %>
10+
11+
.<%= baseClass %> {
12+
display: inline-block;
13+
font-size: inherit;
14+
font: normal normal normal "<%= fontBaseName %>";
15+
text-rendering: auto;
16+
-webkit-font-smoothing: antialiased;
17+
-moz-osx-font-smoothing: grayscale;
18+
}
19+
20+
<% if (iconsStyles) { %>
21+
<% for (var glyphIdx = 0; glyphIdx < glyphs.length; glyphIdx++) { %>
22+
.<%= classPrefix %><%= glyphs[glyphIdx] %>:before { content: "\<%= codepoints[glyphIdx] %>"; }
23+
<% } %>
24+
<% } %>

templates/fonterrific.html

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Custom template: <%= fontBaseName %></title>
6+
<link rel="stylesheet" href="<%= fontBaseName %>.css">
7+
</head>
8+
<body>
9+
<h1><%= fontBaseName %></h1>
10+
11+
<div class="icons" id="icons">
12+
<% for (var glyphIdx = 0; glyphIdx < glyphs.length; glyphIdx++) { var glyph = glyphs[glyphIdx] %>
13+
<div data-name="<%= glyph %>"><i class="<%= baseClass %> <%= classPrefix %><%= glyph %>"></i> <%= classPrefix %><%= glyph %></div>
14+
<% } %>
15+
</div>
16+
17+
<h1>Usage</h1>
18+
<pre><code>&lt;i class=&quot;<%= baseClass ? baseClass + ' ' : '' %><%= classPrefix %><span id="name">name</span>&quot;&gt;&lt;/i&gt;</code></pre>
19+
20+
<footer>Generated by <a href="https://github.com/sapegin/grunt-webfont">grunt-webfont</a>.</footer>
21+
22+
<script>
23+
(function() {
24+
document.getElementById('icons').onclick = function(e) {
25+
e = e || window.event;
26+
document.getElementById('name').innerHTML = e.target.getAttribute('data-name') || e.target.parentNode.getAttribute('data-name');
27+
}
28+
})();
29+
</script>
30+
</body>
31+
</html>

0 commit comments

Comments
 (0)