refactor: clean class (#26885)

This commit is contained in:
Jason Rasmussen
2026-03-12 14:47:35 -04:00
committed by GitHub
parent d4605b21d9
commit 6bb8f4fcc4
5 changed files with 15 additions and 10 deletions

View File

@@ -11,7 +11,7 @@
class?: string; class?: string;
} }
let { album, preload = false, class: className = '' }: Props = $props(); let { album, preload = false, class: className }: Props = $props();
let alt = $derived(album.albumName || $t('unnamed_album')); let alt = $derived(album.albumName || $t('unnamed_album'));
let thumbnailUrl = $derived( let thumbnailUrl = $derived(

View File

@@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { cleanClass } from '$lib';
import { Icon } from '@immich/ui'; import { Icon } from '@immich/ui';
import { mdiImageBrokenVariant } from '@mdi/js'; import { mdiImageBrokenVariant } from '@mdi/js';
import { t } from 'svelte-i18n'; import { t } from 'svelte-i18n';
@@ -11,15 +12,15 @@
height?: string | undefined; height?: string | undefined;
} }
let { class: className = '', hideMessage = false, width = undefined, height = undefined }: Props = $props(); let { class: className, hideMessage = false, width = undefined, height = undefined }: Props = $props();
</script> </script>
<div <div
data-broken-asset data-broken-asset
class={[ class={cleanClass(
'@container flex flex-col overflow-hidden max-h-full max-w-full justify-center items-center bg-gray-100/40 dark:bg-gray-700/40 dark:text-gray-100 p-4', '@container flex flex-col overflow-hidden max-h-full max-w-full justify-center items-center bg-gray-100/40 dark:bg-gray-700/40 dark:text-gray-100 p-4',
className, className,
]} )}
style:width style:width
style:height style:height
> >

View File

@@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { cleanClass } from '$lib';
import { Icon, LoadingSpinner } from '@immich/ui'; import { Icon, LoadingSpinner } from '@immich/ui';
import { mdiAlertCircleOutline, mdiPauseCircleOutline, mdiPlayCircleOutline } from '@mdi/js'; import { mdiAlertCircleOutline, mdiPauseCircleOutline, mdiPlayCircleOutline } from '@mdi/js';
import { Duration } from 'luxon'; import { Duration } from 'luxon';
@@ -25,7 +26,7 @@
curve = false, curve = false,
playIcon = mdiPlayCircleOutline, playIcon = mdiPlayCircleOutline,
pauseIcon = mdiPauseCircleOutline, pauseIcon = mdiPauseCircleOutline,
class: className = undefined, class: className,
}: Props = $props(); }: Props = $props();
let remainingSeconds = $state(durationInSeconds); let remainingSeconds = $state(durationInSeconds);
@@ -60,7 +61,7 @@
{#if enablePlayback} {#if enablePlayback}
<video <video
bind:this={player} bind:this={player}
class={['h-full w-full object-cover', className]} class={cleanClass('h-full w-full object-cover', className)}
class:rounded-xl={curve} class:rounded-xl={curve}
muted muted
autoplay autoplay

View File

@@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { cleanClass } from '$lib';
import BrokenAsset from '$lib/components/assets/broken-asset.svelte'; import BrokenAsset from '$lib/components/assets/broken-asset.svelte';
interface Props { interface Props {
@@ -8,7 +9,7 @@
class?: string; class?: string;
} }
let { alt, preload = false, src, class: className = '' }: Props = $props(); let { alt, preload = false, src, class: className }: Props = $props();
let isBroken = $state(false); let isBroken = $state(false);
</script> </script>
@@ -19,7 +20,7 @@
<img <img
{alt} {alt}
onerror={() => (isBroken = true)} onerror={() => (isBroken = true)}
class="size-full rounded-xl object-cover aspect-square {className}" class={cleanClass('size-full rounded-xl object-cover aspect-square', className)}
data-testid="album-image" data-testid="album-image"
draggable="false" draggable="false"
loading={preload ? 'eager' : 'lazy'} loading={preload ? 'eager' : 'lazy'}

View File

@@ -1,16 +1,18 @@
<script lang="ts"> <script lang="ts">
import { cleanClass } from '$lib';
interface Props { interface Props {
alt?: string; alt?: string;
preload?: boolean; preload?: boolean;
class?: string; class?: string;
} }
let { alt = '', preload = false, class: className = '' }: Props = $props(); let { alt = '', preload = false, class: className }: Props = $props();
</script> </script>
<enhanced:img <enhanced:img
{alt} {alt}
class="size-full rounded-xl object-cover aspect-square {className}" class={cleanClass('size-full rounded-xl object-cover aspect-square', className)}
data-testid="album-image" data-testid="album-image"
draggable="false" draggable="false"
loading={preload ? 'eager' : 'lazy'} loading={preload ? 'eager' : 'lazy'}