Statusable enforces consistent use of status across components.
DaffStatusableDirective applies status-specific CSS classes and validates the status in dev mode. When a status is set, the corresponding daff-[status] class is added.
| Status | CSS Class |
|---|---|
info |
.daff-info |
warn |
.daff-warn |
critical |
.daff-critical |
success |
.daff-success |
Use daffStatusable as an attribute selector:
<div daffStatusable [status]="'critical'">Status content</div>
Or as an Angular host directive:
import { DaffStatusableDirective } from '@daffodil/design';
@Component({
selector: 'custom-component',
template: 'custom-component.html',
hostDirectives: [
{
directive: DaffStatusableDirective,
inputs: ['status'],
},
],
})
export class CustomComponent { }
Set defaultStatus to apply a status when status is not explicitly provided:
constructor(private statusable: DaffStatusableDirective) {
this.statusable.defaultStatus = 'info';
}
Use the applied CSS class to style each status variant:
.custom-component {
&.daff-critical {
background: daff-color($critical, 10);
color: daff-color($critical, 90);
}
}
A console warning is shown in dev mode if a status value is not part of the supported statuses.