simple-icons/_layouts/default.html

163 lines
8.3 KiB
HTML
Raw Normal View History

2017-04-25 15:29:06 +03:00
{% assign iconsUnsortedString = "" %}
{% assign greyscaleIconsUnsortedString = "" %}
{% for icon in site.data.simple-icons.icons %}
2017-04-25 15:29:06 +03:00
{% assign title = icon.title %}
{% assign filename = icon.title | replace: "+", "plus" | replace: " ", "" | replace: ".", "" | replace: "-", "" | replace: "!", "" | replace: "", "" | downcase %}
{% assign hex = icon.hex %}
{% assign hex = icon.hex %}
2017-04-25 15:29:06 +03:00
{% assign hexCharacter1 = hex | slice: 0, 1 %}
{% assign hexCharacter2 = hex | slice: 1, 1 %}
{% assign hexCharacter3 = hex | slice: 2, 1 %}
{% assign hexCharacter4 = hex | slice: 3, 1 %}
{% assign hexCharacter5 = hex | slice: 4, 1 %}
{% assign hexCharacter6 = hex | slice: 5, 1 %}
{% capture hexCharacterString %}{{ hexCharacter1 }},{{ hexCharacter2 }},{{ hexCharacter3 }},{{ hexCharacter4 }},{{ hexCharacter5 }},{{ hexCharacter6 }}{% endcapture %}
{% assign hexCharacterArray = hexCharacterString | split: "," %}
{% assign rgbString = "" %}
{% for hexCharacter in hexCharacterArray %}
{% case hexCharacter %}
{% when "A" %}
2017-04-25 15:29:06 +03:00
{% assign rgbString = rgbString | append: "10" %}
{% when "B" %}
2017-04-25 15:29:06 +03:00
{% assign rgbString = rgbString | append: "11" %}
{% when "C" %}
2017-04-25 15:29:06 +03:00
{% assign rgbString = rgbString | append: "12" %}
{% when "D" %}
2017-04-25 15:29:06 +03:00
{% assign rgbString = rgbString | append: "13" %}
{% when "E" %}
2017-04-25 15:29:06 +03:00
{% assign rgbString = rgbString | append: "14" %}
{% when "F" %}
2017-04-25 15:29:06 +03:00
{% assign rgbString = rgbString | append: "15" %}
{% else %}
{% assign rgbString = rgbString | append: hexCharacter %}
{% endcase %}
2017-04-25 15:29:06 +03:00
{% unless forloop.last %}{% assign rgbString = rgbString | append: "," %}{% endunless %}
{% endfor %}
2017-04-25 15:29:06 +03:00
{% assign rgbArray = rgbString | split: "," %}
{% assign rgbRed = rgbArray[0] | times: 16 | plus: rgbArray[1] | divided_by: 255.0 | round: 2 %}
{% assign rgbGreen = rgbArray[2] | times: 16 | plus: rgbArray[3] | divided_by: 255.0 | round: 2 %}
{% assign rgbBlue = rgbArray[4] | times: 16 | plus: rgbArray[5] | divided_by: 255.0 | round: 2 %}
{% assign rgbMax = 0.0 %}
{% if rgbRed > rgbMax %}
{% assign rgbMax = rgbRed %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% if rgbGreen > rgbMax %}
{% assign rgbMax = rgbGreen %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% if rgbBlue > rgbMax %}
{% assign rgbMax = rgbBlue %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% assign rgbMin = 1.0 %}
{% if rgbRed < rgbMin %}
{% assign rgbMin = rgbRed %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% if rgbGreen < rgbMin %}
{% assign rgbMin = rgbGreen %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% if rgbBlue < rgbMin %}
{% assign rgbMin = rgbBlue %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% assign hslLuminance = rgbMax | plus: rgbMin | times: 50.0 %}
{% assign rgbDelta = rgbMax | minus: rgbMin %}
{% if rgbDelta == 0 %}
{% assign hslHue = 0 %}
{% assign hslSaturation = 0 %}
{% else %}
2017-04-25 15:29:06 +03:00
{% if hslLuminance < 0.5 %}
{% assign rgbMaxPlusMin = rgbMax | plus: rgbMin %}
{% assign hslSaturation = 100 | times: rgbDelta | divided_by: rgbMaxPlusMin %}
{% else %}
2017-04-25 15:29:06 +03:00
{% assign rgbTwoMinusMaxMinusMin = 2 | minus: rgbMax | minus: rgbMin %}
{% assign hslSaturation = 100 | times: rgbDelta | divided_by: rgbTwoMinusMaxMinusMin %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% if rgbMax == rgbRed %}
{% assign hslHue = rgbGreen | minus: rgbBlue | divided_by: rgbDelta | times: 60.0 | modulo: 360.0 %}
{% elsif rgbMax == rgbGreen %}
{% assign hslHue = rgbBlue | minus: rgbRed | divided_by: rgbDelta | plus: 2.0 | times: 60.0 | modulo: 360.0 %}
{% else %}
2017-04-25 15:29:06 +03:00
{% assign hslHue = rgbRed | minus: rgbGreen | divided_by: rgbDelta | plus: 4.0 | times: 60.0 | modulo: 360.0 %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% assign hslHue = hslHue | plus: 90.0 | modulo: 360.0 %}
{% endif %}
2017-04-25 15:29:06 +03:00
{% if hslSaturation < 10 %}
{% assign hslLuminance = hslLuminance | round: 0 | prepend: "000" | slice: -3, 3 %}
{% capture greyscaleIconsUnsortedString %}{{ greyscaleIconsUnsortedString }}{{ hslLuminance }},{{ filename }},{{ hslHue }},{{ hslSaturation }},{{ hex }},{{ title }}{% unless forloop.last %};{% endunless %}{% endcapture %}
{% else %}
2017-04-25 15:29:06 +03:00
{% assign hslHue = hslHue | round: 0 | prepend: "000" | slice: -3, 3 %}
{% capture iconsUnsortedString %}{{ iconsUnsortedString }}{{ hslHue }},{{ hslSaturation }},{{ hslLuminance }},{{ filename }},{{ hex }},{{ title }}{% unless forloop.last %};{% endunless %}{% endcapture %}
{% endif %}
{% endfor %}
2017-04-25 15:29:06 +03:00
{% assign iconsArray = iconsUnsortedString | split: ";" %}
{% assign iconsArray = iconsArray | sort %}
{% assign greyscaleIconsArray = greyscaleIconsUnsortedString | split: ";" %}
{% assign greyscaleIconsArray = greyscaleIconsArray | sort | reverse %}
2017-04-23 19:31:56 +03:00
<!doctype html>
<html lang="en-gb">
<head>
<meta charset="utf-8">
<meta content="initial-scale=1, width=device-width" name="viewport">
<link href="/css/styles.css" rel="stylesheet">
</head>
<body>
<header class="navbar" role="banner">
<ul class="navbar__nav" role="navigation">
<li class="navbar__nav-item navbar__nav-item--home"><a href="/">Simple&nbsp;Icons</a></li>
2017-04-23 19:31:56 +03:00
<li class="navbar__nav-item"><a href="https://github.com/danleech/simple-icons/blob/master/README.md">About</a></li>
<li class="navbar__nav-item"><a href="https://github.com/danleech/simple-icons">GitHub</a></li>
</ul>
</header>
<main role="main">
<ul class="grid">
<li class="grid-item grid-item--ad">
<div id="carbonads">
<span>
<span class="carbon-wrap">
<a class="carbon-img" href="#">
<img src="http://placehold.it/130x100&text=Ad">
</a>
<a class="carbon-text" href="#">Create your website with a beautiful Squarespace template. Start a free trial.</a>
</span>
<a class="carbon-poweredby" href="#">ads via Carbon</a>
</span>
</div>
</li>
2017-04-25 15:29:06 +03:00
{% for icon in iconsArray %}
{% assign iconArray = icon | split: "," %}
<li class="grid-item" style="background-color: #{{ iconArray[4] }}">
2017-04-25 23:35:57 +03:00
<a class="grid-item__link" href="/icons/{{ iconArray[3] }}.svg">
2017-04-25 15:29:06 +03:00
{% assign filePath = iconArray[3] | prepend: "icons/" | append: ".svg" %}
{% include_relative {{ filePath }} %}
<h2 class="grid-item__title">{{ iconArray[5] }}</h2>
</a>
<p class="grid-item__subtitle">#{{ iconArray[4] }}</p>
</li>
{% endfor %}
{% for icon in greyscaleIconsArray %}
{% assign iconArray = icon | split: "," %}
<li class="grid-item" style="background-color: #{{ iconArray[4] }}">
2017-04-25 23:35:57 +03:00
<a class="grid-item__link" href="/icons/{{ iconArray[1] }}.svg">
2017-04-25 15:29:06 +03:00
{% assign filePath = iconArray[1] | prepend: "icons/" | append: ".svg" %}
{% include_relative {{ filePath }} %}
<h2 class="grid-item__title">{{ iconArray[5] }}</h2>
</a>
<p class="grid-item__subtitle">#{{ iconArray[4] }}</p>
</li>
{% endfor %}
</ul>
2017-04-23 19:31:56 +03:00
</main>
<footer class="footer" role="contentinfo">
<p>A <a href="https://github.com/danleech/simple-icons/blob/master/LICENSE.md">CC0</a> project maintained by <a href="https://twitter.com/bathtype">Dan&nbsp;Leech</a>.</p>
<p>Use <a href="https://github.com/danleech/simple-icons">GitHub</a> for requests, corrections and contributions.</p>
2017-04-23 19:31:56 +03:00
</footer>
2017-04-25 21:28:16 +03:00
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-97917186-1', 'auto');
ga('send', 'pageview');
</script>
2017-04-23 19:31:56 +03:00
</body>
</html>