blob: 5ace666f4ea1d4f113b2c8b60d713f028b7c333c (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
<script lang="ts" context="module">
import {
type Action,
type FlowAction,
type GenericPage,
type PrivacyHeader,
type Shelf,
isFlowAction,
} from '@jet-app/app-store/api/models';
import {
isPrivacyTypeShelf,
type PrivacyTypeShelf,
} from '~/components/jet/shelf/PrivacyTypeShelf.svelte';
interface PrivacyHeaderShelf extends Shelf {
items: [PrivacyHeader];
}
interface PrivacyDetailPage extends GenericPage {
shelves: (PrivacyTypeShelf | PrivacyHeaderShelf)[];
}
interface PrivacyDetailPageFlowAction extends FlowAction {
page: 'privacyDetail';
pageData: PrivacyDetailPage;
}
export function isPrivacyHeaderShelf(
shelf: Shelf,
): shelf is PrivacyHeaderShelf {
let { contentType, items } = shelf;
return contentType === 'privacyHeader' && Array.isArray(items);
}
function isPrivacyDetailFlowAction(
action: Action,
): action is PrivacyDetailPageFlowAction {
return isFlowAction(action) && action.page === 'privacyDetail';
}
</script>
<script lang="ts">
import Modal from '@amp/web-app-components/src/components/Modal/Modal.svelte';
import ContentModal from '~/components/jet/item/ContentModal.svelte';
import ShelfWrapper from '~/components/Shelf/Wrapper.svelte';
import ShelfTitle from '~/components/Shelf/Title.svelte';
import PrivacyHeaderItem from '~/components/jet/item/PrivacyHeaderItem.svelte';
import PrivacyTypeItem from '~/components/jet/item/PrivacyTypeItem.svelte';
import { getI18n } from '~/stores/i18n';
import { APP_PRIVACY_MODAL_ID } from '~/utils/metrics';
export let shelf: PrivacyHeaderShelf;
let modalComponent: Modal | undefined;
let modalTriggerElement: HTMLElement | null = null;
const { seeAllAction } = shelf;
const i18n = getI18n();
const translateFn = (key: string) => $i18n.t(key);
const handleModalClose = () => modalComponent?.close();
const handleOpenModalClick = (e: Event) => {
modalTriggerElement = e.target as HTMLElement;
modalComponent?.showModal();
};
const destination =
seeAllAction && isPrivacyDetailFlowAction(seeAllAction)
? seeAllAction
: undefined;
const pageData = destination?.pageData;
</script>
<ShelfWrapper {shelf} withBottomPadding={false}>
<div slot="title" class="title-container">
{#if shelf.title}
<button on:click={handleOpenModalClick}>
<ShelfTitle title={shelf.title} seeAllAction={destination} />
</button>
{/if}
{#if pageData}
<Modal {modalTriggerElement} bind:this={modalComponent}>
<ContentModal
{translateFn}
on:close={handleModalClose}
title={pageData.title || null}
subtitle={null}
targetId={APP_PRIVACY_MODAL_ID}
>
<svelte:fragment slot="content">
<ul class="modal-content-container">
{#each pageData.shelves as shelf}
{#if isPrivacyHeaderShelf(shelf)}
{#each shelf.items as item}
<PrivacyHeaderItem {item} />
{/each}
{/if}
{#if isPrivacyTypeShelf(shelf)}
{#each shelf.items as item}
<PrivacyTypeItem
{item}
isDetailView={true}
/>
{/each}
{/if}
{/each}
</ul>
</svelte:fragment>
</ContentModal>
</Modal>
{/if}
</div>
<div class="header-container">
<div>
<PrivacyHeaderItem item={shelf.items[0]} />
</div>
</div>
</ShelfWrapper>
<style>
.title-container {
display: flex;
justify-content: space-between;
padding-top: 16px;
padding-inline-end: var(--bodyGutter);
}
.header-container {
margin: 0 var(--bodyGutter);
}
.header-container div {
@media (--range-medium-up) {
width: 66%;
}
}
.modal-content-container {
font: var(--body-tall);
white-space: normal;
}
</style>
|