@playpilot/tpi 8.28.1 → 8.29.0-beta.10
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/dist/editorial.mount.js +11 -11
- package/dist/link-injections.js +2 -2
- package/dist/mount.js +9 -9
- package/package.json +1 -1
- package/src/lib/api/participants.ts +9 -0
- package/src/lib/injection.ts +7 -7
- package/src/lib/modal.ts +3 -1
- package/src/lib/routes.ts +7 -2
- package/src/lib/types/participant.d.ts +8 -0
- package/src/routes/components/Explore/Routes/ExploreModal.svelte +18 -10
- package/src/routes/components/Icons/IconAttribution.svelte +3 -0
- package/src/routes/components/InjectionPopover.svelte +1 -1
- package/src/routes/components/Modals/ParticipantModal.svelte +3 -3
- package/src/routes/components/{Participant.svelte → Participants/Participant.svelte} +28 -9
- package/src/routes/components/Participants/ParticipantImage.svelte +130 -0
- package/src/routes/components/Rails/ParticipantsRail.svelte +21 -21
- package/src/routes/components/Rails/TitlesRail.svelte +2 -2
- package/src/tests/lib/routes.test.js +10 -5
- package/src/tests/routes/components/{Participant.test.js → Participants/Participant.test.js} +20 -1
- package/src/tests/routes/components/Rails/ParticipantsRail.test.js +13 -0
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { participants } from '$lib/fakeData'
|
|
1
2
|
import { getLanguage } from '$lib/language'
|
|
2
3
|
import { getApiToken } from '$lib/token'
|
|
3
4
|
import type { ParticipantData } from '$lib/types/participant'
|
|
@@ -25,3 +26,11 @@ export async function fetchParticipantsForTitle(title: TitleData): Promise<Parti
|
|
|
25
26
|
|
|
26
27
|
return response.results
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
export async function fetchParticipantBySid(sid: string): Promise<ParticipantData> {
|
|
31
|
+
const participant = await api<ParticipantData>(`/participants/${sid}?api-token=${getApiToken()}`)
|
|
32
|
+
|
|
33
|
+
if (!participant) throw new Error('No participant was returned for sid: ' + sid)
|
|
34
|
+
|
|
35
|
+
return participant
|
|
36
|
+
}
|
package/src/lib/injection.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { destroyAllModals, openModalForInjectedLink } from './modal'
|
|
|
5
5
|
import { clearCurrentlyHoveredInjection, destroyLinkPopover, destroyLinkPopoverOnMouseleave, isPopoverActive, openPopoverForInjectedLink } from './popover'
|
|
6
6
|
import { clearAfterArticlePlaylinks, insertAfterArticlePlaylinks } from './afterArticle'
|
|
7
7
|
import { clearInTextDisclaimer, insertInTextDisclaimer } from './disclaimer'
|
|
8
|
-
import {
|
|
8
|
+
import { exploreModalUrl, participantUrl, titleUrl } from './routes'
|
|
9
9
|
import { clearInTextWidgets, insertInTextWidgets } from './inTextWidgets'
|
|
10
|
-
import {
|
|
10
|
+
import { encodeHtmlEntities } from './html'
|
|
11
11
|
|
|
12
12
|
export const keyDataAttribute = 'data-playpilot-injection-key'
|
|
13
13
|
export const keySelector = `[${keyDataAttribute}]`
|
|
@@ -32,9 +32,7 @@ export function injectLinksInDocument(elements: HTMLElement[], injections: LinkI
|
|
|
32
32
|
|
|
33
33
|
const failedMessages: Record<string, string> = {}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
// This index is used in Option 3 below.
|
|
37
|
-
let injectionIndex = -1
|
|
35
|
+
let injectionIndex = -1 // This index is used in Option 3 below.
|
|
38
36
|
for (const injection of sortInjections(foundInjections)) {
|
|
39
37
|
injectionIndex++
|
|
40
38
|
|
|
@@ -218,15 +216,17 @@ function createLinkInjectionElement(injection: LinkInjection): { injectionElemen
|
|
|
218
216
|
|
|
219
217
|
const openInExplore = !!window.PlayPilotLinkInjections?.config?.open_tpi_links_in_explore
|
|
220
218
|
|
|
221
|
-
const
|
|
219
|
+
const sid = injection.title_details?.sid || injection.participant_details?.sid
|
|
220
|
+
const href = openInExplore ? exploreModalUrl(sid!) : (injection.type === 'title' ? titleUrl(injection.title_details!) : participantUrl(injection.participant_details!))
|
|
222
221
|
|
|
223
222
|
const linkElement = document.createElement('a')
|
|
224
|
-
linkElement.dataset.playpilotPosterUrl = injection.title_details?.standing_poster
|
|
225
223
|
linkElement.innerText = injection.title
|
|
226
224
|
linkElement.href = href
|
|
227
225
|
linkElement.target = openInExplore ? '' : '_blank'
|
|
228
226
|
linkElement.rel = 'noopener nofollow noreferrer'
|
|
229
227
|
|
|
228
|
+
if (injection.type === 'title') linkElement.dataset.playpilotPosterUrl = injection.title_details?.standing_poster
|
|
229
|
+
|
|
230
230
|
injectionElement.insertAdjacentElement('beforeend', linkElement)
|
|
231
231
|
|
|
232
232
|
return { injectionElement, linkElement }
|
package/src/lib/modal.ts
CHANGED
|
@@ -13,10 +13,12 @@ import { prefersReducedMotion } from 'svelte/motion'
|
|
|
13
13
|
import TitlesRailModal from '../routes/components/Modals/TitlesRailModal.svelte'
|
|
14
14
|
import TitlesReelModal from '../routes/components/Modals/TitlesReelModal.svelte'
|
|
15
15
|
|
|
16
|
+
export type ModalType = 'title' | 'participant' | 'titles-rail' | 'titles-reel'
|
|
17
|
+
|
|
16
18
|
type Modal = {
|
|
17
19
|
injection?: LinkInjection | null
|
|
18
20
|
component?: object
|
|
19
|
-
type:
|
|
21
|
+
type: ModalType
|
|
20
22
|
data: TitleData | TitleData[] | ParticipantData | null
|
|
21
23
|
scrollPosition?: number
|
|
22
24
|
}
|
package/src/lib/routes.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { playPilotBaseUrl } from './constants'
|
|
2
|
+
import type { ParticipantData } from './types/participant'
|
|
2
3
|
import type { TitleData } from './types/title'
|
|
3
4
|
|
|
4
5
|
export function titleUrl(title: TitleData): string {
|
|
5
6
|
return `${playPilotBaseUrl}/${title.type}/${title.slug}/`
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export function
|
|
9
|
-
return
|
|
9
|
+
export function participantUrl(participant: ParticipantData): string {
|
|
10
|
+
return `${playPilotBaseUrl}/name/${participant.sid}/`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function exploreModalUrl(sid: string): string {
|
|
14
|
+
return window.PlayPilotLinkInjections?.config?.explore_navigation_path + `?route=modal&sid=${sid}`
|
|
10
15
|
}
|
|
@@ -6,6 +6,14 @@ export type ParticipantData = {
|
|
|
6
6
|
jobs: Job[]
|
|
7
7
|
image: string | null
|
|
8
8
|
image_uuid: string | null
|
|
9
|
+
image_metadata?: {
|
|
10
|
+
license_name: string
|
|
11
|
+
license_url: string
|
|
12
|
+
source_text: string
|
|
13
|
+
source_url: string
|
|
14
|
+
author_text: string
|
|
15
|
+
author_url: string
|
|
16
|
+
}
|
|
9
17
|
gender: string
|
|
10
18
|
character?: string | null
|
|
11
19
|
bio?: string | null
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { fetchParticipantBySid } from '$lib/api/participants'
|
|
2
3
|
import { fetchSimilarTitles, fetchTitleBySid } from '$lib/api/titles'
|
|
3
4
|
import { mobileBreakpoint } from '$lib/constants'
|
|
4
5
|
import { SplitTest } from '$lib/enums/SplitTest'
|
|
5
6
|
import { t } from '$lib/localization'
|
|
6
|
-
import { openModal } from '$lib/modal'
|
|
7
|
+
import { openModal, type ModalType } from '$lib/modal'
|
|
7
8
|
import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
|
|
8
9
|
import type { TitleData } from '$lib/types/title'
|
|
9
10
|
import Modal from '../../Modals/Modal.svelte'
|
|
@@ -20,20 +21,27 @@
|
|
|
20
21
|
|
|
21
22
|
if (!sid) return
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const type = isMobile && isInReelSplitTest ? 'titles-reel' : 'titles-rail'
|
|
24
|
+
let type: ModalType = sid.startsWith('pr') ? 'participant' : 'title' // Sids with with `pr` for participants, `ti` for titles
|
|
25
|
+
let data: any = null
|
|
26
26
|
|
|
27
|
-
if (
|
|
27
|
+
if (type === 'title') {
|
|
28
|
+
const isMobile = window.innerWidth < mobileBreakpoint
|
|
29
|
+
const isInReelSplitTest = isMobile && getSplitTestVariantName(SplitTest.Reels) === 'Reel'
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (isMobile) trackSplitTestView(SplitTest.Reels)
|
|
32
|
+
|
|
33
|
+
type = isMobile && isInReelSplitTest ? 'titles-reel' : 'titles-rail'
|
|
34
|
+
|
|
35
|
+
const [title, railTitles] = (await Promise.allSettled([fetchTitleBySid(sid), fetchSimilarTitles({ sid } as unknown as TitleData)])).map((promise) => promise.status === 'fulfilled' ? promise.value : null)
|
|
36
|
+
|
|
37
|
+
data = [title as TitleData, ...(railTitles as TitleData[])]
|
|
38
|
+
} else if (type === 'participant') {
|
|
39
|
+
data = await fetchParticipantBySid(sid)
|
|
40
|
+
}
|
|
33
41
|
|
|
34
42
|
openModal({
|
|
35
43
|
type,
|
|
36
|
-
data
|
|
44
|
+
data,
|
|
37
45
|
props: {
|
|
38
46
|
onclose: () => navigate('home'),
|
|
39
47
|
pushState: false,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg height="24px" viewBox="0 -960 960 960" width="24px">
|
|
2
|
+
<path fill="currentColor" d="M430-200h100v-180h60v-184q0-27-28.5-41.5T480-620q-53 0-81.5 14.5T370-564v184h60v180Zm-105 88.5q-73-31.5-127.5-86t-86-127.5Q80-398 80-480.5t31.5-155q31.5-72.5 86-127t127.5-86Q398-880 480.5-880t155 31.5q72.5 31.5 127 86t86 127Q880-563 880-480.5T848.5-325q-31.5 73-86 127.5t-127 86Q563-80 480.5-80T325-111.5Zm381.5-142Q800-347 800-480t-93.5-226.5Q613-800 480-800t-226.5 93.5Q160-613 160-480t93.5 226.5Q347-160 480-160t226.5-93.5ZM523-657q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Zm-43 177Z"/>
|
|
3
|
+
</svg>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { trackViaPixel } from '@playpilot/retargeting-tracking'
|
|
11
11
|
import Popover from './Popover.svelte'
|
|
12
12
|
import Title from './Title.svelte'
|
|
13
|
-
import Participant from './Participant.svelte'
|
|
13
|
+
import Participant from './Participants/Participant.svelte'
|
|
14
14
|
import TopScroll from './Ads/TopScroll.svelte'
|
|
15
15
|
import Display from './Ads/Display.svelte'
|
|
16
16
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import Modal from './Modal.svelte'
|
|
4
|
-
import Participant from '../Participant.svelte'
|
|
4
|
+
import Participant from '../Participants/Participant.svelte'
|
|
5
5
|
import type { ParticipantData } from '$lib/types/participant'
|
|
6
6
|
import { TrackingEvent } from '$lib/enums/TrackingEvent'
|
|
7
7
|
import { track } from '$lib/tracking'
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
initialScrollPosition?: number
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const { participant, initialScrollPosition = 0 }: Props = $props()
|
|
15
|
+
const { participant, initialScrollPosition = 0, ...restProps }: Props = $props()
|
|
16
16
|
|
|
17
17
|
let windowWidth = $state(0)
|
|
18
18
|
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
<svelte:window bind:innerWidth={windowWidth} />
|
|
29
29
|
|
|
30
|
-
<Modal {initialScrollPosition} closeButtonStyle="flat" tall>
|
|
30
|
+
<Modal {initialScrollPosition} {...restProps} closeButtonStyle="flat" tall>
|
|
31
31
|
<Participant {participant} />
|
|
32
32
|
</Modal>
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
import { openModal } from '$lib/modal'
|
|
6
6
|
import type { ParticipantData } from '$lib/types/participant'
|
|
7
7
|
import type { TitleData } from '$lib/types/title'
|
|
8
|
-
import ListTitle from './ListTitle.svelte'
|
|
9
8
|
import { t } from '$lib/localization'
|
|
10
9
|
import { isRetargetingAllowed } from '$lib/retargeting'
|
|
11
10
|
import { trackViaPixel } from '@playpilot/retargeting-tracking'
|
|
12
11
|
import { MetaEvent } from '$lib/enums/TrackingEvent'
|
|
12
|
+
import ParticipantImage from './ParticipantImage.svelte'
|
|
13
|
+
import ListTitle from '../ListTitle.svelte'
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
15
16
|
participant: ParticipantData
|
|
@@ -54,13 +55,17 @@
|
|
|
54
55
|
</script>
|
|
55
56
|
|
|
56
57
|
<div class="header" class:small>
|
|
57
|
-
<
|
|
58
|
+
<ParticipantImage {participant} />
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
<div>
|
|
61
|
+
<div class="heading" use:heading={2} id="heading">{name}</div>
|
|
62
|
+
|
|
63
|
+
{#if birth_date}
|
|
64
|
+
<p class="dates">
|
|
65
|
+
{t('Born On')} <strong>{formatDate(birth_date)}</strong>{#if death_date}, {t('Died On')} <strong>{formatDate(death_date)}</strong>{/if}
|
|
66
|
+
</p>
|
|
67
|
+
{/if}
|
|
68
|
+
</div>
|
|
64
69
|
</div>
|
|
65
70
|
|
|
66
71
|
<div class="content">
|
|
@@ -85,14 +90,24 @@
|
|
|
85
90
|
|
|
86
91
|
<style lang="scss">
|
|
87
92
|
.header {
|
|
88
|
-
|
|
93
|
+
--participant-image-size: #{margin(6)};
|
|
94
|
+
display: grid;
|
|
95
|
+
grid-template-columns: calc(var(--participant-image-size)) auto;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: margin(1);
|
|
98
|
+
padding: margin(3) margin(1) margin(2);
|
|
89
99
|
font-family: theme(detail-font-family, font-family);
|
|
90
100
|
font-weight: theme(detail-font-weight, normal);
|
|
91
101
|
font-size: theme(detail-font-size, font-size-base);
|
|
92
102
|
line-height: theme(participant-description-line-height, normal);
|
|
93
103
|
color: theme(detail-text-color, text-color);
|
|
94
104
|
|
|
105
|
+
@include desktop {
|
|
106
|
+
--participant-image-size: #{margin(8)};
|
|
107
|
+
}
|
|
108
|
+
|
|
95
109
|
&.small {
|
|
110
|
+
--participant-image-size: #{margin(6)};
|
|
96
111
|
padding: margin(1);
|
|
97
112
|
}
|
|
98
113
|
}
|
|
@@ -101,7 +116,7 @@
|
|
|
101
116
|
margin: 0;
|
|
102
117
|
font-family: theme(detail-title-font-family, font-family);
|
|
103
118
|
font-weight: theme(detail-title-font-weight, lighter);
|
|
104
|
-
font-size:
|
|
119
|
+
font-size: clamp(1.25em, 5vw, 1.5em);
|
|
105
120
|
line-height: normal;
|
|
106
121
|
font-style: theme(detail-title-font-style, normal);
|
|
107
122
|
|
|
@@ -109,6 +124,10 @@
|
|
|
109
124
|
margin: 0 0 margin(0.5);
|
|
110
125
|
font-size: theme(detail-title-small-font-size, margin(1.25));
|
|
111
126
|
}
|
|
127
|
+
|
|
128
|
+
.small & {
|
|
129
|
+
font-size: 1em;
|
|
130
|
+
}
|
|
112
131
|
}
|
|
113
132
|
|
|
114
133
|
.dates {
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { t } from '$lib/localization'
|
|
3
|
+
import type { ParticipantData } from '$lib/types/participant'
|
|
4
|
+
import IconAttribution from '../Icons/IconAttribution.svelte'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
participant?: ParticipantData | null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { participant = null }: Props = $props()
|
|
11
|
+
|
|
12
|
+
const { image_metadata } = $derived(participant || { image_metadata: null })
|
|
13
|
+
|
|
14
|
+
let showAttribution = $state(false)
|
|
15
|
+
|
|
16
|
+
function toggleAttribution(event: MouseEvent): void {
|
|
17
|
+
event.stopImmediatePropagation()
|
|
18
|
+
|
|
19
|
+
if ((event.target as HTMLElement).nodeName === 'A') return
|
|
20
|
+
|
|
21
|
+
event.preventDefault()
|
|
22
|
+
|
|
23
|
+
showAttribution = !showAttribution
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div class="image">
|
|
28
|
+
{#if participant?.image}
|
|
29
|
+
<img loading="lazy" src={participant.image} alt="" />
|
|
30
|
+
|
|
31
|
+
{#if image_metadata}
|
|
32
|
+
<button class="attribution-icon" onclick={toggleAttribution}>
|
|
33
|
+
<IconAttribution />
|
|
34
|
+
</button>
|
|
35
|
+
{/if}
|
|
36
|
+
{/if}
|
|
37
|
+
|
|
38
|
+
{#if participant && image_metadata && showAttribution}
|
|
39
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
40
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
41
|
+
<div class="attribution-overlay" onclick={toggleAttribution}>
|
|
42
|
+
<a href={image_metadata.source_url} target="_blank" rel="external nofollow noreferrer">{image_metadata.source_text}</a>
|
|
43
|
+
{t('By')}
|
|
44
|
+
<a href={image_metadata.author_url} target="_blank" rel="external nofollow noreferrer">{image_metadata.author_text}</a>
|
|
45
|
+
/
|
|
46
|
+
<a href={image_metadata.license_url} target="_blank" rel="external nofollow noreferrer">{image_metadata.license_name}</a>
|
|
47
|
+
</div>
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<style lang="scss">
|
|
52
|
+
$item-width: #{var(--participant-image-size, margin(6))};
|
|
53
|
+
|
|
54
|
+
.image {
|
|
55
|
+
position: relative;
|
|
56
|
+
display: block;
|
|
57
|
+
width: $item-width;
|
|
58
|
+
height: $item-width;
|
|
59
|
+
border-radius: theme(border-radius);
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
background: theme(cast-background, lighter);
|
|
62
|
+
|
|
63
|
+
&::before,
|
|
64
|
+
&::after {
|
|
65
|
+
content: '';
|
|
66
|
+
display: block;
|
|
67
|
+
position: absolute;
|
|
68
|
+
width: 50%;
|
|
69
|
+
height: 50%;
|
|
70
|
+
top: 50%;
|
|
71
|
+
left: 50%;
|
|
72
|
+
border-radius: 50%;
|
|
73
|
+
transform: translateX(-50%) translateY(-50%);
|
|
74
|
+
background: currentColor;
|
|
75
|
+
opacity: 0.1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&::after {
|
|
79
|
+
top: 100%;
|
|
80
|
+
width: 75%;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
img {
|
|
84
|
+
z-index: 1;
|
|
85
|
+
position: relative;
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: auto;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.attribution-icon {
|
|
92
|
+
z-index: 2;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
position: absolute;
|
|
95
|
+
right: 0;
|
|
96
|
+
bottom: 0;
|
|
97
|
+
padding: margin(0.25);
|
|
98
|
+
margin: 0;
|
|
99
|
+
border: 0;
|
|
100
|
+
background: transparent;
|
|
101
|
+
color: rgba(255, 255, 255, 0.75);
|
|
102
|
+
|
|
103
|
+
&:hover {
|
|
104
|
+
color: white;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:global(svg) {
|
|
108
|
+
display: block;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.attribution-overlay {
|
|
113
|
+
z-index: 1;
|
|
114
|
+
position: absolute;
|
|
115
|
+
top: 0;
|
|
116
|
+
right: 0;
|
|
117
|
+
bottom: 0;
|
|
118
|
+
left: 0;
|
|
119
|
+
padding: margin(0.25);
|
|
120
|
+
background: rgba(0, 0, 0, 0.85);
|
|
121
|
+
font-size: 11px;
|
|
122
|
+
line-height: 1.25;
|
|
123
|
+
white-space: wrap;
|
|
124
|
+
text-align: left;
|
|
125
|
+
|
|
126
|
+
a {
|
|
127
|
+
color: currentColor;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
</style>
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { track } from '$lib/tracking'
|
|
9
9
|
import type { ParticipantData } from '$lib/types/participant'
|
|
10
10
|
import type { TitleData } from '$lib/types/title'
|
|
11
|
+
import ParticipantImage from '../Participants/ParticipantImage.svelte'
|
|
11
12
|
import Rail from './Rail.svelte'
|
|
12
13
|
|
|
13
14
|
interface Props {
|
|
@@ -35,8 +36,6 @@
|
|
|
35
36
|
participantsByOccurrence[participant.sid] = { participant, count }
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
// Sort all participants by their occurrences. If a participant did not occur their positioned will be retained
|
|
39
|
-
// relative to where it was before
|
|
40
39
|
const participantsSortedByCount = Object.values(participantsByOccurrence).sort((a, b) => b.count - a.count)
|
|
41
40
|
|
|
42
41
|
return participantsSortedByCount.map(({ participant }) => participant)
|
|
@@ -51,7 +50,10 @@
|
|
|
51
50
|
{#await fetchParticipantsForTitle(title)}
|
|
52
51
|
<Rail {heading}>
|
|
53
52
|
{#each { length: 5 }}
|
|
54
|
-
<div class="participant"
|
|
53
|
+
<div class="participant">
|
|
54
|
+
<ParticipantImage />
|
|
55
|
+
<div class="name"> </div>
|
|
56
|
+
</div>
|
|
55
57
|
{/each}
|
|
56
58
|
</Rail>
|
|
57
59
|
{:then participants}
|
|
@@ -59,11 +61,9 @@
|
|
|
59
61
|
<Rail {heading}>
|
|
60
62
|
{#each orderParticipantsByPageTextOccurrence(participants).slice(0, 15) as participant}
|
|
61
63
|
<button class="participant" data-testid="participant" onclick={event => onclick(event, participant)}>
|
|
62
|
-
<
|
|
64
|
+
<ParticipantImage {participant} />
|
|
63
65
|
|
|
64
|
-
{
|
|
65
|
-
<div class="character truncate">{participant.character}</div>
|
|
66
|
-
{/if}
|
|
66
|
+
<div class="name">{participant.name}</div>
|
|
67
67
|
</button>
|
|
68
68
|
{/each}
|
|
69
69
|
</Rail>
|
|
@@ -71,22 +71,25 @@
|
|
|
71
71
|
{/await}
|
|
72
72
|
|
|
73
73
|
<style lang="scss">
|
|
74
|
+
$item-width: #{theme(rail-size-default, margin(6))};
|
|
75
|
+
|
|
74
76
|
.participant {
|
|
77
|
+
--participant-image-size: #{$item-width};
|
|
75
78
|
display: flex;
|
|
76
79
|
flex-direction: column;
|
|
77
|
-
flex: 0 0
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
padding:
|
|
81
|
-
border: theme(cast-border, 0);
|
|
80
|
+
flex: 0 0 $item-width;
|
|
81
|
+
gap: margin(0.5);
|
|
82
|
+
width: $item-width;
|
|
83
|
+
padding: 0;
|
|
82
84
|
border-radius: theme(cast-border-radius, border-radius);
|
|
83
|
-
|
|
85
|
+
border: 0;
|
|
86
|
+
background: transparent;
|
|
84
87
|
cursor: pointer;
|
|
85
|
-
font-family: inherit;
|
|
86
|
-
text-align: left;
|
|
87
88
|
color: inherit;
|
|
89
|
+
font-family: inherit;
|
|
88
90
|
font-size: theme(cast-font-size, font-size-small);
|
|
89
91
|
line-height: normal;
|
|
92
|
+
text-align: center;
|
|
90
93
|
white-space: nowrap;
|
|
91
94
|
|
|
92
95
|
&:is(button):hover,
|
|
@@ -96,13 +99,10 @@
|
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
.
|
|
100
|
-
|
|
101
|
-
font-style: italic;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.truncate {
|
|
102
|
+
.name {
|
|
103
|
+
min-height: 1lh;
|
|
105
104
|
overflow: hidden;
|
|
105
|
+
color: theme(participant-text-color, text-color-alt) !important;
|
|
106
106
|
text-overflow: ellipsis;
|
|
107
107
|
white-space: nowrap;
|
|
108
108
|
}
|
|
@@ -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 {
|
|
8
|
+
import { exploreModalUrl } from '$lib/routes'
|
|
9
9
|
import { generateRandomHash } from '$lib/hash'
|
|
10
10
|
import { getFirstTitleWithAvailableTrailer } from '$lib/trailer'
|
|
11
11
|
import { useExploreRouter } from '$lib/explore'
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
onclick(title)
|
|
89
89
|
|
|
90
90
|
if (navigateToExplore) {
|
|
91
|
-
window.location.href =
|
|
91
|
+
window.location.href = exploreModalUrl(title.sid)
|
|
92
92
|
return
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import {
|
|
2
|
+
import { exploreModalUrl, participantUrl, titleUrl } from '$lib/routes'
|
|
3
3
|
import { playPilotBaseUrl } from '$lib/constants'
|
|
4
|
-
import { title } from '$lib/fakeData'
|
|
4
|
+
import { participants, title } from '$lib/fakeData'
|
|
5
5
|
|
|
6
6
|
describe('$lib/routes', () => {
|
|
7
7
|
describe('titleUrl', () => {
|
|
@@ -14,14 +14,19 @@ describe('$lib/routes', () => {
|
|
|
14
14
|
})
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
describe('
|
|
17
|
+
describe('participantUrl', () => {
|
|
18
|
+
it('Should return url for given title', () => {
|
|
19
|
+
expect(participantUrl(participants[0])).toBe(`${playPilotBaseUrl}/name/${participants[0].sid}/`)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('exploreModalUrl', () => {
|
|
18
24
|
it('Should return url for given title', () => {
|
|
19
25
|
window.PlayPilotLinkInjections.config = {
|
|
20
|
-
open_tpi_links_in_explore: true,
|
|
21
26
|
explore_navigation_path: 'https://some-path.com/explore',
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
expect(
|
|
29
|
+
expect(exploreModalUrl(title.sid)).toBe(`https://some-path.com/explore?route=modal&sid=${title.sid}`)
|
|
25
30
|
})
|
|
26
31
|
})
|
|
27
32
|
})
|
package/src/tests/routes/components/{Participant.test.js → Participants/Participant.test.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fireEvent, render, waitFor } from '@testing-library/svelte'
|
|
2
2
|
import { describe, expect, it, vi, beforeEach } from 'vitest'
|
|
3
3
|
|
|
4
|
-
import Participant from '
|
|
4
|
+
import Participant from '../../../../routes/components/Participants/Participant.svelte'
|
|
5
5
|
import { participants, title } from '$lib/fakeData'
|
|
6
6
|
import { fetchTitlesForParticipant } from '$lib/api/participants'
|
|
7
7
|
|
|
@@ -80,4 +80,23 @@ describe('Participant.svelte', () => {
|
|
|
80
80
|
expect(queryByText('Credits')).not.toBeTruthy()
|
|
81
81
|
expect(container.querySelector('.small')).toBeTruthy()
|
|
82
82
|
})
|
|
83
|
+
|
|
84
|
+
it('Should render image if given', async () => {
|
|
85
|
+
const participantWithImage = { ...participants[0], image: 'some-image.jpg' }
|
|
86
|
+
|
|
87
|
+
const { getByRole } = render(Participant, { participant: participantWithImage })
|
|
88
|
+
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(getByRole('presentation')).toBeTruthy()
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('Should not render image if not given', async () => {
|
|
95
|
+
|
|
96
|
+
const { queryByRole } = render(Participant, { participant: participants[0] })
|
|
97
|
+
|
|
98
|
+
await waitFor(() => {
|
|
99
|
+
expect(queryByRole('presentation')).not.toBeTruthy()
|
|
100
|
+
})
|
|
101
|
+
})
|
|
83
102
|
})
|
|
@@ -36,6 +36,19 @@ describe('ParticipantsRail.svelte', () => {
|
|
|
36
36
|
})
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
+
it('Should render image only for participants with image', async () => {
|
|
40
|
+
const participantsWithImage = [...participants]
|
|
41
|
+
participantsWithImage[0].image = 'some-image.jpg'
|
|
42
|
+
|
|
43
|
+
vi.mocked(fetchParticipantsForTitle).mockResolvedValueOnce(participantsWithImage)
|
|
44
|
+
|
|
45
|
+
const { getAllByRole } = render(ParticipantsRail, { title })
|
|
46
|
+
|
|
47
|
+
await waitFor(() => {
|
|
48
|
+
expect(getAllByRole('presentation')).toHaveLength(1)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
39
52
|
it('Should order participants by their number of occurrences on the page', async () => {
|
|
40
53
|
document.body.innerHTML = `<main>${participants[1].name}. ${participants[2].name}, ${participants[2].name}</main>`
|
|
41
54
|
vi.mocked(fetchParticipantsForTitle).mockResolvedValueOnce(participants)
|