feat: add flags to profile pages
This commit is contained in:
parent
c28df5fc7f
commit
5b954778cf
|
@ -40,6 +40,7 @@
|
||||||
import StatusLine from "$lib/components/StatusLine.svelte";
|
import StatusLine from "$lib/components/StatusLine.svelte";
|
||||||
import defaultPreferences from "$lib/api/default_preferences";
|
import defaultPreferences from "$lib/api/default_preferences";
|
||||||
import { addToast } from "$lib/toast";
|
import { addToast } from "$lib/toast";
|
||||||
|
import ProfileFlag from "./ProfileFlag.svelte";
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
@ -117,16 +118,16 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($userStore && $userStore.id === data.id) {
|
if ($userStore && $userStore.id === data.id) {
|
||||||
console.log("User is current user, fetching members")
|
console.log("User is current user, fetching members");
|
||||||
try {
|
try {
|
||||||
const members = await apiFetchClient<PartialMember[]>("/users/@me/members");
|
const members = await apiFetchClient<PartialMember[]>("/users/@me/members");
|
||||||
data.members = members;
|
data.members = members;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// If it fails, we fail silently but log to console anyway
|
// If it fails, we fail silently but log to console anyway
|
||||||
console.error("Fetching members:", e)
|
console.error("Fetching members:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -140,6 +141,13 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4 text-center">
|
<div class="col-md-4 text-center">
|
||||||
<FallbackImage width={200} urls={userAvatars(data)} alt="Avatar for @{data.name}" />
|
<FallbackImage width={200} urls={userAvatars(data)} alt="Avatar for @{data.name}" />
|
||||||
|
{#if data.flags && data.bio}
|
||||||
|
<div class="d-flex flex-wrap m-4">
|
||||||
|
{#each data.flags as flag}
|
||||||
|
<ProfileFlag {flag} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
{#if data.display_name}
|
{#if data.display_name}
|
||||||
|
@ -174,6 +182,13 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{#if data.flags && !data.bio}
|
||||||
|
<div class="d-flex flex-wrap m-4">
|
||||||
|
{#each data.flags as flag}
|
||||||
|
<ProfileFlag {flag} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3">
|
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3">
|
||||||
{#if data.names.length > 0}
|
{#if data.names.length > 0}
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { flagURL, type PrideFlag } from "$lib/api/entities";
|
||||||
|
import { Tooltip } from "sveltestrap";
|
||||||
|
|
||||||
|
export let flag: PrideFlag;
|
||||||
|
|
||||||
|
let elem: HTMLElement;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<span class="mx-2 my-1">
|
||||||
|
<Tooltip target={elem} aria-hidden placement="top">{flag.description ?? flag.name}</Tooltip>
|
||||||
|
<img bind:this={elem} class="flag" src={flagURL(flag)} alt={flag.description ?? flag.name} />
|
||||||
|
{flag.name}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.flag {
|
||||||
|
height: 1.5rem;
|
||||||
|
max-width: 200px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -20,6 +20,7 @@
|
||||||
import StatusLine from "$lib/components/StatusLine.svelte";
|
import StatusLine from "$lib/components/StatusLine.svelte";
|
||||||
import defaultPreferences from "$lib/api/default_preferences";
|
import defaultPreferences from "$lib/api/default_preferences";
|
||||||
import { addToast } from "$lib/toast";
|
import { addToast } from "$lib/toast";
|
||||||
|
import ProfileFlag from "../ProfileFlag.svelte";
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
@ -69,6 +70,13 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4 text-center">
|
<div class="col-md-4 text-center">
|
||||||
<FallbackImage width={200} urls={memberAvatars(data)} alt="Avatar for @{data.name}" />
|
<FallbackImage width={200} urls={memberAvatars(data)} alt="Avatar for @{data.name}" />
|
||||||
|
{#if data.flags && data.bio}
|
||||||
|
<div class="d-flex flex-wrap m-4">
|
||||||
|
{#each data.flags as flag}
|
||||||
|
<ProfileFlag {flag} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<h2>{data.display_name ?? data.name}</h2>
|
<h2>{data.display_name ?? data.name}</h2>
|
||||||
|
@ -97,6 +105,13 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{#if data.flags && !data.bio}
|
||||||
|
<div class="d-flex flex-wrap m-4">
|
||||||
|
{#each data.flags as flag}
|
||||||
|
<ProfileFlag {flag} />
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3">
|
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3">
|
||||||
{#if data.names.length > 0}
|
{#if data.names.length > 0}
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
|
|
Loading…
Reference in New Issue