Skip to content

Instantly share code, notes, and snippets.

@mukhtyar
Last active January 18, 2018 20:41
Show Gist options
  • Save mukhtyar/c14c1512e553d12a8eb0b348c01206d3 to your computer and use it in GitHub Desktop.
Save mukhtyar/c14c1512e553d12a8eb0b348c01206d3 to your computer and use it in GitHub Desktop.
SVG Icons
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
.container, .container-new {
width: 100%;
height: 100%;
margin: 1rem;
background-color: #fafafa;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
}
.icon {
flex: 0 1 20%;
display: flex;
flex-direction: column;
align-items: center;
}
svg {
width: 50%;
height: 50%;
}
</style>
</head>
<body>
<h3>Existing Topic Icons</h3>
<div class="container">
</div>
<h3>Options for New Topic Icons</h3>
<div class="container equity"></div>
<div class="container financing"></div>
<div class="container tribal"></div>
<script>
var existingIcons = [
{
color: '#479c6b',
topic: 'agriculture'
},
{
color: '#3c5882',
topic: 'biodiversity-and-habitat'
},
{
color: '#809530',
topic: 'parks-recreation-and-historic-and-cultural'
},
{
color: '#a73f3b',
topic: 'emergency-management'
},
{
color: '#ce8a34',
topic: 'energy'
},
{
color: '#1d6440',
topic: 'forestry'
},
{
color: '#815a54',
topic: 'land-use-and-community-development'
},
{
color: '#009290',
topic: 'ocean-and-coast'
},
{
color: '#bc3a6d',
topic: 'public-health'
},
{
color: '#7f5a79',
topic: 'transportation'
},
{
color: '#138db8',
topic: 'water'
}
];
var equityIcons = [
{
color: '#479c6b',
topic: 'equity-and-environmental-justice1'
},
{
color: '#3c5882',
topic: 'equity-and-environmental-justice2'
},
];
var financingIcons = [
{
color: '#809530',
topic: 'financing1'
},
{
color: '#a73f3b',
topic: 'financing2'
},
{
color: '#a73f3b',
topic: 'financing3'
},
];
var tribalIcons = [
{
color: '#1d6440',
topic: 'tribal-and-indigenous-communities1'
},
{
color: '#1d6440',
topic: 'tribal-and-indigenous-communities2'
},
];
function loadSvgFile(filename, className) {
d3.xml(filename).mimeType('image/svg+xml').get(function(error, xml) {
if (error) throw error;
var icon = d3.select('.' + className)
.append('div')
.classed('icon', true)
.node();
icon.appendChild(xml.documentElement);
var span = document.createElement('span');
var topic = filename.split('.')[0];
span.innerHTML = topic.split('topic-')[1];
icon.appendChild(span)
});
}
existingIcons.forEach(function(item){
loadSvgFile('topic-' + item.topic + '.svg', 'container');
});
equityIcons.forEach(function(item){
loadSvgFile('topic-' + item.topic + '.svg', 'equity');
});
financingIcons.forEach(function(item){
loadSvgFile('topic-' + item.topic + '.svg', 'financing');
});
tribalIcons.forEach(function(item){
loadSvgFile('topic-' + item.topic + '.svg', 'tribal');
});
</script>
</body>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
<svg
xmlns="http://www.w3.org/2000/svg"
version="1.1"
viewBox="0 0 120 120">
<circle
class="circle__filled"
fill="#7f5a79"
stroke="none"
stroke-width="0"
r="55"
cy="60"
cx="60" />
<path
class="path__filled"
fill="#ffffff"
d="m 73.31075,82.44476 6.97,0 c 0.231,0 0.369,-0.021 0.424,-0.021 0.011,0 0.018,0 0.022,0.002 0.03,-0.083 0.085,-0.313 0.085,-0.863 l 0,-2.559 c 0,-0.208 0.008,-0.438 0.016,-0.681 0.015,-0.4 0.038,-1.154 -0.037,-1.568 -0.086,0.023 -0.2,0.059 -0.35,0.115 l -6.81,2.28 c -0.873,0.28 -1.868,0.864 -1.825,2.9 0.059,0.103 0.543,0.395 1.505,0.395 m -0.644,-6.04 6.73,-2.252 c 1.488,-0.567 2.704,-0.4 3.52,0.415 1.006,1.004 0.952,2.583 0.909,3.851 -0.006,0.208 -0.014,0.407 -0.014,0.586 l 0,2.559 c 0,0.936 0,3.781 -3.531,3.781 l -6.97,0 c -2.606,0 -4.458,-1.325 -4.5,-3.223 -0.065,-2.865 1.308,-4.898 3.856,-5.717 m -33.8,2.276 0,2.883 c 0,0.596 0.046,0.882 1.088,0.882 l 6.971,0 c 0.961,0 1.444,-0.293 1.5,-0.389 0.037,-1.592 -0.526,-2.488 -1.819,-2.906 l -7.152,-2.302 c -0.202,-0.076 -0.338,-0.108 -0.429,-0.122 -0.173,0.423 -0.159,1.517 -0.159,1.954 m 1.613,-4.556 7.072,2.274 c 2.563,0.826 3.938,2.857 3.871,5.722 -0.042,1.898 -1.892,3.224 -4.498,3.224 l -6.971,0 c -2.522,0 -4.088,-1.449 -4.088,-3.781 l 0,-2.86 c 0,-1.282 -0.025,-3.039 1.074,-4.111 0.861,-0.838 2.242,-0.971 3.54,-0.468 M 27.042,55.432 c 0,0.799 0.671,1.45 1.498,1.45 l 1.498,0 0,-7.25 0,-2.9 c 0,-0.801 0.672,-1.45 1.498,-1.45 0.826,0 1.498,0.649 1.498,1.45 l 0,2.9 0,8.615 c 0,2.244 2.402,4.993 5.972,5.51 14.235,1.97 28.069,1.969 42.293,0.001 3.546,-0.512 5.665,-3.203 5.665,-5.511 l 0,-10.065 0,-1.45 c 0,-0.801 0.671,-1.45 1.499,-1.45 0.827,0 1.498,0.649 1.498,1.45 l 0,1.45 0,8.7 1.498,0 c 0.826,0 1.498,-0.651 1.498,-1.45 l 0,-13.05 c 0,-0.799 -0.672,-1.45 -1.498,-1.45 l -2.996,0 c -0.828,0 -1.499,-0.649 -1.499,-1.45 l 0,-0.227 c 0,-2.271 -2.217,-5.043 -5.783,-5.558 -2.403,-0.324 -4.977,-0.599 -7.855,-0.841 -0.223,0.175 -0.423,0.379 -0.641,0.605 -0.687,0.705 -1.627,1.671 -3.533,1.671 l -17.933,0 c -2.082,0 -3.176,-1.142 -3.978,-1.976 -0.103,-0.109 -0.206,-0.22 -0.315,-0.326 -2.939,0.242 -5.607,0.526 -8.129,0.865 -3.561,0.514 -5.763,3.286 -5.763,5.56 l 0,0.227 c 0,0.801 -0.672,1.45 -1.498,1.45 l -2.996,0 c -0.827,0 -1.498,0.651 -1.498,1.45 l 0,13.05 z m 9.317,34.675 c 0.685,0.149 1.169,0.736 1.169,1.415 l 0,3.061 c 0,0.8 0.673,1.449 1.498,1.449 l 4.495,0 c 0.826,0 1.498,-0.649 1.498,-1.449 l 0,-2.9 c 0,-0.8 0.671,-1.45 1.498,-1.45 l 26.965,0 c 0.827,0 1.498,0.65 1.498,1.45 l 0,2.9 c 0,0.8 0.672,1.449 1.498,1.449 l 4.494,0 c 0.826,0 1.498,-0.649 1.498,-1.449 l 0,-3 c 0,-0.703 0.52,-1.305 1.234,-1.429 1.979,-0.343 3.26,-1.93 3.26,-4.044 l 0,-21.837 c -1.405,1.196 -3.197,2.061 -5.232,2.354 -7.257,1.005 -14.414,1.508 -21.571,1.508 -7.161,0 -14.322,-0.503 -21.587,-1.509 -2.134,-0.309 -4.058,-1.212 -5.539,-2.474 l 0,21.957 c 0,1.958 1.336,3.565 3.324,3.998 M 82.393,27.363 C 66.711,22.848 53.33,22.849 37.656,27.362 c -2.312,0.675 -4.332,3.317 -4.573,5.828 1.428,-1.211 3.26,-2.073 5.286,-2.366 2.779,-0.373 5.711,-0.68 8.965,-0.937 0.391,-0.039 0.761,0.082 1.059,0.314 0.41,0.318 0.748,0.671 1.048,0.982 0.696,0.728 1.036,1.049 1.779,1.049 l 17.933,0 c 0.588,0 0.766,-0.157 1.352,-0.759 0.403,-0.416 0.907,-0.933 1.665,-1.359 0.266,-0.151 0.571,-0.218 0.879,-0.192 3.147,0.257 5.944,0.552 8.562,0.904 2.035,0.294 3.876,1.161 5.312,2.377 -0.229,-2.556 -2.201,-5.159 -4.53,-5.84 m -53.853,10.669 1.498,0 0,-4.35 c 0,-3.928 3.027,-8.009 6.757,-9.099 16.28,-4.687 30.172,-4.687 46.458,0.002 3.761,1.099 6.708,5.095 6.708,9.097 l 0,4.35 1.498,0 c 2.478,0 4.494,1.951 4.494,4.35 l 0,13.05 c 0,2.399 -2.017,4.35 -4.494,4.35 l -1.498,0 0,26.328 c 0,3.09 -1.761,5.599 -4.495,6.576 l 0,1.896 c 0,2.398 -2.016,4.35 -4.494,4.35 l -4.494,0 c -2.478,0 -4.494,-1.951 -4.494,-4.35 l 0,-1.45 -23.969,0 0,1.45 c 0,2.398 -2.016,4.35 -4.494,4.35 l -4.495,0 c -2.478,0 -4.494,-1.951 -4.494,-4.35 l 0,-2.001 c -2.696,-1.063 -4.493,-3.579 -4.493,-6.472 l 0,-26.328 -1.498,0 c -2.479,0 -4.494,-1.951 -4.494,-4.35 l 0,-13.05 c -0.001,-2.398 2.015,-4.349 4.493,-4.349"/>
<circle
class="circle__outline"
fill="none"
stroke="#ffffff"
stroke-width="2"
r="55"
cy="60"
cx="60" />
</svg>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment