|
| 1 | +<script lang="ts"> |
| 2 | + import { Icon } from '@/Components' |
| 3 | + import { numberFormatInt } from '@/helpers' |
| 4 | +
|
| 5 | + const title = 'Last 30 days' |
| 6 | +
|
| 7 | + type Stat = { |
| 8 | + title: string |
| 9 | + previous: string |
| 10 | + current: string |
| 11 | + is_increase: boolean |
| 12 | + percentage: number |
| 13 | + } |
| 14 | +
|
| 15 | + const stats: Stat[] = [ |
| 16 | + { |
| 17 | + title: 'Total Subscribers', |
| 18 | + previous: numberFormatInt(70946), |
| 19 | + current: numberFormatInt(71897), |
| 20 | + is_increase: true, |
| 21 | + percentage: 12, |
| 22 | + }, |
| 23 | + { |
| 24 | + title: 'Avg. Open Rate', |
| 25 | + previous: '56.14%', |
| 26 | + current: '58.16%', |
| 27 | + is_increase: true, |
| 28 | + percentage: 2.02, |
| 29 | + }, |
| 30 | + { |
| 31 | + title: 'Avg. Click Rate', |
| 32 | + previous: '28.62%', |
| 33 | + current: '24.57%', |
| 34 | + is_increase: false, |
| 35 | + percentage: 4.05, |
| 36 | + }, |
| 37 | + ] |
| 38 | +</script> |
| 39 | + |
| 40 | +<div> |
| 41 | + <h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-gray-100">{title}</h3> |
| 42 | + <dl |
| 43 | + class="mt-5 grid grid-cols-1 rounded-lg bg-white dark:bg-gray-800 overflow-hidden shadow divide-y divide-gray-200 dark:divide-gray-600 md:grid-cols-3 md:divide-y-0 md:divide-x" |
| 44 | + > |
| 45 | + {#each stats as item} |
| 46 | + <div class="px-4 py-5 sm:p-6"> |
| 47 | + <dt class="text-base font-normal text-gray-900 dark:text-gray-100">{item.title}</dt> |
| 48 | + <dd class="mt-1 flex justify-between items-baseline md:block lg:flex"> |
| 49 | + <div class="flex items-baseline text-2xl font-semibold text-primary-600 dark:text-primary-300"> |
| 50 | + {item.current} |
| 51 | + <span class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400"> |
| 52 | + from {item.previous} |
| 53 | + </span> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div |
| 57 | + class="inline-flex items-center px-2.5 py-0.5 rounded-full text-sm font-medium md:mt-2 lg:mt-0" |
| 58 | + class:bg-green-100={item.is_increase} |
| 59 | + class:text-green-800={item.is_increase} |
| 60 | + class:bg-red-100={!item.is_increase} |
| 61 | + class:text-red-800={!item.is_increase} |
| 62 | + > |
| 63 | + {#if item.is_increase} |
| 64 | + <Icon name="arrow-up" classes="text-green-500 -ml-1 mr-0.5 text-xl" /> |
| 65 | + {:else} |
| 66 | + <Icon name="arrow-down" classes="text-red-500 -ml-1 mr-0.5 text-xl" /> |
| 67 | + {/if} |
| 68 | + <span class="sr-only"> {item.is_increase ? 'Increased' : 'Decreased'} by </span> |
| 69 | + {item.percentage}% |
| 70 | + </div> |
| 71 | + </dd> |
| 72 | + </div> |
| 73 | + {/each} |
| 74 | + </dl> |
| 75 | +</div> |
0 commit comments