hds-web 1.4.0 → 1.4.2

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.
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
+ import { useRef } from "react";
2
3
  import { Icon } from "../common-components/Icon";
3
4
  export default function CarouselCard(props) {
5
+ const carouselRef = useRef(null); // Create a ref using useRef
4
6
  const [currentCard, setCurrentCard] = React.useState(0);
5
7
  const [touchStart, setTouchStart] = React.useState(0);
6
8
  const [touchEnd, setTouchEnd] = React.useState(0);
@@ -28,49 +30,62 @@ export default function CarouselCard(props) {
28
30
  return acc;
29
31
  }, {});
30
32
 
31
- const scrollToCard = (i) => {
32
- setCurrentCard(i);
33
-
34
- if (refs[i] && refs[i].current) {
35
- refs[i].current.scrollIntoView({
36
- behavior: "smooth",
37
- block: "nearest",
38
- inline: "start",
39
- });
40
- }
41
- };
33
+
42
34
 
43
35
  const totalCards = props.cards.length;
44
36
 
45
37
  const nextCard = () => {
46
-
47
- let scrollByAmount = '';
48
- if(window.innerWidth>1140){scrollByAmount = 3}
49
- else if(window.innerWidth<1140 && window.innerWidth>800) {scrollByAmount = 2}
50
- else scrollByAmount = 1;
51
- if (currentCard >= totalCards - scrollByAmount) {
52
- scrollToCard(0);
53
- } else {
54
- scrollToCard(currentCard + scrollByAmount);
38
+ let scrollByAmount = 1;
39
+ if (window.innerWidth > 800) {
40
+ scrollByAmount = 2;
41
+ }
42
+ if (window.innerWidth > 1140) {
43
+ scrollByAmount = 3;
44
+ }
45
+
46
+ if (currentCard < totalCards - scrollByAmount) {
47
+ setCurrentCard(currentCard + scrollByAmount);
48
+ carouselRef.current.scrollTo({
49
+ left: carouselRef.current.scrollLeft + carouselRef.current.children[0].offsetWidth * scrollByAmount,
50
+ behavior: "smooth",
51
+ });
55
52
  }
53
+ else {
54
+ setCurrentCard(0);
55
+ carouselRef.current.scrollTo({
56
+ left: 0,
57
+ behavior: "smooth",
58
+ });
59
+ }
56
60
  };
57
-
61
+
58
62
  const previousCard = () => {
59
- let scrollByAmount = "";
63
+ let scrollByAmount = 1;
64
+ if (window.innerWidth > 800) {
65
+ scrollByAmount = 2;
66
+ }
60
67
  if (window.innerWidth > 1140) {
61
68
  scrollByAmount = 3;
62
- } else if (window.innerWidth > 800) {
63
- scrollByAmount = 2;
64
- } else {
65
- scrollByAmount = 1;
66
69
  }
67
-
68
- if (currentCard === 0) {
69
- scrollToCard(totalCards - scrollByAmount);
70
+
71
+ if (currentCard > 0) {
72
+ setCurrentCard(currentCard - scrollByAmount);
73
+ carouselRef.current.scrollTo({
74
+ left: carouselRef.current.scrollLeft - carouselRef.current.children[0].offsetWidth * scrollByAmount,
75
+ behavior: "smooth",
76
+ });
70
77
  } else {
71
- scrollToCard(currentCard - scrollByAmount);
78
+ const lastCardIndex = totalCards - 1;
79
+ const scrollLeft = carouselRef.current.scrollWidth - carouselRef.current.children[0].offsetWidth * scrollByAmount;
80
+ setCurrentCard(lastCardIndex);
81
+ carouselRef.current.scrollTo({
82
+ left: scrollLeft,
83
+ behavior: "smooth",
84
+ });
72
85
  }
73
86
  };
87
+
88
+
74
89
 
75
90
  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';
76
91
 
@@ -99,7 +114,7 @@ export default function CarouselCard(props) {
99
114
  <div className="block tb:hidden">
100
115
  {props.cards.map((item, i) => (
101
116
  <div className="my-5" key={i} ref={refs[i]}>
102
- <div className="rounded-3xl ">
117
+ <div className="rounded-3xl overflow-hidden">
103
118
  {React.createElement(props.component, item)}
104
119
  </div>
105
120
 
@@ -131,10 +146,13 @@ export default function CarouselCard(props) {
131
146
  }}
132
147
  >
133
148
  <div className="">
134
- <div className={`snap-x w-full inline-flex select-none overflow-x-hidden scrollbar-hide`}>
149
+ <div className={`snap-x w-full inline-flex select-none overflow-x-hidden scrollbar-hide`}
150
+ ref={carouselRef}
151
+ >
135
152
 
136
153
  {props.cards.map((item, i) => (
137
- <div className="max-[1140px]:snap-center tb:snap-always mx-5 max-[1140px]:shrink-0" key={i} ref={refs[i]}>
154
+ // <div className="max-[1140px]:snap-always tb:snap-always mx-5 max-[1140px]:shrink-0" key={i} ref={refs[i]}>
155
+ <div className=" db:snap-center snap-center tb-m:snap-start mx-5 shrink-0" key={i} ref={refs[i]}>
138
156
  <div className="w-full select-none rounded-3xl object-contain">
139
157
  {React.createElement(props.component, item)}
140
158
  </div>
@@ -3,12 +3,15 @@ import React from 'react';
3
3
  const GridComponent = ({ cards, gridSize }) => {
4
4
  const numCards = cards.length;
5
5
  const cardsLeftInLastRow = numCards % gridSize;
6
- const lastRowColSpan = `col-span-${gridSize / cardsLeftInLastRow}`;
7
-
8
6
  const renderCards = () => {
7
+ let cardClass = '';
8
+ if(cards.length === 4 ){
9
+ cardClass = 'grid grid-cols-2'
10
+ }
11
+ else cardClass = 'gridAutoClass';
9
12
  return cards.map((card, index) => (
10
13
  <div
11
- className='gridClass'
14
+ className={cardClass}
12
15
  key={index}
13
16
  >
14
17
  {/* Render card content */}
@@ -753,6 +753,12 @@ select {
753
753
  }
754
754
  }
755
755
 
756
+ @media (min-width: 800px) {
757
+ .container {
758
+ max-width: 800px;
759
+ }
760
+ }
761
+
756
762
  @media (min-width: 905px) {
757
763
  .container {
758
764
  max-width: 905px;
@@ -1404,10 +1410,6 @@ select {
1404
1410
  max-height: 100%;
1405
1411
  }
1406
1412
 
1407
- .min-h-\[96px\] {
1408
- min-height: 96px;
1409
- }
1410
-
1411
1413
  .min-h-\[116px\] {
1412
1414
  min-height: 116px;
1413
1415
  }
@@ -1538,14 +1540,14 @@ select {
1538
1540
  width: 100vw;
1539
1541
  }
1540
1542
 
1541
- .min-w-\[100px\] {
1542
- min-width: 100px;
1543
- }
1544
-
1545
1543
  .min-w-\[11\.5rem\] {
1546
1544
  min-width: 11.5rem;
1547
1545
  }
1548
1546
 
1547
+ .min-w-\[144px\] {
1548
+ min-width: 144px;
1549
+ }
1550
+
1549
1551
  .min-w-\[18rem\] {
1550
1552
  min-width: 18rem;
1551
1553
  }
@@ -1568,14 +1570,6 @@ select {
1568
1570
  min-width: 100%;
1569
1571
  }
1570
1572
 
1571
- .min-w-\[144px\] {
1572
- min-width: 144px;
1573
- }
1574
-
1575
- .min-w-\[11\.25rem\] {
1576
- min-width: 11.25rem;
1577
- }
1578
-
1579
1573
  .max-w-2xl {
1580
1574
  max-width: 42rem;
1581
1575
  }
@@ -1596,6 +1590,10 @@ select {
1596
1590
  max-width: 18rem;
1597
1591
  }
1598
1592
 
1593
+ .max-w-\[22\.313rem\] {
1594
+ max-width: 22.313rem;
1595
+ }
1596
+
1599
1597
  .max-w-\[22rem\] {
1600
1598
  max-width: 22rem;
1601
1599
  }
@@ -1634,10 +1632,6 @@ select {
1634
1632
  max-width: min-content;
1635
1633
  }
1636
1634
 
1637
- .max-w-\[22\.313rem\] {
1638
- max-width: 22.313rem;
1639
- }
1640
-
1641
1635
  .flex-1 {
1642
1636
  flex: 1 1 0%;
1643
1637
  }
@@ -2066,14 +2060,6 @@ select {
2066
2060
  overflow: hidden;
2067
2061
  }
2068
2062
 
2069
- .overflow-clip {
2070
- overflow: clip;
2071
- }
2072
-
2073
- .overflow-visible {
2074
- overflow: visible;
2075
- }
2076
-
2077
2063
  .overflow-scroll {
2078
2064
  overflow: scroll;
2079
2065
  }
@@ -2180,16 +2166,6 @@ select {
2180
2166
  border-top-right-radius: 0.375rem;
2181
2167
  }
2182
2168
 
2183
- .rounded-l {
2184
- border-top-left-radius: 0.25rem;
2185
- border-bottom-left-radius: 0.25rem;
2186
- }
2187
-
2188
- .rounded-l-full {
2189
- border-top-left-radius: 9999px;
2190
- border-bottom-left-radius: 9999px;
2191
- }
2192
-
2193
2169
  .rounded-tl-2xl {
2194
2170
  border-top-left-radius: 1rem;
2195
2171
  }
@@ -5157,10 +5133,6 @@ select {
5157
5133
  stroke-width: 1.5px;
5158
5134
  }
5159
5135
 
5160
- .stroke-\[1\.5\] {
5161
- stroke-width: 1.5;
5162
- }
5163
-
5164
5136
  .object-contain {
5165
5137
  object-fit: contain;
5166
5138
  }
@@ -5494,18 +5466,10 @@ select {
5494
5466
  padding-top: 1rem;
5495
5467
  }
5496
5468
 
5497
- .pt-5 {
5498
- padding-top: 1.25rem;
5499
- }
5500
-
5501
5469
  .pt-6 {
5502
5470
  padding-top: 1.5rem;
5503
5471
  }
5504
5472
 
5505
- .pr-0 {
5506
- padding-right: 0px;
5507
- }
5508
-
5509
5473
  .pt-8 {
5510
5474
  padding-top: 2rem;
5511
5475
  }
@@ -7466,15 +7430,6 @@ select {
7466
7430
  margin-left: 0px;
7467
7431
  }
7468
7432
 
7469
- .first\:rounded-full:first-child {
7470
- border-radius: 9999px;
7471
- }
7472
-
7473
- .first\:rounded-r-full:first-child {
7474
- border-top-right-radius: 9999px;
7475
- border-bottom-right-radius: 9999px;
7476
- }
7477
-
7478
7433
  .first\:rounded-l-full:first-child {
7479
7434
  border-top-left-radius: 9999px;
7480
7435
  border-bottom-left-radius: 9999px;
@@ -7485,29 +7440,10 @@ select {
7485
7440
  background-color: rgb(57 112 253 / var(--tw-bg-opacity));
7486
7441
  }
7487
7442
 
7488
- .first\:bg-purple-500:first-child {
7489
- --tw-bg-opacity: 1;
7490
- background-color: rgb(140 73 250 / var(--tw-bg-opacity));
7491
- }
7492
-
7493
- .first\:bg-neutral-200:first-child {
7494
- --tw-bg-opacity: 1;
7495
- background-color: rgb(229 231 235 / var(--tw-bg-opacity));
7496
- }
7497
-
7498
7443
  .last\:mr-0:last-child {
7499
7444
  margin-right: 0px;
7500
7445
  }
7501
7446
 
7502
- .last\:rounded-3xl:last-child {
7503
- border-radius: 1.5rem;
7504
- }
7505
-
7506
- .last\:rounded-r-3xl:last-child {
7507
- border-top-right-radius: 1.5rem;
7508
- border-bottom-right-radius: 1.5rem;
7509
- }
7510
-
7511
7447
  .last\:rounded-r-full:last-child {
7512
7448
  border-top-right-radius: 9999px;
7513
7449
  border-bottom-right-radius: 9999px;
@@ -8110,14 +8046,12 @@ select {
8110
8046
  flex-shrink: 0;
8111
8047
  }
8112
8048
 
8113
- .max-\[1140px\]\:snap-center {
8114
- scroll-snap-align: center;
8049
+ .max-\[1140px\]\:snap-end {
8050
+ scroll-snap-align: end;
8115
8051
  }
8116
- }
8117
8052
 
8118
- @media (min-width: 360px) {
8119
- .mb-s\:flex-row {
8120
- flex-direction: row;
8053
+ .max-\[1140px\]\:snap-always {
8054
+ scroll-snap-stop: always;
8121
8055
  }
8122
8056
  }
8123
8057
 
@@ -8276,20 +8210,12 @@ select {
8276
8210
  gap: 4rem;
8277
8211
  }
8278
8212
 
8279
- .tb\:gap-\[31\.5rem\] {
8280
- gap: 31.5rem;
8281
- }
8282
-
8283
8213
  .tb\:gap-3 {
8284
8214
  gap: 0.75rem;
8285
8215
  }
8286
8216
 
8287
- .tb\:gap-1 {
8288
- gap: 0.25rem;
8289
- }
8290
-
8291
- .tb\:gap-6 {
8292
- gap: 1.5rem;
8217
+ .tb\:gap-\[31\.5rem\] {
8218
+ gap: 31.5rem;
8293
8219
  }
8294
8220
 
8295
8221
  .tb\:gap-x-16 {
@@ -8331,6 +8257,11 @@ select {
8331
8257
  padding: 4rem;
8332
8258
  }
8333
8259
 
8260
+ .tb\:px-0 {
8261
+ padding-left: 0px;
8262
+ padding-right: 0px;
8263
+ }
8264
+
8334
8265
  .tb\:px-3 {
8335
8266
  padding-left: 0.75rem;
8336
8267
  padding-right: 0.75rem;
@@ -8346,15 +8277,6 @@ select {
8346
8277
  padding-right: 2rem;
8347
8278
  }
8348
8279
 
8349
- .tb\:px-0 {
8350
- padding-left: 0px;
8351
- padding-right: 0px;
8352
- }
8353
-
8354
- .tb\:pb-14 {
8355
- padding-bottom: 3.5rem;
8356
- }
8357
-
8358
8280
  .tb\:pb-8 {
8359
8281
  padding-bottom: 2rem;
8360
8282
  }
@@ -8367,6 +8289,10 @@ select {
8367
8289
  padding-top: 2.5rem;
8368
8290
  }
8369
8291
 
8292
+ .tb\:pt-14 {
8293
+ padding-top: 3.5rem;
8294
+ }
8295
+
8370
8296
  .tb\:pt-8 {
8371
8297
  padding-top: 2rem;
8372
8298
  }
@@ -8375,14 +8301,6 @@ select {
8375
8301
  padding-top: 2.875rem;
8376
8302
  }
8377
8303
 
8378
- .tb\:pl-0 {
8379
- padding-left: 0px;
8380
- }
8381
-
8382
- .tb\:pt-14 {
8383
- padding-top: 3.5rem;
8384
- }
8385
-
8386
8304
  .tb\:text-left {
8387
8305
  text-align: left;
8388
8306
  }
@@ -8745,6 +8663,12 @@ select {
8745
8663
  }
8746
8664
  }
8747
8665
 
8666
+ @media (min-width: 800px) {
8667
+ .tb-m\:snap-start {
8668
+ scroll-snap-align: start;
8669
+ }
8670
+ }
8671
+
8748
8672
  @media (min-width: 905px) {
8749
8673
  .tb-l\:mb-0 {
8750
8674
  margin-bottom: 0px;
@@ -8782,8 +8706,8 @@ select {
8782
8706
  width: 38%;
8783
8707
  }
8784
8708
 
8785
- .tb-l\:w-\[520px\] {
8786
- width: 520px;
8709
+ .tb-l\:w-\[380px\] {
8710
+ width: 380px;
8787
8711
  }
8788
8712
 
8789
8713
  .tb-l\:w-\[62\%\] {
@@ -8798,14 +8722,6 @@ select {
8798
8722
  width: 100%;
8799
8723
  }
8800
8724
 
8801
- .tb-l\:w-\[456px\] {
8802
- width: 456px;
8803
- }
8804
-
8805
- .tb-l\:w-\[380px\] {
8806
- width: 380px;
8807
- }
8808
-
8809
8725
  .tb-l\:min-w-\[400px\] {
8810
8726
  min-width: 400px;
8811
8727
  }
@@ -8846,10 +8762,6 @@ select {
8846
8762
  gap: 9rem;
8847
8763
  }
8848
8764
 
8849
- .tb-l\:gap-6 {
8850
- gap: 1.5rem;
8851
- }
8852
-
8853
8765
  .tb-l\:space-x-6 > :not([hidden]) ~ :not([hidden]) {
8854
8766
  --tw-space-x-reverse: 0;
8855
8767
  margin-right: calc(1.5rem * var(--tw-space-x-reverse));
@@ -8982,6 +8894,10 @@ select {
8982
8894
  width: 36%;
8983
8895
  }
8984
8896
 
8897
+ .db\:w-\[520px\] {
8898
+ width: 520px;
8899
+ }
8900
+
8985
8901
  .db\:w-\[72\%\] {
8986
8902
  width: 72%;
8987
8903
  }
@@ -9000,10 +8916,6 @@ select {
9000
8916
  width: 100%;
9001
8917
  }
9002
8918
 
9003
- .db\:w-\[520px\] {
9004
- width: 520px;
9005
- }
9006
-
9007
8919
  .db\:min-w-\[625px\] {
9008
8920
  min-width: 625px;
9009
8921
  }
@@ -9024,6 +8936,10 @@ select {
9024
8936
  max-width: 625px;
9025
8937
  }
9026
8938
 
8939
+ .db\:snap-center {
8940
+ scroll-snap-align: center;
8941
+ }
8942
+
9027
8943
  .db\:grid-cols-4 {
9028
8944
  grid-template-columns: repeat(4, minmax(0, 1fr));
9029
8945
  }
@@ -170,6 +170,7 @@ module.exports = {
170
170
  screens: {
171
171
  'mb-s': '360px',
172
172
  'tb': '600px',
173
+ 'tb-m': '800px',
173
174
  'tb-l': '905px',
174
175
  'db': '1240px',
175
176
  'db-l': '2560px'