@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.
- package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.d.ts +10 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.js +69 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.d.ts +12 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.js +90 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.d.ts +12 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.js +10 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.js +24 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.js +57 -0
- package/dist/components/{carousel-component/__tests__/DefaultPageDot.test.d.ts → opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.d.ts} +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.js +48 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.js +19 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.d.ts +12 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.js +67 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.d.ts +6 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +736 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.js +33 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.js +36 -0
- package/dist/components/opta/football/opta-match-stats/shared/styles.js +8 -1
- 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 +19 -5
- 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/opta/football/opta-match-stats/commentary/__tests__/__snapshots__/OptaMatchStatsCommentary.test.tsx.snap +1 -1
- package/src/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.tsx +108 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/MobileWidget.tsx +158 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.tsx +38 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.tsx +23 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.tsx +69 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.tsx +61 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +61 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.tsx +19 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.tsx +81 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +767 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.tsx +67 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.tsx +64 -0
- package/src/components/opta/football/opta-match-stats/shared/styles.ts +8 -0
- 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 +18 -4
- package/src/components/opta/football/opta-match-stats/summary/__tests__/__snapshots__/OptaMatchStatsSummary.test.tsx.snap +1 -1
- package/src/index.ts +3 -2
- package/dist/components/carousel-component/CarouselComponent.stories.js +0 -146
- package/dist/components/carousel-component/CarouselItem.d.ts +0 -3
- package/dist/components/carousel-component/CarouselItem.js +0 -12
- package/dist/components/carousel-component/DefaultNavigationArrow.d.ts +0 -8
- package/dist/components/carousel-component/DefaultNavigationArrow.js +0 -6
- package/dist/components/carousel-component/DefaultPageDot.d.ts +0 -8
- package/dist/components/carousel-component/DefaultPageDot.js +0 -4
- package/dist/components/carousel-component/__tests__/CarouselComponent.test.js +0 -163
- package/dist/components/carousel-component/__tests__/CarouselItem.test.js +0 -80
- package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.js +0 -62
- package/dist/components/carousel-component/__tests__/DefaultPageDot.test.js +0 -68
- package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.d.ts +0 -1
- package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.js +0 -459
- package/dist/components/carousel-component/hooks/useCarousel.d.ts +0 -2
- package/dist/components/carousel-component/hooks/useCarousel.js +0 -167
- package/dist/components/carousel-component/index.d.ts +0 -4
- package/dist/components/carousel-component/index.js +0 -20
- package/dist/components/carousel-component/styles.d.ts +0 -28
- package/dist/components/carousel-component/styles.js +0 -172
- package/dist/components/carousel-component/types.d.ts +0 -53
- package/dist/components/carousel-component/types.js +0 -2
- package/dist/components/trip-cards/SkeletonCard.d.ts +0 -7
- package/dist/components/trip-cards/SkeletonCard.js +0 -22
- package/dist/components/trip-cards/TripCard.d.ts +0 -3
- package/dist/components/trip-cards/TripCard.js +0 -49
- package/dist/components/trip-cards/TripCards.stories.d.ts +0 -1
- package/dist/components/trip-cards/TripCards.stories.js +0 -159
- package/dist/components/trip-cards/TripCardsLayout.d.ts +0 -3
- package/dist/components/trip-cards/TripCardsLayout.js +0 -56
- package/dist/components/trip-cards/__tests__/SkeletonCard.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/SkeletonCard.test.js +0 -139
- package/dist/components/trip-cards/__tests__/TripCard.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/TripCard.test.js +0 -95
- package/dist/components/trip-cards/__tests__/TripCardsLayout.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/TripCardsLayout.test.js +0 -314
- package/dist/components/trip-cards/__tests__/assets.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/assets.test.js +0 -165
- package/dist/components/trip-cards/__tests__/helpers.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/helpers.test.js +0 -220
- package/dist/components/trip-cards/__tests__/index.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/index.test.js +0 -478
- package/dist/components/trip-cards/__tests__/mockData.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/mockData.test.js +0 -57
- package/dist/components/trip-cards/__tests__/skeletonStyles.test.d.ts +0 -1
- package/dist/components/trip-cards/__tests__/skeletonStyles.test.js +0 -194
- package/dist/components/trip-cards/assets/BoatIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/BoatIcon.js +0 -4
- package/dist/components/trip-cards/assets/CalendarIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/CalendarIcon.js +0 -4
- package/dist/components/trip-cards/assets/ChevronRightIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/ChevronRightIcon.js +0 -4
- package/dist/components/trip-cards/assets/LocationIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/LocationIcon.js +0 -4
- package/dist/components/trip-cards/assets/MoonIcon.d.ts +0 -1
- package/dist/components/trip-cards/assets/MoonIcon.js +0 -4
- package/dist/components/trip-cards/assets/index.d.ts +0 -6
- package/dist/components/trip-cards/assets/index.js +0 -7
- package/dist/components/trip-cards/helpers.d.ts +0 -11
- package/dist/components/trip-cards/helpers.js +0 -138
- package/dist/components/trip-cards/index.d.ts +0 -4
- package/dist/components/trip-cards/index.js +0 -68
- package/dist/components/trip-cards/mockData.d.ts +0 -3
- package/dist/components/trip-cards/mockData.js +0 -317
- package/dist/components/trip-cards/skeletonStyles.d.ts +0 -9
- package/dist/components/trip-cards/skeletonStyles.js +0 -37
- package/dist/components/trip-cards/styles.d.ts +0 -43
- package/dist/components/trip-cards/styles.js +0 -404
- package/dist/components/trip-cards/types.d.ts +0 -119
- package/dist/components/trip-cards/types.js +0 -2
- package/src/components/carousel-component/CarouselComponent.stories.tsx +0 -220
- package/src/components/carousel-component/CarouselItem.tsx +0 -26
- package/src/components/carousel-component/DefaultNavigationArrow.tsx +0 -37
- package/src/components/carousel-component/DefaultPageDot.tsx +0 -20
- package/src/components/carousel-component/__tests__/CarouselComponent.test.tsx +0 -259
- package/src/components/carousel-component/__tests__/CarouselItem.test.tsx +0 -140
- package/src/components/carousel-component/__tests__/DefaultNavigationArrow.test.tsx +0 -153
- package/src/components/carousel-component/__tests__/DefaultPageDot.test.tsx +0 -105
- package/src/components/carousel-component/hooks/__tests__/useCarousel.test.ts +0 -625
- package/src/components/carousel-component/hooks/useCarousel.ts +0 -229
- package/src/components/carousel-component/index.tsx +0 -92
- package/src/components/carousel-component/styles.ts +0 -188
- package/src/components/carousel-component/types.ts +0 -62
- package/src/components/trip-cards/SkeletonCard.tsx +0 -64
- package/src/components/trip-cards/TripCard.tsx +0 -140
- package/src/components/trip-cards/TripCards.stories.tsx +0 -224
- package/src/components/trip-cards/TripCardsLayout.tsx +0 -145
- package/src/components/trip-cards/__tests__/SkeletonCard.test.tsx +0 -169
- package/src/components/trip-cards/__tests__/TripCard.test.tsx +0 -120
- package/src/components/trip-cards/__tests__/TripCardsLayout.test.tsx +0 -583
- package/src/components/trip-cards/__tests__/assets.test.tsx +0 -206
- package/src/components/trip-cards/__tests__/helpers.test.ts +0 -272
- package/src/components/trip-cards/__tests__/index.test.tsx +0 -550
- package/src/components/trip-cards/__tests__/mockData.test.ts +0 -67
- package/src/components/trip-cards/__tests__/skeletonStyles.test.tsx +0 -256
- package/src/components/trip-cards/assets/BoatIcon.tsx +0 -17
- package/src/components/trip-cards/assets/CalendarIcon.tsx +0 -17
- package/src/components/trip-cards/assets/ChevronRightIcon.tsx +0 -20
- package/src/components/trip-cards/assets/LocationIcon.tsx +0 -17
- package/src/components/trip-cards/assets/MoonIcon.tsx +0 -17
- package/src/components/trip-cards/assets/index.ts +0 -7
- package/src/components/trip-cards/helpers.ts +0 -176
- package/src/components/trip-cards/index.tsx +0 -119
- package/src/components/trip-cards/mockData.ts +0 -345
- package/src/components/trip-cards/skeletonStyles.ts +0 -46
- package/src/components/trip-cards/styles.ts +0 -450
- package/src/components/trip-cards/types.ts +0 -128
- /package/dist/components/{carousel-component/CarouselComponent.stories.d.ts → opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.d.ts} +0 -0
- /package/dist/components/{carousel-component/__tests__/CarouselComponent.test.d.ts → opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.d.ts} +0 -0
- /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
- /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,220 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import { CarouselComponent, CarouselItem } from './index';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
|
|
6
|
-
// Simple card component for demos
|
|
7
|
-
const SimpleCard = styled.div<{ color: string }>`
|
|
8
|
-
background: ${props => props.color};
|
|
9
|
-
height: 300px;
|
|
10
|
-
border-radius: 8px;
|
|
11
|
-
display: flex;
|
|
12
|
-
align-items: center;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
color: white;
|
|
15
|
-
font-size: 24px;
|
|
16
|
-
font-weight: 600;
|
|
17
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
const Container = styled.div`
|
|
21
|
-
max-width: 1200px;
|
|
22
|
-
margin: 40px auto;
|
|
23
|
-
padding: 0 20px;
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const Title = styled.h2`
|
|
27
|
-
margin-bottom: 24px;
|
|
28
|
-
font-size: 24px;
|
|
29
|
-
font-weight: 600;
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
storiesOf('Typescript Component/CarouselComponent', module)
|
|
33
|
-
.add('Two Cards Per Page', () => {
|
|
34
|
-
const colors = [
|
|
35
|
-
'#005C8A',
|
|
36
|
-
'#FF6B6B',
|
|
37
|
-
'#4ECDC4',
|
|
38
|
-
'#45B7D1',
|
|
39
|
-
'#96CEB4',
|
|
40
|
-
'#FFEAA7'
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
const items = colors.map((color, index) => (
|
|
44
|
-
<CarouselItem
|
|
45
|
-
key={index}
|
|
46
|
-
widthItemConfig={{
|
|
47
|
-
mobile: '90%',
|
|
48
|
-
tablet: '70%',
|
|
49
|
-
desktop: 'calc(47% - 10px)'
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
<SimpleCard color={color}>Card {index + 1}</SimpleCard>
|
|
53
|
-
</CarouselItem>
|
|
54
|
-
));
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Container>
|
|
58
|
-
<Title>Two Cards Per Page (with peek)</Title>
|
|
59
|
-
<CarouselComponent
|
|
60
|
-
items={items}
|
|
61
|
-
options={{
|
|
62
|
-
itemsPerPage: 2
|
|
63
|
-
}}
|
|
64
|
-
showArrows={true}
|
|
65
|
-
showDots={true}
|
|
66
|
-
/>
|
|
67
|
-
</Container>
|
|
68
|
-
);
|
|
69
|
-
})
|
|
70
|
-
.add('Three Cards Per Page', () => {
|
|
71
|
-
const colors = [
|
|
72
|
-
'#005C8A',
|
|
73
|
-
'#FF6B6B',
|
|
74
|
-
'#4ECDC4',
|
|
75
|
-
'#45B7D1',
|
|
76
|
-
'#96CEB4',
|
|
77
|
-
'#FFEAA7',
|
|
78
|
-
'#DFE6E9',
|
|
79
|
-
'#74B9FF',
|
|
80
|
-
'#A29BFE'
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
const items = colors.map((color, index) => (
|
|
84
|
-
<CarouselItem
|
|
85
|
-
key={index}
|
|
86
|
-
widthItemConfig={{
|
|
87
|
-
mobile: '85%',
|
|
88
|
-
tablet: '40%',
|
|
89
|
-
desktop: 'calc(31% - 14px)'
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
<SimpleCard color={color}>Card {index + 1}</SimpleCard>
|
|
93
|
-
</CarouselItem>
|
|
94
|
-
));
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<Container>
|
|
98
|
-
<Title>Three Cards Per Page (with peek)</Title>
|
|
99
|
-
<CarouselComponent
|
|
100
|
-
items={items}
|
|
101
|
-
options={{
|
|
102
|
-
itemsPerPage: 3
|
|
103
|
-
}}
|
|
104
|
-
showArrows={true}
|
|
105
|
-
showDots={true}
|
|
106
|
-
/>
|
|
107
|
-
</Container>
|
|
108
|
-
);
|
|
109
|
-
})
|
|
110
|
-
.add('Minimal Example', () => {
|
|
111
|
-
const items = [
|
|
112
|
-
<CarouselItem
|
|
113
|
-
key="1"
|
|
114
|
-
widthItemConfig={{
|
|
115
|
-
mobile: '90%',
|
|
116
|
-
tablet: '70%',
|
|
117
|
-
desktop: 'calc(47% - 10px)'
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
<SimpleCard color="#005C8A">Card 1</SimpleCard>
|
|
121
|
-
</CarouselItem>,
|
|
122
|
-
<CarouselItem
|
|
123
|
-
key="2"
|
|
124
|
-
widthItemConfig={{
|
|
125
|
-
mobile: '90%',
|
|
126
|
-
tablet: '70%',
|
|
127
|
-
desktop: 'calc(47% - 10px)'
|
|
128
|
-
}}
|
|
129
|
-
>
|
|
130
|
-
<SimpleCard color="#FF6B6B">Card 2</SimpleCard>
|
|
131
|
-
</CarouselItem>,
|
|
132
|
-
<CarouselItem
|
|
133
|
-
key="3"
|
|
134
|
-
widthItemConfig={{
|
|
135
|
-
mobile: '90%',
|
|
136
|
-
tablet: '70%',
|
|
137
|
-
desktop: 'calc(47% - 10px)'
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
<SimpleCard color="#4ECDC4">Card 3</SimpleCard>
|
|
141
|
-
</CarouselItem>,
|
|
142
|
-
<CarouselItem
|
|
143
|
-
key="4"
|
|
144
|
-
widthItemConfig={{
|
|
145
|
-
mobile: '90%',
|
|
146
|
-
tablet: '70%',
|
|
147
|
-
desktop: 'calc(47% - 10px)'
|
|
148
|
-
}}
|
|
149
|
-
>
|
|
150
|
-
<SimpleCard color="#45B7D1">Card 4</SimpleCard>
|
|
151
|
-
</CarouselItem>
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<Container>
|
|
156
|
-
<Title>Simple 4 Cards</Title>
|
|
157
|
-
<CarouselComponent items={items} />
|
|
158
|
-
</Container>
|
|
159
|
-
);
|
|
160
|
-
})
|
|
161
|
-
.add('Without Navigation', () => {
|
|
162
|
-
const colors = ['#005C8A', '#FF6B6B', '#4ECDC4', '#45B7D1'];
|
|
163
|
-
|
|
164
|
-
const items = colors.map((color, index) => (
|
|
165
|
-
<CarouselItem
|
|
166
|
-
key={index}
|
|
167
|
-
widthItemConfig={{
|
|
168
|
-
mobile: '90%',
|
|
169
|
-
tablet: '70%',
|
|
170
|
-
desktop: 'calc(47% - 10px)'
|
|
171
|
-
}}
|
|
172
|
-
>
|
|
173
|
-
<SimpleCard color={color}>Card {index + 1}</SimpleCard>
|
|
174
|
-
</CarouselItem>
|
|
175
|
-
));
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<Container>
|
|
179
|
-
<Title>Scroll Only (No Arrows/Dots)</Title>
|
|
180
|
-
<CarouselComponent items={items} showArrows={false} showDots={false} />
|
|
181
|
-
</Container>
|
|
182
|
-
);
|
|
183
|
-
})
|
|
184
|
-
.add('Three Cards Exact Width (No Peek)', () => {
|
|
185
|
-
const colors = [
|
|
186
|
-
'#005C8A',
|
|
187
|
-
'#FF6B6B',
|
|
188
|
-
'#4ECDC4',
|
|
189
|
-
'#45B7D1',
|
|
190
|
-
'#96CEB4',
|
|
191
|
-
'#FFEAA7'
|
|
192
|
-
];
|
|
193
|
-
|
|
194
|
-
const items = colors.map((color, index) => (
|
|
195
|
-
<CarouselItem
|
|
196
|
-
key={index}
|
|
197
|
-
widthItemConfig={{
|
|
198
|
-
mobile: '90%',
|
|
199
|
-
tablet: '70%',
|
|
200
|
-
desktop: 'calc(33% - 10px)'
|
|
201
|
-
}}
|
|
202
|
-
>
|
|
203
|
-
<SimpleCard color={color}>Card {index + 1}</SimpleCard>
|
|
204
|
-
</CarouselItem>
|
|
205
|
-
));
|
|
206
|
-
|
|
207
|
-
return (
|
|
208
|
-
<Container>
|
|
209
|
-
<Title>Three Cards Per Page (exact width, no peek)</Title>
|
|
210
|
-
<CarouselComponent
|
|
211
|
-
items={items}
|
|
212
|
-
options={{
|
|
213
|
-
itemsPerPage: 3
|
|
214
|
-
}}
|
|
215
|
-
showArrows={true}
|
|
216
|
-
showDots={true}
|
|
217
|
-
/>
|
|
218
|
-
</Container>
|
|
219
|
-
);
|
|
220
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ItemContainer } from './styles';
|
|
3
|
-
import { CarouselItemProps } from './types';
|
|
4
|
-
|
|
5
|
-
export const CarouselItem: React.FC<CarouselItemProps> = ({
|
|
6
|
-
children,
|
|
7
|
-
widthItemConfig = {
|
|
8
|
-
xs: '85%',
|
|
9
|
-
mobile: '85%',
|
|
10
|
-
tablet: '70%',
|
|
11
|
-
desktop: 'calc(50% - 10px)',
|
|
12
|
-
xl: 'calc(50% - 10px)'
|
|
13
|
-
},
|
|
14
|
-
maxWidthItemConfig,
|
|
15
|
-
className
|
|
16
|
-
}) => {
|
|
17
|
-
return (
|
|
18
|
-
<ItemContainer
|
|
19
|
-
widthItemConfig={widthItemConfig}
|
|
20
|
-
maxWidthItemConfig={maxWidthItemConfig}
|
|
21
|
-
className={className}
|
|
22
|
-
>
|
|
23
|
-
{children}
|
|
24
|
-
</ItemContainer>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NavigationArrowButton } from './styles';
|
|
3
|
-
|
|
4
|
-
interface NavigationArrowProps {
|
|
5
|
-
direction: 'left' | 'right';
|
|
6
|
-
onClick: () => void;
|
|
7
|
-
disabled: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const DefaultNavigationArrow: React.FC<NavigationArrowProps> = ({
|
|
11
|
-
direction,
|
|
12
|
-
onClick,
|
|
13
|
-
disabled
|
|
14
|
-
}) => (
|
|
15
|
-
<NavigationArrowButton
|
|
16
|
-
direction={direction}
|
|
17
|
-
onClick={onClick}
|
|
18
|
-
disabled={disabled}
|
|
19
|
-
aria-label={`${direction === 'left' ? 'Previous' : 'Next'} items`}
|
|
20
|
-
>
|
|
21
|
-
<svg
|
|
22
|
-
width="24"
|
|
23
|
-
height="24"
|
|
24
|
-
viewBox="0 0 16 16"
|
|
25
|
-
fill="none"
|
|
26
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
-
>
|
|
28
|
-
<path
|
|
29
|
-
d={direction === 'left' ? 'M10 12L6 8L10 4' : 'M6 12L10 8L6 4'}
|
|
30
|
-
stroke="currentColor"
|
|
31
|
-
strokeWidth="1.5"
|
|
32
|
-
strokeLinecap="round"
|
|
33
|
-
strokeLinejoin="round"
|
|
34
|
-
/>
|
|
35
|
-
</svg>
|
|
36
|
-
</NavigationArrowButton>
|
|
37
|
-
);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PageDotButton } from './styles';
|
|
3
|
-
|
|
4
|
-
interface PageDotProps {
|
|
5
|
-
active: boolean;
|
|
6
|
-
onClick: () => void;
|
|
7
|
-
index: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const DefaultPageDot: React.FC<PageDotProps> = ({
|
|
11
|
-
active,
|
|
12
|
-
onClick,
|
|
13
|
-
index
|
|
14
|
-
}) => (
|
|
15
|
-
<PageDotButton
|
|
16
|
-
active={active}
|
|
17
|
-
onClick={onClick}
|
|
18
|
-
aria-label={`Go to page ${index + 1}`}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { CarouselComponent } from '../index';
|
|
5
|
-
|
|
6
|
-
describe('CarouselComponent', () => {
|
|
7
|
-
const mockItems = [
|
|
8
|
-
<div key="1">Item 1</div>,
|
|
9
|
-
<div key="2">Item 2</div>,
|
|
10
|
-
<div key="3">Item 3</div>,
|
|
11
|
-
<div key="4">Item 4</div>
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
Element.prototype.scrollTo = jest.fn();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('renders all items', () => {
|
|
19
|
-
render(<CarouselComponent items={mockItems} />);
|
|
20
|
-
|
|
21
|
-
expect(screen.getByText('Item 1')).toBeInTheDocument();
|
|
22
|
-
expect(screen.getByText('Item 2')).toBeInTheDocument();
|
|
23
|
-
expect(screen.getByText('Item 3')).toBeInTheDocument();
|
|
24
|
-
expect(screen.getByText('Item 4')).toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('renders navigation arrows by default', () => {
|
|
28
|
-
render(<CarouselComponent items={mockItems} />);
|
|
29
|
-
|
|
30
|
-
const prevButton = screen.getByLabelText('Previous items');
|
|
31
|
-
const nextButton = screen.getByLabelText('Next items');
|
|
32
|
-
|
|
33
|
-
expect(prevButton).toBeInTheDocument();
|
|
34
|
-
expect(nextButton).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('hides navigation arrows when showArrows is false', () => {
|
|
38
|
-
render(<CarouselComponent items={mockItems} showArrows={false} />);
|
|
39
|
-
|
|
40
|
-
const buttons = screen.getAllByRole('button');
|
|
41
|
-
expect(buttons.length).toBe(2);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('renders pagination dots by default', () => {
|
|
45
|
-
render(<CarouselComponent items={mockItems} />);
|
|
46
|
-
|
|
47
|
-
const dots = screen
|
|
48
|
-
.getAllByRole('button')
|
|
49
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
50
|
-
|
|
51
|
-
expect(dots.length).toBeGreaterThan(0);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('hides pagination dots when showDots is false', () => {
|
|
55
|
-
render(
|
|
56
|
-
<CarouselComponent
|
|
57
|
-
items={mockItems}
|
|
58
|
-
showDots={false}
|
|
59
|
-
showArrows={false}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const buttons = screen.queryAllByRole('button');
|
|
64
|
-
|
|
65
|
-
expect(buttons.length).toBe(0);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('applies custom className', () => {
|
|
69
|
-
const { container } = render(
|
|
70
|
-
<CarouselComponent items={mockItems} className="custom-carousel" />
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
expect(container.querySelector('.custom-carousel')).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('handles itemsPerPage option', () => {
|
|
77
|
-
render(
|
|
78
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 1 }} />
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const dots = screen
|
|
82
|
-
.getAllByRole('button')
|
|
83
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
84
|
-
|
|
85
|
-
expect(dots.length).toBe(4);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('handles empty items array', () => {
|
|
89
|
-
const { container } = render(<CarouselComponent items={[]} />);
|
|
90
|
-
|
|
91
|
-
expect(container.querySelector('[role="button"]')).not.toBeInTheDocument();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('handles single item', () => {
|
|
95
|
-
render(<CarouselComponent items={[<div key="1">Single Item</div>]} />);
|
|
96
|
-
|
|
97
|
-
expect(screen.getByText('Single Item')).toBeInTheDocument();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('calls onPageChange callback when provided', () => {
|
|
101
|
-
const onPageChange = jest.fn();
|
|
102
|
-
|
|
103
|
-
render(<CarouselComponent items={mockItems} options={{ onPageChange }} />);
|
|
104
|
-
|
|
105
|
-
const nextButton = screen
|
|
106
|
-
.getAllByRole('button')
|
|
107
|
-
.find(btn => btn.querySelector('svg'));
|
|
108
|
-
|
|
109
|
-
if (nextButton) {
|
|
110
|
-
fireEvent.click(nextButton);
|
|
111
|
-
expect(onPageChange).toHaveBeenCalled();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('renders with custom arrow component', () => {
|
|
116
|
-
const CustomArrow = ({ direction }: { direction: string }) => (
|
|
117
|
-
<button>Custom {direction}</button>
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
render(
|
|
121
|
-
<CarouselComponent
|
|
122
|
-
items={mockItems}
|
|
123
|
-
arrowComponent={CustomArrow as any}
|
|
124
|
-
/>
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const customArrows = screen.getAllByText(/Custom/);
|
|
128
|
-
expect(customArrows.length).toBe(2);
|
|
129
|
-
expect(customArrows[0]).toBeInTheDocument();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('renders with custom dot component', () => {
|
|
133
|
-
const CustomDot = ({ index }: { index: number }) => (
|
|
134
|
-
<button>Dot {index}</button>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
render(
|
|
138
|
-
<CarouselComponent items={mockItems} dotComponent={CustomDot as any} />
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const customDots = screen.getAllByText(/Dot/);
|
|
142
|
-
expect(customDots.length).toBe(2);
|
|
143
|
-
expect(customDots[0]).toBeInTheDocument();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('navigates to next page when next arrow is clicked', () => {
|
|
147
|
-
render(
|
|
148
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const nextButton = screen.getByLabelText('Next items');
|
|
152
|
-
fireEvent.click(nextButton);
|
|
153
|
-
|
|
154
|
-
expect(Element.prototype.scrollTo).toHaveBeenCalled();
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('navigates to previous page when previous arrow is clicked', () => {
|
|
158
|
-
render(
|
|
159
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
const nextButton = screen.getByLabelText('Next items');
|
|
163
|
-
const prevButton = screen.getByLabelText('Previous items');
|
|
164
|
-
|
|
165
|
-
fireEvent.click(nextButton);
|
|
166
|
-
fireEvent.click(prevButton);
|
|
167
|
-
expect(Element.prototype.scrollTo).toHaveBeenCalled();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('handles mouse drag events', () => {
|
|
171
|
-
const { container } = render(
|
|
172
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
const carouselRow = container.querySelector('div > div > div');
|
|
176
|
-
|
|
177
|
-
if (carouselRow) {
|
|
178
|
-
fireEvent.mouseDown(carouselRow, { pageX: 100 });
|
|
179
|
-
fireEvent.mouseMove(carouselRow, { pageX: 50 });
|
|
180
|
-
fireEvent.mouseUp(carouselRow);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
expect(carouselRow).toBeInTheDocument();
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('disables previous arrow on first page', () => {
|
|
187
|
-
render(
|
|
188
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
const prevButton = screen.getByLabelText('Previous items');
|
|
192
|
-
expect(prevButton).toBeDisabled();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('renders correct number of page dots', () => {
|
|
196
|
-
render(
|
|
197
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const dots = screen
|
|
201
|
-
.getAllByRole('button')
|
|
202
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
203
|
-
|
|
204
|
-
expect(dots.length).toBe(2);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it('handles page dot click', () => {
|
|
208
|
-
render(
|
|
209
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
const dots = screen
|
|
213
|
-
.getAllByRole('button')
|
|
214
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
215
|
-
|
|
216
|
-
if (dots[1]) {
|
|
217
|
-
fireEvent.click(dots[1]);
|
|
218
|
-
expect(Element.prototype.scrollTo).toHaveBeenCalled();
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('hides dots when there is only one page', () => {
|
|
223
|
-
render(
|
|
224
|
-
<CarouselComponent
|
|
225
|
-
items={[<div key="1">Item 1</div>]}
|
|
226
|
-
options={{ itemsPerPage: 2 }}
|
|
227
|
-
/>
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
const dots = screen
|
|
231
|
-
.queryAllByRole('button')
|
|
232
|
-
.filter(btn => !btn.querySelector('svg'));
|
|
233
|
-
|
|
234
|
-
expect(dots.length).toBe(0);
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('handles mouse leave event during drag', () => {
|
|
238
|
-
const { container } = render(
|
|
239
|
-
<CarouselComponent items={mockItems} options={{ itemsPerPage: 2 }} />
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
const carouselRow = container.querySelector('div > div > div');
|
|
243
|
-
|
|
244
|
-
if (carouselRow) {
|
|
245
|
-
fireEvent.mouseDown(carouselRow, { pageX: 100 });
|
|
246
|
-
fireEvent.mouseMove(carouselRow, { pageX: 50 });
|
|
247
|
-
fireEvent.mouseLeave(carouselRow);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
expect(carouselRow).toBeInTheDocument();
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('applies correct styles to carousel container', () => {
|
|
254
|
-
const { container } = render(<CarouselComponent items={mockItems} />);
|
|
255
|
-
|
|
256
|
-
const carouselContainer = container.firstChild;
|
|
257
|
-
expect(carouselContainer).toBeInTheDocument();
|
|
258
|
-
});
|
|
259
|
-
});
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { CarouselItem } from '../CarouselItem';
|
|
5
|
-
|
|
6
|
-
describe('CarouselItem', () => {
|
|
7
|
-
it('renders children correctly', () => {
|
|
8
|
-
render(
|
|
9
|
-
<CarouselItem>
|
|
10
|
-
<div>Test Content</div>
|
|
11
|
-
</CarouselItem>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('applies custom className', () => {
|
|
18
|
-
const { container } = render(
|
|
19
|
-
<CarouselItem className="custom-class">
|
|
20
|
-
<div>Test Content</div>
|
|
21
|
-
</CarouselItem>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
expect(container.firstChild).toHaveClass('custom-class');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('uses default widthConfig when not provided', () => {
|
|
28
|
-
const { container } = render(
|
|
29
|
-
<CarouselItem>
|
|
30
|
-
<div>Test Content</div>
|
|
31
|
-
</CarouselItem>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('accepts custom widthConfig', () => {
|
|
38
|
-
render(
|
|
39
|
-
<CarouselItem
|
|
40
|
-
widthItemConfig={{
|
|
41
|
-
xs: '70%',
|
|
42
|
-
mobile: '90%',
|
|
43
|
-
tablet: '45%',
|
|
44
|
-
desktop: '30%',
|
|
45
|
-
xl: '25%'
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<div>Test Content</div>
|
|
49
|
-
</CarouselItem>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('accepts partial widthConfig', () => {
|
|
56
|
-
render(
|
|
57
|
-
<CarouselItem
|
|
58
|
-
widthItemConfig={{
|
|
59
|
-
mobile: '80%',
|
|
60
|
-
desktop: '40%'
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
<div>Test Content</div>
|
|
64
|
-
</CarouselItem>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('renders multiple children correctly', () => {
|
|
71
|
-
render(
|
|
72
|
-
<CarouselItem>
|
|
73
|
-
<div>Child 1</div>
|
|
74
|
-
<div>Child 2</div>
|
|
75
|
-
<div>Child 3</div>
|
|
76
|
-
</CarouselItem>
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
expect(screen.getByText('Child 1')).toBeInTheDocument();
|
|
80
|
-
expect(screen.getByText('Child 2')).toBeInTheDocument();
|
|
81
|
-
expect(screen.getByText('Child 3')).toBeInTheDocument();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('handles complex child components', () => {
|
|
85
|
-
const ComplexChild = () => (
|
|
86
|
-
<div>
|
|
87
|
-
<h1>Title</h1>
|
|
88
|
-
<p>Description</p>
|
|
89
|
-
<button>Action</button>
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
render(
|
|
94
|
-
<CarouselItem>
|
|
95
|
-
<ComplexChild />
|
|
96
|
-
</CarouselItem>
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
expect(screen.getByText('Title')).toBeInTheDocument();
|
|
100
|
-
expect(screen.getByText('Description')).toBeInTheDocument();
|
|
101
|
-
expect(screen.getByText('Action')).toBeInTheDocument();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('applies className along with widthConfig', () => {
|
|
105
|
-
const { container } = render(
|
|
106
|
-
<CarouselItem
|
|
107
|
-
className="custom-item"
|
|
108
|
-
widthItemConfig={{
|
|
109
|
-
mobile: '90%',
|
|
110
|
-
desktop: '45%'
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
<div>Test Content</div>
|
|
114
|
-
</CarouselItem>
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
expect(container.firstChild).toHaveClass('custom-item');
|
|
118
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('renders with no props except children', () => {
|
|
122
|
-
render(
|
|
123
|
-
<CarouselItem>
|
|
124
|
-
<div>Minimal Content</div>
|
|
125
|
-
</CarouselItem>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
expect(screen.getByText('Minimal Content')).toBeInTheDocument();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('handles empty widthConfig object', () => {
|
|
132
|
-
render(
|
|
133
|
-
<CarouselItem widthItemConfig={{}}>
|
|
134
|
-
<div>Test Content</div>
|
|
135
|
-
</CarouselItem>
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
expect(screen.getByText('Test Content')).toBeInTheDocument();
|
|
139
|
-
});
|
|
140
|
-
});
|