@c-rex/components 0.3.0-build.26 → 0.3.0-build.28
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/package.json +1 -1
- package/src/carousel/carousel.tsx +17 -8
package/package.json
CHANGED
|
@@ -324,16 +324,25 @@ const CarouselIndicators: FC<{ className?: string }> = ({ className }) => {
|
|
|
324
324
|
if (!setPage) {
|
|
325
325
|
const totalOfIndicators = Math.max(slidesLength - slidesToShow + 1, 1);
|
|
326
326
|
if (totalOfIndicators === 1) return null;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
327
|
+
const maxVisibleIndicators = 7;
|
|
328
|
+
const visibleIndicators = Math.min(totalOfIndicators, maxVisibleIndicators);
|
|
329
|
+
const halfWindow = Math.floor(visibleIndicators / 2);
|
|
330
|
+
let startIndicator = Math.max(0, current - halfWindow);
|
|
331
|
+
let endIndicator = startIndicator + visibleIndicators - 1;
|
|
332
|
+
|
|
333
|
+
if (endIndicator >= totalOfIndicators) {
|
|
334
|
+
endIndicator = totalOfIndicators - 1;
|
|
335
|
+
startIndicator = Math.max(0, endIndicator - visibleIndicators + 1);
|
|
333
336
|
}
|
|
337
|
+
|
|
338
|
+
const indicatorsToRender = Array.from(
|
|
339
|
+
{ length: endIndicator - startIndicator + 1 },
|
|
340
|
+
(_, index) => startIndicator + index
|
|
341
|
+
);
|
|
342
|
+
|
|
334
343
|
return (
|
|
335
|
-
<ol className={cn("flex gap-2 z-20 list-none p-0 m-0", className)}>
|
|
336
|
-
{
|
|
344
|
+
<ol className={cn("mt-3 flex gap-2 z-20 list-none p-0 m-0", className)}>
|
|
345
|
+
{indicatorsToRender.map((index) => (
|
|
337
346
|
<li key={`indicator-${index}`}>
|
|
338
347
|
<Button
|
|
339
348
|
className={`w-3 h-3 rounded-full border-0 cursor-pointer transition-colors ${index === current ? "bg-gray-800" : "bg-gray-300"}`}
|