From 648febe90f18b00f14faf3828ee6ad19b734d49f Mon Sep 17 00:00:00 2001 From: aramghanipour92 Date: Thu, 14 Nov 2024 13:46:13 +0100 Subject: [PATCH] savings - work in progress (#1793) * savings - work in progress * wip * wip * savings * Fix for main slot * Update savings.ts * wip --------- Co-authored-by: Ghanipour, Aram Co-authored-by: astrit --- apps/core-lib-dev/src/app/app.element.ts | 2 +- .../src/app/dashboard/dashboard.element.ts | 8 + apps/core-lib-dev/src/common/card.ts | 30 +- apps/core-lib-dev/src/components/savings.ts | 408 ++++++++++++++++++ 4 files changed, 444 insertions(+), 4 deletions(-) create mode 100644 apps/core-lib-dev/src/components/savings.ts diff --git a/apps/core-lib-dev/src/app/app.element.ts b/apps/core-lib-dev/src/app/app.element.ts index 0fd66b96ac..1b52045f22 100644 --- a/apps/core-lib-dev/src/app/app.element.ts +++ b/apps/core-lib-dev/src/app/app.element.ts @@ -57,7 +57,7 @@ export class AppElement extends LitElement { popoverOpen: boolean = false @state() - currentView = 'theme-page' + currentView = 'dashboard' connectedCallback() { super.connectedCallback() diff --git a/apps/core-lib-dev/src/app/dashboard/dashboard.element.ts b/apps/core-lib-dev/src/app/dashboard/dashboard.element.ts index 2179563801..65531c4f71 100644 --- a/apps/core-lib-dev/src/app/dashboard/dashboard.element.ts +++ b/apps/core-lib-dev/src/app/dashboard/dashboard.element.ts @@ -27,6 +27,7 @@ import '../../components/todos' import './dashboard.css' import '../../components/savings-outside' import '../../components/savings-goal' +import '../../components/savings' import '../../components/accounts' import '../../components/carousel-trans' import '../../components/cards' @@ -84,6 +85,13 @@ export class CardExample extends LitElement { + + + + + ` diff --git a/apps/core-lib-dev/src/common/card.ts b/apps/core-lib-dev/src/common/card.ts index 13ce97bd02..f094f5f41f 100644 --- a/apps/core-lib-dev/src/common/card.ts +++ b/apps/core-lib-dev/src/common/card.ts @@ -20,6 +20,9 @@ export class TPCard extends LitElement { @state() footerSlotOccupied = false + @state() + mainSlotOccupied = false + connectedCallback() { super.connectedCallback() } @@ -30,6 +33,11 @@ export class TPCard extends LitElement { render() { return html` + - - - + ${this.#renderMainSlot()} ${this.#renderFooterSlot()} @@ -76,4 +82,22 @@ export class TPCard extends LitElement { (node.nodeType === Node.TEXT_NODE && node.textContent?.trim() !== ''), ) } + + #renderMainSlot() { + return html` + + ` + } + + #handleMainSlotChange(event: Event) { + const slot = event.target as HTMLSlotElement + const assignedNodes = slot.assignedNodes({ flatten: true }) + this.mainSlotOccupied = + assignedNodes.length > 0 && + assignedNodes.some( + (node) => + node.nodeType === Node.ELEMENT_NODE || + (node.nodeType === Node.TEXT_NODE && node.textContent?.trim() !== ''), + ) + } } diff --git a/apps/core-lib-dev/src/components/savings.ts b/apps/core-lib-dev/src/components/savings.ts new file mode 100644 index 0000000000..eff8136437 --- /dev/null +++ b/apps/core-lib-dev/src/components/savings.ts @@ -0,0 +1,408 @@ +import { LitElement } from 'lit' +import { customElement } from 'lit/decorators.js' +import { when } from 'lit/directives/when.js' + +import { html } from '@sebgroup/green-core/scoping.js' + +@customElement('tp-savings') +export class TpSavingsWidget extends LitElement { + private isCollapsed: boolean = false + + connectedCallback() { + super.connectedCallback() + } + + disconnectedCallback() { + super.disconnectedCallback() + } + + toggleCollapse() { + this.isCollapsed = !this.isCollapsed + this.requestUpdate() + } + + render() { + return html` Spara + + + + + Sparande + 1 506 408,40 + + + + + Utveckling + +15,45% + + + this.toggleCollapse()} + > + ${when( + !this.isCollapsed, + () => html` + + `, + () => + html``, + )} + + + + + + ${when( + !this.isCollapsed, + () => html` + + + + Värdepapper + Värdepapper + + 56 789,00 + + + + 56 789,00 + + + + + + + + + + + + + + + Utv. i år + + 1,99% + + + + + + Aktier + Aktier + + 159 200,00 + + + + 159 200,00 + + + + + + + + + + + + + + + Utv. i år + + -5,50% + + + + + + Konto + Konto + + 467 200,00 + + + + 467 200,00 + + + + + + + + + + + + + + + Utv. i år + + 7,99% + + + + + + Kapitalförsäkring + Kapitalförsäkring + + 359 200,00 + + + + 359 200,00 + + + + + + + + + + + + + + + Utv. i år + + 10,03% + + + + + + Pensionsförsäkring + Pensionsförsäkring + + 634 000,00 + + + + 634 000,00 + + + + + + + + + + + + + + + Utv. i år + + 4,03% + + + `, + () => html``, + )} + + ` + } +}