summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/pills
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/lib/pills')
-rw-r--r--frontend/src/lib/pills/AssociationPill.svelte27
-rw-r--r--frontend/src/lib/pills/ComicPills.svelte37
-rw-r--r--frontend/src/lib/pills/FooterPill.svelte15
-rw-r--r--frontend/src/lib/pills/Pill.svelte70
-rw-r--r--frontend/src/lib/pills/TagPill.svelte47
5 files changed, 77 insertions, 119 deletions
diff --git a/frontend/src/lib/pills/AssociationPill.svelte b/frontend/src/lib/pills/AssociationPill.svelte
deleted file mode 100644
index fec59b8..0000000
--- a/frontend/src/lib/pills/AssociationPill.svelte
+++ /dev/null
@@ -1,27 +0,0 @@
-<script lang="ts">
- import Artist from '$lib/icons/Artist.svelte';
- import Character from '$lib/icons/Character.svelte';
- import Circle from '$lib/icons/Circle.svelte';
- import World from '$lib/icons/World.svelte';
- import type { Component } from 'svelte';
- import Pill from './Pill.svelte';
-
- type Association = 'artist' | 'circle' | 'world' | 'character';
-
- let { name, type }: { name: string; type: Association } = $props();
-
- const icons: Record<Association, Component> = {
- artist: Artist,
- character: Character,
- circle: Circle,
- world: World
- };
-
- const Icon = icons[type];
-</script>
-
-<Pill {name}>
- {#snippet icon()}
- <Icon />
- {/snippet}
-</Pill>
diff --git a/frontend/src/lib/pills/ComicPills.svelte b/frontend/src/lib/pills/ComicPills.svelte
deleted file mode 100644
index 45c42fd..0000000
--- a/frontend/src/lib/pills/ComicPills.svelte
+++ /dev/null
@@ -1,37 +0,0 @@
-<script lang="ts">
- import type { ComicFragment } from '$gql/graphql';
- import AssociationPill from '$lib/pills/AssociationPill.svelte';
- import TagPill from '$lib/pills/TagPill.svelte';
-
- let { comic }: { comic: ComicFragment } = $props();
-</script>
-
-<div class="flex flex-col gap-1">
- {#if comic.artists.length || comic.circles.length}
- <div class="flex flex-wrap gap-1">
- {#each comic.artists as { name } (name)}
- <AssociationPill {name} type="artist" />
- {/each}
- {#each comic.circles as { name } (name)}
- <AssociationPill {name} type="circle" />
- {/each}
- </div>
- {/if}
- {#if comic.characters.length || comic.worlds.length}
- <div class="flex flex-wrap gap-1">
- {#each comic.worlds as { name } (name)}
- <AssociationPill {name} type="world" />
- {/each}
- {#each comic.characters as { name } (name)}
- <AssociationPill {name} type="character" />
- {/each}
- </div>
- {/if}
- {#if comic.tags.length}
- <div class="flex flex-wrap gap-1">
- {#each comic.tags as { name, description } (name)}
- <TagPill {name} {description} />
- {/each}
- </div>
- {/if}
-</div>
diff --git a/frontend/src/lib/pills/FooterPill.svelte b/frontend/src/lib/pills/FooterPill.svelte
new file mode 100644
index 0000000..3da1811
--- /dev/null
+++ b/frontend/src/lib/pills/FooterPill.svelte
@@ -0,0 +1,15 @@
+<script lang="ts">
+ import type { Snippet } from 'svelte';
+
+ interface Props {
+ text: string;
+ icon?: Snippet;
+ }
+
+ let { text, icon }: Props = $props();
+</script>
+
+<div class="flex items-center rounded-sm p-0.5 text-zinc-300">
+ {@render icon?.()}
+ <span>{text}</span>
+</div>
diff --git a/frontend/src/lib/pills/Pill.svelte b/frontend/src/lib/pills/Pill.svelte
index e7c6a8f..98d9b5a 100644
--- a/frontend/src/lib/pills/Pill.svelte
+++ b/frontend/src/lib/pills/Pill.svelte
@@ -1,49 +1,83 @@
-<script lang="ts" module>
- export type PillColour = 'pink' | 'blue' | 'violet' | 'amber' | 'zinc' | 'sky';
-</script>
-
<script lang="ts">
- import type { Snippet } from 'svelte';
-
interface Props {
name: string;
tooltip?: string | null;
- colour?: PillColour;
- icon?: Snippet;
+ style: string;
+ highlight?: boolean;
}
- let { name, tooltip, colour = 'zinc', icon }: Props = $props();
+ let { name, tooltip, style, highlight = false }: Props = $props();
</script>
-<div class="flex items-center rounded-sm border p-0.5 {colour}" title={tooltip}>
- {@render icon?.()}
+<div class:highlight class="flex items-center rounded-sm border p-0.5 {style}" title={tooltip}>
+ {#if style === 'female'}
+ <span class="icon-xs icon-[material-symbols--female] -mx-[3px]"></span>
+ {:else if style === 'male'}
+ <span class="icon-xs icon-[material-symbols--male] -mx-px"></span>
+ {:else if style === 'trans'}
+ <span class="icon-xs icon-[material-symbols--transgender]"></span>
+ {:else if style === 'location'}
+ <span class="icon-xs icon-[material-symbols--location-on-outline]"></span>
+ {:else if style === 'artist'}
+ <span class="icon-xs icon-[material-symbols--person] -mx-px"></span>
+ {:else if style === 'character'}
+ <span class="icon-xs icon-[material-symbols--face]"></span>
+ {:else if style === 'circle'}
+ <span class="icon-xs icon-[material-symbols--group] mx-px"></span>
+ {:else if style === 'world'}
+ <span class="icon-xs icon-[material-symbols--public]"></span>
+ {/if}
<span>{name}</span>
</div>
<style lang="postcss">
@reference "tailwindcss/theme";
- .pink {
+ div {
+ @apply border-zinc-700 bg-zinc-700/20 text-zinc-300;
+ }
+
+ div.highlight {
+ @apply transition-colors hover:border-zinc-600 hover:bg-zinc-500/20 hover:text-zinc-200;
+ }
+
+ .female {
@apply border-pink-800 bg-pink-800/20 text-pink-200;
}
- .blue {
+ .female.highlight {
+ @apply hover:border-pink-700 hover:bg-pink-600/20 hover:text-pink-100;
+ }
+
+ .male {
@apply border-blue-800 bg-blue-800/20 text-blue-200;
}
- .violet {
+ .male.highlight {
+ @apply hover:border-blue-700 hover:bg-blue-600/20 hover:text-blue-100;
+ }
+
+ .trans {
@apply border-violet-800 bg-violet-800/20 text-violet-200;
}
- .amber {
+ .trans.highlight {
+ @apply hover:border-violet-600 hover:bg-violet-600/20 hover:text-violet-100;
+ }
+
+ .mixed {
@apply border-amber-800 bg-amber-800/20 text-amber-200;
}
- .sky {
+ .mixed.highlight {
+ @apply hover:border-amber-700 hover:bg-amber-600/20 hover:text-amber-100;
+ }
+
+ .location {
@apply border-sky-800 bg-sky-800/20 text-sky-200;
}
- .zinc {
- @apply border-zinc-700 bg-zinc-700/20 text-zinc-300;
+ .location.highlight {
+ @apply hover:border-sky-700 hover:bg-sky-600/20 hover:text-sky-100;
}
</style>
diff --git a/frontend/src/lib/pills/TagPill.svelte b/frontend/src/lib/pills/TagPill.svelte
index 92d2a0b..bbd3c55 100644
--- a/frontend/src/lib/pills/TagPill.svelte
+++ b/frontend/src/lib/pills/TagPill.svelte
@@ -1,43 +1,16 @@
<script lang="ts">
- import Female from '$lib/icons/Female.svelte';
- import Location from '$lib/icons/Location.svelte';
- import Male from '$lib/icons/Male.svelte';
- import Transgender from '$lib/icons/Transgender.svelte';
- import type { Component } from 'svelte';
- import Pill, { type PillColour } from './Pill.svelte';
+ import type { ComicTag } from '$gql/graphql';
+ import { joinText } from '$lib/Utils';
+ import Pill from './Pill.svelte';
- let { name, description }: { name: string; description?: string | null } = $props();
-
- let [namespace, tag] = name.split(':');
-
- const styles: Record<string, PillColour> = {
- female: 'pink',
- male: 'blue',
- trans: 'violet',
- mixed: 'amber',
- location: 'sky',
- rest: 'zinc'
- };
-
- const icons: Record<string, Component> = {
- female: Female,
- male: Male,
- trans: Transgender,
- location: Location
- };
+ interface Props extends Pick<ComicTag, 'name' | 'description'> {
+ highlight?: boolean;
+ }
- const colour = styles[namespace] ?? styles.rest;
- const Icon = icons[namespace];
+ let { name, description, highlight = false }: Props = $props();
- function formatTooltip() {
- return [name, description].filter((v) => v).join('\n\n');
- }
+ let [namespace, tag] = name.split(':');
+ let tooltip = joinText([name, description], '\n\n');
</script>
-<Pill name={tag} tooltip={formatTooltip()} {colour}>
- {#snippet icon()}
- {#if Icon}
- <Icon />
- {/if}
- {/snippet}
-</Pill>
+<Pill {highlight} name={tag} style={namespace} {tooltip}></Pill>