From 65969039a4bbbd9cede66aab955b5e66c654d2a7 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Fri, 31 Jul 2020 18:54:43 +0200 Subject: [PATCH] Add mixin to populate CSS --- src/networksMixin.js | 23 +++++++++++++++++++++++ src/style.css | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 src/networksMixin.js diff --git a/src/networksMixin.js b/src/networksMixin.js new file mode 100644 index 0000000..7c26dae --- /dev/null +++ b/src/networksMixin.js @@ -0,0 +1,23 @@ +import { fullNetworkMap } from './networks'; + +export default function networks() { + const ruleObj = {}; + + Object.entries(fullNetworkMap).forEach(([name, network]) => { + ruleObj[`.shareon > *.${name}`] = { + 'background-color': network.color, + }; + + ruleObj[`.shareon > *.${name}::before`] = { + 'background-image': `url('${network.icon}')`, + }; + + if (Object.prototype.hasOwnProperty.call(network, 'iconWhenText')) { + ruleObj[`.shareon > *.${name}:not(:empty)::before`] = { + 'background-image': `url('${network.iconWhenText}')`, + }; + } + }); + + return ruleObj; +} diff --git a/src/style.css b/src/style.css index dc57cee..6d8c823 100644 --- a/src/style.css +++ b/src/style.css @@ -72,3 +72,5 @@ content: ''; vertical-align: bottom; } + +@mixin networks;