@internetstiftelsen/styleguide
Advanced tools
Comparing version 4.0.12-beta.0.2 to 4.0.12-beta.0.3
'use strict'; | ||
// Usage: data-toggle-target="toggleButton" data-toggle-icon="copy|check" | ||
// Usage: data-toggle-icon-target="targetSvg" data-toggle-icon="copy|check" | ||
function toggleIconOnClick(e) { | ||
@@ -10,10 +10,9 @@ e.preventDefault(); | ||
var target = el.dataset.toggleIconTarget ? document.getElementById(el.dataset.toggleIconTarget) : el; | ||
var i = parseInt(el.dataset.iteration || 0, 10); | ||
var i = parseInt(el.dataset.iconIteration || 0, 10); | ||
var options = el.dataset.toggleIcon.split('|'); | ||
var nextIteration = i + 1 === options.length ? 0 : i + 1; | ||
el.dataset.iteration = nextIteration; | ||
el.dataset.iconIteration = nextIteration; | ||
var useElement = target.querySelector('use'); | ||
useElement.setAttribute('xlink:href', '#icon-' + options[nextIteration]); | ||
console.log(target); | ||
} | ||
@@ -24,2 +23,3 @@ | ||
if (e.target.closest('[data-toggle-icon]')) { | ||
console.log(e.target); | ||
toggleIconOnClick(e); | ||
@@ -26,0 +26,0 @@ return false; |
{ | ||
"name": "@internetstiftelsen/styleguide", | ||
"version": "4.0.12-beta.0.2", | ||
"version": "4.0.12-beta.0.3", | ||
"main": "dist/components.js", | ||
@@ -5,0 +5,0 @@ "ports": { |
@@ -1,2 +0,2 @@ | ||
// Usage: data-toggle-target="toggleButton" data-toggle-icon="copy|check" | ||
// Usage: data-toggle-icon-target="targetSvg" data-toggle-icon="copy|check" | ||
function toggleIconOnClick(e) { | ||
@@ -8,10 +8,9 @@ e.preventDefault(); | ||
const target = (el.dataset.toggleIconTarget) ? document.getElementById(el.dataset.toggleIconTarget) : el; | ||
const i = parseInt(el.dataset.iteration || 0, 10); | ||
const i = parseInt(el.dataset.iconIteration || 0, 10); | ||
const options = el.dataset.toggleIcon.split('|'); | ||
const nextIteration = (i + 1) === options.length ? 0 : i + 1; | ||
el.dataset.iteration = nextIteration; | ||
el.dataset.iconIteration = nextIteration; | ||
const useElement = target.querySelector('use'); | ||
useElement.setAttribute('xlink:href', `#icon-${options[nextIteration]}`); | ||
console.log(target); | ||
} | ||
@@ -22,2 +21,3 @@ | ||
if (e.target.closest('[data-toggle-icon]')) { | ||
console.log(e.target); | ||
toggleIconOnClick(e); | ||
@@ -24,0 +24,0 @@ return false; |
64304754