Created
March 18, 2014 10:32
-
-
Save kazu69/9617529 to your computer and use it in GitHub Desktop.
Icon System with SVG Sprites - http://css-tricks.com/svg-sprites-use-better-icon-fonts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "svg-sprites", | |
"version": "0.0.1", | |
"description": "", | |
"author": "", | |
"license": "MIT", | |
"devDependencies": { | |
"grunt": "^0.4.4", | |
"grunt-svgstore": "0.0.2", | |
"load-grunt-tasks": "^0.4.0", | |
"time-grunt": "^0.2.10", | |
"grunt-php": "~0.3.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
module.exports = (grunt) -> | |
require('load-grunt-tasks') grunt | |
require('time-grunt') grunt | |
grunt.initConfig | |
svgstore: | |
defaults: | |
options: | |
prefix: 'shape-' | |
files: | |
'processed/svg-defs.svg': ['source/*.svg'] | |
php: | |
dist: | |
options: | |
hostname: '0.0.0.0' | |
port: 9000 | |
keepalive: true | |
open: true | |
grunt.registerTask 'default', ['svgstore'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>svg</title> | |
<style type="text/css" media="screen"> | |
iframe { | |
width: 0; | |
height: 0; | |
border: 0; | |
} | |
#source svg { | |
display: none; | |
} | |
.icon { | |
width: 75px; | |
height: 75px; | |
} | |
body { | |
padding: 20px; | |
} | |
#shape-codepen path:first-child { | |
fill: #999; | |
} | |
#shape-codepen path:nth-child(2) { | |
fill: #666; | |
} | |
.shape-codepen-2 { | |
-webkit-filter: drop-shadow(5px 5px 2px #ccc); | |
filter: drop-shadow(5px 5px 2px black); | |
} | |
.shape-youtube { | |
fill: url(#gradient); | |
} | |
.shape-twitter-2 { | |
fill: #55ACEE | |
} | |
.shape-twitter-3 { | |
fill: red; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="source"> | |
<?php include_once("processed/svg-defs.svg"); ?> | |
</div> | |
<svg viewBox="0 0 100 100" class="icon shape-codepen"> | |
<use xlink:href="#shape-codepen"></use> | |
</svg> | |
<svg viewBox="0 0 100 100" class="icon shape-codepen-2"> | |
<use xlink:href="#shape-codepen"></use> | |
</svg> | |
<svg viewBox="0 0 100 100" class="icon shape-youtube"> | |
<linearGradient id="gradient" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="0%" y2="100%"> | |
<stop stop-color="#FF0000" offset="0"/><stop stop-color="#571C1C" offset="1"/> | |
</linearGradient> | |
<use xlink:href="#shape-youtube"></use> | |
</svg> | |
<svg viewBox="0 0 100 100" class="icon shape-twitter"> | |
<use xlink:href="#shape-twitter"></use> | |
</svg> | |
<svg viewBox="0 0 100 100" class="icon shape-twitter-2"> | |
<use xlink:href="#shape-twitter"></use> | |
</svg> | |
<svg viewBox="0 0 100 100" class="icon shape-twitter-3"> | |
<use xlink:href="#shape-twitter"></use> | |
</svg> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment