diff --git a/docs/assets/css/style.css b/docs/assets/css/style.css index fe691c0f..dfc5af3a 100644 --- a/docs/assets/css/style.css +++ b/docs/assets/css/style.css @@ -350,6 +350,37 @@ header { header .icons-list img { max-width: 100%; } + +input[type='color'] { + width: 1.25em; + height: 1.25em; + margin-left: 0.5em; +} + +.copyBtn { + height: 1.25em; + width: 1.25em; + margin-left: 0.25em; + position: relative; + top: 0.5em; + border-radius: 20%; + padding: 0.25em; + box-sizing: content-box; + transition: background-color 0.25s; +} + +.copyBtn:hover { + cursor: pointer; + background-color: #2D804E; +} + +.tooltip { + visibility: hidden; + background-color: #2D804E; + border-radius: 0.25em; + padding: 0.25em; +} + .borders { position: fixed; top: 0; @@ -408,10 +439,4 @@ header { .footer { margin-top: 6rem; - text-align: center; } - -input[type='color'] { - width: 1.25em; - height: 1.25em; - margin-left: 0.5em; -} \ No newline at end of file + text-align: center; } \ No newline at end of file diff --git a/docs/assets/img/copy.svg b/docs/assets/img/copy.svg new file mode 100644 index 00000000..2ee0e55f --- /dev/null +++ b/docs/assets/img/copy.svg @@ -0,0 +1,5 @@ + + +copy + + diff --git a/docs/assets/js/script.js b/docs/assets/js/script.js index 33f5b3a0..3d8abc73 100644 --- a/docs/assets/js/script.js +++ b/docs/assets/js/script.js @@ -95,6 +95,7 @@ devicon.controller('IconListCtrl', function($scope, $http, $compile) { /* | Change selected icon + | param icon: the new icon. |-------------------------------- */ $scope.selectIcon = function(icon) { @@ -158,6 +159,49 @@ devicon.controller('IconListCtrl', function($scope, $http, $compile) { } /*---- End of "Change selected svg icon" ----*/ + + /** + * Copy the text located using `id` into the user's clipboard. + * @param {Event} event - a JS Event object. + * @param {String} id - id of the element we are copying its text + * content from. + */ + $scope.copyToClipboard = function(event, id) { + let text = document.getElementById(id).textContent + navigator.clipboard.writeText(text) + .then(() => { + $scope.displayTooltip("Copied", event.target) + }) + .catch(() => { + $scope.displayTooltip("Failed to copy", event.target) + }) + } + + /** + * Display a tooltip. + * @param {String} text - text the tooltip should have. + * @param {Element} copyBtn - the copyBtn element, which is an + */ + $scope.displayTooltip = function(text, copyBtn) { + let tooltip = copyBtn.parentElement.getElementsByClassName("tooltip")[0] + tooltip.textContent = text + // reset opacity (for some reason, default opacity is null) + tooltip.style.opacity = 1 + tooltip.style.visibility = "visible" + + // create fade out effect after 2 sec + setTimeout(() => { + let count = 10 + let intervalObj + intervalObj = setInterval(() => { + tooltip.style.opacity -= 0.1 + if (--count == 0) { + clearInterval(intervalObj) + tooltip.style.visibility = "hidden" + } + }, 50) + }, 2000) + } }); /*================ End of "Devicons controller" ================*/ diff --git a/docs/index.html b/docs/index.html index c3e1fad2..4071fddf 100644 --- a/docs/index.html +++ b/docs/index.html @@ -62,6 +62,17 @@ -

Using <img> element

-
+

+ Using <img> element + + + + +

+
<img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/{{selectedIcon.name}}/{{selectedIcon.name}}-{{selectedIcon.svg[selectedSvgIndex]}}.svg" />
-

*To change the size, change the img's height and width

+

*To change the size, change the img's height and width attributes.


-

Using Pure SVG

-
+

+ Using Pure SVG + + + + +

+
<svg viewBox="0 0 128 128">
{{selectedSvgIcon}}
</svg>
-

*To change the size, change the svg's height and width

+

*To change the size, change the svg's height and width attributes.