design-angular-kit icon indicating copy to clipboard operation
design-angular-kit copied to clipboard

feat(chip): support href attribute for link chips (#545)

Open giulio-leone opened this issue 8 months ago • 2 comments

Summary

Fixes #545 — The it-chip component now supports the href attribute for navigable chips.

Problem

The chip component always rendered as <div class="chip">, making it impossible to use the href attribute. Users had to manually construct the HTML structure as a workaround.

Solution

Added an @Input() href property. When set, the chip renders as <a class="chip" [href]="href"> instead of <div class="chip">, following Bootstrap Italia's a.chip CSS pattern.

Uses <ng-template> to share inner content (icon, avatar, label, close button) between both rendering branches, avoiding duplication.

Changes

File What changed
chip.component.ts Added @Input() href, added NgTemplateOutlet import
chip.component.html Conditional <a>/<div> rendering with shared #chipContent template

Usage

<it-chip label="Argomento"></it-chip>

<it-chip label="Argomento" href="https://designers.italia.it"></it-chip>

Testing

  • 3 new regression tests:
    • Without href → renders <div> wrapper
    • With href → renders <a> wrapper with correct href
    • With href + size + color → preserves all CSS classes
  • All 112 existing tests pass ✅
  • 0 lint errors ✅
  • Chip tests: 100% statement/line/function coverage

⚠️ This reopens #620 which was accidentally closed due to fork deletion.

giulio-leone avatar Mar 25 '26 19:03 giulio-leone

@giulio-leone is attempting to deploy a commit to the dip-trasformazione-digitale Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 25 '26 19:03 vercel[bot]

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-angular-kit Ready Ready Preview Mar 27, 2026 3:56pm

Request Review

vercel[bot] avatar Mar 27 '26 15:03 vercel[bot]