@molecule/app-integration-card-angular

Feature · integration-card · App (browser) · v1.1.2 · Apache-2.0

Integration / connection card with icon, status, connect/disconnect action

npm install @molecule/app-integration-card-angular

npm · Source on GitHub

How it works

@molecule/app-integration-card-angular is a ready-made integration-card 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 { IntegrationCard } from '@molecule/app-integration-card-angular'

@Component({
  selector: 'app-integrations',
  standalone: true,
  imports: [IntegrationCard],
  template: `
    <div
      mol-integration-card
      title="Slack"
      description="Send notifications to your team channels."
      status="disconnected"
      [action]="connectSlack"
      dataMolId="slack-integration-card"
    ></div>
  `,
})
export class Integrations {
  connectSlack = {
    label: 'Connect',
    onClick: (): void => {
      window.location.href = '/oauth/slack'
    },
  }
}

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

Reference

Angular integration / connection card — the counterpart of @molecule/app-integration-card-react: the same props and the same DOM for the same input.

Exports <IntegrationCard> — icon + title + description + status label + action button. Props: icon?, title, description?, status? (default 'disconnected'), action? ({ label, onClick?, href?, loading?, disabled? }), variant? ('card' default | 'cta' gradient promo), className?, dataMolId?.

Use for OAuth/API integrations, bank-connect CTAs, webhook setup cards.

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 { IntegrationCard } from '@molecule/app-integration-card-angular'

@Component({
  selector: 'app-integrations',
  standalone: true,
  imports: [IntegrationCard],
  template: `
    <div
      mol-integration-card
      title="Slack"
      description="Send notifications to your team channels."
      status="disconnected"
      [action]="connectSlack"
      dataMolId="slack-integration-card"
    ></div>
  `,
})
export class Integrations {
  connectSlack = {
    label: 'Connect',
    onClick: (): void => {
      window.location.href = '/oauth/slack'
    },
  }
}

Type

feature

Installation

npm install @molecule/app-integration-card-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

IntegrationCardProps

Props accepted by IntegrationCard — the same props @molecule/app-integration-card-react accepts. Node props (icon, title, description, action.label) are projected content in Angular (an input cannot carry a node), so they are typed unknown: pass node content as [slot=<name>] children of the host element, and plain strings as the input.

interface IntegrationCardProps {
  /** Leading icon / logo — a string input, or `[slot=icon]` projected content. */
  icon?: unknown
  /** Integration title — a string input, or `[slot=title]` projected content. */
  title?: unknown
  /** Supporting description — a string input, or `[slot=description]` content. */
  description?: unknown
  /** Current connection status. Defaults to `'disconnected'`. */
  status?: IntegrationStatus
  /** Action button configuration (its `label` may be a projected node template). */
  action?: {
    /** Button label — a string input, or a projected node template. */
    label?: unknown
    /** Click handler (receives the DOM click event, as React's handler does). */
    onClick?: (event?: Event) => void
    /** When set, the button renders inside a plain anchor to this URL. */
    href?: string
    /** While true on the button branch, the label is replaced by an ellipsis glyph. */
    loading?: boolean
    /** Disables the action. */
    disabled?: boolean
  } | null
  /** `'card'` default, `'cta'` for premium gradient-tinted promos. */
  variant?: 'card' | 'cta'
  /** Extra classes. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string
}

Types

IntegrationStatus

Connection status for an integration.

type IntegrationStatus = 'connected' | 'disconnected' | 'pending' | 'error'

Classes

IntegrationCard

IntegrationCard component.

Card for an integration / external connection (Slack, Stripe, Google Drive, bank-link CTAs, etc.) — icon + title + description + status label + action. The host IS the Card div (div[mol-integration-card]), matching React's root exactly: the card's ClassMap classes, the cta gradient style and data-mol-id are the host's.

Node props (icon, title, description) are projected content ([slot=<name>]) or plain string inputs; action.label may be a projected node template. The optional icon / description wrappers and the action anchor/button render only when React would render them — Angular projection needs always-mounted capture points, so IntegrationCard.reconcile reconciles them.

@Component({
  selector: 'div[mol-integration-card]',
  standalone: true,
  hostDirectives: [MolPlacement],
  imports: [Button, NgTemplateOutlet],
  inputs: ['icon', 'title', 'description', 'status', 'action', 'variant', 'className', 'dataMolId'],
  host: {
    '[class]': 'cardClasses()',
    '[style]': 'hostStyle()',
    '[attr.data-mol-id]': 'dataMolId ?? null',
  },
  // prettier-ignore
  template: `<div [class]="rowClasses()"><div #iconWrap [class]="iconClasses()">@if (hasIconText()) {<ng-container>{{ icon }}</ng-container>}@if (iconTemplate(); as iconTpl) {<ng-container [ngTemplateOutlet]="iconTpl" />}<ng-content select="[slot=icon]"></ng-content></div><div [class]="bodyClasses()"><h3 [class]="titleClasses()">@if (hasTitleText()) {<ng-container>{{ title }}</ng-container>}@if (titleTemplate(); as titleTpl) {<ng-container [ngTemplateOutlet]="titleTpl" />}<ng-content select="[slot=title]"></ng-content></h3><p #descriptionWrap [class]="descriptionClasses()">@if (hasDescriptionText()) {<ng-container>{{ description }}</ng-container>}@if (descriptionTemplate(); as descriptionTpl) {<ng-container [ngTemplateOutlet]="descriptionTpl" />}<ng-content select="[slot=description]"></ng-content></p><div #statusRow [class]="statusRowClasses()"><span [class]="statusClasses()">{{ statusLabel() }}</span><a #actionAnchor [attr.href]="action?.href ?? null"></a><button #actionButton mol-button [disabled]="buttonDisabled()" (click)="runAction($event)">@if (showEllipsis()) {<ng-container>…</ng-container>}@else if (actionLabelTemplate(); as labelTpl) {<ng-container [ngTemplateOutlet]="labelTpl" />}@else {<ng-container>{{ actionLabelText() }}</ng-container>}</button></div></div></div>`,
})
export class IntegrationCard {
  icon?: unknown
  title?: unknown
  description?: unknown
  /** Current connection status (defaults to `'disconnected'` at read time). */
  status?: IntegrationStatus
  action?: IntegrationCardAction | null
  /** `'card'` default, `'cta'` for premium gradient-tinted promos. */
  variant?: 'card' | 'cta'
  /** Extra classes on the card. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string

  /** The optional icon wrapper (detached when React would render none). */
  @ViewChild('iconWrap') private iconWrap?: ElementRef<HTMLElement>
  /** The optional description paragraph. */
  @ViewChild('descriptionWrap') private descriptionWrap?: ElementRef<HTMLElement>
  /** The status row (the action's home when it is not a link). */
  @ViewChild('statusRow') private statusRow?: ElementRef<HTMLElement>
  /** The action's anchor (present only when `action.href` is set). */
  @ViewChild('actionAnchor') private actionAnchor?: ElementRef<HTMLAnchorElement>
  @ViewChild('actionButton', { read: ElementRef })
  private actionButton?: ElementRef<HTMLButtonElement>

  /** The i18n provider above the card (the status label). */
  private readonly i18n = useTranslation()

  constructor() {
    usePlacement((hasContent) => this.reconcile(hasContent))
  }

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

  cardClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.card({ variant: 'elevated' }), cm.cardPadding('md'), this.className)
  }

  /** The `cta` gradient, serialized as React's inline style writes it. */
  hostStyle(): string | null {
    return styleText(
      (this.variant ?? 'card') === 'cta' ? { backgroundImage: CTA_GRADIENT } : undefined,
    )
  }

  rowClasses(): string {
    return this.cm().flex({ align: 'start', gap: 'md' })
  }

  /** The icon wrapper's class (`cm.shrink0`). */
  iconClasses(): string {
    return this.cm().cn(this.cm().shrink0)
  }

  /** The body column's class list (`cm.cn(cm.flex1, cm.stack(2))`). */
  bodyClasses(): string {
    return this.cm().cn(this.cm().flex1, this.cm().stack(2))
  }

  titleClasses(): string {
    return this.cm().cn(this.cm().textSize('base'), this.cm().fontWeight('semibold'))
  }

  /** The description's class (`cm.textSize('sm')`). */
  descriptionClasses(): string {
    return this.cm().textSize('sm')
  }

  statusRowClasses(): string {
    return this.cm().flex({ align: 'center', justify: 'between', gap: 'sm' })
  }

  statusClasses(): string {
    return this.cm().cn(this.cm().textSize('xs'), this.cm().fontWeight('semibold'))
  }

  /** The translated status label (React's `integrationCard.status.*` keys). */
  statusLabel(): string {
    const status: IntegrationStatus = this.status ?? 'disconnected'
    return status === 'connected'
      ? this.i18n.t('integrationCard.status.connected', {}, { defaultValue: 'Connected' })
      : status === 'pending'
        ? this.i18n.t('integrationCard.status.pending', {}, { defaultValue: 'Connecting…' })
        : status === 'error'
          ? this.i18n.t('integrationCard.status.error', {}, { defaultValue: 'Error' })
          : this.i18n.t(
              'integrationCard.status.disconnected',
              {},
              { defaultValue: 'Not connected' },
            )
  }

  /** Whether the icon input renders as text. */
  hasIconText(): boolean {
    return hasText(this.icon)
  }

  /** Whether the title input renders as text. */
  hasTitleText(): boolean {
    return hasText(this.title)
  }

  /** Whether the description input renders as text. */
  hasDescriptionText(): boolean {
    return hasText(this.description)
  }

  /** The icon as a projected node template, when the caller passed one. */
  iconTemplate(): TemplateRef<unknown> | null {
    return isTemplate(this.icon) ? this.icon : null
  }

  /** The title as a projected node template, when the caller passed one. */
  titleTemplate(): TemplateRef<unknown> | null {
    return isTemplate(this.title) ? this.title : null
  }

  descriptionTemplate(): TemplateRef<unknown> | null {
    return isTemplate(this.description) ? this.description : null
  }

  actionLabelTemplate(): TemplateRef<unknown> | null {
    return isTemplate(this.action?.label) ? (this.action?.label as TemplateRef<unknown>) : null
  }

  /** The action label's text (React renders strings and numbers). */
  actionLabelText(): string {
    const label = this.action?.label
    return typeof label === 'string' || typeof label === 'number' ? String(label) : ''
  }

  /** React's loading ellipsis: only the button branch replaces its label. */
  showEllipsis(): boolean {
    return Boolean(this.action && !this.action.href && this.action.loading)
  }

  buttonDisabled(): boolean {
    if (!this.action) return false
    return this.action.href
      ? Boolean(this.action.disabled)
      : Boolean(this.action.disabled) || Boolean(this.action.loading)
  }

  showIcon(hasContent: SlotReader): boolean {
    return (
      this.hasIconText() || this.iconTemplate() !== null || hasContent(this.iconWrap?.nativeElement)
    )
  }

  showDescription(hasContent: SlotReader): boolean {
    return (
      this.hasDescriptionText() ||
      this.descriptionTemplate() !== null ||
      hasContent(this.descriptionWrap?.nativeElement)
    )
  }

  runAction(event: Event): void {
    if (this.action && !this.action.href) this.action.onClick?.(event)
  }

  private reconcile(hasContent: SlotReader): void {
    setElementPresent(this.iconWrap?.nativeElement, this.showIcon(hasContent))
    setElementPresent(this.descriptionWrap?.nativeElement, this.showDescription(hasContent))
    this.syncAction()
  }

  private syncAction(): void {
    const row = this.statusRow?.nativeElement
    const anchor = this.actionAnchor?.nativeElement
    const button = this.actionButton?.nativeElement
    if (!row || !anchor || !button) return
    if (!this.action) {
      setElementPresent(button, false)
      setElementPresent(anchor, false)
      return
    }
    setElementPresent(button, true)
    if (this.action.href) {
      setElementPresent(anchor, true)
      placeElement(button, anchor)
      return
    }
    placeElement(button, null)
    setElementPresent(anchor, false)
  }
}

(Member comments are shortened to their first sentence, and the 18 longest are left out to fit; the full declaration is in node_modules/@molecule/app-integration-card-angular/dist/integration-card.component.d.ts.)

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.13.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @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

  • The status label text ('Connected', 'Connecting…', 'Error', 'Not connected') routes through t() under integrationCard.status.*, translated by the @molecule/app-locales-integration-card companion bond. There is no override prop.

  • variant="cta" paints an inline linear-gradient background over the Card using var(--color-primary) (falls back to a fixed blue when the theme token is missing). Inline styles beat ClassMap classes, so this overrides the themed card surface; check text contrast against your primary color before using it.

  • action.href renders an anchor wrapping the Button and ignores action.loading; prefer action.onClick for anything that needs a loading state. While action.loading is true the button label is replaced by an ellipsis glyph.

  • Node props are projected content: icon, title and description are selected by [slot=icon], [slot=title] and [slot=description]; plain strings may also be passed as inputs. action.label may likewise be a projected node template.

  • Styling resolves through getClassMap() — wire a ClassMap bond (e.g. @molecule/app-ui-tailwind) before rendering.

Translations

Translation strings are provided by @molecule/app-locales-integration-card.