From 7219a9b8ead07f51669309994e069bb9acd23b73 Mon Sep 17 00:00:00 2001 From: Jenna Badanowski <29607818+jbadan@users.noreply.github.com> Date: Tue, 3 Mar 2020 13:58:27 -0800 Subject: [PATCH] fix: postcss plugin to remove fonts from sap-theming css variables (#750) --- config/postcss-remove-fonts.js | 12 ++++++++++++ config/postcss.config.js | 2 ++ src/fundamental-styles.scss | 1 + src/variables.scss | 1 + 4 files changed, 16 insertions(+) create mode 100644 config/postcss-remove-fonts.js create mode 100644 src/variables.scss diff --git a/config/postcss-remove-fonts.js b/config/postcss-remove-fonts.js new file mode 100644 index 0000000000..2bbbe03663 --- /dev/null +++ b/config/postcss-remove-fonts.js @@ -0,0 +1,12 @@ +const postcss = require('postcss'); + +module.exports = postcss.plugin('remove font variables', function (opts) { + return function (root) { + root.walkDecls(decl => { + const regex = /--sapFontUrl_([a-zA-Z-_0-9])+/g; + if(decl.prop.match(regex)){ + decl.remove(); + } + }); + } +}); \ No newline at end of file diff --git a/config/postcss.config.js b/config/postcss.config.js index f3b67cc8c1..8c77dbd860 100644 --- a/config/postcss.config.js +++ b/config/postcss.config.js @@ -6,6 +6,7 @@ const postcssBanner = require('postcss-banner'); const postcssAddFallback = require('./postcss-add-fallback.js'); const postcssCustomProperties = require('postcss-custom-properties'); //ie11 fallbacks const postcssImport = require('postcss-import'); +const postcssRemoveFonts = require('./postcss-remove-fonts.js'); const packageVersion = require('../package.json').version; const year = new Date().getFullYear(); @@ -36,6 +37,7 @@ module.exports = { postcssCustomProperties({ preserve: true }), + postcssRemoveFonts(), // remove fonts from @sap-theming/theming-base-content minify, postcssBanner({ banner: `Fundamental Library Styles v${packageVersion} diff --git a/src/fundamental-styles.scss b/src/fundamental-styles.scss index 6e82b28659..4d99d3c4e1 100644 --- a/src/fundamental-styles.scss +++ b/src/fundamental-styles.scss @@ -1,5 +1,6 @@ // do not change import order @import "./root"; +@import "./variables"; @import "./settings"; @import "./icon"; @import "./layout"; diff --git a/src/variables.scss b/src/variables.scss new file mode 100644 index 0000000000..84ca873763 --- /dev/null +++ b/src/variables.scss @@ -0,0 +1 @@ +@import '@sap-theming/theming-base-content/content/Base/baseLib/sap_fiori_3/css_variables.css';