@times-components/ts-components 1.145.1-82bc6796129e892c1eb22c6257c5e3809c159767.3 → 1.145.1-cfea81c4084e6f91221ea00fec9fc730d5b933cb.4
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/components/carousel-component/CarouselComponent.stories.js +146 -0
- package/dist/components/carousel-component/CarouselItem.d.ts +3 -0
- package/dist/components/carousel-component/CarouselItem.js +11 -0
- package/dist/components/carousel-component/DefaultNavigationArrow.d.ts +8 -0
- package/dist/components/carousel-component/DefaultNavigationArrow.js +6 -0
- package/dist/components/carousel-component/DefaultPageDot.d.ts +8 -0
- package/dist/components/carousel-component/DefaultPageDot.js +4 -0
- package/dist/components/carousel-component/__tests__/CarouselComponent.test.js +163 -0
- package/dist/components/carousel-component/__tests__/CarouselItem.test.js +80 -0
- package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.js +62 -0
- package/dist/components/{opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.d.ts → carousel-component/__tests__/DefaultPageDot.test.d.ts} +0 -1
- package/dist/components/carousel-component/__tests__/DefaultPageDot.test.js +68 -0
- package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.d.ts +1 -0
- package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.js +314 -0
- package/dist/components/carousel-component/hooks/useCarousel.d.ts +2 -0
- package/dist/components/carousel-component/hooks/useCarousel.js +140 -0
- package/dist/components/carousel-component/index.d.ts +4 -0
- package/dist/components/carousel-component/index.js +20 -0
- package/dist/components/carousel-component/styles.d.ts +30 -0
- package/dist/components/carousel-component/styles.js +120 -0
- package/dist/components/carousel-component/types.d.ts +46 -0
- package/dist/components/carousel-component/types.js +2 -0
- package/dist/components/opta/football/opta-match-stats/shared/styles.js +1 -8
- package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.js +2 -2
- package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.js +1 -1
- package/dist/components/opta/football/opta-match-stats/summary/WidgetContainer.js +4 -13
- package/dist/components/trip-cards/SkeletonCard.d.ts +2 -0
- package/dist/components/trip-cards/SkeletonCard.js +21 -0
- package/dist/components/trip-cards/TripCard.d.ts +3 -0
- package/dist/components/trip-cards/TripCard.js +47 -0
- package/dist/components/trip-cards/TripCards.stories.d.ts +1 -0
- package/dist/components/trip-cards/TripCards.stories.js +40 -0
- package/dist/components/trip-cards/TripCardsLayout.d.ts +3 -0
- package/dist/components/trip-cards/TripCardsLayout.js +26 -0
- package/dist/components/trip-cards/__tests__/SkeletonCard.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/SkeletonCard.test.js +139 -0
- package/dist/components/trip-cards/__tests__/TripCard.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/TripCard.test.js +95 -0
- package/dist/components/trip-cards/__tests__/TripCardsLayout.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/TripCardsLayout.test.js +277 -0
- package/dist/components/trip-cards/__tests__/assets.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/assets.test.js +165 -0
- package/dist/components/trip-cards/__tests__/helpers.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/helpers.test.js +135 -0
- package/dist/components/trip-cards/__tests__/index.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/index.test.js +437 -0
- package/dist/components/trip-cards/__tests__/mockData.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/mockData.test.js +57 -0
- package/dist/components/trip-cards/__tests__/skeletonStyles.test.d.ts +1 -0
- package/dist/components/trip-cards/__tests__/skeletonStyles.test.js +194 -0
- package/dist/components/trip-cards/assets/BoatIcon.d.ts +1 -0
- package/dist/components/trip-cards/assets/BoatIcon.js +4 -0
- package/dist/components/trip-cards/assets/CalendarIcon.d.ts +1 -0
- package/dist/components/trip-cards/assets/CalendarIcon.js +4 -0
- package/dist/components/trip-cards/assets/ChevronRightIcon.d.ts +1 -0
- package/dist/components/trip-cards/assets/ChevronRightIcon.js +4 -0
- package/dist/components/trip-cards/assets/LocationIcon.d.ts +1 -0
- package/dist/components/trip-cards/assets/LocationIcon.js +4 -0
- package/dist/components/trip-cards/assets/MoonIcon.d.ts +1 -0
- package/dist/components/trip-cards/assets/MoonIcon.js +4 -0
- package/dist/components/trip-cards/assets/index.d.ts +6 -0
- package/dist/components/trip-cards/assets/index.js +7 -0
- package/dist/components/trip-cards/helpers.d.ts +4 -0
- package/dist/components/trip-cards/helpers.js +74 -0
- package/dist/components/trip-cards/index.d.ts +4 -0
- package/dist/components/trip-cards/index.js +70 -0
- package/dist/components/trip-cards/mockData.d.ts +3 -0
- package/dist/components/trip-cards/mockData.js +323 -0
- package/dist/components/trip-cards/skeletonStyles.d.ts +9 -0
- package/dist/components/trip-cards/skeletonStyles.js +37 -0
- package/dist/components/trip-cards/styles.d.ts +39 -0
- package/dist/components/trip-cards/styles.js +387 -0
- package/dist/components/trip-cards/types.d.ts +87 -0
- package/dist/components/trip-cards/types.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +3 -3
- package/rnw.js +1 -1
- package/src/components/carousel-component/CarouselComponent.stories.tsx +220 -0
- package/src/components/carousel-component/CarouselItem.tsx +20 -0
- package/src/components/carousel-component/DefaultNavigationArrow.tsx +37 -0
- package/src/components/carousel-component/DefaultPageDot.tsx +20 -0
- package/src/components/carousel-component/__tests__/CarouselComponent.test.tsx +259 -0
- package/src/components/carousel-component/__tests__/CarouselItem.test.tsx +140 -0
- package/src/components/carousel-component/__tests__/DefaultNavigationArrow.test.tsx +153 -0
- package/src/components/carousel-component/__tests__/DefaultPageDot.test.tsx +105 -0
- package/src/components/carousel-component/hooks/__tests__/useCarousel.test.ts +438 -0
- package/src/components/carousel-component/hooks/useCarousel.ts +187 -0
- package/src/components/carousel-component/index.tsx +88 -0
- package/src/components/carousel-component/styles.ts +140 -0
- package/src/components/carousel-component/types.ts +51 -0
- package/src/components/opta/football/opta-match-stats/commentary/__tests__/__snapshots__/OptaMatchStatsCommentary.test.tsx.snap +1 -1
- package/src/components/opta/football/opta-match-stats/shared/styles.ts +0 -8
- package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/__snapshots__/OptaMatchStatsGraphs.test.tsx.snap +1 -1
- package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.tsx +1 -1
- package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.tsx +1 -1
- package/src/components/opta/football/opta-match-stats/summary/WidgetContainer.tsx +3 -12
- package/src/components/opta/football/opta-match-stats/summary/__tests__/__snapshots__/OptaMatchStatsSummary.test.tsx.snap +1 -1
- package/src/components/trip-cards/SkeletonCard.tsx +54 -0
- package/src/components/trip-cards/TripCard.tsx +135 -0
- package/src/components/trip-cards/TripCards.stories.tsx +67 -0
- package/src/components/trip-cards/TripCardsLayout.tsx +75 -0
- package/src/components/trip-cards/__tests__/SkeletonCard.test.tsx +169 -0
- package/src/components/trip-cards/__tests__/TripCard.test.tsx +120 -0
- package/src/components/trip-cards/__tests__/TripCardsLayout.test.tsx +532 -0
- package/src/components/trip-cards/__tests__/assets.test.tsx +206 -0
- package/src/components/trip-cards/__tests__/helpers.test.ts +165 -0
- package/src/components/trip-cards/__tests__/index.test.tsx +499 -0
- package/src/components/trip-cards/__tests__/mockData.test.ts +67 -0
- package/src/components/trip-cards/__tests__/skeletonStyles.test.tsx +256 -0
- package/src/components/trip-cards/assets/BoatIcon.tsx +17 -0
- package/src/components/trip-cards/assets/CalendarIcon.tsx +17 -0
- package/src/components/trip-cards/assets/ChevronRightIcon.tsx +20 -0
- package/src/components/trip-cards/assets/LocationIcon.tsx +17 -0
- package/src/components/trip-cards/assets/MoonIcon.tsx +17 -0
- package/src/components/trip-cards/assets/index.ts +7 -0
- package/src/components/trip-cards/helpers.ts +99 -0
- package/src/components/trip-cards/index.tsx +104 -0
- package/src/components/trip-cards/mockData.ts +351 -0
- package/src/components/trip-cards/skeletonStyles.ts +46 -0
- package/src/components/trip-cards/styles.ts +426 -0
- package/src/components/trip-cards/types.ts +91 -0
- package/src/index.ts +2 -3
- package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.d.ts +0 -10
- package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.js +0 -69
- package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.d.ts +0 -12
- package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.js +0 -90
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.d.ts +0 -12
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.js +0 -10
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.js +0 -24
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.js +0 -57
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.js +0 -48
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.d.ts +0 -1
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.js +0 -19
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.d.ts +0 -12
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.js +0 -67
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.d.ts +0 -6
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +0 -730
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.js +0 -33
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.js +0 -36
- package/src/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.tsx +0 -108
- package/src/components/opta/football/opta-match-stats/matchday-live/MobileWidget.tsx +0 -158
- package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.tsx +0 -38
- package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.tsx +0 -23
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.tsx +0 -69
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.tsx +0 -61
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +0 -61
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.tsx +0 -19
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.tsx +0 -81
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +0 -761
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.tsx +0 -67
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.tsx +0 -64
- /package/dist/components/{opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.d.ts → carousel-component/CarouselComponent.stories.d.ts} +0 -0
- /package/dist/components/{opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.d.ts → carousel-component/__tests__/CarouselComponent.test.d.ts} +0 -0
- /package/dist/components/{opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.d.ts → carousel-component/__tests__/CarouselItem.test.d.ts} +0 -0
- /package/dist/components/{opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.d.ts → carousel-component/__tests__/DefaultNavigationArrow.test.d.ts} +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React, { FC, useState } from 'react';
|
|
2
|
+
import { Placeholder } from '@times-components/image';
|
|
3
|
+
import { TripCardProps } from './types';
|
|
4
|
+
import {
|
|
5
|
+
CardContainer,
|
|
6
|
+
ImageContainer,
|
|
7
|
+
CardImage,
|
|
8
|
+
OfferLabel,
|
|
9
|
+
GiftBanner,
|
|
10
|
+
CardContent,
|
|
11
|
+
TopContainer,
|
|
12
|
+
BottomContainer,
|
|
13
|
+
Headline,
|
|
14
|
+
DataPointsList,
|
|
15
|
+
DataPoint,
|
|
16
|
+
DataIcon,
|
|
17
|
+
PriceSection,
|
|
18
|
+
PriceContainer,
|
|
19
|
+
OfferContainer,
|
|
20
|
+
PriceLabel,
|
|
21
|
+
OriginalPrice,
|
|
22
|
+
CurrentPrice,
|
|
23
|
+
LogoContainer,
|
|
24
|
+
CTAButton
|
|
25
|
+
} from './styles';
|
|
26
|
+
import { MoonIcon, LocationIcon, BoatIcon, CalendarIcon } from './assets';
|
|
27
|
+
|
|
28
|
+
export const TripCard: FC<TripCardProps> = ({ card }) => {
|
|
29
|
+
const [imageLoaded, setImageLoaded] = useState(false);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<CardContainer>
|
|
33
|
+
<a
|
|
34
|
+
href={card.cta_url}
|
|
35
|
+
target="_blank"
|
|
36
|
+
rel="noopener noreferrer"
|
|
37
|
+
style={{ textDecoration: 'none', color: 'inherit' }}
|
|
38
|
+
>
|
|
39
|
+
<ImageContainer>
|
|
40
|
+
{!imageLoaded && <Placeholder />}
|
|
41
|
+
<CardImage
|
|
42
|
+
src={card.image}
|
|
43
|
+
alt={card.headline}
|
|
44
|
+
onLoad={() => setImageLoaded(true)}
|
|
45
|
+
style={{ display: imageLoaded ? 'block' : 'none' }}
|
|
46
|
+
/>
|
|
47
|
+
{card.offer_label && <OfferLabel>{card.offer_label}</OfferLabel>}
|
|
48
|
+
{card.gift_banner && <GiftBanner>{card.gift_banner}</GiftBanner>}
|
|
49
|
+
</ImageContainer>
|
|
50
|
+
</a>
|
|
51
|
+
|
|
52
|
+
<CardContent>
|
|
53
|
+
<TopContainer>
|
|
54
|
+
<a
|
|
55
|
+
href={card.cta_url}
|
|
56
|
+
target="_blank"
|
|
57
|
+
rel="noopener noreferrer"
|
|
58
|
+
style={{ textDecoration: 'none', color: 'inherit' }}
|
|
59
|
+
>
|
|
60
|
+
<Headline>{card.headline}</Headline>
|
|
61
|
+
</a>
|
|
62
|
+
|
|
63
|
+
<DataPointsList>
|
|
64
|
+
{card.date && (
|
|
65
|
+
<DataPoint>
|
|
66
|
+
<DataIcon>
|
|
67
|
+
<CalendarIcon />
|
|
68
|
+
</DataIcon>
|
|
69
|
+
<span>{card.date}</span>
|
|
70
|
+
</DataPoint>
|
|
71
|
+
)}
|
|
72
|
+
{card.duration && (
|
|
73
|
+
<DataPoint>
|
|
74
|
+
<DataIcon>
|
|
75
|
+
<MoonIcon />
|
|
76
|
+
</DataIcon>
|
|
77
|
+
<span>{card.duration}</span>
|
|
78
|
+
</DataPoint>
|
|
79
|
+
)}
|
|
80
|
+
{card.route && (
|
|
81
|
+
<DataPoint>
|
|
82
|
+
<DataIcon>
|
|
83
|
+
<LocationIcon />
|
|
84
|
+
</DataIcon>
|
|
85
|
+
<span>{card.route}</span>
|
|
86
|
+
</DataPoint>
|
|
87
|
+
)}
|
|
88
|
+
{card.ship && (
|
|
89
|
+
<DataPoint>
|
|
90
|
+
<DataIcon>
|
|
91
|
+
<BoatIcon />
|
|
92
|
+
</DataIcon>
|
|
93
|
+
<span>{card.ship}</span>
|
|
94
|
+
</DataPoint>
|
|
95
|
+
)}
|
|
96
|
+
</DataPointsList>
|
|
97
|
+
</TopContainer>
|
|
98
|
+
|
|
99
|
+
<BottomContainer>
|
|
100
|
+
<PriceSection>
|
|
101
|
+
<PriceContainer>
|
|
102
|
+
<OfferContainer>
|
|
103
|
+
{card.price !== 'Enquire now' && <PriceLabel>From</PriceLabel>}
|
|
104
|
+
{card.original_price && (
|
|
105
|
+
<OriginalPrice>{card.original_price}</OriginalPrice>
|
|
106
|
+
)}
|
|
107
|
+
</OfferContainer>
|
|
108
|
+
<CurrentPrice>{card.price}</CurrentPrice>
|
|
109
|
+
</PriceContainer>
|
|
110
|
+
|
|
111
|
+
{card.logo && (
|
|
112
|
+
<LogoContainer>
|
|
113
|
+
<a
|
|
114
|
+
href={card.logo_url}
|
|
115
|
+
target="_blank"
|
|
116
|
+
rel="noopener noreferrer"
|
|
117
|
+
>
|
|
118
|
+
<img src={card.logo} alt="Partner logo" />
|
|
119
|
+
</a>
|
|
120
|
+
</LogoContainer>
|
|
121
|
+
)}
|
|
122
|
+
</PriceSection>
|
|
123
|
+
|
|
124
|
+
<CTAButton
|
|
125
|
+
href={card.cta_url}
|
|
126
|
+
target="_blank"
|
|
127
|
+
rel="noopener noreferrer"
|
|
128
|
+
>
|
|
129
|
+
{card.cta_text || 'View Itinerary'}
|
|
130
|
+
</CTAButton>
|
|
131
|
+
</BottomContainer>
|
|
132
|
+
</CardContent>
|
|
133
|
+
</CardContainer>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { storiesOf } from '@storybook/react';
|
|
3
|
+
import { TripCards } from './index';
|
|
4
|
+
|
|
5
|
+
storiesOf('Typescript Component/TripCards', module)
|
|
6
|
+
.add('Default', () => (
|
|
7
|
+
<TripCards
|
|
8
|
+
element={{
|
|
9
|
+
class: 'trip-cards',
|
|
10
|
+
tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
|
|
11
|
+
title: 'Similar cruises',
|
|
12
|
+
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
13
|
+
description: 'Brought to you by Times Holidays'
|
|
14
|
+
}}
|
|
15
|
+
useMockData={true}
|
|
16
|
+
/>
|
|
17
|
+
))
|
|
18
|
+
.add('Two Cards', () => (
|
|
19
|
+
<TripCards
|
|
20
|
+
element={{
|
|
21
|
+
class: 'trip-cards',
|
|
22
|
+
tripcards: btoa(JSON.stringify([2074350, 2140335])),
|
|
23
|
+
title: 'Similar cruises',
|
|
24
|
+
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
25
|
+
description: 'Brought to you by Times Holidays'
|
|
26
|
+
}}
|
|
27
|
+
useMockData={true}
|
|
28
|
+
/>
|
|
29
|
+
))
|
|
30
|
+
.add('Three Cards', () => (
|
|
31
|
+
<TripCards
|
|
32
|
+
element={{
|
|
33
|
+
class: 'trip-cards',
|
|
34
|
+
tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
|
|
35
|
+
title: 'Similar cruises',
|
|
36
|
+
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
37
|
+
description: 'Brought to you by Times Holidays'
|
|
38
|
+
}}
|
|
39
|
+
useMockData={true}
|
|
40
|
+
/>
|
|
41
|
+
))
|
|
42
|
+
.add('Six Cards (Carousel)', () => (
|
|
43
|
+
<TripCards
|
|
44
|
+
element={{
|
|
45
|
+
class: 'trip-cards',
|
|
46
|
+
tripcards: btoa(
|
|
47
|
+
JSON.stringify([2074350, 2140335, 2177685, 2074351, 2140336, 2177686])
|
|
48
|
+
),
|
|
49
|
+
title: 'Featured Voyages',
|
|
50
|
+
titleUrl: 'https://www.thetimes.com/travel/holidays',
|
|
51
|
+
description: 'Handpicked by our travel experts'
|
|
52
|
+
}}
|
|
53
|
+
useMockData={true}
|
|
54
|
+
/>
|
|
55
|
+
))
|
|
56
|
+
.add('With Title Link', () => (
|
|
57
|
+
<TripCards
|
|
58
|
+
element={{
|
|
59
|
+
class: 'trip-cards',
|
|
60
|
+
tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
|
|
61
|
+
title: 'Explore Mediterranean',
|
|
62
|
+
titleUrl: 'https://www.thetimes.com/travel/holidays/cruises',
|
|
63
|
+
description: 'Discover amazing cruise deals'
|
|
64
|
+
}}
|
|
65
|
+
useMockData={true}
|
|
66
|
+
/>
|
|
67
|
+
));
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { CarouselComponent, CarouselItem } from '../carousel-component';
|
|
3
|
+
import { TripCardsLayoutProps } from './types';
|
|
4
|
+
import {
|
|
5
|
+
Container,
|
|
6
|
+
TitleSection,
|
|
7
|
+
TitleBar,
|
|
8
|
+
TitleContent,
|
|
9
|
+
Title,
|
|
10
|
+
Subtitle,
|
|
11
|
+
TitleLink,
|
|
12
|
+
StaticCardsGrid
|
|
13
|
+
} from './styles';
|
|
14
|
+
import { ChevronRightIcon } from './assets';
|
|
15
|
+
|
|
16
|
+
export const TripCardsLayout: FC<TripCardsLayoutProps> = ({
|
|
17
|
+
element,
|
|
18
|
+
items,
|
|
19
|
+
CardComponent,
|
|
20
|
+
itemsPerPage
|
|
21
|
+
}) => {
|
|
22
|
+
const { titleUrl, title, description } = element;
|
|
23
|
+
const isStaticGrid = items.length === 2;
|
|
24
|
+
return (
|
|
25
|
+
<Container data-testid="trip-cards-container">
|
|
26
|
+
<TitleSection data-testid="title-section">
|
|
27
|
+
<TitleBar data-testid="title-bar">
|
|
28
|
+
<TitleContent data-testid="title-content">
|
|
29
|
+
<Title data-testid="trip-cards-title">{title}</Title>
|
|
30
|
+
<Subtitle data-testid="trip-cards-subtitle">{description}</Subtitle>
|
|
31
|
+
</TitleContent>
|
|
32
|
+
{titleUrl && (
|
|
33
|
+
<TitleLink
|
|
34
|
+
href={titleUrl}
|
|
35
|
+
target="_blank"
|
|
36
|
+
rel="noopener noreferrer"
|
|
37
|
+
data-testid="title-link"
|
|
38
|
+
>
|
|
39
|
+
<ChevronRightIcon />
|
|
40
|
+
</TitleLink>
|
|
41
|
+
)}
|
|
42
|
+
</TitleBar>
|
|
43
|
+
</TitleSection>
|
|
44
|
+
|
|
45
|
+
{isStaticGrid ? (
|
|
46
|
+
<StaticCardsGrid data-testid="static-cards-grid">
|
|
47
|
+
{items.map(item => (
|
|
48
|
+
<CardComponent key={item.id} card={item.data} />
|
|
49
|
+
))}
|
|
50
|
+
</StaticCardsGrid>
|
|
51
|
+
) : (
|
|
52
|
+
<CarouselComponent
|
|
53
|
+
items={items.map(item => (
|
|
54
|
+
<CarouselItem
|
|
55
|
+
key={item.id}
|
|
56
|
+
widthConfig={{
|
|
57
|
+
mobile: '90%',
|
|
58
|
+
tablet: '43.5%',
|
|
59
|
+
desktop: '46.5%',
|
|
60
|
+
xl: '45.5%'
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<CardComponent card={item.data} />
|
|
64
|
+
</CarouselItem>
|
|
65
|
+
))}
|
|
66
|
+
options={{
|
|
67
|
+
itemsPerPage
|
|
68
|
+
}}
|
|
69
|
+
showArrows={true}
|
|
70
|
+
showDots={true}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</Container>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { SkeletonCard } from '../SkeletonCard';
|
|
5
|
+
|
|
6
|
+
describe('SkeletonCard', () => {
|
|
7
|
+
it('renders without crashing', () => {
|
|
8
|
+
const { container } = render(<SkeletonCard />);
|
|
9
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders placeholder image', () => {
|
|
13
|
+
render(<SkeletonCard />);
|
|
14
|
+
const imageContainer = screen.getByTestId('skeleton-image-container');
|
|
15
|
+
expect(imageContainer).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders skeleton headline', () => {
|
|
19
|
+
render(<SkeletonCard />);
|
|
20
|
+
const skeletonHeadline = screen.getByTestId('skeleton-headline');
|
|
21
|
+
expect(skeletonHeadline).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('renders four skeleton data points in the list', () => {
|
|
25
|
+
render(<SkeletonCard />);
|
|
26
|
+
const dataPoints = [
|
|
27
|
+
screen.getByTestId('skeleton-data-point-1'),
|
|
28
|
+
screen.getByTestId('skeleton-data-point-2'),
|
|
29
|
+
screen.getByTestId('skeleton-data-point-3'),
|
|
30
|
+
screen.getByTestId('skeleton-data-point-4')
|
|
31
|
+
];
|
|
32
|
+
expect(dataPoints.length).toBe(4);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders skeleton lines for data points', () => {
|
|
36
|
+
render(<SkeletonCard />);
|
|
37
|
+
const skeletonLines = [
|
|
38
|
+
screen.getByTestId('skeleton-line-1'),
|
|
39
|
+
screen.getByTestId('skeleton-line-2'),
|
|
40
|
+
screen.getByTestId('skeleton-line-3'),
|
|
41
|
+
screen.getByTestId('skeleton-line-4'),
|
|
42
|
+
screen.getByTestId('skeleton-price-label')
|
|
43
|
+
];
|
|
44
|
+
expect(skeletonLines.length).toBe(5);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('renders skeleton price', () => {
|
|
48
|
+
render(<SkeletonCard />);
|
|
49
|
+
const skeletonPrice = screen.getByTestId('skeleton-price');
|
|
50
|
+
expect(skeletonPrice).toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('renders skeleton button', () => {
|
|
54
|
+
render(<SkeletonCard />);
|
|
55
|
+
const skeletonButton = screen.getByTestId('skeleton-button');
|
|
56
|
+
expect(skeletonButton).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('has correct card structure', () => {
|
|
60
|
+
render(<SkeletonCard />);
|
|
61
|
+
const cardContainer = screen.getByTestId('skeleton-card-container');
|
|
62
|
+
const cardContent = screen.getByTestId('skeleton-card-content');
|
|
63
|
+
const topContainer = screen.getByTestId('skeleton-top-container');
|
|
64
|
+
const bottomContainer = screen.getByTestId('skeleton-bottom-container');
|
|
65
|
+
|
|
66
|
+
expect(cardContainer).toBeInTheDocument();
|
|
67
|
+
expect(cardContent).toBeInTheDocument();
|
|
68
|
+
expect(topContainer).toBeInTheDocument();
|
|
69
|
+
expect(bottomContainer).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('renders price section with container', () => {
|
|
73
|
+
render(<SkeletonCard />);
|
|
74
|
+
const priceSection = screen.getByTestId('skeleton-price-section');
|
|
75
|
+
const priceContainer = screen.getByTestId('skeleton-price-container');
|
|
76
|
+
|
|
77
|
+
expect(priceSection).toBeInTheDocument();
|
|
78
|
+
expect(priceContainer).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('renders data points list', () => {
|
|
82
|
+
render(<SkeletonCard />);
|
|
83
|
+
const dataPointsList = screen.getByTestId('skeleton-data-points-list');
|
|
84
|
+
expect(dataPointsList).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('skeleton lines are rendered for each data point', () => {
|
|
88
|
+
render(<SkeletonCard />);
|
|
89
|
+
const skeletonLines = [
|
|
90
|
+
screen.getByTestId('skeleton-line-1'),
|
|
91
|
+
screen.getByTestId('skeleton-line-2'),
|
|
92
|
+
screen.getByTestId('skeleton-line-3'),
|
|
93
|
+
screen.getByTestId('skeleton-line-4'),
|
|
94
|
+
screen.getByTestId('skeleton-price-label')
|
|
95
|
+
];
|
|
96
|
+
expect(skeletonLines.length).toBe(5);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('renders with correct skeleton styling', () => {
|
|
100
|
+
render(<SkeletonCard />);
|
|
101
|
+
|
|
102
|
+
expect(screen.getByTestId('skeleton-headline')).toBeInTheDocument();
|
|
103
|
+
expect(screen.getByTestId('skeleton-price')).toBeInTheDocument();
|
|
104
|
+
expect(screen.getByTestId('skeleton-button')).toBeInTheDocument();
|
|
105
|
+
// Check that skeleton lines are present
|
|
106
|
+
expect(screen.getByTestId('skeleton-line-1')).toBeInTheDocument();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('renders consistent structure', () => {
|
|
110
|
+
render(<SkeletonCard />);
|
|
111
|
+
|
|
112
|
+
expect(screen.getByTestId('skeleton-card-container')).toBeInTheDocument();
|
|
113
|
+
expect(screen.getByTestId('skeleton-image-container')).toBeInTheDocument();
|
|
114
|
+
expect(screen.getByTestId('skeleton-card-content')).toBeInTheDocument();
|
|
115
|
+
expect(screen.getByTestId('skeleton-top-container')).toBeInTheDocument();
|
|
116
|
+
expect(screen.getByTestId('skeleton-bottom-container')).toBeInTheDocument();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('can render multiple skeleton cards', () => {
|
|
120
|
+
render(
|
|
121
|
+
<>
|
|
122
|
+
<SkeletonCard />
|
|
123
|
+
<SkeletonCard />
|
|
124
|
+
<SkeletonCard />
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const cards = screen.getAllByTestId('skeleton-card-container');
|
|
129
|
+
expect(cards.length).toBe(3);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('renders skeleton elements in correct order', () => {
|
|
133
|
+
render(<SkeletonCard />);
|
|
134
|
+
|
|
135
|
+
const cardContent = screen.getByTestId('skeleton-card-content');
|
|
136
|
+
const topContainer = screen.getByTestId('skeleton-top-container');
|
|
137
|
+
const bottomContainer = screen.getByTestId('skeleton-bottom-container');
|
|
138
|
+
|
|
139
|
+
// Verify both containers exist as children of card content
|
|
140
|
+
expect(cardContent.contains(topContainer)).toBe(true);
|
|
141
|
+
expect(cardContent.contains(bottomContainer)).toBe(true);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('skeleton button has correct structure', () => {
|
|
145
|
+
render(<SkeletonCard />);
|
|
146
|
+
const skeletonButton = screen.getByTestId('skeleton-button');
|
|
147
|
+
|
|
148
|
+
expect(skeletonButton.tagName.toLowerCase()).toBe('div');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('skeleton lines have correct width props', () => {
|
|
152
|
+
render(<SkeletonCard />);
|
|
153
|
+
|
|
154
|
+
// Check that the skeleton lines are rendered
|
|
155
|
+
expect(screen.getByTestId('skeleton-line-1')).toBeInTheDocument();
|
|
156
|
+
expect(screen.getByTestId('skeleton-line-2')).toBeInTheDocument();
|
|
157
|
+
expect(screen.getByTestId('skeleton-line-3')).toBeInTheDocument();
|
|
158
|
+
expect(screen.getByTestId('skeleton-line-4')).toBeInTheDocument();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('renders without any interactive elements', () => {
|
|
162
|
+
const { container } = render(<SkeletonCard />);
|
|
163
|
+
const buttons = container.querySelectorAll('button');
|
|
164
|
+
const links = container.querySelectorAll('a');
|
|
165
|
+
|
|
166
|
+
expect(buttons.length).toBe(0);
|
|
167
|
+
expect(links.length).toBe(0);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { TripCard } from '../TripCard';
|
|
5
|
+
import { TripCardApiData } from '../types';
|
|
6
|
+
|
|
7
|
+
const mockCard: TripCardApiData = {
|
|
8
|
+
cruise_id: '2074350',
|
|
9
|
+
image: 'https://example.com/image.jpg',
|
|
10
|
+
headline: 'Mediterranean from Barcelona',
|
|
11
|
+
date: 'Oct 2025 - Oct 2025',
|
|
12
|
+
duration: 'Seven Days',
|
|
13
|
+
route: 'Barcelona → Marseille',
|
|
14
|
+
ship: 'MSC Seaside',
|
|
15
|
+
price: '£2000',
|
|
16
|
+
logo: 'https://example.com/logo.png',
|
|
17
|
+
logo_url: 'https://example.com',
|
|
18
|
+
cta_url: 'https://example.com/cruise',
|
|
19
|
+
cta_text: 'View Itinerary'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('TripCard', () => {
|
|
23
|
+
it('renders card with all required data', () => {
|
|
24
|
+
render(<TripCard card={mockCard} />);
|
|
25
|
+
|
|
26
|
+
expect(
|
|
27
|
+
screen.getByText('Mediterranean from Barcelona')
|
|
28
|
+
).toBeInTheDocument();
|
|
29
|
+
expect(screen.getByText('Oct 2025 - Oct 2025')).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByText('Seven Days')).toBeInTheDocument();
|
|
31
|
+
expect(screen.getByText('Barcelona → Marseille')).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText('MSC Seaside')).toBeInTheDocument();
|
|
33
|
+
expect(screen.getByText('£2000')).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText('From')).toBeInTheDocument();
|
|
35
|
+
expect(screen.getByText('View Itinerary')).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders image with correct src and alt', () => {
|
|
39
|
+
render(<TripCard card={mockCard} />);
|
|
40
|
+
|
|
41
|
+
const image = screen.getByAltText('Mediterranean from Barcelona');
|
|
42
|
+
expect(image).toHaveAttribute('src', 'https://example.com/image.jpg');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('renders offer label when provided', () => {
|
|
46
|
+
const cardWithOffer = {
|
|
47
|
+
...mockCard,
|
|
48
|
+
offer_label: 'Special Offer'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
render(<TripCard card={cardWithOffer} />);
|
|
52
|
+
|
|
53
|
+
expect(screen.getByText('Special Offer')).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders gift banner when provided', () => {
|
|
57
|
+
const cardWithGift = {
|
|
58
|
+
...mockCard,
|
|
59
|
+
gift_banner: 'Free gift with purchase'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
render(<TripCard card={cardWithGift} />);
|
|
63
|
+
|
|
64
|
+
expect(screen.getByText('Free gift with purchase')).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('renders original price when provided', () => {
|
|
68
|
+
const cardWithOriginalPrice = {
|
|
69
|
+
...mockCard,
|
|
70
|
+
original_price: '£2500'
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
render(<TripCard card={cardWithOriginalPrice} />);
|
|
74
|
+
|
|
75
|
+
expect(screen.getByText('£2500')).toBeInTheDocument();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('does not render "From" when price is "Enquire now"', () => {
|
|
79
|
+
const cardWithEnquire = {
|
|
80
|
+
...mockCard,
|
|
81
|
+
price: 'Enquire now'
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
render(<TripCard card={cardWithEnquire} />);
|
|
85
|
+
|
|
86
|
+
expect(screen.queryByText('From')).not.toBeInTheDocument();
|
|
87
|
+
expect(screen.getByText('Enquire now')).toBeInTheDocument();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('renders all CTA links with correct href and target', () => {
|
|
91
|
+
render(<TripCard card={mockCard} />);
|
|
92
|
+
|
|
93
|
+
const links = screen.getAllByRole('link');
|
|
94
|
+
const imageLink = links[0];
|
|
95
|
+
const headlineLink = links[1];
|
|
96
|
+
const ctaButton = screen.getByText('View Itinerary').closest('a');
|
|
97
|
+
|
|
98
|
+
expect(imageLink).toHaveAttribute('href', 'https://example.com/cruise');
|
|
99
|
+
expect(imageLink).toHaveAttribute('target', '_blank');
|
|
100
|
+
expect(headlineLink).toHaveAttribute('href', 'https://example.com/cruise');
|
|
101
|
+
expect(ctaButton).toHaveAttribute('href', 'https://example.com/cruise');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('renders logo with link when provided', () => {
|
|
105
|
+
render(<TripCard card={mockCard} />);
|
|
106
|
+
const logoLink = screen.getByRole('link', { name: /partner logo/i });
|
|
107
|
+
expect(logoLink).toHaveAttribute('href', 'https://example.com');
|
|
108
|
+
const logoImg = screen.getByAltText('Partner logo');
|
|
109
|
+
expect(logoImg).toHaveAttribute('src', 'https://example.com/logo.png');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('shows card image after it loads', () => {
|
|
113
|
+
render(<TripCard card={mockCard} />);
|
|
114
|
+
|
|
115
|
+
const cardImage = screen.getByAltText('Mediterranean from Barcelona');
|
|
116
|
+
expect(cardImage).toHaveStyle({ display: 'none' });
|
|
117
|
+
fireEvent.load(cardImage);
|
|
118
|
+
expect(cardImage).toHaveStyle({ display: 'block' });
|
|
119
|
+
});
|
|
120
|
+
});
|