metric-card.component.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { Component, Input } from '@angular/core';
  2. @Component({
  3. selector: 'app-metric-card',
  4. standalone: true,
  5. template: `
  6. <article class="metric-card" [class.is-warning]="tone === 'warning'" [class.is-success]="tone === 'success'">
  7. <span>{{ label }}</span>
  8. <strong>{{ value }}</strong>
  9. @if (hint) {
  10. <small>{{ hint }}</small>
  11. }
  12. </article>
  13. `,
  14. styles: [`
  15. .metric-card {
  16. background: rgba(255, 255, 255, 0.96);
  17. border: 1px solid #e4e9f2;
  18. border-radius: 8px;
  19. box-shadow: 0 16px 32px rgba(17, 24, 39, 0.045);
  20. display: grid;
  21. gap: 8px;
  22. min-height: 128px;
  23. padding: 20px;
  24. position: relative;
  25. overflow: hidden;
  26. transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  27. }
  28. .metric-card::before {
  29. background: #2864c9;
  30. border-radius: 999px;
  31. content: "";
  32. height: 8px;
  33. position: absolute;
  34. right: 18px;
  35. top: 18px;
  36. width: 8px;
  37. }
  38. .metric-card:hover {
  39. border-color: #bfd0ee;
  40. box-shadow: 0 20px 38px rgba(37, 99, 235, 0.09);
  41. transform: translateY(-2px);
  42. }
  43. .metric-card.is-warning {
  44. border-color: #fed7aa;
  45. background: linear-gradient(135deg, #fff 0%, #fff7ed 100%);
  46. }
  47. .metric-card.is-warning::before {
  48. background: #f97316;
  49. }
  50. .metric-card.is-success {
  51. border-color: #bbf7d0;
  52. background: linear-gradient(135deg, #fff 0%, #f0fdf4 100%);
  53. }
  54. .metric-card.is-success::before {
  55. background: #16a34a;
  56. }
  57. span {
  58. color: #6b7280;
  59. font-size: 14px;
  60. }
  61. strong {
  62. color: #111827;
  63. font-size: 32px;
  64. line-height: 1;
  65. }
  66. small {
  67. color: #6b7280;
  68. line-height: 1.45;
  69. }
  70. `]
  71. })
  72. export class MetricCardComponent {
  73. @Input({ required: true }) label = '';
  74. @Input({ required: true }) value = '';
  75. @Input() hint = '';
  76. @Input() tone: 'default' | 'warning' | 'success' = 'default';
  77. }