Skip to content

Commit 1c68eac

Browse files
authored
Merge pull request #352 from EducationalTools/334-more-gmae-metadata
add more metadata
2 parents 041f372 + 86aa9de commit 1c68eac

6 files changed

Lines changed: 210 additions & 28 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"svelte-check": "^4.2.1",
3434
"svelte-sonner": "^0.3.28",
3535
"tailwind-merge": "^3.2.0",
36-
"tailwind-variants": "^1.0.0",
36+
"tailwind-variants": "^0.2.1",
3737
"tailwindcss": "^3.4.17",
3838
"tailwindcss-animate": "^1.0.7",
3939
"typescript": "^5.8.3",

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/components/play.svelte

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import { Button, buttonVariants } from '$lib/components/ui/button/index.js';
66
import { Drawer } from 'vaul-svelte';
77
import { toast } from 'svelte-sonner';
8+
import { Badge } from '$lib/components/ui/badge/index.js';
9+
import { badgeVariants } from '$lib/components/ui/badge/index.js';
810
911
// Icons
1012
import Refresh from 'lucide-svelte/icons/refresh-cw';
@@ -13,11 +15,13 @@
1315
import Share from 'lucide-svelte/icons/share';
1416
import Bookmark from 'lucide-svelte/icons/bookmark';
1517
import Comment from 'lucide-svelte/icons/message-square';
18+
import ArrowRight from 'lucide-svelte/icons/arrow-right';
1619
1720
// App imports
1821
import { getGameById } from '$lib/gmaes';
1922
import { preferencesStore, favoritesStore, historyStore } from '$lib/stores';
2023
import { onMount } from 'svelte';
24+
import clsx from 'clsx';
2125
2226
function openNewTab(url: string) {
2327
url = location.origin + url;
@@ -60,8 +64,21 @@
6064
<iframe src={gmaedata?.url} frameborder="0" class="flex-grow rounded" title={gmaedata?.name}
6165
></iframe>
6266

63-
<div class="flex h-full w-72 flex-col">
67+
<div class="flex h-full w-72 flex-col gap-2">
68+
<a href="/" class={clsx(badgeVariants({ variant: 'secondary' }), 'w-fit')}
69+
>{gmaedata?.category}<ArrowRight class="ml-1 size-3" /></a
70+
>
6471
<h1 class="text-4xl font-bold">{gmaedata?.name}</h1>
72+
<div class="flex w-full flex-row flex-wrap gap-2">
73+
{#each gmaedata?.tags || [] as tag}
74+
<Badge variant="default">#{tag}</Badge>
75+
{/each}
76+
{#each gmaedata?.links || [] as link}
77+
<a href={link.url} target="_blank" class={badgeVariants({ variant: 'outline' })}>
78+
<OpenInNewTab class="mr-1 size-3" />{link.name}
79+
</a>
80+
{/each}
81+
</div>
6582
<p class="text-xl">{gmaedata?.description}</p>
6683
<div class="flex-grow"></div>
6784
<div class="flex flex-col gap-3">
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script lang="ts" module>
2+
import { type VariantProps, tv } from 'tailwind-variants';
3+
4+
export const badgeVariants = tv({
5+
base: 'focus:ring-ring inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2',
6+
variants: {
7+
variant: {
8+
default: 'bg-primary text-primary-foreground hover:bg-primary/80 border-transparent',
9+
secondary:
10+
'bg-secondary text-secondary-foreground hover:bg-secondary/80 border-transparent',
11+
destructive:
12+
'bg-destructive text-destructive-foreground hover:bg-destructive/80 border-transparent',
13+
outline: 'text-foreground'
14+
}
15+
},
16+
defaultVariants: {
17+
variant: 'default'
18+
}
19+
});
20+
21+
export type BadgeVariant = VariantProps<typeof badgeVariants>['variant'];
22+
</script>
23+
24+
<script lang="ts">
25+
import type { WithElementRef } from 'bits-ui';
26+
import type { HTMLAnchorAttributes } from 'svelte/elements';
27+
import { cn } from '$lib/utils.js';
28+
29+
let {
30+
ref = $bindable(null),
31+
href,
32+
class: className,
33+
variant = 'default',
34+
children,
35+
...restProps
36+
}: WithElementRef<HTMLAnchorAttributes> & {
37+
variant?: BadgeVariant;
38+
} = $props();
39+
</script>
40+
41+
<svelte:element
42+
this={href ? 'a' : 'span'}
43+
bind:this={ref}
44+
{href}
45+
class={cn(badgeVariants({ variant }), className)}
46+
{...restProps}
47+
>
48+
{@render children?.()}
49+
</svelte:element>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as Badge } from './badge.svelte';
2+
export { badgeVariants, type BadgeVariant } from './badge.svelte';

0 commit comments

Comments
 (0)