Skip to content

Commit

Permalink
add update queue
Browse files Browse the repository at this point in the history
  • Loading branch information
iisa committed Dec 23, 2024
1 parent a419eda commit 0bf2bae
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 57 deletions.
3 changes: 2 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@

updateNotices = [update, ...updateNotices];

mgcComponent.updates = updateNotices;

mgcComponent.updateReceived(update);
await mgcComponent.updateComplete;
});

Expand Down
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { MonthlyGivingCircle } from './src/monthly-giving-circle';
export type { anUpdate } from './src/monthly-giving-circle';
22 changes: 20 additions & 2 deletions src/monthly-giving-circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,44 @@
import { LitElement, html, TemplateResult, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js';

import type { IauxNotificationToast } from '@internetarchive/iaux-notification-toast';
import '@internetarchive/iaux-notification-toast';
import './welcome-message';
import './presentational/mgc-title';
import './receipts';
import './presentational/button-style';
import './presentational/update-queue';

export type anUpdate = {
message: string;
status: 'success' | 'fail';
};

@customElement('iaux-monthly-giving-circle')
export class MonthlyGivingCircle extends LitElement {
@property({ type: String }) patronName: string = '';

@property({ type: Array }) receipts = [];

@property({ type: Array }) updates = [];
@property({ type: Array }) updates: anUpdate[] = [];

@property({ type: String }) viewToDisplay: 'welcome' | 'receipts' = 'welcome';

protected createRenderRoot() {
return this;
}

get notificationToastElement(): IauxNotificationToast {
return this.querySelector(
'iaux-notification-toast'
) as IauxNotificationToast;
}

updateReceived(update: { message: string; status: 'success' | 'fail' }) {
this.notificationToastElement.addNotification(update);
this.updates.unshift(update);
}

get showReceiptsCTA(): TemplateResult {
return html`
<iaux-button-style class="link">
Expand Down Expand Up @@ -59,7 +77,7 @@ export class MonthlyGivingCircle extends LitElement {
</iaux-button-style>
</span>
</iaux-mgc-title>
<iaux-update-queue .updates=${this.updates}></iaux-update-queue>
<iaux-notification-toast></iaux-notification-toast>
<iaux-mgc-receipts
.donations=${this.receipts}
@EmailReceiptRequest=${(event: CustomEvent) => {
Expand Down
54 changes: 0 additions & 54 deletions src/presentational/update-queue.ts

This file was deleted.

0 comments on commit 0bf2bae

Please sign in to comment.