+
+ ${this._requestStatus === "complete"
+ ? html`${this.hass.localize("ui.newsletter.thanks")}`
+ : html`
+
+ ${this._requestStatus === "inprogress"
+ ? html`
+
+ `
+ : html`
+
+ `}
+ `}
+
+
+ `;
+ }
+
+ private async _subscribe() {
+ if (!this._emailField?.reportValidity()) {
+ this._emailField!.focus();
+ return;
+ }
+
+ this._requestStatus = "inprogress";
+
+ await fetch(
+ `https://newsletter.home-assistant.io/subscribe?email=${
+ this._emailField!.value
+ }`
+ )
+ .then(() => {
+ this._requestStatus = "complete";
+ })
+ .catch((err) => {
+ this._requestStatus = undefined;
+ // eslint-disable-next-line no-console
+ console.error(err);
+ });
+ }
+
+ static get styles(): CSSResultGroup {
+ return css`
+ .newsletter {
+ display: flex;
+ flex-direction: row;
+ padding: 0 16px 16px;
+ }
+
+ ha-textfield {
+ flex: 1;
+ display: block;
+ padding-right: 8px;
+ }
+
+ mwc-button {
+ padding-top: 12px;
+ }
+ `;
+ }
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ "ha-newsletter": HaNewsletter;
+ }
+}
diff --git a/src/panels/config/dashboard/ha-config-dashboard.ts b/src/panels/config/dashboard/ha-config-dashboard.ts
index 552692e1e3..a776efa613 100644
--- a/src/panels/config/dashboard/ha-config-dashboard.ts
+++ b/src/panels/config/dashboard/ha-config-dashboard.ts
@@ -1,3 +1,4 @@
+import "../../../components/ha-newsletter";
import { mdiCloudLock, mdiDotsVertical, mdiMagnify } from "@mdi/js";
import "@material/mwc-list/mwc-list-item";
import type { ActionDetail } from "@material/mwc-list";
@@ -134,6 +135,7 @@ class HaConfigDashboard extends LitElement {
.pages=${configSections.dashboard}
>
`}
+