2026-01-18 14:59:00 +03:00
|
|
|
<!--
|
|
|
|
|
Component: FontListItem
|
|
|
|
|
Displays a font item with a checkbox and its characteristics in badges.
|
|
|
|
|
-->
|
2026-01-18 12:59:12 +03:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { Badge } from '$shared/shadcn/ui/badge';
|
|
|
|
|
import { Checkbox } from '$shared/shadcn/ui/checkbox';
|
|
|
|
|
import { Label } from '$shared/shadcn/ui/label';
|
2026-01-18 14:59:00 +03:00
|
|
|
import {
|
|
|
|
|
type UnifiedFont,
|
|
|
|
|
selectedFontsStore,
|
|
|
|
|
} from '../../model';
|
2026-01-18 12:59:12 +03:00
|
|
|
import FontApplicator from '../FontApplicator/FontApplicator.svelte';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
font: UnifiedFont;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-18 14:59:00 +03:00
|
|
|
const { font }: Props = $props();
|
2026-01-18 12:59:12 +03:00
|
|
|
|
|
|
|
|
const handleChange = (checked: boolean) => {
|
2026-01-18 14:59:00 +03:00
|
|
|
if (checked) {
|
|
|
|
|
selectedFontsStore.addOne(font);
|
|
|
|
|
} else {
|
|
|
|
|
selectedFontsStore.removeOne(font.id);
|
2026-01-18 12:59:12 +03:00
|
|
|
}
|
|
|
|
|
};
|
2026-01-18 14:59:00 +03:00
|
|
|
|
|
|
|
|
const selected = $derived(selectedFontsStore.has(font.id));
|
2026-01-18 12:59:12 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="pb-1">
|
|
|
|
|
<Label
|
|
|
|
|
for={font.id}
|
|
|
|
|
class="
|
|
|
|
|
w-full hover:bg-accent/50 flex items-start gap-3 rounded-lg border border-transparent p-3
|
|
|
|
|
active:scale-[0.98] active:transition-transform active:duration-75
|
|
|
|
|
has-aria-checked:border-blue-600
|
|
|
|
|
has-aria-checked:bg-blue-50
|
|
|
|
|
dark:has-aria-checked:border-blue-900
|
|
|
|
|
dark:has-aria-checked:bg-blue-950
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<div class="w-full">
|
|
|
|
|
<div class="flex flex-row gap-1 w-full items-center justify-between">
|
|
|
|
|
<div class="flex flex-col gap-1 transition-all duration-150 ease-out">
|
|
|
|
|
<div class="flex flex-row gap-1">
|
|
|
|
|
<Badge variant="outline" class="text-[0.5rem]">
|
|
|
|
|
{font.provider}
|
|
|
|
|
</Badge>
|
|
|
|
|
<Badge variant="outline" class="text-[0.5rem]">
|
|
|
|
|
{font.category}
|
|
|
|
|
</Badge>
|
|
|
|
|
</div>
|
|
|
|
|
<FontApplicator
|
|
|
|
|
id={font.id}
|
|
|
|
|
className="text-2xl"
|
|
|
|
|
name={font.name}
|
|
|
|
|
>
|
|
|
|
|
{font.name}
|
|
|
|
|
</FontApplicator>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
id={font.id}
|
|
|
|
|
checked={selected}
|
|
|
|
|
onCheckedChange={handleChange}
|
|
|
|
|
class="
|
|
|
|
|
transition-all duration-150 ease-out
|
|
|
|
|
data-[state=checked]:scale-100
|
|
|
|
|
data-[state=checked]:border-blue-600
|
|
|
|
|
data-[state=checked]:bg-blue-600
|
|
|
|
|
data-[state=checked]:text-white
|
|
|
|
|
dark:data-[state=checked]:border-blue-700
|
|
|
|
|
dark:data-[state=checked]:bg-blue-700
|
|
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Label>
|
|
|
|
|
</div>
|