FIX: set Discourse consistent styles on Stripe card element (#124)

* FIX: set Discourse consistent styles on Stripe card element

* use correct placeholder color

* applied prettier

* mock update method for cardElement

* minor formatting
This commit is contained in:
Faizaan Gagan 2022-06-24 21:18:38 +05:30 committed by GitHub
parent 8762d6742e
commit 392b88265b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -4,6 +4,25 @@ export default Component.extend({
didInsertElement() {
this._super(...arguments);
this.cardElement.mount("#card-element");
this.setCardElementStyles();
},
setCardElementStyles() {
const root = document.querySelector(":root");
const computedStyle = getComputedStyle(root);
const primaryColor = computedStyle.getPropertyValue("--primary");
const placeholderColor =
computedStyle.getPropertyValue("--secondary-medium");
this.cardElement.update({
style: {
base: {
color: primaryColor,
"::placeholder": {
color: placeholderColor,
},
},
},
});
},
didDestroyElement() {},
});

View File

@ -15,6 +15,7 @@ export function stubStripe() {
on() {},
card() {},
mount() {},
update() {},
};
},
};