2022-02-07 22:34:53 +08:00
|
|
|
<script lang="ts">
|
2023-07-05 00:21:23 +08:00
|
|
|
import { onMount } from "svelte";
|
2023-01-18 04:47:40 +08:00
|
|
|
|
2024-01-30 08:51:22 +08:00
|
|
|
export let value: string | null;
|
2023-01-18 04:47:40 +08:00
|
|
|
export let type: "gallery" | "table";
|
2023-07-05 00:21:23 +08:00
|
|
|
export let selected = false;
|
|
|
|
|
|
|
|
let size: number;
|
|
|
|
let el: HTMLDivElement;
|
|
|
|
|
|
|
|
function set_styles(element: HTMLElement, el_width: number): void {
|
|
|
|
if (!element || !el_width) return;
|
|
|
|
el.style.setProperty(
|
|
|
|
"--local-text-width",
|
|
|
|
`${el_width < 150 ? el_width : 200}px`
|
|
|
|
);
|
|
|
|
el.style.whiteSpace = "unset";
|
|
|
|
}
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
set_styles(el, size);
|
|
|
|
});
|
2022-02-01 21:45:55 +08:00
|
|
|
</script>
|
2022-02-01 23:46:50 +08:00
|
|
|
|
2023-01-18 04:47:40 +08:00
|
|
|
<div
|
2023-07-05 00:21:23 +08:00
|
|
|
bind:clientWidth={size}
|
|
|
|
bind:this={el}
|
2023-01-18 04:47:40 +08:00
|
|
|
class:table={type === "table"}
|
|
|
|
class:gallery={type === "gallery"}
|
|
|
|
class:selected
|
|
|
|
>
|
2024-01-30 08:51:22 +08:00
|
|
|
{value ? value : ""}
|
2023-01-18 04:47:40 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.gallery {
|
|
|
|
padding: var(--size-1) var(--size-2);
|
|
|
|
}
|
2023-07-05 00:21:23 +08:00
|
|
|
|
|
|
|
div {
|
|
|
|
overflow: hidden;
|
|
|
|
min-width: var(--local-text-width);
|
|
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
2023-01-18 04:47:40 +08:00
|
|
|
</style>
|