hds-web 1.4.6 → 1.4.7
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/index.css +1 -1
- package/dist/index.es.css +1 -1
- package/dist/index.es.js +6 -6
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/HDS/components/Cards/Misc/talkcard2.js +1 -1
- package/src/HDS/components/Cards/TalkDetailCard/talkDetailCard.js +1 -1
- package/src/HDS/components/Carousels/carouselCard.js +77 -42
- package/src/styles/tailwind.css +0 -11
package/package.json
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import { useRef } from "react";
|
2
|
+
import { useRef,useState } from "react";
|
3
3
|
import { Icon } from "../common-components/Icon";
|
4
|
+
import { HDSButton } from "../Buttons";
|
4
5
|
export default function CarouselCard(props) {
|
5
6
|
const carouselRef = useRef(null); // Create a ref using useRef
|
6
7
|
const [currentCard, setCurrentCard] = React.useState(0);
|
7
8
|
const [touchStart, setTouchStart] = React.useState(0);
|
8
9
|
const [touchEnd, setTouchEnd] = React.useState(0);
|
10
|
+
const [showAllCards, setShowAllCards] = useState(false);
|
9
11
|
|
10
12
|
const handleTouchStart = e => {
|
11
13
|
setTouchStart(e.targetTouches[0].clientX);
|
@@ -30,63 +32,63 @@ export default function CarouselCard(props) {
|
|
30
32
|
return acc;
|
31
33
|
}, {});
|
32
34
|
|
33
|
-
|
35
|
+
|
34
36
|
|
35
37
|
const totalCards = props.cards.length;
|
36
38
|
|
37
39
|
const nextCard = () => {
|
38
40
|
let scrollByAmount = 1;
|
39
41
|
if (window.innerWidth > 800) {
|
40
|
-
|
42
|
+
scrollByAmount = 2;
|
41
43
|
}
|
42
44
|
if (window.innerWidth > 1140) {
|
43
|
-
|
45
|
+
scrollByAmount = 3;
|
44
46
|
}
|
45
|
-
|
47
|
+
|
46
48
|
if (currentCard < totalCards - scrollByAmount) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
setCurrentCard(currentCard + scrollByAmount);
|
50
|
+
carouselRef.current.scrollTo({
|
51
|
+
left: carouselRef.current.scrollLeft + carouselRef.current.children[0].offsetWidth * scrollByAmount,
|
52
|
+
behavior: "smooth",
|
53
|
+
});
|
52
54
|
}
|
53
55
|
else {
|
54
56
|
setCurrentCard(0);
|
55
57
|
carouselRef.current.scrollTo({
|
56
|
-
|
57
|
-
|
58
|
+
left: 0,
|
59
|
+
behavior: "smooth",
|
58
60
|
});
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
const previousCard = () => {
|
63
65
|
let scrollByAmount = 1;
|
64
66
|
if (window.innerWidth > 800) {
|
65
|
-
|
67
|
+
scrollByAmount = 2;
|
66
68
|
}
|
67
69
|
if (window.innerWidth > 1140) {
|
68
|
-
|
70
|
+
scrollByAmount = 3;
|
69
71
|
}
|
70
|
-
|
72
|
+
|
71
73
|
if (currentCard > 0) {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
setCurrentCard(currentCard - scrollByAmount);
|
75
|
+
carouselRef.current.scrollTo({
|
76
|
+
left: carouselRef.current.scrollLeft - carouselRef.current.children[0].offsetWidth * scrollByAmount,
|
77
|
+
behavior: "smooth",
|
78
|
+
});
|
77
79
|
} else {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
const lastCardIndex = totalCards - 1;
|
81
|
+
const scrollLeft = carouselRef.current.scrollWidth - carouselRef.current.children[0].offsetWidth * scrollByAmount;
|
82
|
+
setCurrentCard(lastCardIndex);
|
83
|
+
carouselRef.current.scrollTo({
|
84
|
+
left: scrollLeft,
|
85
|
+
behavior: "smooth",
|
86
|
+
});
|
85
87
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
};
|
89
|
+
|
90
|
+
const maxVisibleCards = 6;
|
91
|
+
|
90
92
|
const arrowStyle = ' text-2xl z-10 bg-black h-10 ml-6 w-10 rounded-full bg-purple-200 hover:bg-neutral-0 flex items-center justify-center';
|
91
93
|
|
92
94
|
const sliderControl = isLeft => (
|
@@ -112,16 +114,49 @@ export default function CarouselCard(props) {
|
|
112
114
|
return (
|
113
115
|
<div className="">
|
114
116
|
<div className="block tb:hidden">
|
115
|
-
{
|
116
|
-
|
117
|
-
<div className="
|
118
|
-
|
117
|
+
{showAllCards
|
118
|
+
? props.cards.map((item, i) => (
|
119
|
+
<div className="my-5" key={i} ref={refs[i]}>
|
120
|
+
<div className="rounded-3xl overflow-hidden">
|
121
|
+
{React.createElement(props.component, item)}
|
122
|
+
</div>
|
119
123
|
</div>
|
120
|
-
|
124
|
+
))
|
125
|
+
: props.cards.slice(0, maxVisibleCards).map((item, i) => (
|
126
|
+
<div className="my-5" key={i} ref={refs[i]}>
|
127
|
+
<div className="rounded-3xl overflow-hidden">
|
128
|
+
{React.createElement(props.component, item)}
|
129
|
+
</div>
|
130
|
+
</div>
|
131
|
+
))}
|
132
|
+
{props.cards.length > maxVisibleCards && (
|
133
|
+
<div className="flex">
|
134
|
+
<HDSButton
|
135
|
+
label={showAllCards ? "View less" : "View more"}
|
136
|
+
type='secondary'
|
137
|
+
leftIconVariant='none'
|
138
|
+
rightIconVariant='none'
|
139
|
+
state='default'
|
140
|
+
size='sm'
|
141
|
+
rightAnimatedArrow={true}
|
142
|
+
rightAnimatedArrowColor='#1E56E3'
|
143
|
+
animatedHoverStroke='group-hover:stroke-neutral-0'
|
144
|
+
className='flex'
|
145
|
+
btnTextColorClass='text-blue-600'
|
146
|
+
btnBgColorClass=''
|
147
|
+
onClick={() => setShowAllCards(!showAllCards)}
|
148
|
+
/>
|
149
|
+
{/* <button
|
150
|
+
className="text-blue-500 mt-1 cursor-pointer"
|
151
|
+
onClick={() => setShowAllCards(!showAllCards)}
|
152
|
+
>
|
153
|
+
{showAllCards ? "View less" : "View more"}
|
154
|
+
</button> */}
|
121
155
|
</div>
|
122
|
-
)
|
156
|
+
)}
|
123
157
|
</div>
|
124
158
|
|
159
|
+
|
125
160
|
<div className="hidden tb:flex tb:flex-col">
|
126
161
|
<div className="flex pb-12 items-center justify-end ">
|
127
162
|
{/* {slider()} */}
|
@@ -147,7 +182,7 @@ export default function CarouselCard(props) {
|
|
147
182
|
>
|
148
183
|
<div className="">
|
149
184
|
<div className={`snap-x w-full inline-flex select-none overflow-x-hidden scrollbar-hide`}
|
150
|
-
|
185
|
+
ref={carouselRef}
|
151
186
|
>
|
152
187
|
|
153
188
|
{props.cards.map((item, i) => (
|
package/src/styles/tailwind.css
CHANGED
@@ -8037,17 +8037,6 @@ select {
|
|
8037
8037
|
}
|
8038
8038
|
}
|
8039
8039
|
|
8040
|
-
@media (max-width: 419px) {
|
8041
|
-
.max-\[419px\]\:rounded-full {
|
8042
|
-
border-radius: 9999px;
|
8043
|
-
}
|
8044
|
-
|
8045
|
-
.max-\[419px\]\:bg-blue-300 {
|
8046
|
-
--tw-bg-opacity: 1;
|
8047
|
-
background-color: rgb(198 214 255 / var(--tw-bg-opacity));
|
8048
|
-
}
|
8049
|
-
}
|
8050
|
-
|
8051
8040
|
@media (max-width: 399px) {
|
8052
8041
|
.max-\[399px\]\:rounded-full {
|
8053
8042
|
border-radius: 9999px;
|