aboutsummaryrefslogtreecommitdiff
path: root/src/lib/User/BadgeWall/FallbackBadge.svelte
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-03-01 16:04:11 -0800
committerFuwn <[email protected]>2026-03-01 16:04:11 -0800
commit48f0c30d47d62e4f35706edb93a1bb2f97eba14c (patch)
tree44866d7a61adfdf01a780e0108c370294d3db78b /src/lib/User/BadgeWall/FallbackBadge.svelte
parentchore(biome): re-enable useAltText rule (diff)
downloaddue.moe-48f0c30d47d62e4f35706edb93a1bb2f97eba14c.tar.xz
due.moe-48f0c30d47d62e4f35706edb93a1bb2f97eba14c.zip
chore(biome): enable svelte formatting
Diffstat (limited to 'src/lib/User/BadgeWall/FallbackBadge.svelte')
-rw-r--r--src/lib/User/BadgeWall/FallbackBadge.svelte112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/lib/User/BadgeWall/FallbackBadge.svelte b/src/lib/User/BadgeWall/FallbackBadge.svelte
index bda93e4e..86e90939 100644
--- a/src/lib/User/BadgeWall/FallbackBadge.svelte
+++ b/src/lib/User/BadgeWall/FallbackBadge.svelte
@@ -1,70 +1,70 @@
<script lang="ts">
- import { classifyDesignerName } from './badge';
- import locale from '$stores/locale';
- import { tweened } from 'svelte/motion';
- import type { Badge } from '../../Database/SB/User/badges';
- import type { AWCBadge } from '../../Data/awc';
- import Tooltip from '../../Tooltip/LinkedTooltip.svelte';
- import { databaseTimeToDate } from '../../Utility/time';
- import { cubicOut } from 'svelte/easing';
- import { dev } from '$app/environment';
- import type { Preferences } from '../../../graphql/$types';
+import { classifyDesignerName } from './badge';
+import locale from '$stores/locale';
+import { tweened } from 'svelte/motion';
+import type { Badge } from '../../Database/SB/User/badges';
+import type { AWCBadge } from '../../Data/awc';
+import Tooltip from '../../Tooltip/LinkedTooltip.svelte';
+import { databaseTimeToDate } from '../../Utility/time';
+import { cubicOut } from 'svelte/easing';
+import { dev } from '$app/environment';
+import type { Preferences } from '../../../graphql/$types';
- export let source: string | null | undefined;
- export let alternative: string | null | undefined;
- export let fallback: string | null | undefined;
- export let maxReplaceCount = 1;
- export let replaceDelay = 1000;
- export let error = 'https://i2.kym-cdn.com/photos/images/newsfeed/000/290/992/0aa.jpg';
- export let hideOnError = false;
- export let badge: Badge | AWCBadge;
- export let style = '';
- export let selectedBadge: Badge | null = null;
- export let awc = false;
- export let index: number | null = null;
- export let preferences: Preferences | undefined;
+export let source: string | null | undefined;
+export let alternative: string | null | undefined;
+export let fallback: string | null | undefined;
+export let maxReplaceCount = 1;
+export let replaceDelay = 1000;
+export let error = 'https://i2.kym-cdn.com/photos/images/newsfeed/000/290/992/0aa.jpg';
+export let hideOnError = false;
+export let badge: Badge | AWCBadge;
+export let style = '';
+export let selectedBadge: Badge | null = null;
+export let awc = false;
+export let index: number | null = null;
+export let preferences: Preferences | undefined;
- let replaceCount = 0;
- let badgeReference: HTMLImageElement;
- const mouse = tweened(
- { x: 0, y: 0 },
- {
- duration: 75,
- easing: cubicOut
- }
- );
+let replaceCount = 0;
+let badgeReference: HTMLImageElement;
+const mouse = tweened(
+ { x: 0, y: 0 },
+ {
+ duration: 75,
+ easing: cubicOut
+ }
+);
- const delayedReplace = (event: Event, image: string | undefined | null) => {
- if (replaceCount >= maxReplaceCount) return;
+const delayedReplace = (event: Event, image: string | undefined | null) => {
+ if (replaceCount >= maxReplaceCount) return;
- setTimeout(() => {
- (event.target as HTMLImageElement).src = image || '';
+ setTimeout(() => {
+ (event.target as HTMLImageElement).src = image || '';
- replaceCount += 1;
- }, replaceDelay);
- };
+ replaceCount += 1;
+ }, replaceDelay);
+};
- const handleMouseMove = (event: MouseEvent) => {
- const boundingRectangle = badgeReference.getBoundingClientRect();
- const factor = 1.25;
- const limit = 50;
+const handleMouseMove = (event: MouseEvent) => {
+ const boundingRectangle = badgeReference.getBoundingClientRect();
+ const factor = 1.25;
+ const limit = 50;
- if ($mouse.x === 0 && $mouse.y === 0) $mouse = { x: event.clientX, y: event.clientY };
+ if ($mouse.x === 0 && $mouse.y === 0) $mouse = { x: event.clientX, y: event.clientY };
- $mouse.x +=
- (-(event.clientX - boundingRectangle.left - boundingRectangle.width / 2) - $mouse.x) * factor;
- $mouse.y +=
- (-(event.clientY - boundingRectangle.top - boundingRectangle.height / 2) - $mouse.y) * factor;
- $mouse.x = Math.max(Math.min($mouse.x, limit), -limit);
- $mouse.y = Math.max(Math.min($mouse.y, limit), -limit);
- };
+ $mouse.x +=
+ (-(event.clientX - boundingRectangle.left - boundingRectangle.width / 2) - $mouse.x) * factor;
+ $mouse.y +=
+ (-(event.clientY - boundingRectangle.top - boundingRectangle.height / 2) - $mouse.y) * factor;
+ $mouse.x = Math.max(Math.min($mouse.x, limit), -limit);
+ $mouse.y = Math.max(Math.min($mouse.y, limit), -limit);
+};
- const handleMouseLeave = () => {
- $mouse = { x: 0, y: 0 };
- };
+const handleMouseLeave = () => {
+ $mouse = { x: 0, y: 0 };
+};
- const isDBBadge = (b: Badge | AWCBadge): b is Badge => 'id' in b;
- const asAWCBadge = (b: Badge | AWCBadge) => b as AWCBadge;
+const isDBBadge = (b: Badge | AWCBadge): b is Badge => 'id' in b;
+const asAWCBadge = (b: Badge | AWCBadge) => b as AWCBadge;
</script>
{#if replaceCount < maxReplaceCount}