Image.svelte 568 Bytes
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
<script lang="ts">
Timothy J. Baek's avatar
Timothy J. Baek committed
2
	import { WEBUI_BASE_URL } from '$lib/constants';
Timothy J. Baek's avatar
Timothy J. Baek committed
3
4
5
6
7
	import ImagePreview from './ImagePreview.svelte';

	export let src = '';
	export let alt = '';

Timothy J. Baek's avatar
Timothy J. Baek committed
8
	export let className = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
9

Timothy J. Baek's avatar
Timothy J. Baek committed
10
	let _src = '';
Timothy J. Baek's avatar
Timothy J. Baek committed
11
12
	$: _src = src.startsWith('/') ? `${WEBUI_BASE_URL}${src}` : src;

Timothy J. Baek's avatar
Timothy J. Baek committed
13
14
15
	let showImagePreview = false;
</script>

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
16
17
18
19
20
21
22
23
24
<button
	class={className}
	on:click={() => {
		showImagePreview = true;
	}}
>
	<img src={_src} {alt} class=" rounded-lg cursor-pointer" draggable="false" data-cy="image" />
</button>

Timothy J. Baek's avatar
revert  
Timothy J. Baek committed
25
<ImagePreview bind:show={showImagePreview} src={_src} {alt} />