Skip to content

Commit e57e807

Browse files
authored
feat(design): deprecate DaffCompactable and clean up documentation (#4423)
This isn't removing the `DaffCompactableDirective`, just removing the superfluous and unused interface.
1 parent 86cd9cd commit e57e807

4 files changed

Lines changed: 51 additions & 45 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Compactable
2+
3+
Compactable enforces consistent use of the compact property across components.
4+
5+
## Overview
6+
7+
`DaffCompactableDirective` applies the `daff-compact` CSS class when `compact` is `true`.
8+
9+
## Usage
10+
11+
Use `daffCompactable` as an attribute selector:
12+
13+
```html
14+
<div daffCompactable [compact]="true">Content</div>
15+
```
16+
17+
Or as an Angular host directive:
18+
19+
```ts
20+
import { DaffCompactableDirective } from '@daffodil/design';
21+
22+
@Component({
23+
selector: 'custom-component',
24+
template: 'custom-component.html',
25+
hostDirectives: [
26+
{
27+
directive: DaffCompactableDirective,
28+
inputs: ['compact'],
29+
},
30+
],
31+
})
32+
export class CustomComponent { }
33+
```
34+
35+
## Styling
36+
37+
Use the applied CSS class to style the compact variant:
38+
39+
```scss
40+
.custom-component {
41+
padding: 0.5rem 1rem;
42+
43+
&.daff-compact {
44+
padding: 0.25rem 0.5rem;
45+
}
46+
}
47+
```

libs/design/src/core/compactable/compactable.directive.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from '@angular/core/testing';
1010
import { By } from '@angular/platform-browser';
1111

12-
import { DaffCompactableDirective } from './compactable.directive';
12+
import { DaffCompactableDirective } from '@daffodil/design';
1313

1414
@Component({
1515
template: `

libs/design/src/core/compactable/compactable.directive.ts

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,7 @@ import {
44
} from '@angular/core';
55

66
/**
7-
* `DaffCompactableDirective` allows a component to conditionally apply a compact
8-
* style by toggling a CSS class. This is useful for creating components that can
9-
* switch between regular and compact styles based on the `compact` property.
10-
*
11-
* @example Implementing it as an attribute directive
12-
*
13-
* ```html
14-
* <div daffCompactable [compact]="isCompact">Content goes here</div>
15-
* ```
16-
*
17-
* In this example, the `daff-compact` class is applied to the `div` element when
18-
* `isCompact` is `true`, making the `div` display its compact state.
19-
*
20-
* @example Implementing it as an Angular host directive
21-
*
22-
* ```ts
23-
* @Component({
24-
* selector: 'custom-component',
25-
* template: 'custom-component.html',
26-
* hostDirectives: [
27-
* {
28-
* directive: DaffCompactableDirective,
29-
* inputs: ['compact'],
30-
* },
31-
* ],
32-
* })
33-
* export class CustomComponent { }
34-
* ```
35-
*
36-
* The directive applies the `daff-compact` class to the component and
37-
* should be defined in your styles to display the compact state as desired.
38-
*
39-
* ```scss
40-
* :host {
41-
* padding: 8px 16px;
42-
*
43-
* &.daff-compact {
44-
* padding: 4px 8px;
45-
* }
46-
* }
47-
* ```
7+
* Enforces consistent use of the compact property.
488
*/
499
@Directive({
5010
selector: '[daffCompactable]',
@@ -54,7 +14,7 @@ import {
5414
})
5515
export class DaffCompactableDirective {
5616
/**
57-
* Controls whether the component is compact.
17+
* Whether the component is compact.
5818
*/
5919
@Input() compact = false;
6020
}

libs/design/src/core/compactable/compactable.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* An interface for giving a component the ability to display a compact UI.
3-
* In order to be compactable, the class must implement this property.
2+
* @deprecated Deprecated in version 0.92.0. Will be removed in version 1.0.0.
43
*/
54
export interface DaffCompactable {
65
compact: boolean;

0 commit comments

Comments
 (0)