Files
classroomio/apps/dashboard/src/lib/features/course/components/analytics/analytics-card.svelte
T

45 lines
1.6 KiB
Svelte
Raw Normal View History

2025-09-18 01:00:49 +01:00
<script lang="ts">
2026-03-09 11:18:22 +01:00
import type { Component } from 'svelte';
2025-11-01 15:49:29 +01:00
interface Props {
title: string;
value: string | number;
subtitle?: string;
2026-03-09 11:18:22 +01:00
icon: Component;
2025-11-01 15:49:29 +01:00
iconColor?: string;
className?: string;
}
2025-09-18 01:00:49 +01:00
2025-11-01 15:49:29 +01:00
let { title, value, subtitle = '', icon, iconColor = 'blue', className = '' }: Props = $props();
let colorClasses = $derived({
2025-09-18 01:00:49 +01:00
blue: 'bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400',
green: 'bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400',
purple: 'bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400',
orange: 'bg-orange-50 dark:bg-orange-900/20 text-orange-600 dark:text-orange-400',
red: 'bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400',
yellow: 'bg-yellow-50 dark:bg-yellow-900/20 text-yellow-600 dark:text-yellow-400'
2025-11-01 15:49:29 +01:00
});
const SvelteComponent = $derived(icon);
2025-09-18 01:00:49 +01:00
</script>
2025-11-01 15:49:29 +01:00
<div class="rounded-lg border border-gray-200 bg-white p-6 dark:border-neutral-700 dark:bg-neutral-800 {className}">
2025-09-18 01:00:49 +01:00
<div class="flex items-center space-x-4">
<div class="flex h-12 w-12 items-center justify-center rounded-lg {colorClasses[iconColor]}">
2025-11-01 15:49:29 +01:00
<SvelteComponent className={colorClasses[iconColor]} />
2025-09-18 01:00:49 +01:00
</div>
<div>
<p class="text-sm font-medium text-gray-600 dark:text-gray-400">{title}</p>
<p class="text-2xl font-semibold text-gray-900 dark:text-white">
{value}
</p>
{#if subtitle}
2026-03-09 11:18:22 +01:00
<p class="text-xs text-gray-500 capitalize dark:text-gray-500">
2025-09-18 01:00:49 +01:00
{subtitle}
</p>
{/if}
</div>
</div>
</div>