feat(frontend): preference cheatsheet

This commit is contained in:
sam 2024-12-18 21:38:39 +01:00
parent 546e900204
commit 8a2ffd7d69
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
3 changed files with 33 additions and 2 deletions

View file

@ -0,0 +1,29 @@
<script lang="ts">
import { type User, type Member, type CustomPreference } from "$api/models";
import StatusIcon from "$components/StatusIcon.svelte";
type Props = { profile: User | Member; allPreferences: Record<string, CustomPreference> };
let { profile, allPreferences }: Props = $props();
let preferences = $derived.by(() => {
let preferenceKeys = Object.keys(allPreferences).filter(
(pref) =>
profile.names.some((entry) => entry.status === pref) ||
profile.pronouns.some((entry) => entry.status === pref) ||
profile.fields.some((field) => field.entries.some((entry) => entry.status === pref)),
);
return preferenceKeys.map((pref) => allPreferences[pref]);
});
</script>
<div class="text-center text-body-secondary">
<ul class="list-inline">
{#each preferences as preference}
<li class="list-inline-item mx-2">
<StatusIcon {preference} />
{preference.tooltip}
</li>
{/each}
</ul>
</div>