Asymmetrik/ngx-starter

View on GitHub
src/app/core/messages/recent-messages/recent-messages.component.html

Summary

Maintainability
Test Coverage
@if (messages.length > 0) {
    <h4 class="mb-0">Notifications</h4>
    <div class="cards">
        @for (message of messages; track message) {
            <div class="card card-message">
                <div class="row g-0">
                    <div class="col col-alert-icon {{ messageType[message.type] | lowercase }}">
                        <span
                            class="fa-solid alert-icon {{ messageType[message.type] | lowercase }}"
                            [ngClass]="{
                                'fa-check': message.type === messageType.MOTD,
                                'fa-info': message.type === messageType.INFO,
                                'fa-exclamation': message.type === messageType.WARN,
                                'fa-exclamation-triangle': message.type === messageType.ERROR
                            }"
                        ></span>
                    </div>
                    <div class="col-alert-body">
                        <div class="card-body">
                            <div class="d-flex">
                                <h4 class="card-title text-truncate me-3">{{ message.title }}</h4>
                                <button
                                    class="btn-close ms-auto"
                                    type="button"
                                    aria-label="Dismiss Message"
                                    (click)="dismissMessage(message)"
                                ></button>
                            </div>
                            <p class="card-text line-clamp" [innerHTML]="message.body"></p>
                        </div>
                    </div>
                </div>
            </div>
        }
    </div>
    <div class="d-flex">
        <button class="btn btn-secondary btn-sm px-3" type="button" (click)="dismissAll()">
            Dismiss all
        </button>
        <button class="btn btn-primary btn-sm px-3 ms-auto" type="button" (click)="viewAll()">
            View All
        </button>
    </div>
} @else if (!loading()) {
    <div class="text-center">
        <h2 class="mt-4">You're all caught up!</h2>
        <p class="mb-4">You don't have any new notifications.</p>
        <button class="btn btn-sm btn-outline-primary px-3 mb-2" type="button" (click)="viewAll()">
            View All
        </button>
    </div>
}