summaryrefslogtreecommitdiff
path: root/src/components/jet/shelf/ActionShelf.svelte
blob: 847438f9c4caab94797610a97e4b1f68c45073ce (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script lang="ts" context="module">
    import type { Shelf, Action } from '@jet-app/app-store/api/models';

    interface ActionShelf extends Shelf {
        items: Action[];
    }

    export function isActionShelf(shelf: Shelf): shelf is ActionShelf {
        return shelf.contentType === 'action' && Array.isArray(shelf.items);
    }
</script>

<script lang="ts">
    import Artwork, { getNaturalProfile } from '~/components/Artwork.svelte';
    import LinkWrapper from '~/components/LinkWrapper.svelte';
    import ShelfItemLayout from '~/components/ShelfItemLayout.svelte';
    import ShelfWrapper from '~/components/Shelf/Wrapper.svelte';

    export let shelf: ActionShelf;
</script>

<ShelfWrapper {shelf}>
    <ShelfItemLayout {shelf} gridType="F" let:item>
        {@const action = item}
        {@const artwork = item.artwork}
        {@const title = item.title}

        <div class="container">
            <LinkWrapper {action}>
                {#if artwork}
                    <div class="artwork-container" aria-hidden="true">
                        <Artwork
                            {artwork}
                            profile={getNaturalProfile(artwork, [24])}
                            hasTransparentBackground
                        />
                    </div>
                {/if}
                {title}
            </LinkWrapper>
        </div>
    </ShelfItemLayout>
</ShelfWrapper>

<style>
    .container :global(a) {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        background: var(--pageBG);
        border-radius: var(--global-border-radius-medium);
        box-shadow: var(--shadow-small);
        padding: 16px 10px;
        width: 100%;
        font: var(--title-3-medium);
        transition: background-color 210ms ease-out;
    }

    .container :global(a:hover) {
        /* stylelint-disable color-function-notation */
        background-color: rgb(from var(--pageBG) r g b/0.1);
        /* stylelint-enable color-function-notation */

        @media (prefers-color-scheme: dark) {
            /* stylelint-disable color-function-notation */
            background-color: rgb(from var(--pageBG) r g b/0.85);
            /* stylelint-enable color-function-notation */
        }
    }

    .artwork-container {
        width: 24px;
        height: 24px;
    }

    .container :global(.external-link-arrow) {
        height: 10px;
    }
</style>