update feedback form, tambahan lib untuk star rating

This commit is contained in:
2025-06-06 11:45:34 +08:00
parent f568b365c7
commit 7d8a08770e
3 changed files with 154 additions and 12 deletions

24
src/lib/StarRating.svelte Normal file
View File

@@ -0,0 +1,24 @@
<script>
export let value = 0;
export let name = '';
export let size = 'base'; // 'base', 'lg', 'xl'
let sizeClass = {
base: 'text-2xl',
lg: 'text-3xl',
xl: 'text-4xl'
}[size] || 'text-2xl';
</script>
<div class="flex items-center gap-1">
{#each Array(5) as _, i}
<button
type="button"
class={`focus:outline-none ${sizeClass}`}
on:click={() => value = i + 1}
aria-label="{name} {i + 1} stars"
>
<span class={i < value ? 'text-yellow-400' : 'text-gray-300'}>★</span>
</button>
{/each}
</div>