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

feat(ratio): add ItRatioDirective that auto-applies .ratio base class (#544)

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

Summary

Fixes #544 — The .ratio-* classes in bootstrap-italia only set the --aspect-ratio CSS variable but require the base .ratio class for the actual layout structure. Consumers currently must write class="ratio ratio-16x9".

Solution

Created an attribute directive (ItRatioDirective) that:

  • Uses @HostBinding('class') to automatically apply the base .ratio class
  • Appends the .ratio-{size} variant based on the input value
  • Follows the same pattern as ItBadgeDirective

Usage

<div class="ratio ratio-16x9">
  <iframe src="..."></iframe>
</div>

<div itRatio="16x9">
  <iframe src="..."></iframe>
</div>

Supported ratios

1x1 · 3x2 · 4x3 · 16x9 · 21x9

Using itRatio without a value applies only the base .ratio class (for custom aspect ratios via CSS variables).

Testing

  • 6 new unit tests covering:
    • Base .ratio class applied for 16x9
    • Variant .ratio-16x9 class applied
    • Content projection
    • 1x1 ratio (both classes)
    • Base-only (no size input, no variant class)
    • All 5 supported sizes in a single template
  • Full test suite: 115/115 PASS, 0 lint errors, library builds clean

⚠️ This reopens #615 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 Error Error Mar 27, 2026 3:58pm

Request Review

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