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
<svg
xmlns="http://www.w3.org/2000/svg"
version="1.1"
viewBox="0 0 120 120">
<circle
cx="60"
cy="60"
r="55"
stroke-width="0"
stroke="none"
fill="#009290"
class="circle__filled" />
<path
class="path__filled"
fill="none"
stroke="#ffffff"
stroke-width="2.5"
stroke-linecap="round"
stroke-linejoin="round"
d="m 40.661749,62.57887 c -0.066,-0.652 -0.101,-1.313 -0.101,-1.985 0,-10.649 8.634,-19.283 19.285,-19.283 10.649,0 19.283,8.634 19.283,19.283 0,0.768 -0.045,1.524 -0.132,2.268 M 97.365737,41.530909 85.209732,49.126886 M 23.301715,41.530909 35.112751,48.910913 M 81.947708,26.122889 75.402725,37.930902 M 38.719745,26.122889 45.305744,38.0039 m 14.78601,-17.533996 0,13.5 M 40.220739,79.335899 c -1.386,2.158 -3.808,3.587 -6.562,3.587 -2.668,0 -5.021,-1.338 -6.426,-3.379 m 26.143,-0.208 c -1.386,2.158 -3.808,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.142,-0.208 c -1.386,2.158 -3.808,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.142,-0.208 c -1.387,2.158 -3.809,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.141,-0.208 c -1.386,2.158 -3.809,3.587 -6.563,3.587 -2.667,0 -5.02,-1.338 -6.425,-3.379 m -52.851,-17.438 c -1.386,2.158 -3.808,3.587 -6.563,3.587 -2.666,0 -5.02,-1.338 -6.426,-3.379 m 26.212,-0.208 c -1.386,2.158 -3.808,3.587 -6.562,3.587 -2.668,0 -5.021,-1.338 -6.426,-3.379 m 26.143,-0.208 c -1.386,2.158 -3.808,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.142,-0.208 c -1.386,2.158 -3.808,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.142,-0.208 c -1.387,2.158 -3.809,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.141,-0.208 c -1.386,2.158 -3.809,3.587 -6.563,3.587 -2.667,0 -5.02,-1.338 -6.425,-3.379 m 26.143001,-0.208 c -1.386,2.158 -3.809,3.587 -6.563001,3.587 -2.667,0 -5.02,-1.338 -6.426,-3.379 m -39.627,33.647 c -1.386,2.158 -3.808,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.142,-0.208 c -1.386,2.158 -3.808,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379 m 26.142,-0.208 c -1.387,2.158 -3.809,3.587 -6.563,3.587 -2.666,0 -5.019,-1.338 -6.425,-3.379"/>
<circle
cx="60"
cy="60"
r="55"
stroke-width="2"
stroke="#ffffff"
fill="none"
class="circle__outline" />
</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.
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