@rebilly/instruments 3.6.0-beta.0 → 3.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebilly/instruments",
3
- "version": "3.6.0-beta.0",
3
+ "version": "3.7.0-beta.0",
4
4
  "author": "Rebilly",
5
5
  "main": "dist/index.js",
6
6
  "unpkg": "dist/index.min.js",
@@ -25,7 +25,6 @@
25
25
  "lodash.merge": "^4.6.2",
26
26
  "popostmate": "^1.6.4",
27
27
  "postcss": "^8.4.5",
28
- "postcss-css-variables": "^0.18.0",
29
28
  "rebilly-js-sdk": "^44.4.0",
30
29
  "values.js": "^2.0.0"
31
30
  },
@@ -1,13 +1,37 @@
1
1
  import css from 'css';
2
- import postcss from 'postcss';
3
- import cssvariables from 'postcss-css-variables';
4
2
  import camelCase from 'lodash.camelcase';
5
3
 
6
- const resolveCssVars = async (rawCss) => postcss([
7
- cssvariables({ preserve: false })
8
- ])
9
- .process(rawCss, { from: undefined })
10
- .then(output => output.css);
4
+ function processCSS(rawCss) {
5
+ const cssMap = {};
6
+ [...rawCss.matchAll(/(--rebilly.*(?=:))[:\s](.*(?=;))/g)]
7
+ .forEach(item => {
8
+ cssMap[item[1]] = item[2].trim();
9
+ });
10
+
11
+ function parseValue(value) {
12
+ const cssVariables = value.match(/var\((.+?)\)/g);
13
+ if(cssVariables) {
14
+ let cssValue = value;
15
+ cssVariables.forEach(variable => {
16
+ const cssVarName = variable.match(/\((.*)\)/i)[1];
17
+ cssValue = value.replace(variable, cssMap[cssVarName]);
18
+ });
19
+ return parseValue(cssValue);
20
+ }
21
+ return value
22
+ }
23
+
24
+ return Object.entries(cssMap)
25
+ .map(([key, value]) => [key, parseValue(value)]);
26
+ }
27
+
28
+ function replaceCssVars(rawCss) {
29
+ processCSS(rawCss).forEach(([key, value]) => {
30
+ rawCss = rawCss.split(`var(${key})`).join(value);
31
+ });
32
+
33
+ return rawCss;
34
+ }
11
35
 
12
36
  const getStyleProps = (ast, selector) => {
13
37
  const { rules } = ast.stylesheet;
@@ -44,7 +68,7 @@ export default async ({
44
68
  ${options.css || ''}
45
69
  `;
46
70
 
47
- const resolvedCss = await resolveCssVars(fullCss);
71
+ const resolvedCss = replaceCssVars(fullCss);
48
72
  const cssAst = css.parse(resolvedCss);
49
73
 
50
74
  const cssSelectors = {
@@ -102,4 +126,4 @@ export default async ({
102
126
  }
103
127
 
104
128
  return framepayStyle;
105
- }
129
+ }
@@ -20,7 +20,7 @@ export const framepayStyle = () => `
20
20
  box-shadow: none;
21
21
  }
22
22
 
23
- .rebilly-instruments-framepay .rebilly-framepay.rebilly-framepay-digital-wallet {
23
+ .rebilly-instruments-framepay .rebilly-framepay.rebilly-framepay-google-pay {
24
24
  min-height: auto;
25
25
  border: none;
26
26
  margin: 0;