Skip to content

Commit 19a5583

Browse files
committed
feat: placeholder
1 parent 8c2044c commit 19a5583

File tree

6 files changed

+69
-0
lines changed

6 files changed

+69
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './public_api';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { PlaceholderDirective } from './placeholder.directive';
2+
3+
describe('PlaceholderDirective', () => {
4+
it('should create an instance', () => {
5+
const directive = new PlaceholderDirective();
6+
expect(directive).toBeTruthy();
7+
});
8+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Directive, HostBinding, Input } from '@angular/core';
2+
import { Colors } from '../coreui.types';
3+
4+
@Directive({
5+
selector: '[cPlaceholder]'
6+
})
7+
export class PlaceholderDirective {
8+
9+
constructor() { }
10+
11+
/**
12+
* Animation type for placeholder
13+
* @type 'glow' | 'wave'
14+
* @default undefined
15+
*/
16+
@Input() animation?: 'glow' | 'wave';
17+
18+
/**
19+
* Custom color for placeholder
20+
* @type Colors
21+
* @default undefined
22+
*/
23+
@Input('cPlaceholderColor') color?: Colors;
24+
25+
/**
26+
* Size the placeholder extra small, small, large.
27+
*/
28+
@Input('cPlaceholderSize') size?: 'xs' | 'sm' | 'lg';
29+
30+
@HostBinding('class')
31+
get hostClasses(): any {
32+
return {
33+
'placeholder': true,
34+
[`placeholder-${this.animation}`]: !!this.animation,
35+
[`placeholder-${this.size}`]: !!this.size,
36+
[`bg-${this.color}`]: !!this.color
37+
};
38+
}
39+
40+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { PlaceholderDirective } from './placeholder.directive';
4+
5+
@NgModule({
6+
declarations: [
7+
PlaceholderDirective
8+
],
9+
imports: [
10+
CommonModule
11+
],
12+
exports: [
13+
PlaceholderDirective
14+
]
15+
})
16+
export class PlaceholderModule {
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { PlaceholderDirective } from './placeholder.directive';
2+
export { PlaceholderModule } from './placeholder.module';

projects/coreui-angular/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export * from './lib/navbar';
2727
export * from './lib/modal';
2828
export * from './lib/offcanvas';
2929
export * from './lib/pagination';
30+
export * from './lib/placeholder';
3031
export * from './lib/popover';
3132
export * from './lib/progress';
3233
export * from './lib/services';

0 commit comments

Comments
 (0)