Skip to content

A platform for community discussion. Free, open, simple.

DEV: Convert SubscribeCard to glimmer/gjs (#37388)

Jarek Radoszd1e581209ed6
diff --git a/plugins/discourse-subscriptions/assets/javascripts/discourse/components/subscribe-card.gjs b/plugins/discourse-subscriptions/assets/javascripts/discourse/components/subscribe-card.gjs
index 5abf69781ad..a958c6eb9d8 100644
--- a/plugins/discourse-subscriptions/assets/javascripts/discourse/components/subscribe-card.gjs
+++ b/plugins/discourse-subscriptions/assets/javascripts/discourse/components/subscribe-card.gjs
@@ -1,35 +1,31 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
+import Component from "@glimmer/component";
+import { action } from "@ember/object";
+import didInsert from "@ember/render-modifiers/modifiers/did-insert";
export default class SubscribeCard extends Component {
- didInsertElement() {
- super.didInsertElement(...arguments);
- this.cardElement.mount("#card-element");
- this.setCardElementStyles();
- }
-
+ @action
setCardElementStyles() {
+ this.args.cardElement.mount("#card-element");
+
const computedStyle = getComputedStyle(document.documentElement);
- const primaryColor = computedStyle.getPropertyValue("--primary");
- const placeholderColor =
- computedStyle.getPropertyValue("--secondary-medium");
- this.cardElement.update({
+
+ this.args.cardElement.update({
style: {
base: {
- color: primaryColor,
+ color: computedStyle.getPropertyValue("--primary"),
"::placeholder": {
- color: placeholderColor,
+ color: computedStyle.getPropertyValue("--secondary-medium"),
},
},
},
});
}
- didDestroyElement() {
- super.didDestroyElement(...arguments);
- }
-
<template>
- <div id="card-element"></div>
+ <div
+ {{didInsert this.setCardElementStyles}}
+ id="card-element"
+ ...attributes
+ ></div>
</template>
}