@times-components/ts-components 1.146.2-be27d508c972211ad80599875cd69c63bf67d4b1.45 → 1.146.2-e5795a0ef59e2adb61ba52aeb7332fda4405cb7a.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.
Files changed (156) hide show
  1. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.d.ts +10 -0
  2. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.js +69 -0
  3. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.d.ts +12 -0
  4. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.js +90 -0
  5. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.d.ts +12 -0
  6. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.js +10 -0
  7. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.js +24 -0
  8. package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.js +57 -0
  9. package/dist/components/{carousel-component/__tests__/DefaultPageDot.test.d.ts → opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.d.ts} +1 -0
  10. package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.js +48 -0
  11. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.d.ts +1 -0
  12. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.js +19 -0
  13. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.d.ts +12 -0
  14. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.js +67 -0
  15. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.d.ts +6 -0
  16. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +736 -0
  17. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.js +33 -0
  18. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.js +36 -0
  19. package/dist/components/opta/football/opta-match-stats/shared/styles.js +8 -1
  20. package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.js +2 -2
  21. package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.js +1 -1
  22. package/dist/components/opta/football/opta-match-stats/summary/WidgetContainer.js +19 -5
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +2 -2
  25. package/package.json +3 -3
  26. package/rnw.js +1 -1
  27. package/src/components/opta/football/opta-match-stats/commentary/__tests__/__snapshots__/OptaMatchStatsCommentary.test.tsx.snap +1 -1
  28. package/src/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.tsx +108 -0
  29. package/src/components/opta/football/opta-match-stats/matchday-live/MobileWidget.tsx +158 -0
  30. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.tsx +38 -0
  31. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.tsx +23 -0
  32. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.tsx +69 -0
  33. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.tsx +61 -0
  34. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +61 -0
  35. package/src/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.tsx +19 -0
  36. package/src/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.tsx +81 -0
  37. package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +767 -0
  38. package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.tsx +67 -0
  39. package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.tsx +64 -0
  40. package/src/components/opta/football/opta-match-stats/shared/styles.ts +8 -0
  41. package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/__snapshots__/OptaMatchStatsGraphs.test.tsx.snap +1 -1
  42. package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.tsx +1 -1
  43. package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.tsx +1 -1
  44. package/src/components/opta/football/opta-match-stats/summary/WidgetContainer.tsx +18 -4
  45. package/src/components/opta/football/opta-match-stats/summary/__tests__/__snapshots__/OptaMatchStatsSummary.test.tsx.snap +1 -1
  46. package/src/index.ts +3 -2
  47. package/dist/components/carousel-component/CarouselComponent.stories.js +0 -146
  48. package/dist/components/carousel-component/CarouselItem.d.ts +0 -3
  49. package/dist/components/carousel-component/CarouselItem.js +0 -12
  50. package/dist/components/carousel-component/DefaultNavigationArrow.d.ts +0 -8
  51. package/dist/components/carousel-component/DefaultNavigationArrow.js +0 -6
  52. package/dist/components/carousel-component/DefaultPageDot.d.ts +0 -8
  53. package/dist/components/carousel-component/DefaultPageDot.js +0 -4
  54. package/dist/components/carousel-component/__tests__/CarouselComponent.test.js +0 -163
  55. package/dist/components/carousel-component/__tests__/CarouselItem.test.js +0 -80
  56. package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.js +0 -62
  57. package/dist/components/carousel-component/__tests__/DefaultPageDot.test.js +0 -68
  58. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.d.ts +0 -1
  59. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.js +0 -459
  60. package/dist/components/carousel-component/hooks/useCarousel.d.ts +0 -2
  61. package/dist/components/carousel-component/hooks/useCarousel.js +0 -167
  62. package/dist/components/carousel-component/index.d.ts +0 -4
  63. package/dist/components/carousel-component/index.js +0 -20
  64. package/dist/components/carousel-component/styles.d.ts +0 -28
  65. package/dist/components/carousel-component/styles.js +0 -172
  66. package/dist/components/carousel-component/types.d.ts +0 -53
  67. package/dist/components/carousel-component/types.js +0 -2
  68. package/dist/components/trip-cards/SkeletonCard.d.ts +0 -7
  69. package/dist/components/trip-cards/SkeletonCard.js +0 -22
  70. package/dist/components/trip-cards/TripCard.d.ts +0 -3
  71. package/dist/components/trip-cards/TripCard.js +0 -49
  72. package/dist/components/trip-cards/TripCards.stories.d.ts +0 -1
  73. package/dist/components/trip-cards/TripCards.stories.js +0 -159
  74. package/dist/components/trip-cards/TripCardsLayout.d.ts +0 -3
  75. package/dist/components/trip-cards/TripCardsLayout.js +0 -56
  76. package/dist/components/trip-cards/__tests__/SkeletonCard.test.d.ts +0 -1
  77. package/dist/components/trip-cards/__tests__/SkeletonCard.test.js +0 -139
  78. package/dist/components/trip-cards/__tests__/TripCard.test.d.ts +0 -1
  79. package/dist/components/trip-cards/__tests__/TripCard.test.js +0 -95
  80. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.d.ts +0 -1
  81. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.js +0 -314
  82. package/dist/components/trip-cards/__tests__/assets.test.d.ts +0 -1
  83. package/dist/components/trip-cards/__tests__/assets.test.js +0 -165
  84. package/dist/components/trip-cards/__tests__/helpers.test.d.ts +0 -1
  85. package/dist/components/trip-cards/__tests__/helpers.test.js +0 -220
  86. package/dist/components/trip-cards/__tests__/index.test.d.ts +0 -1
  87. package/dist/components/trip-cards/__tests__/index.test.js +0 -478
  88. package/dist/components/trip-cards/__tests__/mockData.test.d.ts +0 -1
  89. package/dist/components/trip-cards/__tests__/mockData.test.js +0 -57
  90. package/dist/components/trip-cards/__tests__/skeletonStyles.test.d.ts +0 -1
  91. package/dist/components/trip-cards/__tests__/skeletonStyles.test.js +0 -194
  92. package/dist/components/trip-cards/assets/BoatIcon.d.ts +0 -1
  93. package/dist/components/trip-cards/assets/BoatIcon.js +0 -4
  94. package/dist/components/trip-cards/assets/CalendarIcon.d.ts +0 -1
  95. package/dist/components/trip-cards/assets/CalendarIcon.js +0 -4
  96. package/dist/components/trip-cards/assets/ChevronRightIcon.d.ts +0 -1
  97. package/dist/components/trip-cards/assets/ChevronRightIcon.js +0 -4
  98. package/dist/components/trip-cards/assets/LocationIcon.d.ts +0 -1
  99. package/dist/components/trip-cards/assets/LocationIcon.js +0 -4
  100. package/dist/components/trip-cards/assets/MoonIcon.d.ts +0 -1
  101. package/dist/components/trip-cards/assets/MoonIcon.js +0 -4
  102. package/dist/components/trip-cards/assets/index.d.ts +0 -6
  103. package/dist/components/trip-cards/assets/index.js +0 -7
  104. package/dist/components/trip-cards/helpers.d.ts +0 -11
  105. package/dist/components/trip-cards/helpers.js +0 -138
  106. package/dist/components/trip-cards/index.d.ts +0 -4
  107. package/dist/components/trip-cards/index.js +0 -68
  108. package/dist/components/trip-cards/mockData.d.ts +0 -3
  109. package/dist/components/trip-cards/mockData.js +0 -317
  110. package/dist/components/trip-cards/skeletonStyles.d.ts +0 -9
  111. package/dist/components/trip-cards/skeletonStyles.js +0 -37
  112. package/dist/components/trip-cards/styles.d.ts +0 -43
  113. package/dist/components/trip-cards/styles.js +0 -404
  114. package/dist/components/trip-cards/types.d.ts +0 -119
  115. package/dist/components/trip-cards/types.js +0 -2
  116. package/src/components/carousel-component/CarouselComponent.stories.tsx +0 -220
  117. package/src/components/carousel-component/CarouselItem.tsx +0 -26
  118. package/src/components/carousel-component/DefaultNavigationArrow.tsx +0 -37
  119. package/src/components/carousel-component/DefaultPageDot.tsx +0 -20
  120. package/src/components/carousel-component/__tests__/CarouselComponent.test.tsx +0 -259
  121. package/src/components/carousel-component/__tests__/CarouselItem.test.tsx +0 -140
  122. package/src/components/carousel-component/__tests__/DefaultNavigationArrow.test.tsx +0 -153
  123. package/src/components/carousel-component/__tests__/DefaultPageDot.test.tsx +0 -105
  124. package/src/components/carousel-component/hooks/__tests__/useCarousel.test.ts +0 -625
  125. package/src/components/carousel-component/hooks/useCarousel.ts +0 -229
  126. package/src/components/carousel-component/index.tsx +0 -92
  127. package/src/components/carousel-component/styles.ts +0 -188
  128. package/src/components/carousel-component/types.ts +0 -62
  129. package/src/components/trip-cards/SkeletonCard.tsx +0 -64
  130. package/src/components/trip-cards/TripCard.tsx +0 -140
  131. package/src/components/trip-cards/TripCards.stories.tsx +0 -224
  132. package/src/components/trip-cards/TripCardsLayout.tsx +0 -145
  133. package/src/components/trip-cards/__tests__/SkeletonCard.test.tsx +0 -169
  134. package/src/components/trip-cards/__tests__/TripCard.test.tsx +0 -120
  135. package/src/components/trip-cards/__tests__/TripCardsLayout.test.tsx +0 -583
  136. package/src/components/trip-cards/__tests__/assets.test.tsx +0 -206
  137. package/src/components/trip-cards/__tests__/helpers.test.ts +0 -272
  138. package/src/components/trip-cards/__tests__/index.test.tsx +0 -550
  139. package/src/components/trip-cards/__tests__/mockData.test.ts +0 -67
  140. package/src/components/trip-cards/__tests__/skeletonStyles.test.tsx +0 -256
  141. package/src/components/trip-cards/assets/BoatIcon.tsx +0 -17
  142. package/src/components/trip-cards/assets/CalendarIcon.tsx +0 -17
  143. package/src/components/trip-cards/assets/ChevronRightIcon.tsx +0 -20
  144. package/src/components/trip-cards/assets/LocationIcon.tsx +0 -17
  145. package/src/components/trip-cards/assets/MoonIcon.tsx +0 -17
  146. package/src/components/trip-cards/assets/index.ts +0 -7
  147. package/src/components/trip-cards/helpers.ts +0 -176
  148. package/src/components/trip-cards/index.tsx +0 -119
  149. package/src/components/trip-cards/mockData.ts +0 -345
  150. package/src/components/trip-cards/skeletonStyles.ts +0 -46
  151. package/src/components/trip-cards/styles.ts +0 -450
  152. package/src/components/trip-cards/types.ts +0 -128
  153. /package/dist/components/{carousel-component/CarouselComponent.stories.d.ts → opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.d.ts} +0 -0
  154. /package/dist/components/{carousel-component/__tests__/CarouselComponent.test.d.ts → opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.d.ts} +0 -0
  155. /package/dist/components/{carousel-component/__tests__/CarouselItem.test.d.ts → opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.d.ts} +0 -0
  156. /package/dist/components/{carousel-component/__tests__/DefaultNavigationArrow.test.d.ts → opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.d.ts} +0 -0
@@ -1,229 +0,0 @@
1
- import { useState, useEffect, useRef, useCallback } from 'react';
2
- import { UseCarouselOptions, UseCarouselReturn } from '../types';
3
-
4
- const DRAG_THRESHOLD = 30;
5
-
6
- export const useCarousel = (
7
- totalItems: number,
8
- options: UseCarouselOptions = {}
9
- ): UseCarouselReturn => {
10
- const { itemsPerPage = 2, onPageChange } = options;
11
-
12
- const [currentPage, setCurrentPage] = useState(0);
13
- const carouselRef = useRef<HTMLDivElement>(null);
14
- const isScrollingRef = useRef(false);
15
- const isDraggingRef = useRef(false);
16
- const startXRef = useRef(0);
17
- const touchStartXRef = useRef<number | null>(null);
18
- const isSwipingRef = useRef(false);
19
-
20
- const totalPages = Math.ceil(totalItems / itemsPerPage);
21
-
22
- const scrollToPage = useCallback(
23
- (page: number) => {
24
- if (carouselRef.current) {
25
- const cardElements = carouselRef.current.children;
26
-
27
- if (cardElements.length > 0) {
28
- isScrollingRef.current = true;
29
-
30
- const container = carouselRef.current;
31
- const targetCardIndex = page * itemsPerPage;
32
- const targetCard = cardElements[targetCardIndex] as HTMLElement;
33
-
34
- if (targetCard) {
35
- const targetScroll = targetCard.offsetLeft;
36
-
37
- container.scrollTo({
38
- left: targetScroll,
39
- behavior: 'smooth'
40
- });
41
- setCurrentPage(page);
42
-
43
- if (onPageChange) {
44
- onPageChange(page);
45
- }
46
-
47
- setTimeout(() => {
48
- isScrollingRef.current = false;
49
- }, 400);
50
- }
51
- }
52
- }
53
- },
54
- [itemsPerPage, onPageChange]
55
- );
56
-
57
- const handlePrevious = useCallback(
58
- () => {
59
- const newPage = Math.max(0, currentPage - 1);
60
- scrollToPage(newPage);
61
- },
62
- [currentPage, scrollToPage]
63
- );
64
-
65
- const handleNext = useCallback(
66
- () => {
67
- const newPage = Math.min(totalPages - 1, currentPage + 1);
68
- scrollToPage(newPage);
69
- },
70
- [currentPage, totalPages, scrollToPage]
71
- );
72
-
73
- const handleDragNavigation = useCallback(
74
- (diff: number) => {
75
- if (Math.abs(diff) > DRAG_THRESHOLD) {
76
- if (diff > 0) {
77
- handleNext();
78
- } else {
79
- handlePrevious();
80
- }
81
- }
82
- },
83
- [handleNext, handlePrevious]
84
- );
85
-
86
- const handleMouseDown = useCallback((e: React.MouseEvent) => {
87
- if (!carouselRef.current) {
88
- return;
89
- }
90
- e.preventDefault();
91
- isDraggingRef.current = true;
92
- startXRef.current = e.pageX;
93
- carouselRef.current.style.cursor = 'grabbing';
94
- }, []);
95
-
96
- const handleMouseUp = useCallback(
97
- (e: React.MouseEvent) => {
98
- if (!isDraggingRef.current) {
99
- return;
100
- }
101
- isDraggingRef.current = false;
102
-
103
- if (carouselRef.current) {
104
- carouselRef.current.style.cursor = 'grab';
105
-
106
- const endX = e.pageX;
107
- const diff = startXRef.current - endX;
108
-
109
- handleDragNavigation(diff);
110
- }
111
- },
112
- [handleDragNavigation]
113
- );
114
-
115
- const handleMouseLeave = useCallback(
116
- (e: React.MouseEvent) => {
117
- if (!isDraggingRef.current) {
118
- return;
119
- }
120
- isDraggingRef.current = false;
121
-
122
- if (carouselRef.current) {
123
- carouselRef.current.style.cursor = 'grab';
124
-
125
- const endX = e.pageX;
126
- const diff = startXRef.current - endX;
127
-
128
- handleDragNavigation(diff);
129
- }
130
- },
131
- [handleDragNavigation]
132
- );
133
-
134
- const handleTouchStart = (e: React.TouchEvent) => {
135
- if (!carouselRef.current) {
136
- return;
137
- }
138
- touchStartXRef.current = e.touches[0].clientX;
139
- isSwipingRef.current = false;
140
- };
141
-
142
- const handleTouchMove = (e: React.TouchEvent) => {
143
- if (touchStartXRef.current === null || isSwipingRef.current) {
144
- return;
145
- }
146
-
147
- const currentX = e.touches[0].clientX;
148
- const diff = touchStartXRef.current - currentX;
149
-
150
- if (Math.abs(diff) > DRAG_THRESHOLD) {
151
- isSwipingRef.current = true;
152
- handleDragNavigation(diff);
153
- }
154
- };
155
-
156
- const handleTouchEnd = () => {
157
- touchStartXRef.current = null;
158
- isSwipingRef.current = false;
159
- };
160
-
161
- const handleScroll = useCallback(
162
- () => {
163
- if (isScrollingRef.current) {
164
- return;
165
- }
166
-
167
- if (carouselRef.current) {
168
- const container = carouselRef.current;
169
- const children = container.children;
170
- if (children.length === 0) {
171
- return;
172
- }
173
-
174
- const scrollLeft = container.scrollLeft;
175
-
176
- let closestPage = 0;
177
- let closestDistance = Infinity;
178
-
179
- for (let page = 0; page < totalPages; page++) {
180
- const cardIndex = page * itemsPerPage;
181
- if (cardIndex < children.length) {
182
- const card = children[cardIndex] as HTMLElement;
183
- const distance = Math.abs(card.offsetLeft - scrollLeft);
184
- if (distance < closestDistance) {
185
- closestDistance = distance;
186
- closestPage = page;
187
- }
188
- }
189
- }
190
-
191
- if (closestPage !== currentPage) {
192
- setCurrentPage(closestPage);
193
- if (onPageChange) {
194
- onPageChange(closestPage);
195
- }
196
- }
197
- }
198
- },
199
- [totalPages, itemsPerPage, onPageChange]
200
- );
201
-
202
- useEffect(
203
- () => {
204
- const carousel = carouselRef.current;
205
- if (carousel) {
206
- carousel.addEventListener('scroll', handleScroll);
207
- return () => carousel.removeEventListener('scroll', handleScroll);
208
- }
209
- return undefined;
210
- },
211
- [handleScroll]
212
- );
213
-
214
- return {
215
- currentPage,
216
- totalPages,
217
- carouselRef,
218
- isScrolling: isScrollingRef.current,
219
- handlePrevious,
220
- handleNext,
221
- scrollToPage,
222
- handleMouseDown,
223
- handleMouseUp,
224
- handleMouseLeave,
225
- handleTouchStart,
226
- handleTouchMove,
227
- handleTouchEnd
228
- };
229
- };
@@ -1,92 +0,0 @@
1
- import React from 'react';
2
- import { useCarousel } from './hooks/useCarousel';
3
- import {
4
- CarouselContainer,
5
- CarouselWrapper,
6
- CarouselContent,
7
- CardsRow,
8
- PageControl
9
- } from './styles';
10
- import { DefaultNavigationArrow } from './DefaultNavigationArrow';
11
- import { DefaultPageDot } from './DefaultPageDot';
12
- import { CarouselComponentProps } from './types';
13
-
14
- export const CarouselComponent: React.FC<CarouselComponentProps> = ({
15
- items,
16
- options,
17
- showArrows = true,
18
- showDots = true,
19
- arrowComponent: CustomArrow,
20
- dotComponent: CustomDot,
21
- className
22
- }) => {
23
- const {
24
- currentPage,
25
- totalPages,
26
- carouselRef,
27
- handlePrevious,
28
- handleNext,
29
- scrollToPage,
30
- handleMouseDown,
31
- handleMouseUp,
32
- handleMouseLeave,
33
- handleTouchStart,
34
- handleTouchMove,
35
- handleTouchEnd
36
- } = useCarousel(items.length, options);
37
-
38
- const ArrowComponent = CustomArrow || DefaultNavigationArrow;
39
- const DotComponent = CustomDot || DefaultPageDot;
40
-
41
- return (
42
- <CarouselContainer className={className}>
43
- <CarouselWrapper>
44
- {showArrows && (
45
- <ArrowComponent
46
- direction="left"
47
- onClick={handlePrevious}
48
- disabled={currentPage === 0}
49
- />
50
- )}
51
-
52
- <CarouselContent>
53
- <CardsRow
54
- ref={carouselRef}
55
- onMouseDown={handleMouseDown}
56
- onMouseUp={handleMouseUp}
57
- onMouseLeave={handleMouseLeave}
58
- onTouchStart={handleTouchStart}
59
- onTouchMove={handleTouchMove}
60
- onTouchEnd={handleTouchEnd}
61
- >
62
- {items}
63
- </CardsRow>
64
- </CarouselContent>
65
-
66
- {showArrows && (
67
- <ArrowComponent
68
- direction="right"
69
- onClick={handleNext}
70
- disabled={currentPage >= totalPages - 1}
71
- />
72
- )}
73
- </CarouselWrapper>
74
-
75
- {showDots &&
76
- totalPages > 1 && (
77
- <PageControl>
78
- {Array.from({ length: totalPages }).map((_, pageIndex) => (
79
- <DotComponent
80
- key={pageIndex}
81
- active={pageIndex === currentPage}
82
- onClick={() => scrollToPage(pageIndex)}
83
- index={pageIndex}
84
- />
85
- ))}
86
- </PageControl>
87
- )}
88
- </CarouselContainer>
89
- );
90
- };
91
-
92
- export { CarouselItem } from './CarouselItem';
@@ -1,188 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
- import { ResponsiveConfig } from './types';
3
- export const breakpoints = {
4
- xs: '0px',
5
- sm: '520px',
6
- md: '768px',
7
- lg: '1024px',
8
- xl: '1320px'
9
- };
10
-
11
- export const colors = {
12
- primary: '#005C8A',
13
- white: '#FFFFFF'
14
- };
15
-
16
- export const ItemContainer = styled.div<{
17
- widthItemConfig?: ResponsiveConfig;
18
- maxWidthItemConfig?: ResponsiveConfig;
19
- }>`
20
- scroll-snap-align: start;
21
- display: flex;
22
- flex-direction: column;
23
- align-self: stretch;
24
-
25
- ${props => {
26
- if (!props.widthItemConfig) {
27
- return '';
28
- }
29
- const { xs, mobile, tablet, desktop, xl } = props.widthItemConfig;
30
- return css`
31
- ${xs && `flex: 0 0 ${xs};`}
32
- ${mobile &&
33
- `
34
- @media (min-width: ${breakpoints.sm}) {
35
- flex: 0 0 ${mobile};
36
- }
37
- `}
38
- ${tablet &&
39
- `
40
- @media (min-width: ${breakpoints.md}) {
41
- flex: 0 0 ${tablet};
42
- }
43
- `}
44
- ${desktop &&
45
- `
46
- @media (min-width: ${breakpoints.lg}) {
47
- flex: 0 0 ${desktop};
48
- }
49
- `}
50
- ${xl &&
51
- `
52
- @media (min-width: ${breakpoints.xl}) {
53
- flex: 0 0 ${xl};
54
- }
55
- `}
56
- `;
57
- }} ${props => {
58
- if (!props.maxWidthItemConfig) {
59
- return '';
60
- }
61
- const { xs, mobile, tablet, desktop, xl } = props.maxWidthItemConfig;
62
- return css`
63
- ${xs && `max-width: ${xs};`}
64
- ${mobile &&
65
- `
66
- @media (min-width: ${breakpoints.sm}) {
67
- max-width: ${mobile};
68
- }
69
- `}
70
- ${tablet &&
71
- `
72
- @media (min-width: ${breakpoints.md}) {
73
- max-width: ${tablet};
74
- }
75
- `}
76
- ${desktop &&
77
- `
78
- @media (min-width: ${breakpoints.lg}) {
79
- max-width: ${desktop};
80
- }
81
- `}
82
- ${xl &&
83
- `
84
- @media (min-width: ${breakpoints.xl}) {
85
- max-width: ${xl};
86
- }
87
- `}
88
- `;
89
- }};
90
- `;
91
-
92
- export const CarouselContainer = styled.div`
93
- width: 100%;
94
- `;
95
-
96
- export const CarouselWrapper = styled.div`
97
- position: relative;
98
- width: 100%;
99
- `;
100
-
101
- export const CarouselContent = styled.div`
102
- overflow: hidden;
103
- `;
104
-
105
- export const CardsRow = styled.div`
106
- display: flex;
107
- gap: 20px;
108
- overflow-x: hidden;
109
- scroll-snap-type: x mandatory;
110
- scrollbar-width: none;
111
- -ms-overflow-style: none;
112
- padding: 0;
113
- scroll-behavior: smooth;
114
- cursor: grab;
115
- user-select: none;
116
- align-items: stretch;
117
-
118
- &::-webkit-scrollbar {
119
- display: none;
120
- }
121
-
122
- &:active {
123
- cursor: grabbing;
124
- }
125
- `;
126
-
127
- export const PageControl = styled.div`
128
- display: flex;
129
- justify-content: center;
130
- align-items: center;
131
- gap: 10px;
132
- padding: 12px;
133
- background: ${colors.white};
134
- `;
135
-
136
- export const NavigationArrowButton = styled.button<{
137
- direction: 'left' | 'right';
138
- disabled?: boolean;
139
- }>`
140
- display: none;
141
- position: absolute;
142
- top: 50%;
143
- transform: translateY(-50%);
144
- ${({ direction }) =>
145
- direction === 'left' ? 'left: -68px;' : 'right: -68px;'} z-index: 10;
146
- width: 48px;
147
- height: 48px;
148
- border: none;
149
- border-radius: 50%;
150
- background: ${({ disabled }) => (disabled ? '#CCCCCC' : colors.primary)};
151
- cursor: ${({ disabled }) => (disabled ? 'default' : 'pointer')};
152
- align-items: center;
153
- justify-content: center;
154
- transition: background 0.2s ease;
155
- pointer-events: ${({ disabled }) => (disabled ? 'none' : 'auto')};
156
-
157
- svg {
158
- width: 24px;
159
- height: 24px;
160
- }
161
-
162
- svg path {
163
- stroke: ${colors.white};
164
- }
165
-
166
- &:hover:not(:disabled) {
167
- background: #004a6e;
168
- }
169
-
170
- @media (min-width: ${breakpoints.lg}) {
171
- display: flex;
172
- }
173
- `;
174
-
175
- export const PageDotButton = styled.button<{ active: boolean }>`
176
- width: 8px;
177
- height: 8px;
178
- border-radius: 1000px;
179
- border: none;
180
- padding: 0;
181
- background: ${({ active }) => (active ? '#01000D' : '#AAAAAA')};
182
- cursor: pointer;
183
- transition: background 0.2s ease;
184
-
185
- &:hover {
186
- background: #01000d;
187
- }
188
- `;
@@ -1,62 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- export interface ResponsiveConfig {
4
- xs?: string;
5
- mobile?: string;
6
- tablet?: string;
7
- desktop?: string;
8
- xl?: string;
9
- }
10
-
11
- export type ResponsiveConfigNoXs = Omit<ResponsiveConfig, 'xs'>;
12
-
13
- export interface ArrowComponentProps {
14
- direction: 'left' | 'right';
15
- onClick: () => void;
16
- disabled: boolean;
17
- }
18
-
19
- export interface DotComponentProps {
20
- active: boolean;
21
- onClick: () => void;
22
- index: number;
23
- }
24
-
25
- export interface CarouselComponentProps {
26
- items: ReactNode[];
27
- options?: UseCarouselOptions;
28
- showArrows?: boolean;
29
- showDots?: boolean;
30
- arrowComponent?: React.ComponentType<ArrowComponentProps>;
31
- dotComponent?: React.ComponentType<DotComponentProps>;
32
- className?: string;
33
- }
34
-
35
- export interface CarouselItemProps {
36
- children: ReactNode;
37
- widthItemConfig?: ResponsiveConfig;
38
- maxWidthItemConfig?: ResponsiveConfig;
39
- className?: string;
40
- }
41
-
42
- // Carousel Hook Types
43
- export interface UseCarouselOptions {
44
- itemsPerPage?: number;
45
- onPageChange?: (page: number) => void;
46
- }
47
-
48
- export interface UseCarouselReturn {
49
- currentPage: number;
50
- totalPages: number;
51
- carouselRef: React.RefObject<HTMLDivElement>;
52
- isScrolling: boolean;
53
- handlePrevious: () => void;
54
- handleNext: () => void;
55
- scrollToPage: (page: number) => void;
56
- handleMouseDown: (e: React.MouseEvent) => void;
57
- handleMouseUp: (e: React.MouseEvent) => void;
58
- handleMouseLeave: (e: React.MouseEvent<Element, MouseEvent>) => void;
59
- handleTouchStart: (e: React.TouchEvent) => void;
60
- handleTouchMove: (e: React.TouchEvent) => void;
61
- handleTouchEnd: () => void;
62
- }
@@ -1,64 +0,0 @@
1
- import React, { FC } from 'react';
2
- import { Placeholder } from '@times-components/image';
3
- import {
4
- CardContainer,
5
- ImageContainer,
6
- CardContent,
7
- TopContainer,
8
- BottomContainer,
9
- DataPointsList,
10
- DataPoint,
11
- PriceSection,
12
- PriceContainer
13
- } from './styles';
14
- import {
15
- SkeletonLine,
16
- SkeletonHeadline,
17
- SkeletonPrice,
18
- SkeletonButton
19
- } from './skeletonStyles';
20
- import { ImageHeightConfig } from './types';
21
- import { defaultTripCardImgHeight } from './helpers';
22
-
23
- export const SkeletonCard: FC<{
24
- isStaticGrid?: boolean;
25
- imgHeight?: ImageHeightConfig;
26
- forceStaticGrid?: boolean;
27
- }> = ({ isStaticGrid, imgHeight = {}, forceStaticGrid }) => {
28
- return (
29
- <CardContainer data-testid="skeleton-card-container">
30
- <ImageContainer
31
- data-testid="skeleton-image-container"
32
- isStaticGrid={isStaticGrid && !forceStaticGrid}
33
- {...{ ...defaultTripCardImgHeight, ...imgHeight }}
34
- >
35
- <Placeholder />
36
- </ImageContainer>
37
- <CardContent data-testid="skeleton-card-content">
38
- <TopContainer data-testid="skeleton-top-container">
39
- <SkeletonHeadline data-testid="skeleton-headline" />
40
- <DataPointsList data-testid="skeleton-data-points-list">
41
- {[1, 2, 3, 4].map(i => (
42
- <DataPoint key={i} data-testid={`skeleton-data-point-${i}`}>
43
- <SkeletonLine width="80px" data-testid={`skeleton-line-${i}`} />
44
- </DataPoint>
45
- ))}
46
- </DataPointsList>
47
- </TopContainer>
48
- <BottomContainer data-testid="skeleton-bottom-container">
49
- <PriceSection data-testid="skeleton-price-section">
50
- <PriceContainer data-testid="skeleton-price-container">
51
- <SkeletonLine
52
- width="40px"
53
- marginBottom="4px"
54
- data-testid="skeleton-price-label"
55
- />
56
- <SkeletonPrice data-testid="skeleton-price" />
57
- </PriceContainer>
58
- </PriceSection>
59
- <SkeletonButton as="div" data-testid="skeleton-button" />
60
- </BottomContainer>
61
- </CardContent>
62
- </CardContainer>
63
- );
64
- };