@times-components/ts-components 1.146.2-0f9388fe36c532b90db3f35d17847fc17a611f1e.44 → 1.146.2-784617dc4a33959b8795da1d7f425c9929322fae.24

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.
Files changed (138) hide show
  1. package/dist/components/travel-mini-cta/__tests__/index.test.js +262 -0
  2. package/dist/components/travel-mini-cta/index.d.ts +10 -0
  3. package/dist/components/travel-mini-cta/index.js +93 -0
  4. package/dist/components/travel-mini-cta/styles.d.ts +42 -0
  5. package/dist/components/travel-mini-cta/styles.js +268 -0
  6. package/dist/components/travel-mini-cta/travel-mini-cta.stories.js +8 -0
  7. package/dist/components/travel-mini-cta/types.d.ts +10 -0
  8. package/dist/components/{trip-cards → travel-mini-cta}/types.js +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/utils/applyDarkMode.d.ts +1 -0
  12. package/dist/utils/applyDarkMode.js +12 -0
  13. package/dist/utils/getMediaQuery.d.ts +11 -0
  14. package/dist/utils/getMediaQuery.js +19 -0
  15. package/dist/utils/index.d.ts +2 -0
  16. package/dist/utils/index.js +3 -0
  17. package/package.json +3 -3
  18. package/rnw.js +1 -1
  19. package/src/components/travel-mini-cta/__tests__/__snapshots__/index.test.tsx.snap +211 -0
  20. package/src/components/travel-mini-cta/__tests__/index.test.tsx +330 -0
  21. package/src/components/travel-mini-cta/index.tsx +190 -0
  22. package/src/components/travel-mini-cta/styles.ts +331 -0
  23. package/src/components/travel-mini-cta/travel-mini-cta.stories.tsx +23 -0
  24. package/src/components/travel-mini-cta/types.ts +10 -0
  25. package/src/index.ts +1 -2
  26. package/src/utils/applyDarkMode.ts +12 -0
  27. package/src/utils/getMediaQuery.ts +25 -0
  28. package/src/utils/index.ts +2 -0
  29. package/dist/components/carousel-component/CarouselComponent.stories.js +0 -146
  30. package/dist/components/carousel-component/CarouselItem.d.ts +0 -3
  31. package/dist/components/carousel-component/CarouselItem.js +0 -12
  32. package/dist/components/carousel-component/DefaultNavigationArrow.d.ts +0 -8
  33. package/dist/components/carousel-component/DefaultNavigationArrow.js +0 -6
  34. package/dist/components/carousel-component/DefaultPageDot.d.ts +0 -8
  35. package/dist/components/carousel-component/DefaultPageDot.js +0 -4
  36. package/dist/components/carousel-component/__tests__/CarouselComponent.test.d.ts +0 -1
  37. package/dist/components/carousel-component/__tests__/CarouselComponent.test.js +0 -163
  38. package/dist/components/carousel-component/__tests__/CarouselItem.test.d.ts +0 -1
  39. package/dist/components/carousel-component/__tests__/CarouselItem.test.js +0 -80
  40. package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.d.ts +0 -1
  41. package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.js +0 -62
  42. package/dist/components/carousel-component/__tests__/DefaultPageDot.test.d.ts +0 -1
  43. package/dist/components/carousel-component/__tests__/DefaultPageDot.test.js +0 -68
  44. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.d.ts +0 -1
  45. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.js +0 -459
  46. package/dist/components/carousel-component/hooks/useCarousel.d.ts +0 -2
  47. package/dist/components/carousel-component/hooks/useCarousel.js +0 -167
  48. package/dist/components/carousel-component/index.d.ts +0 -4
  49. package/dist/components/carousel-component/index.js +0 -20
  50. package/dist/components/carousel-component/styles.d.ts +0 -28
  51. package/dist/components/carousel-component/styles.js +0 -172
  52. package/dist/components/carousel-component/types.d.ts +0 -53
  53. package/dist/components/carousel-component/types.js +0 -2
  54. package/dist/components/trip-cards/SkeletonCard.d.ts +0 -7
  55. package/dist/components/trip-cards/SkeletonCard.js +0 -22
  56. package/dist/components/trip-cards/TripCard.d.ts +0 -3
  57. package/dist/components/trip-cards/TripCard.js +0 -49
  58. package/dist/components/trip-cards/TripCards.stories.d.ts +0 -1
  59. package/dist/components/trip-cards/TripCards.stories.js +0 -159
  60. package/dist/components/trip-cards/TripCardsLayout.d.ts +0 -3
  61. package/dist/components/trip-cards/TripCardsLayout.js +0 -56
  62. package/dist/components/trip-cards/__tests__/SkeletonCard.test.d.ts +0 -1
  63. package/dist/components/trip-cards/__tests__/SkeletonCard.test.js +0 -139
  64. package/dist/components/trip-cards/__tests__/TripCard.test.d.ts +0 -1
  65. package/dist/components/trip-cards/__tests__/TripCard.test.js +0 -95
  66. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.d.ts +0 -1
  67. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.js +0 -314
  68. package/dist/components/trip-cards/__tests__/assets.test.d.ts +0 -1
  69. package/dist/components/trip-cards/__tests__/assets.test.js +0 -165
  70. package/dist/components/trip-cards/__tests__/helpers.test.d.ts +0 -1
  71. package/dist/components/trip-cards/__tests__/helpers.test.js +0 -220
  72. package/dist/components/trip-cards/__tests__/index.test.js +0 -478
  73. package/dist/components/trip-cards/__tests__/mockData.test.d.ts +0 -1
  74. package/dist/components/trip-cards/__tests__/mockData.test.js +0 -57
  75. package/dist/components/trip-cards/__tests__/skeletonStyles.test.d.ts +0 -1
  76. package/dist/components/trip-cards/__tests__/skeletonStyles.test.js +0 -194
  77. package/dist/components/trip-cards/assets/BoatIcon.d.ts +0 -1
  78. package/dist/components/trip-cards/assets/BoatIcon.js +0 -4
  79. package/dist/components/trip-cards/assets/CalendarIcon.d.ts +0 -1
  80. package/dist/components/trip-cards/assets/CalendarIcon.js +0 -4
  81. package/dist/components/trip-cards/assets/ChevronRightIcon.d.ts +0 -1
  82. package/dist/components/trip-cards/assets/ChevronRightIcon.js +0 -4
  83. package/dist/components/trip-cards/assets/LocationIcon.d.ts +0 -1
  84. package/dist/components/trip-cards/assets/LocationIcon.js +0 -4
  85. package/dist/components/trip-cards/assets/MoonIcon.d.ts +0 -1
  86. package/dist/components/trip-cards/assets/MoonIcon.js +0 -4
  87. package/dist/components/trip-cards/assets/index.d.ts +0 -6
  88. package/dist/components/trip-cards/assets/index.js +0 -7
  89. package/dist/components/trip-cards/helpers.d.ts +0 -11
  90. package/dist/components/trip-cards/helpers.js +0 -138
  91. package/dist/components/trip-cards/index.d.ts +0 -4
  92. package/dist/components/trip-cards/index.js +0 -68
  93. package/dist/components/trip-cards/mockData.d.ts +0 -3
  94. package/dist/components/trip-cards/mockData.js +0 -317
  95. package/dist/components/trip-cards/skeletonStyles.d.ts +0 -9
  96. package/dist/components/trip-cards/skeletonStyles.js +0 -37
  97. package/dist/components/trip-cards/styles.d.ts +0 -43
  98. package/dist/components/trip-cards/styles.js +0 -404
  99. package/dist/components/trip-cards/types.d.ts +0 -119
  100. package/src/components/carousel-component/CarouselComponent.stories.tsx +0 -220
  101. package/src/components/carousel-component/CarouselItem.tsx +0 -26
  102. package/src/components/carousel-component/DefaultNavigationArrow.tsx +0 -37
  103. package/src/components/carousel-component/DefaultPageDot.tsx +0 -20
  104. package/src/components/carousel-component/__tests__/CarouselComponent.test.tsx +0 -259
  105. package/src/components/carousel-component/__tests__/CarouselItem.test.tsx +0 -140
  106. package/src/components/carousel-component/__tests__/DefaultNavigationArrow.test.tsx +0 -153
  107. package/src/components/carousel-component/__tests__/DefaultPageDot.test.tsx +0 -105
  108. package/src/components/carousel-component/hooks/__tests__/useCarousel.test.ts +0 -625
  109. package/src/components/carousel-component/hooks/useCarousel.ts +0 -229
  110. package/src/components/carousel-component/index.tsx +0 -92
  111. package/src/components/carousel-component/styles.ts +0 -188
  112. package/src/components/carousel-component/types.ts +0 -62
  113. package/src/components/trip-cards/SkeletonCard.tsx +0 -64
  114. package/src/components/trip-cards/TripCard.tsx +0 -140
  115. package/src/components/trip-cards/TripCards.stories.tsx +0 -224
  116. package/src/components/trip-cards/TripCardsLayout.tsx +0 -145
  117. package/src/components/trip-cards/__tests__/SkeletonCard.test.tsx +0 -169
  118. package/src/components/trip-cards/__tests__/TripCard.test.tsx +0 -120
  119. package/src/components/trip-cards/__tests__/TripCardsLayout.test.tsx +0 -583
  120. package/src/components/trip-cards/__tests__/assets.test.tsx +0 -206
  121. package/src/components/trip-cards/__tests__/helpers.test.ts +0 -272
  122. package/src/components/trip-cards/__tests__/index.test.tsx +0 -550
  123. package/src/components/trip-cards/__tests__/mockData.test.ts +0 -67
  124. package/src/components/trip-cards/__tests__/skeletonStyles.test.tsx +0 -256
  125. package/src/components/trip-cards/assets/BoatIcon.tsx +0 -17
  126. package/src/components/trip-cards/assets/CalendarIcon.tsx +0 -17
  127. package/src/components/trip-cards/assets/ChevronRightIcon.tsx +0 -20
  128. package/src/components/trip-cards/assets/LocationIcon.tsx +0 -17
  129. package/src/components/trip-cards/assets/MoonIcon.tsx +0 -17
  130. package/src/components/trip-cards/assets/index.ts +0 -7
  131. package/src/components/trip-cards/helpers.ts +0 -176
  132. package/src/components/trip-cards/index.tsx +0 -119
  133. package/src/components/trip-cards/mockData.ts +0 -345
  134. package/src/components/trip-cards/skeletonStyles.ts +0 -46
  135. package/src/components/trip-cards/styles.ts +0 -450
  136. package/src/components/trip-cards/types.ts +0 -128
  137. /package/dist/components/{trip-cards → travel-mini-cta}/__tests__/index.test.d.ts +0 -0
  138. /package/dist/components/{carousel-component/CarouselComponent.stories.d.ts → travel-mini-cta/travel-mini-cta.stories.d.ts} +0 -0
@@ -1,140 +0,0 @@
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
- PriceSuffix,
26
- StyledLink
27
- } from './styles';
28
- import { MoonIcon, LocationIcon, BoatIcon, CalendarIcon } from './assets';
29
-
30
- export const TripCard: FC<TripCardProps> = ({
31
- card,
32
- isStaticGrid,
33
- imgHeight = {}
34
- }) => {
35
- const [imageLoaded, setImageLoaded] = useState(false);
36
-
37
- return (
38
- <CardContainer>
39
- <StyledLink href={card.cta_url} target="_blank" rel="noopener noreferrer">
40
- <ImageContainer isStaticGrid={isStaticGrid} {...imgHeight}>
41
- {!imageLoaded && <Placeholder />}
42
- <CardImage
43
- src={card.image}
44
- alt={card.headline}
45
- onLoad={() => setImageLoaded(true)}
46
- isLoaded={imageLoaded}
47
- />
48
- {card.offer_label && <OfferLabel>{card.offer_label}</OfferLabel>}
49
- {card.gift_banner && <GiftBanner>{card.gift_banner}</GiftBanner>}
50
- </ImageContainer>
51
- </StyledLink>
52
-
53
- <CardContent>
54
- <TopContainer>
55
- <StyledLink
56
- href={card.cta_url}
57
- target="_blank"
58
- rel="noopener noreferrer"
59
- >
60
- <Headline>{card.headline}</Headline>
61
- </StyledLink>
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
- {card.price !== 'Enquire now' && (
103
- <OfferContainer>
104
- {<PriceLabel>From</PriceLabel>}
105
- {card.original_price && (
106
- <OriginalPrice>{card.original_price}</OriginalPrice>
107
- )}
108
- </OfferContainer>
109
- )}
110
- <CurrentPrice $isEnquire={card.price === 'Enquire now'}>
111
- {card.price}
112
- {card.price !== 'Enquire now' && <PriceSuffix>pp</PriceSuffix>}
113
- </CurrentPrice>
114
- </PriceContainer>
115
-
116
- {card.logo && (
117
- <LogoContainer>
118
- <a
119
- href={card.logo_url}
120
- target="_blank"
121
- rel="noopener noreferrer"
122
- >
123
- <img src={card.logo} alt="Partner logo" />
124
- </a>
125
- </LogoContainer>
126
- )}
127
- </PriceSection>
128
-
129
- <CTAButton
130
- href={card.cta_url}
131
- target="_blank"
132
- rel="noopener noreferrer"
133
- >
134
- {card.cta_text || 'View Itinerary'}
135
- </CTAButton>
136
- </BottomContainer>
137
- </CardContent>
138
- </CardContainer>
139
- );
140
- };
@@ -1,224 +0,0 @@
1
- import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { TripCards } from './index';
4
- import styled from 'styled-components';
5
- import { defaultTripCardImgHeight } from './helpers';
6
-
7
- const spacing = (multiplier: number) => `${multiplier * 8}px`;
8
-
9
- const breakpoints = {
10
- medium: 768,
11
- wide: 1024
12
- };
13
-
14
- const InteractiveContainer = styled.div`
15
- position: relative;
16
- margin-bottom: ${spacing(4)};
17
- padding: 0 ${spacing(2)};
18
-
19
- @media (min-width: ${breakpoints.medium}px) {
20
- width: 80.8%;
21
- margin-left: auto;
22
- margin-right: auto;
23
- padding: 0;
24
- }
25
-
26
- @media (min-width: ${breakpoints.wide}px) {
27
- width: 56.2%;
28
- }
29
- `;
30
-
31
- storiesOf('Typescript Component/TripCards', module)
32
- .add('Channel View Two Cards', () => (
33
- <TripCards
34
- element={{
35
- class: 'trip-cards',
36
- tripcards: btoa(JSON.stringify([2074350, 2140335])),
37
- title: 'Similar cruises',
38
- titleurl: 'https://www.thetimes.com/travel/holidays',
39
- description: 'Brought to you by Times Holidays'
40
- }}
41
- useMockData={true}
42
- maxWidthItemConfig={{
43
- xs: '85%',
44
- mobile: '87%',
45
- tablet: '44%',
46
- desktop: '314px',
47
- xl: '368px'
48
- }}
49
- widthContainerConfig={{
50
- tablet: '728px',
51
- desktop: '984px',
52
- xl: '1144px'
53
- }}
54
- />
55
- ))
56
- .add('Channel View Three Cards', () => (
57
- <TripCards
58
- element={{
59
- class: 'trip-cards',
60
- tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
61
- title: 'Featured Voyages',
62
- titleurl: 'https://www.thetimes.com/travel/holidays',
63
- description: 'Handpicked by our travel experts'
64
- }}
65
- forceStaticGrid={true}
66
- maxWidthItemConfig={{
67
- xs: '85%',
68
- mobile: '87%',
69
- tablet: '44%',
70
- desktop: '314px',
71
- xl: '368px'
72
- }}
73
- widthContainerConfig={{
74
- tablet: '728px',
75
- desktop: '984px',
76
- xl: '1144px'
77
- }}
78
- useMockData={true}
79
- />
80
- ))
81
- .add('Article View Two Trip Cards', () => (
82
- <InteractiveContainer>
83
- <TripCards
84
- element={{
85
- class: 'trip-cards',
86
- tripcards: btoa(JSON.stringify([2074350, 2140335])),
87
- title: 'Similar cruises',
88
- titleurl: 'https://www.thetimes.com/travel/holidays',
89
- description: 'Brought to you by Times Holidays'
90
- }}
91
- useMockData={true}
92
- maxWidthItemConfig={{
93
- mobile: '320px',
94
- tablet: '260px',
95
- desktop: '260px',
96
- xl: '300px'
97
- }}
98
- widthContainerConfig={{
99
- mobile: '390px',
100
- tablet: '620px',
101
- desktop: '574px',
102
- xl: '663px'
103
- }}
104
- imgHeight={defaultTripCardImgHeight}
105
- />
106
- </InteractiveContainer>
107
- ))
108
- .add('Article View Three Cards', () => (
109
- <InteractiveContainer>
110
- <TripCards
111
- element={{
112
- class: 'trip-cards',
113
- tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
114
- title: 'Similar cruises',
115
- titleurl: 'https://www.thetimes.com/travel/holidays',
116
- description: 'Brought to you by Times Holidays'
117
- }}
118
- useMockData={true}
119
- maxWidthItemConfig={{
120
- mobile: '320px',
121
- tablet: '260px',
122
- desktop: '260px',
123
- xl: '300px'
124
- }}
125
- widthContainerConfig={{
126
- mobile: '390px',
127
- tablet: '620px',
128
- desktop: '574px',
129
- xl: '663px'
130
- }}
131
- imgHeight={{ ...defaultTripCardImgHeight, $heightXs: '100%' }}
132
- />
133
- </InteractiveContainer>
134
- ))
135
- .add('Article View Two Trip Cards', () => (
136
- <InteractiveContainer>
137
- <TripCards
138
- element={{
139
- class: 'trip-cards',
140
- tripcards: btoa(JSON.stringify([2074350, 2140335])),
141
- title: 'Similar cruises',
142
- titleurl: 'https://www.thetimes.com/travel/holidays',
143
- description: 'Brought to you by Times Holidays'
144
- }}
145
- useMockData={true}
146
- maxWidthItemConfig={{
147
- mobile: '320px',
148
- tablet: '260px',
149
- desktop: '260px',
150
- xl: '300px'
151
- }}
152
- widthContainerConfig={{
153
- mobile: '390px',
154
- tablet: '620px',
155
- desktop: '574px',
156
- xl: '663px'
157
- }}
158
- imgHeight={defaultTripCardImgHeight}
159
- />
160
- </InteractiveContainer>
161
- ))
162
- .add('Article View Trip Cards', () => (
163
- <InteractiveContainer>
164
- <TripCards
165
- element={{
166
- class: 'trip-cards',
167
- tripcards: btoa(JSON.stringify([2074350, 2140335, 2177685])),
168
- title: 'Similar cruises',
169
- titleurl: 'https://www.thetimes.com/travel/holidays',
170
- description: 'Brought to you by Times Holidays'
171
- }}
172
- useMockData={true}
173
- maxWidthItemConfig={{
174
- mobile: '320px',
175
- tablet: '260px',
176
- desktop: '260px',
177
- xl: '300px'
178
- }}
179
- widthContainerConfig={{
180
- mobile: '390px',
181
- tablet: '620px',
182
- desktop: '574px',
183
- xl: '663px'
184
- }}
185
- imgHeight={defaultTripCardImgHeight}
186
- />
187
- </InteractiveContainer>
188
- ))
189
- .add('Article View Six Cards', () => (
190
- <InteractiveContainer>
191
- <TripCards
192
- element={{
193
- class: 'trip-cards',
194
- tripcards: btoa(
195
- JSON.stringify([
196
- 2074350,
197
- 2140335,
198
- 2177685,
199
- 2074351,
200
- 2140336,
201
- 2177686
202
- ])
203
- ),
204
- title: 'Similar cruises',
205
- titleurl: 'https://www.thetimes.com/travel/holidays',
206
- description: 'Brought to you by Times Holidays'
207
- }}
208
- useMockData={true}
209
- maxWidthItemConfig={{
210
- mobile: '320px',
211
- tablet: '260px',
212
- desktop: '260px',
213
- xl: '300px'
214
- }}
215
- widthContainerConfig={{
216
- mobile: '390px',
217
- tablet: '620px',
218
- desktop: '574px',
219
- xl: '663px'
220
- }}
221
- imgHeight={defaultTripCardImgHeight}
222
- />
223
- </InteractiveContainer>
224
- ));
@@ -1,145 +0,0 @@
1
- import React, { FC, useRef, useState, useEffect } 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
- widthContainerConfig = {},
22
- widthItemConfig,
23
- maxWidthItemConfig,
24
- imgHeight,
25
- forceStaticGrid
26
- }) => {
27
- const { titleurl, title, description } = element;
28
- const gridRef = useRef<HTMLDivElement>(null);
29
- const [hasOverflow, setHasOverflow] = useState(false);
30
- const [isTabletMobile, setIsTabletMobile] = useState(false);
31
-
32
- const isStaticGrid = items.length === 2 || forceStaticGrid;
33
-
34
- // Handle responsive breakpoint detection
35
- useEffect(() => {
36
- const mediaQuery = window.matchMedia('(max-width: 1024px)');
37
- const handleMediaChange = (e: MediaQueryListEvent | MediaQueryList) => {
38
- setIsTabletMobile(e.matches);
39
- };
40
- handleMediaChange(mediaQuery);
41
- mediaQuery.addEventListener('change', handleMediaChange);
42
-
43
- return () => {
44
- mediaQuery.removeEventListener('change', handleMediaChange);
45
- };
46
- }, []);
47
-
48
- useEffect(
49
- () => {
50
- if (!isStaticGrid || !gridRef.current) {
51
- setHasOverflow(false);
52
- return;
53
- }
54
-
55
- const checkOverflow = () => {
56
- if (gridRef.current) {
57
- const isOverflowing =
58
- gridRef.current.scrollWidth > gridRef.current.clientWidth;
59
- setHasOverflow(isOverflowing);
60
- }
61
- };
62
-
63
- checkOverflow();
64
- const resizeObserver = new ResizeObserver(checkOverflow);
65
- resizeObserver.observe(gridRef.current);
66
-
67
- return () => {
68
- resizeObserver.disconnect();
69
- };
70
- },
71
- [isStaticGrid, items.length]
72
- );
73
-
74
- const shouldUseCarousel =
75
- (isTabletMobile && items.length >= 3) || !isStaticGrid || hasOverflow;
76
-
77
- return (
78
- <Container data-testid="trip-cards-container" {...widthContainerConfig}>
79
- <TitleSection data-testid="title-section">
80
- <TitleBar
81
- data-testid="title-bar"
82
- applyRightPadding={!!widthContainerConfig.mobile}
83
- >
84
- <TitleContent data-testid="title-content">
85
- {titleurl ? (
86
- <TitleLink
87
- href={titleurl}
88
- target="_blank"
89
- rel="noopener noreferrer"
90
- data-testid="trip-cards-title-link"
91
- style={{ textDecoration: 'none', color: 'inherit' }}
92
- >
93
- <Title data-testid="trip-cards-title">{title}</Title>
94
- </TitleLink>
95
- ) : (
96
- <Title data-testid="trip-cards-title">{title}</Title>
97
- )}
98
- <Subtitle data-testid="trip-cards-subtitle">{description}</Subtitle>
99
- </TitleContent>
100
- {titleurl && (
101
- <TitleLink
102
- href={titleurl}
103
- target="_blank"
104
- rel="noopener noreferrer"
105
- data-testid="title-link"
106
- >
107
- <ChevronRightIcon />
108
- </TitleLink>
109
- )}
110
- </TitleBar>
111
- </TitleSection>
112
-
113
- {!shouldUseCarousel ? (
114
- <StaticCardsGrid data-testid="static-cards-grid" ref={gridRef}>
115
- {items.map(item => (
116
- <CardComponent
117
- imgHeight={imgHeight}
118
- key={item.id}
119
- card={item.data}
120
- isStaticGrid={true}
121
- forceStaticGrid={forceStaticGrid}
122
- />
123
- ))}
124
- </StaticCardsGrid>
125
- ) : (
126
- <CarouselComponent
127
- items={items.map(item => (
128
- <CarouselItem
129
- key={item.id}
130
- widthItemConfig={widthItemConfig}
131
- maxWidthItemConfig={maxWidthItemConfig}
132
- >
133
- <CardComponent card={item.data} imgHeight={imgHeight} />
134
- </CarouselItem>
135
- ))}
136
- options={{
137
- itemsPerPage
138
- }}
139
- showArrows={!isStaticGrid}
140
- showDots={true}
141
- />
142
- )}
143
- </Container>
144
- );
145
- };
@@ -1,169 +0,0 @@
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
- });