Skip to content

Commit

Permalink
Refactor icon component
Browse files Browse the repository at this point in the history
Inline svg via data URIs and build out color modifier classes
  • Loading branch information
Thomas Lowry committed Apr 23, 2020
1 parent 0990eab commit 2f1a462
Show file tree
Hide file tree
Showing 94 changed files with 727 additions and 36 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"autoprefixer": "^9.7.6",
"node-sass": "^4.13.1",
"npm-run-all": "^4.1.5",
"postcss-inline-svg": "^4.1.0",
"prettier": "^2.0.5",
"rollup": "^1.16.2",
"rollup-plugin-postcss": "^2.9.0",
Expand Down
240 changes: 240 additions & 0 deletions public/figma-plugin-ds.css

Large diffs are not rendered by default.

63 changes: 31 additions & 32 deletions public/figma-plugin-ds.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
(function () {
'use strict';
'use strict';

const selector = 'disclosure';
Object.defineProperty(exports, '__esModule', { value: true });

const disclosureHandler = function (event) {
let disclosureSet = this.parentNode.parentNode;
let disclosuresInSet = disclosureSet.querySelectorAll('li');
let alreadyActive = this.parentNode.classList.contains(selector + '--expanded');
const selector = 'disclosure';

disclosuresInSet.forEach((disclosure) => {
disclosure.classList.remove(selector + '--expanded');
});
const disclosureHandler = function (event) {
let disclosureSet = this.parentNode.parentNode;
let disclosuresInSet = disclosureSet.querySelectorAll('li');
let alreadyActive = this.parentNode.classList.contains(selector + '--expanded');

disclosuresInSet.forEach((disclosure) => {
disclosure.classList.remove(selector + '--expanded');
});

this.parentNode.classList.add(selector + '--expanded');
this.parentNode.classList.add(selector + '--expanded');

if (alreadyActive) {
this.parentNode.classList.remove(selector + '--expanded');
}
};
if (alreadyActive) {
this.parentNode.classList.remove(selector + '--expanded');
}
};

const disclosure = {
init: function () {
let disclosures = document.querySelectorAll('.' + selector + '__label');
const disclosure = {
init: function () {
let disclosures = document.querySelectorAll('.' + selector + '__label');

disclosures.forEach((disclosure) => {
disclosure.addEventListener('click', disclosureHandler, false);
});
},
disclosures.forEach((disclosure) => {
disclosure.addEventListener('click', disclosureHandler, false);
});
},

destroy: function () {
let disclosures = document.querySelectorAll('.' + selector + '__label');
destroy: function () {
let disclosures = document.querySelectorAll('.' + selector + '__label');

disclosures.forEach((disclosure) => {
disclosure.removeEventListener('click', disclosureHandler, false);
});
}
};
disclosures.forEach((disclosure) => {
disclosure.removeEventListener('click', disclosureHandler, false);
});
}
};

// import css to be processed to css file
disclosure.init();
})();
exports.disclosure = disclosure;
18 changes: 18 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@
<body class="m-medium">


<h3>Icons</h3>

<div class="flex row">
<div class="icon icon--theme icon"></div>
<div class="icon icon--theme icon--black8"></div>
<div class="icon icon--theme icon--black3"></div>
<div class="icon icon--theme icon--blue"></div>
<div class="icon icon--theme icon--purple"></div>
<div class="icon icon--theme icon--red"></div>
<div class="icon icon--theme icon--yellow"></div>
<div class="icon icon--theme icon--hot-pink"></div>
<div class="icon icon--theme icon--green"></div>
</div>


</div>

<hr>

<h3>Buttons</h3>
<button class="button button--primary mb-xxsmall">Label</button>
Expand Down
6 changes: 4 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { terser } from 'rollup-plugin-terser';
import prettier from 'rollup-plugin-prettier';
import postcss from 'rollup-plugin-postcss';
import autoprefixer from 'autoprefixer';
import inlineSVG from 'postcss-inline-svg';

const production = !process.env.ROLLUP_WATCH;

export default {
input: 'src/js/figma-plugin-ds.js',
output: {
file: 'public/figma-plugin-ds.js',
format: 'iife'
format: 'cjs'
},
plugins: [
resolve(),
Expand All @@ -23,7 +24,8 @@ export default {
extract: true,
minimize: production && true, // minify, only on build for prod
plugins: [
autoprefixer()
autoprefixer(),
inlineSVG()
]
}),
production && terser() // minify, only on build for prod
Expand Down
Loading

0 comments on commit 2f1a462

Please sign in to comment.