@playpilot/tpi 8.15.0 → 8.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +0 -2
- package/dist/editorial.mount.js +8 -8
- package/dist/link-injections.js +1 -1
- package/dist/mount.js +9 -9
- package/package.json +2 -2
- package/src/lib/modal.ts +1 -3
- package/src/routes/components/Rails/TitlesRail.svelte +12 -5
- package/src/routes/components/Widgets/InjectionsWidgetRail.svelte +5 -1
- package/src/routes/elements/+page.svelte +0 -4
- package/src/tests/lib/injection.test.js +1 -1
- package/src/tests/lib/routes.test.js +1 -1
- package/src/tests/routes/components/Rails/TitlesRail.test.js +10 -0
- package/src/routes/components/Modals/ExploreModal.svelte +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playpilot/tpi",
|
|
3
|
-
"version": "8.15.
|
|
3
|
+
"version": "8.15.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"release": "node release.js"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@playpilot/retargeting-tracking": "^
|
|
19
|
+
"@playpilot/retargeting-tracking": "^1.0.0",
|
|
20
20
|
"@sveltejs/adapter-auto": "^7.0.1",
|
|
21
21
|
"@sveltejs/kit": "^2.56.1",
|
|
22
22
|
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
package/src/lib/modal.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { ParticipantData } from './types/participant'
|
|
|
6
6
|
import { mobileBreakpoint } from './constants'
|
|
7
7
|
import TitleModal from '../routes/components/Modals/TitleModal.svelte'
|
|
8
8
|
import ParticipantModal from '../routes/components/Modals/ParticipantModal.svelte'
|
|
9
|
-
import ExploreModal from '../routes/components/Modals/ExploreModal.svelte'
|
|
10
9
|
import { getPlayPilotWrapperElement, keyDataAttribute, keySelector } from './injection'
|
|
11
10
|
import { playFallbackViewTransition } from './viewTransition'
|
|
12
11
|
import { destroyLinkPopover } from './popover'
|
|
@@ -16,7 +15,7 @@ import TitlesRailModal from '../routes/components/Modals/TitlesRailModal.svelte'
|
|
|
16
15
|
type Modal = {
|
|
17
16
|
injection?: LinkInjection | null
|
|
18
17
|
component?: object
|
|
19
|
-
type: 'title' | 'participant' | '
|
|
18
|
+
type: 'title' | 'participant' | 'titles-rail'
|
|
20
19
|
data: TitleData | TitleData[] | ParticipantData | null
|
|
21
20
|
scrollPosition?: number
|
|
22
21
|
}
|
|
@@ -52,7 +51,6 @@ function getModalComponentByType(
|
|
|
52
51
|
{ type = 'title', target, data, props = {} }:
|
|
53
52
|
{ type: Modal['type'], target: Element, data: Modal['data'], props?: Record<string, any> }): ReturnType<typeof mount> {
|
|
54
53
|
if (type === 'participant') return mount(ParticipantModal, { target, props: { participant: data as ParticipantData, ...props } })
|
|
55
|
-
if (type === 'explore') return mount(ExploreModal, { target, props: { ...props } })
|
|
56
54
|
if (type === 'titles-rail') return mount(TitlesRailModal, { target, props: { titles: data as TitleData[], ...props } })
|
|
57
55
|
return mount(TitleModal, { target, props: { title: data as TitleData, ...props } })
|
|
58
56
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import Rail from './Rail.svelte'
|
|
6
6
|
import type { TitleData } from '$lib/types/title'
|
|
7
7
|
import { openModal } from '$lib/modal'
|
|
8
|
-
import { titleUrl } from '$lib/routes'
|
|
8
|
+
import { exploreTitleUrl, titleUrl } from '$lib/routes'
|
|
9
9
|
import { generateRandomHash } from '$lib/hash'
|
|
10
10
|
import { getFirstTitleWithAvailableTrailer } from '$lib/trailer'
|
|
11
11
|
import { useExploreRouter } from '$lib/explore'
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
size?: 'small' | 'large' | 'huge' | 'flexible'
|
|
20
20
|
aside?: boolean,
|
|
21
21
|
expandable?: boolean,
|
|
22
|
+
navigateToExplore?: boolean,
|
|
22
23
|
expandedTitle?: TitleData | null,
|
|
23
24
|
expandedRailKey?: string | null,
|
|
24
25
|
onclick?: (title: TitleData) => void,
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
size = 'small',
|
|
33
34
|
aside = false,
|
|
34
35
|
expandable = false,
|
|
36
|
+
navigateToExplore = false,
|
|
35
37
|
expandedTitle = $bindable(null),
|
|
36
38
|
expandedRailKey = $bindable(null),
|
|
37
39
|
onclick = () => null,
|
|
@@ -80,14 +82,19 @@
|
|
|
80
82
|
|
|
81
83
|
if (!event) return
|
|
82
84
|
|
|
85
|
+
embed?.toggleMute(true)
|
|
86
|
+
onclick(title)
|
|
87
|
+
|
|
88
|
+
if (navigateToExplore) {
|
|
89
|
+
window.location.href = exploreTitleUrl(title)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
83
93
|
if (useExploreRouter()) {
|
|
84
94
|
openModal({ event, type: 'titles-rail', data: titles as TitleData[], returnToTitle, props: { initialIndex: index } })
|
|
85
95
|
} else {
|
|
86
96
|
openModal({ event, data: title, returnToTitle })
|
|
87
97
|
}
|
|
88
|
-
|
|
89
|
-
embed?.toggleMute(true)
|
|
90
|
-
onclick(title)
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
async function expandFirstAvailableTrailer(): Promise<void> {
|
|
@@ -167,7 +174,7 @@
|
|
|
167
174
|
onresize={() => slider?.reposition()}>
|
|
168
175
|
{#each titles as title, index}
|
|
169
176
|
{@const expanded = isExpanded(title)}
|
|
170
|
-
{@const href = titleUrl(title)}
|
|
177
|
+
{@const href = navigateToExplore ? exploreTitleUrl(title) : titleUrl(title)}
|
|
171
178
|
{@const onclick = (event: MouseEvent): void => openTitle(event, titles, index)}
|
|
172
179
|
|
|
173
180
|
<div class="title" class:expanded data-testid="title">
|
|
@@ -35,7 +35,11 @@
|
|
|
35
35
|
|
|
36
36
|
{#if titles.length}
|
|
37
37
|
<div class="widget" bind:this={element} data-testid="widget">
|
|
38
|
-
<TitlesRail
|
|
38
|
+
<TitlesRail
|
|
39
|
+
{titles}
|
|
40
|
+
{heading}
|
|
41
|
+
navigateToExplore={!!window.PlayPilotLinkInjections?.config?.open_tpi_links_in_explore}
|
|
42
|
+
onclick={(title) => track(TrackingEvent.WidgetArticleRailTitleClick, title)} />
|
|
39
43
|
</div>
|
|
40
44
|
{/if}
|
|
41
45
|
|
|
@@ -197,10 +197,6 @@
|
|
|
197
197
|
{/key}
|
|
198
198
|
</div>
|
|
199
199
|
|
|
200
|
-
<div class="item">
|
|
201
|
-
<button onclick={() => openModal({ type: 'explore' })}>Show explore modal</button>
|
|
202
|
-
</div>
|
|
203
|
-
|
|
204
200
|
<div class="item">
|
|
205
201
|
<button onclick={insertExplore}>Insert explore component</button>
|
|
206
202
|
<button onclick={insertExploreIntoNavigation}>Insert explore into navigation</button>
|
|
@@ -969,7 +969,7 @@ describe('injection.ts', () => {
|
|
|
969
969
|
injectLinksInDocument(elements, { aiInjections: [injection], manualInjections: [] })
|
|
970
970
|
|
|
971
971
|
const link = /** @type {HTMLAnchorElement} */ (document.querySelector('a'))
|
|
972
|
-
expect(link.href).toBe(window.PlayPilotLinkInjections.config.explore_navigation_path + `?route=
|
|
972
|
+
expect(link.href).toBe(window.PlayPilotLinkInjections.config.explore_navigation_path + `?route=modal&sid=${injection.title_details?.sid}`)
|
|
973
973
|
expect(link.target).not.toBeTruthy()
|
|
974
974
|
})
|
|
975
975
|
|
|
@@ -21,7 +21,7 @@ describe('$lib/routes', () => {
|
|
|
21
21
|
explore_navigation_path: 'https://some-path.com/explore',
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
expect(exploreTitleUrl(title)).toBe(`https://some-path.com/explore?route=
|
|
24
|
+
expect(exploreTitleUrl(title)).toBe(`https://some-path.com/explore?route=modal&sid=${title.sid}`)
|
|
25
25
|
})
|
|
26
26
|
})
|
|
27
27
|
})
|
|
@@ -213,4 +213,14 @@ describe('TitlesRail.svelte', () => {
|
|
|
213
213
|
|
|
214
214
|
expect(container.querySelector('.titles .slider')).toBeTruthy()
|
|
215
215
|
})
|
|
216
|
+
|
|
217
|
+
it('Should navigate to explore page rather than open modal when navigateToExplore is true', async () => {
|
|
218
|
+
const { getAllByRole } = render(TitlesRail, { titles: [title], navigateToExplore: true })
|
|
219
|
+
|
|
220
|
+
await fireEvent.click(getAllByRole('link')[0])
|
|
221
|
+
|
|
222
|
+
expect(getAllByRole('link')[0].getAttribute('href')).toContain(`?route=modal&sid=${title.sid}`)
|
|
223
|
+
expect(window.location.href).toContain(`?route=modal&sid=${title.sid}`)
|
|
224
|
+
expect(openModal).not.toHaveBeenCalledWith()
|
|
225
|
+
})
|
|
216
226
|
})
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import Modal from './Modal.svelte'
|
|
4
|
-
import ExploreRouter from '../Explore/ExploreRouter.svelte'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
initialScrollPosition?: number
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const { initialScrollPosition = 0 }: Props = $props()
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<Modal {initialScrollPosition} closeButtonStyle="flat" wide>
|
|
14
|
-
<div class="content">
|
|
15
|
-
<ExploreRouter />
|
|
16
|
-
</div>
|
|
17
|
-
</Modal>
|
|
18
|
-
|
|
19
|
-
<style lang="scss">
|
|
20
|
-
.content {
|
|
21
|
-
padding-top: margin(2);
|
|
22
|
-
}
|
|
23
|
-
</style>
|