@rebilly/instruments 2.0.0-beta → 3.0.1-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.
Files changed (197) hide show
  1. package/dist/events/index.js +2 -1
  2. package/dist/functions/mount/fetch-data.js +187 -0
  3. package/dist/functions/mount/fetch-data.spec.js +189 -0
  4. package/dist/functions/mount/index.js +132 -164
  5. package/dist/functions/mount/mount.spec.js +2 -4
  6. package/dist/functions/mount/setup-element.js +40 -0
  7. package/dist/functions/mount/setup-framepay-theme.js +95 -0
  8. package/dist/functions/mount/setup-framepay.js +5 -1
  9. package/dist/functions/mount/setup-i18n.js +33 -0
  10. package/dist/functions/mount/setup-options.js +68 -47
  11. package/dist/functions/mount/setup-options.spec.js +66 -0
  12. package/dist/functions/mount/setup-storefront.js +6 -4
  13. package/dist/functions/mount/setup-styles.js +4 -2
  14. package/dist/functions/purchase.js +129 -24
  15. package/dist/functions/purchase.spec.js +13 -10
  16. package/dist/functions/setup.js +85 -0
  17. package/dist/functions/setup.spec.js +87 -0
  18. package/dist/functions/show.js +8 -4
  19. package/dist/functions/show.spec.js +9 -5
  20. package/dist/functions/update.js +39 -24
  21. package/dist/functions/update.spec.js +0 -4
  22. package/dist/i18n/en.json +5 -2
  23. package/dist/i18n/es.json +4 -1
  24. package/dist/index.js +17 -3
  25. package/dist/index.spec.js +3 -16
  26. package/dist/loader/index.js +4 -3
  27. package/dist/storefront/index.js +33 -0
  28. package/dist/storefront/invoices.js +27 -0
  29. package/dist/storefront/models/base-model.js +18 -0
  30. package/dist/storefront/models/invoice-model.js +14 -0
  31. package/dist/storefront/models/plan-model.js +4 -35
  32. package/dist/storefront/models/product-model.js +4 -23
  33. package/dist/storefront/models/summary-model.js +12 -25
  34. package/dist/storefront/models/transaction-model.js +31 -0
  35. package/dist/storefront/payment-instruments.js +47 -0
  36. package/dist/storefront/payment-instruments.spec.js +55 -0
  37. package/dist/storefront/plans.js +10 -18
  38. package/dist/storefront/plans.spec.js +3 -13
  39. package/dist/storefront/products.js +10 -13
  40. package/dist/storefront/products.spec.js +12 -19
  41. package/dist/storefront/purchase.js +23 -12
  42. package/dist/storefront/purchase.spec.js +1 -20
  43. package/dist/storefront/ready-to-pay.js +18 -15
  44. package/dist/storefront/ready-to-pay.spec.js +2 -12
  45. package/dist/storefront/summary.js +21 -17
  46. package/dist/storefront/summary.spec.js +4 -15
  47. package/dist/storefront/transactions.js +27 -0
  48. package/dist/style/base/__snapshots__/theme.spec.js.snap +188 -45
  49. package/dist/style/base/default-theme.js +699 -0
  50. package/dist/style/base/index.js +48 -16
  51. package/dist/style/base/theme.js +16 -48
  52. package/dist/style/base/theme.spec.js +4 -15
  53. package/dist/style/components/address.js +3 -3
  54. package/dist/style/components/button.js +32 -22
  55. package/dist/style/components/divider.js +9 -9
  56. package/dist/style/components/forms/checkbox.js +12 -9
  57. package/dist/style/components/forms/field.js +18 -6
  58. package/dist/style/components/forms/form.js +2 -2
  59. package/dist/style/components/forms/input.js +54 -13
  60. package/dist/style/components/forms/label.js +39 -18
  61. package/dist/style/components/forms/select.js +54 -22
  62. package/dist/style/components/forms/validation.js +53 -6
  63. package/dist/style/components/icons.js +4 -4
  64. package/dist/style/components/loader.js +5 -3
  65. package/dist/style/components/methods.js +18 -15
  66. package/dist/style/components/overlay.js +5 -5
  67. package/dist/style/helpers/index.js +46 -46
  68. package/dist/style/index.js +3 -1
  69. package/dist/style/payment-instruments/payment-card.js +4 -4
  70. package/dist/style/utils/border.js +47 -0
  71. package/dist/style/utils/color-values.js +39 -3
  72. package/dist/style/utils/remove-empty-null.js +20 -0
  73. package/dist/style/vendor/framepay.js +11 -8
  74. package/dist/style/vendor/postmate.js +2 -2
  75. package/dist/style/views/confirmation.js +13 -13
  76. package/dist/style/views/method-selector.js +2 -2
  77. package/dist/style/views/modal.js +6 -6
  78. package/dist/style/views/result.js +4 -4
  79. package/dist/style/views/summary.js +26 -22
  80. package/dist/views/__snapshots__/summary.spec.js.snap +77 -119
  81. package/dist/views/common/iframe/base-iframe.js +2 -0
  82. package/dist/views/common/iframe/modal-iframe.js +50 -4
  83. package/dist/views/confirmation.js +19 -8
  84. package/dist/views/method-selector/generate-digital-wallet.js +12 -3
  85. package/dist/views/method-selector/generate-digital-wallet.spec.js +11 -0
  86. package/dist/views/method-selector/get-payment-methods.js +13 -2
  87. package/dist/views/method-selector/get-payment-methods.spec.js +21 -19
  88. package/dist/views/method-selector/index.js +23 -34
  89. package/dist/views/method-selector/method-selector.spec.js +50 -55
  90. package/dist/views/method-selector/mount-methods.js +5 -8
  91. package/dist/views/modal.js +8 -2
  92. package/dist/views/result.js +3 -4
  93. package/dist/views/summary.js +156 -97
  94. package/dist/views/summary.spec.js +53 -58
  95. package/package.json +4 -2
  96. package/src/events/index.js +2 -1
  97. package/src/functions/mount/fetch-data.js +152 -0
  98. package/src/functions/mount/fetch-data.spec.js +238 -0
  99. package/src/functions/mount/index.js +101 -158
  100. package/src/functions/mount/mount.spec.js +3 -5
  101. package/src/functions/mount/setup-element.js +26 -0
  102. package/src/functions/mount/setup-framepay-theme.js +82 -0
  103. package/src/functions/mount/setup-framepay.js +5 -1
  104. package/src/functions/mount/setup-i18n.js +19 -0
  105. package/src/functions/mount/setup-options.js +78 -48
  106. package/src/functions/mount/setup-options.spec.js +60 -0
  107. package/src/functions/mount/setup-storefront.js +6 -4
  108. package/src/functions/mount/setup-styles.js +4 -2
  109. package/src/functions/on.spec.js +1 -1
  110. package/src/functions/purchase.js +99 -23
  111. package/src/functions/purchase.spec.js +10 -10
  112. package/src/functions/setup.js +48 -0
  113. package/src/functions/setup.spec.js +98 -0
  114. package/src/functions/show.js +2 -4
  115. package/src/functions/show.spec.js +3 -4
  116. package/src/functions/update.js +40 -25
  117. package/src/functions/update.spec.js +0 -4
  118. package/src/i18n/en.json +5 -2
  119. package/src/i18n/es.json +4 -1
  120. package/src/index.js +9 -3
  121. package/src/index.spec.js +3 -21
  122. package/src/loader/index.js +3 -3
  123. package/src/storefront/index.js +28 -0
  124. package/src/storefront/invoices.js +11 -0
  125. package/src/storefront/models/base-model.js +10 -0
  126. package/src/storefront/models/invoice-model.js +3 -0
  127. package/src/storefront/models/plan-model.js +3 -35
  128. package/src/storefront/models/product-model.js +3 -23
  129. package/src/storefront/models/summary-model.js +12 -19
  130. package/src/storefront/models/transaction-model.js +19 -0
  131. package/src/storefront/payment-instruments.js +30 -0
  132. package/src/storefront/payment-instruments.spec.js +69 -0
  133. package/src/storefront/plans.js +6 -17
  134. package/src/storefront/plans.spec.js +4 -11
  135. package/src/storefront/products.js +8 -16
  136. package/src/storefront/products.spec.js +16 -22
  137. package/src/storefront/purchase.js +14 -16
  138. package/src/storefront/purchase.spec.js +2 -14
  139. package/src/storefront/ready-to-pay.js +13 -16
  140. package/src/storefront/ready-to-pay.spec.js +3 -10
  141. package/src/storefront/summary.js +19 -17
  142. package/src/storefront/summary.spec.js +5 -12
  143. package/src/storefront/transactions.js +11 -0
  144. package/src/style/base/__snapshots__/theme.spec.js.snap +188 -45
  145. package/src/style/base/default-theme.js +674 -0
  146. package/src/style/base/index.js +48 -16
  147. package/src/style/base/theme.js +17 -47
  148. package/src/style/base/theme.spec.js +4 -16
  149. package/src/style/components/address.js +3 -3
  150. package/src/style/components/button.js +32 -24
  151. package/src/style/components/divider.js +9 -9
  152. package/src/style/components/forms/checkbox.js +11 -11
  153. package/src/style/components/forms/field.js +18 -6
  154. package/src/style/components/forms/form.js +2 -2
  155. package/src/style/components/forms/input.js +54 -13
  156. package/src/style/components/forms/label.js +39 -18
  157. package/src/style/components/forms/select.js +54 -22
  158. package/src/style/components/forms/validation.js +53 -6
  159. package/src/style/components/icons.js +4 -4
  160. package/src/style/components/loader.js +4 -5
  161. package/src/style/components/methods.js +18 -15
  162. package/src/style/components/overlay.js +5 -5
  163. package/src/style/helpers/index.js +46 -46
  164. package/src/style/index.js +2 -1
  165. package/src/style/payment-instruments/payment-card.js +4 -4
  166. package/src/style/utils/border.js +34 -0
  167. package/src/style/utils/color-values.js +27 -1
  168. package/src/style/utils/remove-empty-null.js +10 -0
  169. package/src/style/vendor/framepay.js +11 -8
  170. package/src/style/vendor/postmate.js +2 -2
  171. package/src/style/views/confirmation.js +13 -13
  172. package/src/style/views/method-selector.js +2 -2
  173. package/src/style/views/modal.js +6 -6
  174. package/src/style/views/result.js +4 -4
  175. package/src/style/views/summary.js +26 -22
  176. package/src/views/__snapshots__/summary.spec.js.snap +77 -119
  177. package/src/views/common/iframe/base-iframe.js +2 -0
  178. package/src/views/common/iframe/modal-iframe.js +45 -3
  179. package/src/views/confirmation.js +15 -5
  180. package/src/views/method-selector/generate-digital-wallet.js +10 -3
  181. package/src/views/method-selector/generate-digital-wallet.spec.js +10 -0
  182. package/src/views/method-selector/get-payment-methods.js +7 -2
  183. package/src/views/method-selector/get-payment-methods.spec.js +26 -23
  184. package/src/views/method-selector/index.js +21 -28
  185. package/src/views/method-selector/method-selector.spec.js +49 -64
  186. package/src/views/method-selector/mount-methods.js +5 -8
  187. package/src/views/modal.js +6 -2
  188. package/src/views/result.js +4 -3
  189. package/src/views/summary.js +161 -117
  190. package/src/views/summary.spec.js +60 -75
  191. package/tests/mocks/rebilly-instruments-mock.js +37 -7
  192. package/tests/mocks/storefront-api-mock.js +8 -0
  193. package/tests/mocks/storefront-mock.js +17 -0
  194. package/dist/functions/mount/fetch-summary-data.js +0 -46
  195. package/dist/functions/mount/fetch-summary-data.spec.js +0 -43
  196. package/src/functions/mount/fetch-summary-data.js +0 -29
  197. package/src/functions/mount/fetch-summary-data.spec.js +0 -40
@@ -1,4 +1,31 @@
1
1
  export const base = (theme) => `
2
+ /* Instruments 'global' variables
3
+ ------------------------------------------------------------ */
4
+ :root,
5
+ #rebilly-instruments-app,
6
+ .rebilly-instruments-content,
7
+ .rebilly-instruments-loader,
8
+ .rebilly-instruments-modal-overlay {
9
+ ${theme.cssVars}
10
+
11
+ --rebilly-spacings-base: calc(var(--rebilly-fontSizeBase) * 1.5);
12
+ --rebilly-spacings-2xs: calc(var(--rebilly-spacings-base) * 0.16667);
13
+ --rebilly-spacings-xs: calc(var(--rebilly-spacings-base) * 0.25);
14
+ --rebilly-spacings-s: calc(var(--rebilly-spacings-base) * 0.5);
15
+ --rebilly-spacings-m: var(--rebilly-spacings-base);
16
+ --rebilly-spacings-l: calc(var(--rebilly-spacings-base) * 2);
17
+ --rebilly-spacings-xl: calc(var(--rebilly-spacings-base) * 4);
18
+ --rebilly-spacings-2xl: calc(var(--rebilly-spacings-base) * 4.6667);
19
+
20
+ --rebilly-spacings-input-py: calc(var(--rebilly-spacings-2xs) * 2);
21
+ --rebilly-spacings-input-px: calc(var(--rebilly-spacings-s) + var(--rebilly-spacings-2xs));
22
+ --rebilly-spacings-label-offset-left: var(--rebilly-spacings-input-px);
23
+ --rebilly-spacings-form-element-min-height: calc(var(--rebilly-spacings-base) * 1.83333);
24
+ --rebilly-spacings-button-py: var(--rebilly-spacings-input-py);
25
+ --rebilly-spacings-button-px: var(--rebilly-spacings-input-px);
26
+ }
27
+
28
+
2
29
  /* Base, Typography
3
30
  ------------------------------------------------------------ */
4
31
  /* Base setup for top level elements */
@@ -6,19 +33,21 @@ export const base = (theme) => `
6
33
  .rebilly-instruments-method-content,
7
34
  .rebilly-instruments-confirmation,
8
35
  .rebilly-instruments-results {
9
- color: ${theme.color.text};
10
- background: ${theme.color.background};
11
- font-size: ${theme.typography.fontSize};
12
- line-height: ${theme.typography.lineHeight};
13
- font-family: ${theme.typography.fontFamily};
36
+ color: var(--rebilly-colorText);
37
+ background: var(--rebilly-colorBackground);
38
+ font-size: var(--rebilly-fontSizeBase);
39
+ font-weight: var(--rebilly-fontWeightBase);
40
+ line-height: var(--rebilly-fontLineHeightBase, calc(var(--rebilly-fontSizeBase) * 1.5));
41
+ font-family: var(--rebilly-fontFamily);
14
42
  -webkit-font-smoothing: antialiased;
15
43
  -moz-osx-font-smoothing: grayscale;
16
44
  text-align: left;
17
45
  transition: all 200ms;
46
+ font-smooth: var(--rebilly-fontSmooth);
18
47
  }
19
48
 
20
49
  .rebilly-instruments-link {
21
- color: ${theme.color.primary};
50
+ color: var(--rebilly-colorPrimary);
22
51
  cursor: pointer;
23
52
  }
24
53
 
@@ -27,7 +56,7 @@ export const base = (theme) => `
27
56
  }
28
57
 
29
58
  .rebilly-instruments-link .rebilly-instruments-icon {
30
- fill: ${theme.color.primary};
59
+ fill: var(--rebilly-colorPrimary);
31
60
  }
32
61
 
33
62
  .rebilly-instruments-link.has-icon-left,
@@ -36,28 +65,31 @@ export const base = (theme) => `
36
65
  }
37
66
 
38
67
  .rebilly-instruments-link.has-icon-left .rebilly-instruments-icon {
39
- margin-right: ${theme.space.xs};
68
+ margin-right: var(--rebilly-spacings-xs);
40
69
  }
41
70
 
42
71
  .rebilly-instruments-link.has-icon-right .rebilly-instruments-icon {
43
- margin-left: ${theme.space.xs};
72
+ margin-left: var(--rebilly-spacings-xs);
44
73
  }
45
74
 
46
75
  /* Typography */
47
76
  .rebilly-instruments-h1,
48
77
  .rebilly-instruments-h2 {
49
- font-weight: 500;
78
+ font-weight: var(--rebilly-headingFontWeight);
79
+ font-family: var(--rebilly-headingFontFamily);
80
+ color: var(--rebilly-headingColorText);
50
81
  }
51
82
 
52
83
  .rebilly-instruments-h1 {
53
- font-size: calc(${theme.typography.fontSize} * 1.5);
54
- line-height: calc(${theme.typography.lineHeight} * 1.5);
55
- margin: 0 0 calc(${theme.space.m} * 1.5) 0;
84
+ font-size: calc(var(--rebilly-fontSizeBase) * 1.5);
85
+ line-height: 1.5;
86
+ line-height: calc(${theme.fontLineHeightBase} * 1.5);
87
+ margin: 0 0 calc(var(--rebilly-spacings-base) * 1.5) 0;
56
88
  }
57
89
 
58
90
  .rebilly-instruments-h2 {
59
- font-size: calc(${theme.typography.fontSize} * 1.12);
60
- line-height: ${theme.typography.lineHeight};
61
- margin: 0 0 ${theme.space.m} 0;
91
+ font-size: calc(var(--rebilly-fontSizeBase) * 1.125);
92
+ line-height: var(--rebilly-fontLineHeightBase, 1.33);
93
+ margin: 0 0 var(--rebilly-spacings-base) 0;
62
94
  }
63
95
  `;
@@ -1,61 +1,31 @@
1
- import merge from 'lodash.merge';
2
- import { colorValues, alphaColor } from '../utils/color-values';
1
+ import theme from './default-theme';
3
2
 
4
3
  export class Theme {
5
4
  constructor(overrides = {}) {
6
5
  this.overrides = overrides;
7
- this.theme = {
8
- color: {
9
- primary: '#0044d4',
10
- errorText: '#cd5c5c',
11
- text: '#0D2B3E',
12
- buttonText: '#ffffff',
13
- background: '#ffffff'
14
- },
15
- typography: {
16
- fontFamily: 'Avenir, Helvetica, Arial, sans-serif',
17
- fontSize: '16px',
18
- lineHeight: '24px',
19
- captionFontSize: '12px',
20
- captionLineHeight: '12px'
21
- },
22
- space: {
23
- xxs: '4px',
24
- xs: '6px',
25
- s: '12px',
26
- m: '24px',
27
- l: '48px',
28
- xl: '96px',
29
- xxl: '112px',
30
- form: {
31
- padding: '8px 16px',
32
- verticalPadding: '8px',
33
- horizontalPadding: '16px',
34
- minHeight: '44px'
35
- }
36
- },
37
- borderRadius: '4px'
38
- };
6
+ this.theme = theme;
39
7
  }
40
8
 
41
- get getComputed() {
42
- return this.computed();
9
+ static nonCssProperties = ['labels'];
10
+
11
+ overrideTheme() {
12
+ Object.keys(this.overrides).forEach(prop => {
13
+ this.theme[prop] = this.overrides[prop];
14
+ })
43
15
  }
44
16
 
45
- computed() {
46
- return {
47
- color: {
48
- primaryValues: colorValues(this.theme.color.primary),
49
- mutedText: alphaColor(this.theme.color.text, 0.6),
50
- mutedBorder: alphaColor(this.theme.color.text, 0.25)
51
- }
52
- };
17
+ get cssVars() {
18
+ return Object.keys(this.theme)
19
+ .filter(v => !Theme.nonCssProperties.includes(v))
20
+ .map(p => `--rebilly-${p}: ${this.theme[p]};`)
21
+ .join('\n');
53
22
  }
54
23
 
55
24
  build() {
25
+ this.overrideTheme();
56
26
  return {
57
- ...merge(this.theme, this.overrides),
58
- getComputed: this.getComputed
59
- };
27
+ ...this.theme,
28
+ cssVars: this.cssVars
29
+ }
60
30
  }
61
31
  }
@@ -1,5 +1,4 @@
1
1
  import { Theme } from './theme';
2
- import Values from 'values.js';
3
2
 
4
3
  describe('RebillyInstruments theme', () => {
5
4
  it('builds the theme object', () => {
@@ -10,23 +9,12 @@ describe('RebillyInstruments theme', () => {
10
9
 
11
10
  it('properly overrides the default properties', () => {
12
11
  const overrides = {
13
- color: {
14
- primary: 'purple',
15
- text: 'gray'
16
- }
12
+ colorPrimary: 'red',
13
+ buttonBorderRadius: '30px'
17
14
  };
18
15
  const theme = new Theme(overrides).build();
19
16
 
20
- expect(theme.color.primary).toEqual('purple');
21
- expect(theme.color.text).toEqual('gray');
22
- });
23
-
24
- it('computes new styles from theme properties', () => {
25
- const theme = new Theme().build();
26
-
27
- expect(theme.getComputed.color.primaryValues instanceof Values).toEqual(
28
- true
29
- );
30
- expect(theme.getComputed.color.mutedText).toEqual('rgba(13, 43, 62, 0.6)');
17
+ expect(theme.colorPrimary).toEqual('red');
18
+ expect(theme.buttonBorderRadius).toEqual('30px');
31
19
  });
32
20
  });
@@ -1,13 +1,13 @@
1
1
  // -----------------------------------------------------------------------------
2
2
  // This file contains all styles related to the address component.
3
3
  // -----------------------------------------------------------------------------
4
- export const address = (theme) => `
4
+ export const address = () => `
5
5
  /**
6
6
  * Address
7
7
  */
8
8
  .rebilly-instruments-address {
9
- margin: 0 0 ${theme.space.m};
10
- color: ${theme.getComputed.color.mutedText};
9
+ margin: 0 0 var(--rebilly-spacings-base);
10
+ color: var(--rebilly-colorMutedText);
11
11
  font-style: normal;
12
12
  }
13
13
 
@@ -1,22 +1,23 @@
1
1
  // -----------------------------------------------------------------------------
2
2
  // This file contains all styles related to the button component.
3
3
  // -----------------------------------------------------------------------------
4
- export const button = (theme) => `
4
+ export const button = () => `
5
5
  /**
6
6
  * Buttons
7
7
  */
8
8
  .rebilly-instruments-button {
9
- font-size: ${theme.typography.fontSize};
10
- font-family: ${theme.typography.fontFamily};
11
- line-height: ${theme.typography.lineHeight};
12
- padding: ${theme.space.form.padding};
9
+ font-size: var(--rebilly-buttonFontSize);
10
+ font-family: var(--rebilly-buttonFontFamily);
11
+ line-height: var(--rebilly-buttonFontLineHeight);
12
+ padding: var(--rebilly-spacings-button-py) var(--rebilly-spacings-button-px);
13
13
  box-sizing: border-box;
14
- background: ${theme.color.primary};
15
- color: ${theme.color.buttonText};
16
- border-radius: ${theme.borderRadius};
17
- margin: calc(${theme.space.xxs} + ${theme.space.s} / 2) 0;
18
- font-weight: 500;
19
- border: none;
14
+ background: var(--rebilly-buttonColorBackground);
15
+ color: var(--rebilly-buttonColorText, #FFF);
16
+ border-radius: var(--rebilly-buttonBorderRadius);
17
+ font-weight: var(--rebilly-buttonFontWeight);
18
+ border: var(--rebilly-buttonBorder);
19
+ box-shadow: var(--rebilly-buttonBoxShadow);
20
+ margin: calc(var(--rebilly-spacings-2xs) + var(--rebilly-spacings-s) / 2) 0;
20
21
  width: 100%;
21
22
  cursor: pointer;
22
23
  min-height: 44px;
@@ -24,27 +25,34 @@ export const button = (theme) => `
24
25
  outline: none;
25
26
  }
26
27
 
27
- .rebilly-instruments-button:hover,
28
- .rebilly-instruments-button:active {
29
- background: ${theme.getComputed.color.primaryValues.shade(20).hexString()};
28
+ .rebilly-instruments-button:not([disabled]):hover {
29
+ background: var(--rebilly-buttonHoverColorBackground);
30
+ }
31
+
32
+ .rebilly-instruments-button:not([disabled]):active {
33
+ background: var(--rebilly-buttonActiveColorBackground);
30
34
  }
31
35
 
32
36
  .rebilly-instruments-button.rebilly-instruments-button-secondary {
33
- background: ${theme.color.background};
34
- box-shadow: inset 0 0 0 1px ${theme.color.primary};
35
- color: ${theme.color.primary};
37
+ background: var(--rebilly-colorBackground);
38
+ color: var(--rebilly-buttonColorBackground);
39
+ border-color: var(--rebilly-buttonColorBackground);
36
40
  }
37
41
 
38
- .rebilly-instruments-button.rebilly-instruments-button-secondary:hover,
39
- .rebilly-instruments-button.rebilly-instruments-button-secondary:active {
40
- background: ${theme.color.background};
42
+ .rebilly-instruments-button.rebilly-instruments-button-secondary:not([disabled]):hover,
43
+ .rebilly-instruments-button.rebilly-instruments-button-secondary:not([disabled]):active {
44
+ background: var(--rebilly-colorBackground);
41
45
  }
42
46
 
43
- .rebilly-instruments-button:focus { box-shadow: 0 0 0 2px ${theme.getComputed.color.primaryValues
44
- .tint(60)
45
- .hexString()}; }
47
+ .rebilly-instruments-button:focus {
48
+ box-shadow: 0 0 0 1px var(--rebilly-colorPrimary);
49
+ }
46
50
 
47
- .rebilly-instruments-button:disabled { opacity: 0.6; }
51
+ .rebilly-instruments-button:disabled,
52
+ .rebilly-instruments-button:disabled:hover {
53
+ cursor: not-allowed;
54
+ opacity: 0.6;
55
+ }
48
56
 
49
57
  .rebilly-instruments-button::first-letter { text-transform: uppercase; }
50
58
 
@@ -1,13 +1,13 @@
1
1
  // -----------------------------------------------------------------------------
2
2
  // This file contains all styles related to the divider component.
3
3
  // -----------------------------------------------------------------------------
4
- export const divider = (theme) => `
4
+ export const divider = () => `
5
5
  /**
6
6
  * Divider
7
7
  */
8
8
  .rebilly-instruments-divider {
9
- line-height: ${theme.typography.lineHeight};
10
- padding: ${theme.space.m} 0;
9
+ line-height: var(--rebilly-fontLineHeightBase, calc(var(--rebilly-fontSizeBase) * 1.5));
10
+ padding: var(--rebilly-spacings-base) 0;
11
11
  margin: 0;
12
12
  position: relative;
13
13
  outline: 0;
@@ -16,7 +16,7 @@ export const divider = (theme) => `
16
16
  }
17
17
 
18
18
  .rebilly-instruments-divider::before {
19
- background: ${theme.getComputed.color.mutedBorder};
19
+ background: var(--rebilly-colorMutedBorder);
20
20
  content: '';
21
21
  position: absolute;
22
22
  left: 0;
@@ -26,13 +26,13 @@ export const divider = (theme) => `
26
26
  }
27
27
 
28
28
  .rebilly-instruments-divider .rebilly-instruments-divider-label {
29
- color: ${theme.getComputed.color.mutedText};
29
+ color: var(--rebilly-colorMutedText);
30
30
  font-weight: 500;
31
31
  text-transform: uppercase;
32
- padding: 0 ${theme.space.s};
33
- line-height: 14px;
34
- background-color: ${theme.color.background};
35
- font-size: 12px;
32
+ padding: 0 var(--rebilly-spacings-s);
33
+ line-height: calc(var(--rebilly-fontSizeBase) * 0.875);
34
+ background-color: var(--rebilly-colorBackground);
35
+ font-size: calc(var(--rebilly-fontSizeBase) * 0.875);
36
36
  position: relative;
37
37
  display: inline-block;
38
38
  }
@@ -1,3 +1,4 @@
1
+ import { lighten } from '../../utils/color-values';
1
2
  // -----------------------------------------------------------------------------
2
3
  // This file contains all styles related to the checkbox component.
3
4
  // -----------------------------------------------------------------------------
@@ -8,9 +9,10 @@ export const checkbox = (theme) => `
8
9
  .rebilly-instruments-form-field-checkbox {
9
10
  position: relative;
10
11
  opacity: 1;
11
- padding-left: calc(${theme.space.m} + ${theme.space.s});
12
12
  align-items: center;
13
- display: inline-block;
13
+ display: flex;
14
+ flex-direction: row-reverse;
15
+ justify-content: start;
14
16
  cursor: pointer;
15
17
  transform: none;
16
18
  }
@@ -28,13 +30,14 @@ export const checkbox = (theme) => `
28
30
  }
29
31
 
30
32
  .rebilly-instruments-form-field-checkbox span {
31
- position: absolute;
33
+ position: relative;
32
34
  top: 0;
33
35
  left: 0;
34
36
  height: 24px;
35
37
  width: 24px;
36
- border-radius: ${theme.borderRadius};
37
- box-shadow: inset 0 0 0 1px ${theme.getComputed.color.mutedBorder};
38
+ border-radius: 4px;
39
+ box-shadow: inset 0 0 0 1px var(--rebilly-colorMutedBorder);
40
+ margin-right: var(--rebilly-spacings-s);
38
41
  background-color: transparent;
39
42
  transition: all 200ms;
40
43
  }
@@ -47,7 +50,7 @@ export const checkbox = (theme) => `
47
50
  opacity: 0;
48
51
  width: 5px;
49
52
  height: 11px;
50
- border: solid ${theme.color.primary};
53
+ border: solid var(--rebilly-colorPrimary);
51
54
  border-width: 0 2px 2px 0;
52
55
  -webkit-transform: rotate(45deg);
53
56
  -ms-transform: rotate(45deg);
@@ -56,7 +59,7 @@ export const checkbox = (theme) => `
56
59
  }
57
60
 
58
61
  .rebilly-instruments-form-field-checkbox input[type="checkbox"]:checked ~ span {
59
- box-shadow: inset 0 0 0 2px ${theme.color.primary};
62
+ box-shadow: inset 0 0 0 2px var(--rebilly-colorPrimary);
60
63
  }
61
64
 
62
65
  .rebilly-instruments-form-field-checkbox input[type="checkbox"]:checked ~ span:after {
@@ -64,10 +67,7 @@ export const checkbox = (theme) => `
64
67
  }
65
68
 
66
69
  .rebilly-instruments-form-field-checkbox input[type="checkbox"]:focus ~ span {
67
- box-shadow: 0 0 0 2px ${theme.getComputed.color.primaryValues
68
- .tint(80)
69
- .hexString()},
70
- inset 0 0 0 1px ${theme.color.primary};
70
+ box-shadow: 0 0 0 2px ${lighten(theme.colorPrimary, 80)}, inset 0 0 0 1px var(--rebilly-colorPrimary);
71
71
  }
72
72
 
73
73
  .rebilly-instruments-form-field-checkbox input[type="checkbox"]:disabled ~ span {
@@ -1,25 +1,37 @@
1
1
  // -----------------------------------------------------------------------------
2
2
  // This file contains all styles related to the field component.
3
3
  // -----------------------------------------------------------------------------
4
- export const field = (theme) => `
4
+ export const field = () => `
5
5
  /**
6
6
  * Field
7
7
  */
8
8
  .rebilly-instruments-form-field {
9
- margin: calc(${theme.space.xxs} + ${theme.space.s}) 0;
9
+ margin: calc(var(--rebilly-spacings-xs) + var(--rebilly-spacings-s)) 0;
10
+ position: relative;
11
+ }
12
+
13
+ .rebilly-instruments-form-field.is-compact {
14
+ margin-top: calc(var(--rebilly-spacings-2xs) + var(--rebilly-spacings-s));
15
+ margin-bottom: calc(var(--rebilly-spacings-2xs) + var(--rebilly-spacings-s));
16
+ }
17
+
18
+ .rebilly-instruments-form-field > div {
19
+ display: flex;
20
+ flex-wrap: wrap;
21
+ flex-direction: column;
10
22
  position: relative;
11
23
  }
12
24
 
13
25
  /* Field group */
14
26
  .rebilly-instruments-form-field-group {
15
- margin: calc(-${theme.space.xxs} - ${theme.space.s}) 0;
27
+ margin: calc(calc(var(--rebilly-spacings-xs) * -1) - var(--rebilly-spacings-s)) 0;
16
28
  display: flex;
17
29
  }
18
30
 
19
31
  .rebilly-instruments-form-field-group > * {
20
32
  flex: 1 0;
21
- margin-left: ${theme.space.xs};
22
- margin-right: ${theme.space.xs}
33
+ margin-left: var(--rebilly-spacings-xs);
34
+ margin-right: var(--rebilly-spacings-xs);
23
35
  }
24
36
 
25
37
  .rebilly-instruments-form-field-group > *:first-child {
@@ -33,7 +45,7 @@ export const field = (theme) => `
33
45
  @media (max-width: 480px) {
34
46
  .rebilly-instruments-form-field-group {
35
47
  display: block;
36
- margin: calc(${theme.space.xxs} + ${theme.space.s}) 0;
48
+ margin: calc(var(--rebilly-spacings-2xs) + var(--rebilly-spacings-s)) 0;
37
49
  }
38
50
 
39
51
  .rebilly-instruments-form-field-group > * {
@@ -1,7 +1,7 @@
1
1
  // -----------------------------------------------------------------------------
2
2
  // This file contains all styles related to the form component.
3
3
  // -----------------------------------------------------------------------------
4
- export const form = (theme) => `
4
+ export const form = () => `
5
5
  /**
6
6
  * Form
7
7
  */
@@ -12,7 +12,7 @@ export const form = (theme) => `
12
12
  .rebilly-instruments-form select:-webkit-autofill,
13
13
  .rebilly-instruments-form select:-webkit-autofill:hover,
14
14
  .rebilly-instruments-form select:-webkit-autofill:focus {
15
- -webkit-text-fill-color: ${theme.color.text};
15
+ -webkit-text-fill-color: var(--rebilly-colorText);
16
16
  -webkit-box-shadow: 0 0 0px 1000px transparent inset;
17
17
  transition: background-color 5000s ease-in-out 0s;
18
18
  }
@@ -1,36 +1,77 @@
1
1
  // -----------------------------------------------------------------------------
2
2
  // This file contains all styles related to the input component.
3
3
  // -----------------------------------------------------------------------------
4
- export const input = (theme) => `
4
+ export const input = () => `
5
5
  /**
6
6
  * Input
7
7
  */
8
8
  .rebilly-instruments-form-field-input {
9
- font-size: ${theme.typography.fontSize};
10
- line-height: ${theme.typography.lineHeight};
11
- padding: ${theme.space.form.padding};
12
- min-height: ${theme.space.form.minHeight};
13
- border: 1px solid ${theme.getComputed.color.mutedBorder};
14
- border-radius: ${theme.borderRadius};
15
- color: ${theme.color.text};
16
- background: transparent;
9
+ font-size: var(--rebilly-inputFontSize);
10
+ font-family: var(--rebilly-inputFontFamily);
11
+ font-weight: var(--rebilly-inputFontWeight);
12
+ line-height: var(--rebilly-inputFontLineHeight);
13
+ padding: var(--rebilly-spacings-input-py) var(--rebilly-spacings-input-px);
14
+ min-height: var(--rebilly-spacings-form-element-min-height);
15
+ border: var(--rebilly-inputBorder);
16
+ border-radius: var(--rebilly-inputBorderRadius);
17
+ color: var(--rebilly-inputColorText);
18
+ background: var(--rebilly-inputColorBackground);
17
19
  box-sizing: border-box;
20
+ box-shadow: var(--rebilly-inputBoxShadow);
18
21
  width: 100%;
19
22
  transition: all 200ms;
23
+ order: 1;
24
+ }
25
+
26
+ .rebilly-instruments-form-field-input:hover {
27
+ background: var(--rebilly-inputHoverColorBackground);
28
+ color: var(--rebilly-inputHoverColorText);
29
+ font-family: var(--rebilly-inputHoverFontFamily);
30
+ font-size: var(--rebilly-inputHoverFontSize);
31
+ line-height: var(--rebilly-inputHoverFontLineHeight);
32
+ font-weight: var(--rebilly-inputHoverFontWeight);
33
+ border: var(--rebilly-inputHoverBorder);
34
+ border-radius: var(--rebilly-inputHoverBorderRadius);
35
+ box-shadow: var(--rebilly-inputHoverBoxShadow);
20
36
  }
21
37
 
22
38
  .rebilly-instruments-form-field-input:focus {
23
39
  outline: none;
24
- border: 1px solid ${theme.color.primary};
25
- box-shadow: 0 0 0 1px ${theme.color.primary};
40
+ background: var(--rebilly-inputFocusColorBackground);
41
+ color: var(--rebilly-inputFocusColorText);
42
+ font-family: var(--rebilly-inputFocusFontFamily);
43
+ font-size: var(--rebilly-inputFocusFontSize);
44
+ line-height: var(--rebilly-inputFocusFontLineHeight);
45
+ font-weight: var(--rebilly-inputFocusFontWeight);
46
+ border: var(--rebilly-inputFocusBorder);
47
+ border-radius: var(--rebilly-inputFocusBorderRadius);
48
+ box-shadow: var(--rebilly-inputFocusBoxShadow);
26
49
  }
27
50
 
28
51
  .rebilly-instruments-form-field-input::placeholder {
29
- color: ${theme.color.text};
30
- opacity: 0.5;
52
+ color: var(--rebilly-inputPlaceholderColorText);
53
+ font-family: var(--rebilly-inputPlaceholderFontFamily);
54
+ font-size: var(--rebilly-inputPlaceholderFontSize);
55
+ line-height: var(--rebilly-inputPlaceholderFontLineHeight);
56
+ font-weight: var(--rebilly-inputPlaceholderFontWeight);
57
+ opacity: 1;
58
+ }
59
+
60
+ .rebilly-instruments-form-field-input::selection {
61
+ color: var(--rebilly-inputSelectionColorText);
62
+ background: var(--rebilly-inputSelectionColorBackground);
31
63
  }
32
64
 
33
65
  .rebilly-instruments-form-field-input:disabled {
34
66
  opacity: 0.6;
35
67
  }
68
+
69
+ /* Floating Labels */
70
+ .is-floating .rebilly-instruments-form-field-input::placeholder {
71
+ opacity: 0;
72
+ }
73
+
74
+ .is-floating .rebilly-instruments-form-field-input:focus::placeholder {
75
+ opacity: 1;
76
+ }
36
77
  `;
@@ -1,34 +1,55 @@
1
1
  // -----------------------------------------------------------------------------
2
2
  // This file contains all styles related to the label component.
3
3
  // -----------------------------------------------------------------------------
4
- export const label = (theme) => `
4
+ export const label = () => `
5
5
  /**
6
6
  * Label
7
7
  */
8
8
  .rebilly-instruments-form-field-label {
9
- left: ${theme.space.form.horizontalPadding};
10
- color: ${theme.color.text};
11
- top: calc(${theme.space.form.minHeight} / 2);
9
+ font-size: calc(var(--rebilly-fontSizeBase) * 0.92);
10
+ line-height: calc(var(--rebilly-fontSizeBase) * 0.92);
11
+ margin-bottom: var(--rebilly-spacings-2xs);
12
+ }
13
+
14
+ /* Floating Labels */
15
+ .is-floating .rebilly-instruments-form-field-label {
16
+ font-size: var(--rebilly-fontSizeBase);
17
+ left: var(--rebilly-spacings-label-offset-left);
18
+ color: var(--rebilly-colorText);
19
+ top: 50%;
12
20
  background: transparent;
13
- opacity: 0;
21
+ opacity: 1;
14
22
  position: absolute;
15
- transform: translateY(-50%);
16
- transition: all 200ms;
23
+ transform: translateY(-50%) scale(1);
24
+ transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1), background 0.35s cubic-bezier(0.19, 1, 0.22, 1);
17
25
  cursor: text;
18
26
  pointer-events: none;
27
+ transform-origin: left top;
28
+ }
29
+
30
+ /* Includes Google autocomplete fix */
31
+ .is-floating input:-webkit-autofill + .rebilly-instruments-form-field-label,
32
+ .is-floating input:-webkit-autofill:hover + .rebilly-instruments-form-field-label,
33
+ .is-floating input:-webkit-autofill:focus + .rebilly-instruments-form-field-label,
34
+ .is-floating select:-webkit-autofill + .rebilly-instruments-form-field-label,
35
+ .is-floating select:-webkit-autofill:hover + .rebilly-instruments-form-field-label,
36
+ .is-floating select:-webkit-autofill:focus + .rebilly-instruments-form-field-label {
37
+ padding: 0 var(--rebilly-spacings-2xs);
38
+ left: calc(var(--rebilly-spacings-label-offset-left) - var(--rebilly-spacings-2xs));
39
+ line-height: 1;
40
+ background: var(--rebilly-colorBackground);
41
+ opacity: 1!important;
42
+ transform: translateY(-175%) scale(0.875);
19
43
  }
20
44
 
21
- .rebilly-instruments-form-field-input:not(:placeholder-shown) + .rebilly-instruments-form-field-label,
22
- .rebilly-instruments-form-field-select:focus + .rebilly-instruments-form-field-label,
23
- .rebilly-instruments-form-field-label.is-active {
24
- padding: 0 ${theme.space.xxs};
25
- left: calc(${theme.space.form.horizontalPadding} - ${theme.space.xxs});
26
- font-size: ${theme.typography.captionFontSize};
27
- line-height: ${theme.typography.captionLineHeight};
28
- color: ${theme.color.text};
29
- background: ${theme.color.background};
30
- font-weight: 500;
45
+ .is-floating .rebilly-instruments-form-field-input:focus + .rebilly-instruments-form-field-label,
46
+ .is-floating .rebilly-instruments-form-field-select:focus + .rebilly-instruments-form-field-label,
47
+ .is-floating .rebilly-instruments-form-field-label.is-active {
48
+ padding: 0 var(--rebilly-spacings-2xs);
49
+ left: calc(var(--rebilly-spacings-label-offset-left) - var(--rebilly-spacings-2xs));
50
+ line-height: 1;
51
+ background: var(--rebilly-colorBackground);
31
52
  opacity: 1;
32
- top: 0;
53
+ transform: translateY(-175%) scale(0.875);
33
54
  }
34
55
  `;