Skip to content

Migrate dot-contentlet-status-chip from p-chip to p-tag with severity mapping and size variant #36089

@oidacra

Description

@oidacra

Description

The contentlet status badge component dot-contentlet-status-chip (core-web/libs/ui/src/lib/components/dot-contentlet-status-chip/) currently wraps PrimeNG p-chip and hardcodes status colors with Tailwind !important overrides (bg-green-100! text-green-700!, etc.) via an @switch in the template. This has several problems:

  • p-chip has no severity API, so colors fight the PrimeNG theme with ! overrides.
  • Neither p-chip nor p-tag has a size API, and the status badge is rendered at different text sizes depending on the host component.
  • The current compact sizing relies on a global CSS override on .p-chip in CustomLaraPreset (core-web/libs/ui/src/lib/theme/theme.config.ts), which affects every chip in the app.

Decision: keep the wrapper component (its ~10 consumers stay untouched), but internally replace p-chip with p-tag using native severity, and add a size input whose compact variant is styled via design tokens in CustomLaraPreset.

Status → severity mapping

Status Severity Current color
Published success green
Archived danger red
Revision info blue
New (state is null) info blue
Draft / default warn yellow

Scope

  1. dot-contentlet-status-chip.component.ts / .html

    • Replace ChipModule with TagModule (primeng/tag).
    • Replace the @switch of Tailwind classes with a single <p-tag [severity]="severity()" [value]="label()" />; severity computed from the existing DotContentletStatusPipe result (pipe unchanged).
    • New input: size = input<'small' | 'normal'>('small') — default small preserves the current compact look (text-xs) for all consumers. small applies a p-tag-sm modifier class.
    • Keep the 'New' | dm translated label for the null-state case (current behavior).
  2. core-web/libs/ui/src/lib/theme/theme.config.ts

    • Add a tag block under components: .p-tag-sm variant via components.tag.css using design tokens (dt(...) / spacing), following the existing chip block precedent. PrimeNG styling lives in the JS preset, not SCSS.
    • Update the chip block comment that mentions "Content Status" (no longer applies once status uses p-tag).
  3. Tests — update dot-contentlet-status-chip.component.spec.ts for severity-per-status and size-class assertions.

Out of scope

  • Renaming the selector to dot-contentlet-status-tag (cosmetic; would touch 10+ consumer files).
  • Changing any consumer (content drive, dot-pages, templates, containers, block editor, asset search, es-search, edit-content sidebar). Contexts needing larger text will opt into size="normal" later.

Acceptance Criteria

  • The component renders a single p-tag with native severity per the mapping table above (Published→success, Archived→danger, Revision→info, Draft→warn).
  • When state is null, the tag shows the translated New label ('New' | dm) with info severity.
  • New size input ('small' | 'normal') defaults to 'small'; small applies the p-tag-sm modifier class, normal renders PrimeNG's default tag size.
  • No Tailwind !important color overrides remain in the component template.
  • CustomLaraPreset (theme.config.ts) defines the p-tag-sm variant via components.tag.css using design tokens; the stale "Content Status" reference in the chip block comment is updated.
  • All existing consumers render the status badge visually compact as today, with no template changes required in any consumer.
  • dot-contentlet-status-chip.component.spec.ts covers severity per status (including null → New/info) and both size variants; yarn nx test ui --testPathPattern=dot-contentlet-status-chip passes.

Priority

Medium

Additional Context

  • Existing p-tag usages in the repo (analytics tables, experiments header) confirm the severity API is already in use.
  • The global .p-chip compact CSS in the preset stays for the remaining chip use cases (locale, relationships); status badges stop depending on it.
  • Verify visually in: Pages table, Content Drive list view, Edit Content sidebar, block editor contentlet card.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Task.

    Projects

    Status
    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions