@molecule/app-notification-feed-angular

Feature · notification-feed · App (browser) · v1.1.1 · Apache-2.0

Vertical notification feed: typed icon + title + body + relative time + unread indicator, with optional per-row link wrapping

npm install @molecule/app-notification-feed-angular

npm · Source on GitHub

How it works

@molecule/app-notification-feed-angular is a ready-made notification-feed feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { Component } from '@angular/core'
import { NotificationFeed } from '@molecule/app-notification-feed-angular'

@Component({
  selector: 'app-feed',
  standalone: true,
  imports: [NotificationFeed],
  template: `<ul
    mol-notification-feed
    [items]="items"
    ariaLabel="Notifications"
    dataMolId="notification-feed"
  ></ul>`,
})
export class Feed {
  items = [
    {
      id: '1',
      icon: 'check_circle',
      title: 'Build succeeded',
      body: 'main branch deployed to prod',
      createdAt: '2024-06-01T09:00:00Z',
      unread: true,
      href: '/deployments/42',
    },
    {
      id: '2',
      icon: 'chat',
      title: 'New comment',
      body: 'Alice left a comment on PR #17',
      createdAt: '2024-06-01T08:30:00Z',
    },
  ]
}

Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular

Reference

Angular vertical notification feed.

Exports <NotificationFeed> — the Angular counterpart of @molecule/app-notification-feed-react, with the same props and the same DOM: a list of notification rows with typed icon, title, body, relative time, and unread indicator, each row optionally wrapped in a link.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { Component } from '@angular/core'
import { NotificationFeed } from '@molecule/app-notification-feed-angular'

@Component({
  selector: 'app-feed',
  standalone: true,
  imports: [NotificationFeed],
  template: `<ul
    mol-notification-feed
    [items]="items"
    ariaLabel="Notifications"
    dataMolId="notification-feed"
  ></ul>`,
})
export class Feed {
  items = [
    {
      id: '1',
      icon: 'check_circle',
      title: 'Build succeeded',
      body: 'main branch deployed to prod',
      createdAt: '2024-06-01T09:00:00Z',
      unread: true,
      href: '/deployments/42',
    },
    {
      id: '2',
      icon: 'chat',
      title: 'New comment',
      body: 'Alice left a comment on PR #17',
      createdAt: '2024-06-01T08:30:00Z',
    },
  ]
}

Type

feature

Installation

npm install @molecule/app-notification-feed-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

FeedItem

A single item rendered inside a NotificationFeed list.

interface FeedItem {
  /** Stable identifier (used as the row's key). */
  id: string
  /** Material symbol icon name (e.g. `'check_circle'`, `'chat'`). */
  icon: string
  /** Bolded headline string. */
  title: string
  /** Secondary body string. */
  body: string
  /** ISO timestamp shown as relative time on the right. */
  createdAt: string
  /** Optional route — when set, wraps the row in a link. */
  href?: string | null
  /** When true, the row gets a left primary-accent border. */
  unread?: boolean
}

NotificationFeedProps

Props for the NotificationFeed component — the same props @molecule/app-notification-feed-react accepts.

interface NotificationFeedProps {
  /** Items to render, top to bottom. */
  items: ReadonlyArray<FeedItem>
  /** Aria-label for the underlying `<ul>`. */
  ariaLabel?: string
  /** Extra classes on the outer `<ul>`. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string
}

Classes

NotificationFeed

NotificationFeed component.

Vertical notification feed — typed icon + title + body + relative time, with an optional unread left-border accent and an optional per-row link. The host IS the outer <ul> (ul[mol-notification-feed]), matching React's root exactly, so the aria-label and data-mol-id land on the same element.

Each row is a <li> whose child is either the binding's Link (<a molLink>, react-router's <Link to> contract) wrapping the row card, or the card alone — React's item.href ? <Link> : card branch. Rows are tracked by item.id, as React keys them.

@Component({
  selector: 'ul[mol-notification-feed]',
  standalone: true,
  imports: [Link, NotificationFeedRow],
  inputs: ['items', 'ariaLabel', 'className', 'dataMolId'],
  host: {
    '[class]': 'listClasses()',
    '[attr.aria-label]': 'ariaLabel ?? null',
    '[attr.data-mol-id]': 'dataMolId ?? null',
  },
  // prettier-ignore
  template: `@for (item of items; track item.id) {<li>@if (item.href) {<a [molLink]="item.href" [class]="linkClasses()"><div mol-notification-row [item]="item"></div></a>} @else {<div mol-notification-row [item]="item"></div>}</li>}`,
})
export class NotificationFeed {
  /** Items to render, top to bottom. */
  items: ReadonlyArray<FeedItem> = []
  /** Aria-label for the underlying `<ul>`. */
  ariaLabel?: string
  /** Extra classes on the outer `<ul>`. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string

  /**
   * The current class map.
   * @returns The UIClassMap.
   */
  cm(): UIClassMap {
    return getClassMap()
  }

  /**
   * Computes the list's class list (`cm.notificationFeedList` + `className`).
   * @returns The class string.
   */
  listClasses(): string {
    return this.cm().cn(this.cm().notificationFeedList, this.className)
  }

  /**
   * Computes a linked row's anchor class list (`cm.displayBlock`).
   * @returns The class string.
   */
  linkClasses(): string {
    return this.cm().cn(this.cm().displayBlock)
  }
}
  • props — Component props (see NotificationFeedProps).

Functions

fmtRelativeShort(iso)

Render an ISO timestamp as a short relative string: "12m", "3h", "5d".

Angular counterpart of @molecule/app-notification-feed-react's formatter: the same implementation, so a feed renders the same text on every framework.

function fmtRelativeShort(iso: string): string
  • iso — ISO 8601 timestamp string

Returns: short relative string (e.g. "12m", "3h", "5d")

Injection Notes

Requirements

Peer dependencies:

  • @angular/common ^22.0.0
  • @angular/core ^22.0.0
  • @angular/platform-browser ^22.0.0
  • @molecule/app-angular ^3.6.0
  • @molecule/app-ui ^1.3.11
  • @molecule/app-ui-angular ^1.1.0

Runtime Dependencies

  • @angular/common
  • @angular/core
  • @angular/platform-browser
  • @molecule/app-angular
  • @molecule/app-ui
  • @molecule/app-ui-angular

FeedItem.icon is a Material Symbols LIGATURE — the app must load the "Material Symbols Outlined" font and define the material-symbols-outlined CSS class, or icon names render as plain text (the literal string check_circle). The icon circle background and the unread left-border accent additionally rely on raw Tailwind utilities (bg-primary-container, border-l-4) that standard molecule scaffolds neither scan nor theme — add an @source line for this package's dist plus a primary-container theme color, or expect both to be invisible until the package is migrated to ClassMap.

Rows WITH href render the binding's Link (<a molLink>, react-router's <Link to> contract) — it navigates through the router the app's molecule context mounts, and needs that router. In apps without one, omit href (rows render as plain divs) or handle navigation on a wrapping element. Requires a wired ClassMap bond — getClassMap() throws before wiring.

fmtRelativeShort (exported) renders compact 12m / 3h / 5d strings with English unit letters — swap in your own formatter for localized feeds by pre-formatting and rendering your own rows.

E2E Tests

Integration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual screens/flows, and check every box off one by one. A box you can't check is an integration bug to fix — not a skip:

  • The feed renders real notifications with icon, title, body, and a relative time — no undefined fields or raw timestamps.
  • Unread rows are visibly distinct, and any unread badge/count matches the number of unread rows.
  • Clicking a notification that carries an href navigates to its target.
  • Marking as read (however this app wires it) clears the unread state and it stays cleared after a full reload.
  • Performing an action the app notifies about adds a new notification to the feed (newest first).
  • An empty feed shows a readable empty state — not a blank panel.