mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-10 13:57:26 +08:00
[+] Wrapper for pfp path
This commit is contained in:
@@ -3,13 +3,12 @@
|
|||||||
import Welcome from "./pages/Welcome.svelte";
|
import Welcome from "./pages/Welcome.svelte";
|
||||||
import MaimaiRating from "./pages/MaimaiRating.svelte";
|
import MaimaiRating from "./pages/MaimaiRating.svelte";
|
||||||
import UserHome from "./pages/UserHome.svelte";
|
import UserHome from "./pages/UserHome.svelte";
|
||||||
import Icon from '@iconify/svelte';
|
|
||||||
import Home from "./pages/Home.svelte";
|
import Home from "./pages/Home.svelte";
|
||||||
import Ranking from "./pages/Ranking.svelte";
|
import Ranking from "./pages/Ranking.svelte";
|
||||||
import { USER } from "./libs/sdk";
|
import { USER } from "./libs/sdk";
|
||||||
import type { UserMe } from "./libs/generalTypes";
|
import type { UserMe } from "./libs/generalTypes";
|
||||||
import { DEFAULT_PFP, IMG_HOST } from "./libs/config";
|
|
||||||
import Settings from "./pages/User/Settings.svelte";
|
import Settings from "./pages/User/Settings.svelte";
|
||||||
|
import { pfp } from "./libs/ui"
|
||||||
|
|
||||||
console.log(`%c
|
console.log(`%c
|
||||||
┏━┓ ┳━┓━┓┏━
|
┏━┓ ┳━┓━┓┏━
|
||||||
@@ -42,7 +41,7 @@
|
|||||||
<a href="/ranking">rankings</a>
|
<a href="/ranking">rankings</a>
|
||||||
{#if me}
|
{#if me}
|
||||||
<a href="/u/{me.username}">
|
<a href="/u/{me.username}">
|
||||||
<img src={me.profilePicture ? `${IMG_HOST}/${me.profilePicture}` : DEFAULT_PFP} alt="profile" class="pfp" />
|
<img alt="profile" class="pfp" use:pfp={me}/>
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import moment from 'moment/moment'
|
|||||||
import CalHeatmap from 'cal-heatmap'
|
import CalHeatmap from 'cal-heatmap'
|
||||||
// @ts-expect-error Cal-heatmap does not have proper types
|
// @ts-expect-error Cal-heatmap does not have proper types
|
||||||
import CalTooltip from 'cal-heatmap/plugins/Tooltip'
|
import CalTooltip from 'cal-heatmap/plugins/Tooltip'
|
||||||
import { DEFAULT_PFP } from "./config";
|
import { DEFAULT_PFP, IMG_HOST } from "./config";
|
||||||
|
import type { UserMe } from "./generalTypes";
|
||||||
|
|
||||||
export function title(t: string) {
|
export function title(t: string) {
|
||||||
document.title = `AquaNet - ${t}`
|
document.title = `AquaNet - ${t}`
|
||||||
@@ -152,3 +153,8 @@ export function tooltip(element: HTMLElement, params: { text: string } | string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function pfp(node: HTMLImageElement, me: UserMe) {
|
||||||
|
node.src = me.profilePicture ? `${IMG_HOST}/${me.profilePicture}` : DEFAULT_PFP
|
||||||
|
node.onerror = e => pfpNotFound(e as Event)
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import StatusOverlays from "../../components/StatusOverlays.svelte";
|
import StatusOverlays from "../../components/StatusOverlays.svelte";
|
||||||
import Icon from "@iconify/svelte";
|
import Icon from "@iconify/svelte";
|
||||||
import { IMG_HOST } from "../../libs/config.js";
|
import { IMG_HOST } from "../../libs/config.js";
|
||||||
|
import { pfpNotFound, pfp } from "../../libs/ui";
|
||||||
|
|
||||||
USER.ensureLoggedIn()
|
USER.ensureLoggedIn()
|
||||||
|
|
||||||
@@ -65,7 +66,10 @@
|
|||||||
<label for="profile-upload">Profile Picture</label>
|
<label for="profile-upload">Profile Picture</label>
|
||||||
<div>
|
<div>
|
||||||
{#if me && me.profilePicture}
|
{#if me && me.profilePicture}
|
||||||
<img src="{IMG_HOST}/{me?.profilePicture}" alt="Profile" />
|
<div on:click={() => pfpField.click()} on:keydown={e => e.key === 'Enter' && pfpField.click()}
|
||||||
|
role="button" tabindex="0" class="clickable">
|
||||||
|
<img use:pfp={me} alt="Profile" />
|
||||||
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<button on:click={() => pfpField.click()}>
|
<button on:click={() => pfpField.click()}>
|
||||||
Upload New
|
Upload New
|
||||||
@@ -100,6 +104,7 @@
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
<style lang="sass">
|
<style lang="sass">
|
||||||
|
@import "../../vars"
|
||||||
|
|
||||||
.field
|
.field
|
||||||
display: flex
|
display: flex
|
||||||
@@ -114,4 +119,10 @@
|
|||||||
> input
|
> input
|
||||||
flex: 1
|
flex: 1
|
||||||
|
|
||||||
|
img
|
||||||
|
max-width: 100px
|
||||||
|
max-height: 100px
|
||||||
|
border-radius: $border-radius
|
||||||
|
object-fit: cover
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user