feat(ratio): add ItRatioDirective that auto-applies .ratio base class (#544)
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.ratioclass - 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
.ratioclass applied for 16x9 - Variant
.ratio-16x9class applied - Content projection
- 1x1 ratio (both classes)
- Base-only (no size input, no variant class)
- All 5 supported sizes in a single template
- Base
- 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 is attempting to deploy a commit to the dip-trasformazione-digitale Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated (UTC) |
|---|---|---|---|
| design-angular-kit | Mar 27, 2026 3:58pm |