Files

77 lines
2.2 KiB
Svelte
Raw Permalink Normal View History

2023-10-02 23:10:49 +03:00
<script>
import Icon from "../common/Icon.svelte";
2024-08-15 22:11:26 +03:00
import {imgurl} from "./imageserver.js";
2023-10-04 13:32:30 +03:00
import {getContext} from "svelte";
2023-10-02 23:10:49 +03:00
export let record;
const channel = getContext("channel");
export let size = "small";
export let showFilename = false;
let imageSide;
let fileSide;
let fontSize;
if (size == "large") {
imageSide = 256;
fileSide = 32;
fontSize = "20";
} else if (size == "medium") {
imageSide = 128;
fileSide = 12;
fontSize = "17";
} else if (size == "small") {
imageSide = 64;
fileSide = 12;
fontSize = "15";
} else if (size == "tiny") {
imageSide = 42;
fileSide = 12;
fontSize = "13";
}
</script>
2024-08-15 14:44:53 +03:00
<div style="display: flex;align-items: center;gap: 5px;">
{#if record}
2023-10-02 23:10:49 +03:00
2024-08-15 14:44:53 +03:00
{#if record._file.mime.startsWith("image")}
<!-- href={imgurl(record)} -->
<a
href="{channel.lucentUrl}/records/{record.id}"
2024-08-15 22:11:26 +03:00
title={record._file.originalName}
2024-08-15 14:44:53 +03:00
style="width:{imageSide}px;height:{imageSide}px"
>
<img
class="rounded w-100"
2024-08-18 17:23:18 +03:00
src={imgurl(channel,record)}
2024-08-15 14:44:53 +03:00
alt={record._file.path}
/>
</a>
{:else}
<a
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.path}
class="file-preview-small"
style="width:{imageSide}px;height:{imageSide}px"
>
<Icon icon="file" width={fileSide} height={fileSide}/>
<span class="ms-2"
2024-08-16 14:34:39 +03:00
>.{record._file.path.split(".").pop().toLowerCase()}</span
2024-08-15 14:44:53 +03:00
>
</a>
{/if}
{/if}
{#if showFilename}
2023-10-02 23:10:49 +03:00
<a
2023-10-04 13:32:30 +03:00
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.path}
2024-08-15 14:44:53 +03:00
class="preview-file-filename lx-small-text text-decoration-none"
2024-08-16 14:34:39 +03:00
>{record._file.path} </a
2023-10-02 23:10:49 +03:00
>
{/if}
2024-08-15 14:44:53 +03:00
</div>
<style>
img{
border-radius: 12px;
padding: 4px;
}
2024-08-17 19:23:19 +03:00
2024-08-15 14:44:53 +03:00
</style>