@@ -10,27 +10,52 @@ import { CommonModule } from '@angular/common'
1010 `
1111 :host {
1212 display: block;
13- background-color: rgba(255, 255, 255, 0.2);
14- animation: pulse 1.5s infinite ease-in-out;
13+ background-color: rgba(255, 255, 255, 0.01);
14+ position: relative;
15+ overflow: hidden;
16+ }
17+
18+ :host::before {
19+ content: '';
20+ position: absolute;
21+ top: var(--shimmer-top, 0);
22+ left: var(--shimmer-left, 0);
23+ width: var(--shimmer-width, 100%);
24+ height: var(--shimmer-height, 100%);
25+ background: linear-gradient(
26+ 90deg,
27+ rgba(255, 255, 255, 0.08) 0%,
28+ rgba(255, 255, 255, 0.08) 30%,
29+ rgba(255, 255, 255, 0.12) 50%,
30+ rgba(255, 255, 255, 0.08) 70%,
31+ rgba(255, 255, 255, 0.08) 100%
32+ );
33+ background-size: 200% 100%;
34+ animation: shimmer 2s infinite ease-in-out;
1535 }
1636
1737 :host.circle {
1838 border-radius: 50%;
1939 }
2040
41+ :host.circle::before {
42+ border-radius: 50%;
43+ }
44+
2145 :host.square {
2246 border-radius: 4px;
2347 }
2448
25- @keyframes pulse {
49+ :host.square::before {
50+ border-radius: 4px;
51+ }
52+
53+ @keyframes shimmer {
2654 0% {
27- opacity: 0.6;
28- }
29- 50% {
30- opacity: 0.3;
55+ background-position: -200% 0;
3156 }
3257 100% {
33- opacity: 0.6 ;
58+ background-position: 200% 0 ;
3459 }
3560 }
3661 ` ,
@@ -40,6 +65,7 @@ export class SkeletonPlaceholderComponent {
4065 @Input ( ) shape : 'square' | 'circle' = 'square'
4166 @Input ( ) width = '100%'
4267 @Input ( ) height = '100%'
68+ @Input ( ) shimmerPercentage = 100
4369
4470 @HostBinding ( 'class' ) get hostClasses ( ) {
4571 return this . shape
@@ -52,4 +78,20 @@ export class SkeletonPlaceholderComponent {
5278 @HostBinding ( 'style.height' ) get hostHeight ( ) {
5379 return this . height
5480 }
81+
82+ @HostBinding ( 'style.--shimmer-width' ) get shimmerWidth ( ) {
83+ return `${ this . shimmerPercentage } %`
84+ }
85+
86+ @HostBinding ( 'style.--shimmer-left' ) get shimmerLeft ( ) {
87+ return `${ ( 100 - this . shimmerPercentage ) / 2 } %`
88+ }
89+
90+ @HostBinding ( 'style.--shimmer-height' ) get shimmerHeight ( ) {
91+ return `${ this . shimmerPercentage } %`
92+ }
93+
94+ @HostBinding ( 'style.--shimmer-top' ) get shimmerTop ( ) {
95+ return `${ ( 100 - this . shimmerPercentage ) / 2 } %`
96+ }
5597}
0 commit comments