1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 import { computed } from 'vue'
import fallbackImage from '../assets/fallback.svg';
export const Tiles = (props: {
allowHScroll?: boolean,
tileSize?: number,
twoRows?: boolean,
}) => {
const
classes = computed(() => ({
'scroll': props.allowHScroll ?? false,
'two-rows': props.twoRows ?? false,
})),
styles = computed(() => ({
'--tile-size': (props.tileSize ?? 150)+'px',
'--tile-size-mobile': (Math.round((props.tileSize ?? 150) * 0.85))+'px',
}))
return vine`
<div class="tiles" :class="classes" :style="styles">
<slot />
</div>
`
}
export const Tile = ({
to, title, text, image = fallbackImage
}: {
to?: object,
title?: string,
text?: string,
image?: string,
}) => {
return vine`
<div class="tile">
<div class="image">
<component :is="to ? 'router-link' : 'template'" :to="to ? to : undefined">
<img :src="image" loading="lazy">
</component>
</div>
<div class="body text-truncate">
<div class="title text-truncate">
<slot name="title">
<component :is="to ? 'router-link' : 'span'" :to="to ? to : undefined">{{ title }}</component>
</slot>
</div>
<slot name="text">{{ text }}</slot>
<ContextMenu :enabled="!!$slots['context-menu']">
<template #context-menu>
<slot name="context-menu" />
</template>
</ContextMenu>
</div>
</div>
`
}