react-styled-slider-component 0.1.6 → 0.1.8

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/App.js CHANGED
@@ -12,6 +12,9 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import Slider from './components/Slider';
14
14
  var App = function () {
15
- return (_jsx("div", { children: _jsxs(Slider, __assign({ visibleSlides: 2, showDots: true, showArrows: true, dotsPosition: "bottom", slideStep: 1, direction: "horizontal", arrowStyle: "minimal" }, { children: [_jsx("div", __assign({ style: { backgroundColor: 'red', height: '200px' } }, { children: "Slide 1" })), _jsx("div", __assign({ style: { backgroundColor: 'blue', height: '200px' } }, { children: "Slide 2" })), _jsx("div", __assign({ style: { backgroundColor: 'green', height: '200px' } }, { children: "Slide 3" })), _jsx("div", __assign({ style: { backgroundColor: 'yellow', height: '200px' } }, { children: "Slide 4" })), _jsx("div", __assign({ style: { backgroundColor: 'red', height: '200px' } }, { children: "Slide 5" })), _jsx("div", __assign({ style: { backgroundColor: 'blue', height: '200px' } }, { children: "Slide 6" })), _jsx("div", __assign({ style: { backgroundColor: 'green', height: '200px' } }, { children: "Slide 7" })), _jsx("div", __assign({ style: { backgroundColor: 'yellow', height: '200px' } }, { children: "Slide 8" }))] })) }));
15
+ return (_jsxs("div", __assign({ style: { padding: '50px', maxWidth: '1200px', margin: '0 auto', fontFamily: 'Arial, sans-serif' } }, { children: [_jsx("h1", __assign({ style: { textAlign: 'center', marginBottom: '50px' } }, { children: "Slider Component Test Lab" })), _jsxs("section", __assign({ style: { marginBottom: '80px' } }, { children: [_jsx("h3", { children: "1. Full Width Hero (1 slide at a time)" }), _jsxs(Slider, __assign({ visibleSlides: 1, infinite: true, autoplay: true, autoplaySpeed: 4000, gap: 0 }, { children: [_jsx(Slider.Button, { type: "prev", style: "minimal" }), _jsxs(Slider.Track, { children: [_jsx("div", __assign({ style: { width: '100%', height: '400px' } }, { children: _jsx("img", { src: "https://picsum.photos/1200/400?random=11", alt: "1", style: { width: '100%', height: '100%', objectFit: 'cover' } }) })), _jsx("div", __assign({ style: { width: '100%', height: '400px' } }, { children: _jsx("img", { src: "https://picsum.photos/1200/400?random=12", alt: "2", style: { width: '100%', height: '100%', objectFit: 'cover' } }) })), _jsx("div", __assign({ style: { width: '100%', height: '400px' } }, { children: _jsx("img", { src: "https://picsum.photos/1200/400?random=13", alt: "3", style: { width: '100%', height: '100%', objectFit: 'cover' } }) }))] }), _jsx(Slider.Button, { type: "next", style: "minimal" }), _jsx(Slider.Dots, { position: "bottom" })] }))] })), _jsxs("section", __assign({ style: { marginBottom: '80px' } }, { children: [_jsx("h3", { children: "2. Multi-Item Carousel (8 items total)" }), _jsxs(Slider, __assign({ visibleSlides: 1, infinite: true, gap: 20, breakpoints: {
16
+ 768: { visibleSlides: 2 },
17
+ 1024: { visibleSlides: 4 }
18
+ } }, { children: [_jsx(Slider.Button, { type: "prev", style: "filled" }), _jsxs(Slider.Track, { children: [_jsx("div", __assign({ style: { height: '200px', background: '#FFD700', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 1" })), _jsx("div", __assign({ style: { height: '200px', background: '#FF8C00', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 2" })), _jsx("div", __assign({ style: { height: '200px', background: '#FF4500', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 3" })), _jsx("div", __assign({ style: { height: '200px', background: '#FF0000', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 4" })), _jsx("div", __assign({ style: { height: '200px', background: '#C71585', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 5" })), _jsx("div", __assign({ style: { height: '200px', background: '#8B008B', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 6" })), _jsx("div", __assign({ style: { height: '200px', background: '#483D8B', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 7" })), _jsx("div", __assign({ style: { height: '200px', background: '#2F4F4F', display: 'flex', alignItems: 'center', justifyContent: 'center', borderRadius: '8px' } }, { children: "Item 8" }))] }), _jsx(Slider.Button, { type: "next", style: "filled" }), _jsx(Slider.Dots, { position: "bottom" })] }))] })), _jsxs("section", __assign({ style: { marginBottom: '80px' } }, { children: [_jsx("h3", { children: "3. Vertical Slider (2 slides visible)" }), _jsx("div", __assign({ style: { height: '500px', border: '1px solid #ddd', borderRadius: '12px', padding: '20px' } }, { children: _jsxs(Slider, __assign({ direction: "vertical", visibleSlides: 2, infinite: true, gap: 10 }, { children: [_jsx(Slider.Button, { type: "prev", style: "outlined" }), _jsxs(Slider.Track, { children: [_jsx("div", __assign({ style: { height: '200px', backgroundColor: '#f0f0f0', borderRadius: '8px', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, { children: "Vertical 1" })), _jsx("div", __assign({ style: { height: '200px', backgroundColor: '#e0e0e0', borderRadius: '8px', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, { children: "Vertical 2" })), _jsx("div", __assign({ style: { height: '200px', backgroundColor: '#d0d0d0', borderRadius: '8px', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, { children: "Vertical 3" })), _jsx("div", __assign({ style: { height: '200px', backgroundColor: '#c0c0c0', borderRadius: '8px', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, { children: "Vertical 4" }))] }), _jsx(Slider.Button, { type: "next", style: "outlined" }), _jsx(Slider.Dots, { position: "right" })] })) }))] })), _jsx("footer", __assign({ style: { textAlign: 'center', paddingBottom: '50px' } }, { children: _jsx("p", { children: "All sliders are working with the same component logic!" }) }))] })));
16
19
  };
17
20
  export default App;
package/dist/App.test.js CHANGED
@@ -1,8 +1,26 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import { render, screen } from '@testing-library/react';
3
- import App from './App';
4
- test('renders learn react link', function () {
5
- render(_jsx(App, {}));
6
- var linkElement = screen.getByText(/learn react/i);
7
- expect(linkElement).toBeInTheDocument();
14
+ import Slider from './components/Slider';
15
+ describe('Slider Component Test', function () {
16
+ // Step 2: Test for the Slider component
17
+ test('renders correct number of slides', function () {
18
+ render(_jsxs(Slider, __assign({ visibleSlides: 1 }, { children: [_jsx("div", { children: "Slide 1" }), _jsx("div", { children: "Slide 2" }), _jsx("div", { children: "Slide 3" })] })));
19
+ // Selecting the slides by their text content
20
+ var slide1 = screen.getByText("Slide 1");
21
+ var slide2 = screen.getByText("Slide 2");
22
+ // Expect: Checking if the slides are present in the document
23
+ expect(slide1).toBeInTheDocument();
24
+ expect(slide2).toBeInTheDocument();
25
+ });
8
26
  });
@@ -1,14 +1,47 @@
1
1
  import React from "react";
2
+ interface SliderContextProps {
3
+ currentIndex: number;
4
+ totalSlides: number;
5
+ visibleSlides: number;
6
+ direction: "horizontal" | "vertical";
7
+ infinite: boolean;
8
+ gap: number;
9
+ setTotalSlides: (count: number) => void;
10
+ goToNext: () => void;
11
+ goToPrev: () => void;
12
+ goToSlide: (index: number) => void;
13
+ }
14
+ export declare const useSlider: () => SliderContextProps;
2
15
  interface SliderProps {
3
16
  children: React.ReactNode;
4
17
  visibleSlides?: number;
5
- showDots?: boolean;
6
- showArrows?: boolean;
7
- dotsPosition?: "top" | "bottom" | "left" | "right";
8
- slideStep?: number;
9
18
  direction?: "horizontal" | "vertical";
10
- arrowStyle?: "minimal" | "filled" | "outlined";
11
- arrowColor?: "black" | "white";
19
+ initialIndex?: number;
20
+ infinite?: boolean;
21
+ autoplay?: boolean;
22
+ autoplaySpeed?: number;
23
+ gap?: number;
24
+ breakpoints?: {
25
+ [key: number]: {
26
+ visibleSlides: number;
27
+ };
28
+ };
29
+ }
30
+ declare const SliderMain: React.FC<SliderProps> & {
31
+ Track: typeof SliderTrack;
32
+ Button: typeof SliderButton;
33
+ Dots: typeof SliderDots;
34
+ };
35
+ declare const SliderTrack: React.FC<{
36
+ children: React.ReactNode;
37
+ }>;
38
+ interface ButtonProps {
39
+ type: "prev" | "next";
40
+ children?: React.ReactNode;
41
+ style?: "minimal" | "filled" | "outlined" | "plain";
12
42
  }
13
- declare const Slider: React.FC<SliderProps>;
14
- export default Slider;
43
+ declare const SliderButton: React.FC<ButtonProps>;
44
+ declare const SliderDots: React.FC<{
45
+ position?: "top" | "bottom" | "left" | "right";
46
+ }>;
47
+ export default SliderMain;
@@ -9,55 +9,99 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import React, { useState } from "react";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import React, { createContext, useContext, useState, useCallback, useMemo, useEffect } from "react";
14
14
  import { SliderWrapper, SlideTrack, Slide, DotsWrapper, Dot, Arrow, } from "./SliderStyles.styles";
15
- var Slider = function (_a) {
16
- var children = _a.children, _b = _a.visibleSlides, visibleSlides = _b === void 0 ? 1 : _b, _c = _a.showDots, showDots = _c === void 0 ? true : _c, _d = _a.showArrows, showArrows = _d === void 0 ? true : _d, _e = _a.dotsPosition, dotsPosition = _e === void 0 ? "bottom" : _e, _f = _a.slideStep, slideStep = _f === void 0 ? 1 : _f, _g = _a.direction, direction = _g === void 0 ? "horizontal" : _g, _h = _a.arrowStyle, arrowStyle = _h === void 0 ? "minimal" : _h, _j = _a.arrowColor, arrowColor = _j === void 0 ? "black" : _j;
17
- // Hooks must always be called unconditionally
18
- var _k = useState(0), currentIndex = _k[0], setCurrentIndex = _k[1];
19
- if (!children || React.Children.count(children) === 0) {
20
- return null; // Return null if children is null, avoiding rendering anything
15
+ var SliderContext = createContext(undefined);
16
+ export var useSlider = function () {
17
+ var context = useContext(SliderContext);
18
+ if (!context) {
19
+ throw new Error("Slider sub-components must be used within a <Slider />");
21
20
  }
22
- var totalSlides = React.Children.count(children);
23
- // Maximum index value, preventing overflow when navigating through slides.
24
- var maxIndex = totalSlides - visibleSlides;
25
- // Calculate the number of dots based on the total number of slides and the number of visible slides.
26
- var numberOfDots = Math.ceil((totalSlides - visibleSlides + 1) / slideStep);
21
+ return context;
22
+ };
23
+ var SliderMain = function (_a) {
24
+ var children = _a.children, _b = _a.visibleSlides, defaultVisibleSlides = _b === void 0 ? 1 : _b, _c = _a.direction, direction = _c === void 0 ? "horizontal" : _c, _d = _a.initialIndex, initialIndex = _d === void 0 ? 0 : _d, _e = _a.infinite, infinite = _e === void 0 ? false : _e, _f = _a.autoplay, autoplay = _f === void 0 ? false : _f, _g = _a.autoplaySpeed, autoplaySpeed = _g === void 0 ? 3000 : _g, _h = _a.gap, gap = _h === void 0 ? 0 : _h, breakpoints = _a.breakpoints;
25
+ var _j = useState(initialIndex), currentIndex = _j[0], setCurrentIndex = _j[1];
26
+ var _k = useState(defaultVisibleSlides), visibleSlides = _k[0], setVisibleSlides = _k[1];
27
+ var _l = useState(0), totalSlides = _l[0], setTotalSlides = _l[1];
28
+ // Responsive logic
29
+ useEffect(function () {
30
+ var handleResize = function () {
31
+ var width = window.innerWidth;
32
+ var activeVisibleSlides = defaultVisibleSlides;
33
+ if (breakpoints) {
34
+ var sorted = Object.keys(breakpoints).map(Number).sort(function (a, b) { return a - b; });
35
+ for (var _i = 0, sorted_1 = sorted; _i < sorted_1.length; _i++) {
36
+ var b = sorted_1[_i];
37
+ if (width >= b)
38
+ activeVisibleSlides = breakpoints[b].visibleSlides;
39
+ }
40
+ }
41
+ setVisibleSlides(activeVisibleSlides);
42
+ };
43
+ handleResize();
44
+ window.addEventListener("resize", handleResize);
45
+ return function () { return window.removeEventListener("resize", handleResize); };
46
+ }, [breakpoints, defaultVisibleSlides]);
47
+ var maxIndex = useMemo(function () { return Math.max(0, totalSlides - visibleSlides); }, [totalSlides, visibleSlides]);
48
+ var goToNext = useCallback(function () {
49
+ setCurrentIndex(function (prev) { return (infinite ? (prev >= maxIndex ? 0 : prev + 1) : Math.min(prev + 1, maxIndex)); });
50
+ }, [maxIndex, infinite]);
51
+ var goToPrev = useCallback(function () {
52
+ setCurrentIndex(function (prev) { return (infinite ? (prev <= 0 ? maxIndex : prev - 1) : Math.max(prev - 1, 0)); });
53
+ }, [maxIndex, infinite]);
54
+ var goToSlide = useCallback(function (index) { return setCurrentIndex(index); }, []);
55
+ useEffect(function () {
56
+ var interval;
57
+ if (autoplay && totalSlides > visibleSlides)
58
+ interval = setInterval(goToNext, autoplaySpeed);
59
+ return function () { return clearInterval(interval); };
60
+ }, [autoplay, autoplaySpeed, goToNext, totalSlides, visibleSlides]);
61
+ return (_jsx(SliderContext.Provider, __assign({ value: { currentIndex: currentIndex, totalSlides: totalSlides, setTotalSlides: setTotalSlides, visibleSlides: visibleSlides, direction: direction, infinite: infinite, gap: gap, goToNext: goToNext, goToPrev: goToPrev, goToSlide: goToSlide } }, { children: _jsx(SliderWrapper, __assign({ direction: direction }, { children: children })) })));
62
+ };
63
+ // --- Sub-Components ---
64
+ var SliderTrack = function (_a) {
65
+ var children = _a.children;
66
+ var _b = useSlider(), currentIndex = _b.currentIndex, direction = _b.direction, visibleSlides = _b.visibleSlides, setTotalSlides = _b.setTotalSlides, gap = _b.gap, goToNext = _b.goToNext, goToPrev = _b.goToPrev;
27
67
  var isHorizontal = direction === "horizontal";
28
- var goToNext = function () {
29
- setCurrentIndex(function (prevIndex) { return Math.min(prevIndex + slideStep, maxIndex); });
30
- };
31
- var goToPrev = function () {
32
- setCurrentIndex(function (prevIndex) { return Math.max(prevIndex - slideStep, 0); });
33
- };
34
- var goToSlide = function (index) {
35
- setCurrentIndex(index);
36
- };
37
- var slidePercentage = isHorizontal
38
- ? 100 / visibleSlides
39
- : 100 / totalSlides;
40
- return (_jsxs(SliderWrapper, __assign({ direction: direction, style: {
41
- height: isHorizontal ? "auto" : "".concat(visibleSlides * 200, "px"),
42
- display: isHorizontal ? "block" : "flex",
43
- flexDirection: isHorizontal ? "row" : "column",
44
- } }, { children: [showArrows && (_jsx(Arrow, __assign({ direction: isHorizontal ? "left" : "up", arrowStyle: arrowStyle, arrowColor: arrowColor, onClick: goToPrev }, { children: isHorizontal ? "<" : "˄" }))), _jsx(SlideTrack, __assign({ style: {
45
- transform: isHorizontal
46
- ? "translateX(-".concat(currentIndex * slidePercentage, "%)")
47
- : "translateY(-".concat((currentIndex * slideStep * 100) / totalSlides, "%)"),
48
- display: "flex",
49
- flexDirection: isHorizontal ? "row" : "column",
50
- width: isHorizontal ? "100%" : "100%",
51
- height: isHorizontal ? "auto" : "".concat(totalSlides * 100, "%"),
52
- transition: "transform 0.3s ease-in-out",
53
- boxSizing: "border-box",
54
- } }, { children: React.Children.map(children, function (child, index) { return (_jsx(Slide, __assign({ visibleSlides: visibleSlides, style: {
55
- flex: isHorizontal ? "0 0 ".concat(slidePercentage, "%") : "1",
56
- width: isHorizontal ? "".concat(slidePercentage, "%") : "100%",
57
- height: isHorizontal ? "auto" : "".concat(100 / totalSlides, "%"),
58
- boxSizing: "border-box",
59
- margin: "0",
60
- padding: "0",
61
- } }, { children: child }), index)); }) })), showArrows && (_jsx(Arrow, __assign({ direction: isHorizontal ? "right" : "down", arrowStyle: arrowStyle, arrowColor: arrowColor, onClick: goToNext }, { children: isHorizontal ? ">" : "˅" }))), showDots && (_jsx(DotsWrapper, __assign({ position: dotsPosition }, { children: Array.from({ length: numberOfDots }).map(function (_, index) { return (_jsx(Dot, { active: index * slideStep === currentIndex, onClick: function () { return goToSlide(index * slideStep); } }, index)); }) })))] })));
68
+ var count = React.Children.count(children);
69
+ // Sync totalSlides count back to context
70
+ useEffect(function () {
71
+ setTotalSlides(count);
72
+ }, [count, setTotalSlides]);
73
+ if (count === 0)
74
+ return null;
75
+ var transformPercentage = (currentIndex / count) * 100;
76
+ var transformValue = isHorizontal ? "translateX(-".concat(transformPercentage, "%)") : "translateY(-".concat(transformPercentage, "%)");
77
+ var trackWidth = (count / visibleSlides) * 100;
78
+ return (_jsx("div", __assign({ style: { overflow: "hidden", width: "100%", height: isHorizontal ? "auto" : "100%" } }, { children: _jsx(SlideTrack, __assign({ style: {
79
+ transform: transformValue,
80
+ flexDirection: isHorizontal ? "row" : "column",
81
+ width: isHorizontal ? "".concat(trackWidth, "%") : "100%",
82
+ height: isHorizontal ? "auto" : "".concat(trackWidth, "%"),
83
+ } }, { children: React.Children.map(children, function (child, index) { return (_jsx(Slide, __assign({ visibleSlides: visibleSlides, style: {
84
+ flex: "0 0 ".concat(100 / count, "%"),
85
+ padding: isHorizontal ? "0 ".concat(gap / 2, "px") : "".concat(gap / 2, "px 0"),
86
+ } }, { children: child }), index)); }) })) })));
87
+ };
88
+ var SliderButton = function (_a) {
89
+ var type = _a.type, children = _a.children, _b = _a.style, style = _b === void 0 ? "minimal" : _b;
90
+ var _c = useSlider(), goToNext = _c.goToNext, goToPrev = _c.goToPrev, direction = _c.direction;
91
+ var isHorizontal = direction === "horizontal";
92
+ var handleClick = type === "next" ? goToNext : goToPrev;
93
+ var defaultIcon = type === "next" ? (isHorizontal ? ">" : "˅") : (isHorizontal ? "<" : "˄");
94
+ return (_jsx(Arrow, __assign({ direction: type === "next" ? (isHorizontal ? "right" : "down") : (isHorizontal ? "left" : "up"), arrowStyle: style, arrowColor: "black", onClick: handleClick }, { children: children || defaultIcon })));
95
+ };
96
+ var SliderDots = function (_a) {
97
+ var _b = _a.position, position = _b === void 0 ? "bottom" : _b;
98
+ var _c = useSlider(), totalSlides = _c.totalSlides, visibleSlides = _c.visibleSlides, currentIndex = _c.currentIndex, goToSlide = _c.goToSlide;
99
+ var numberOfDots = Math.max(0, totalSlides - visibleSlides + 1);
100
+ if (numberOfDots <= 1)
101
+ return null;
102
+ return (_jsx(DotsWrapper, __assign({ position: position }, { children: Array.from({ length: numberOfDots }).map(function (_, index) { return (_jsx(Dot, { active: index === currentIndex, onClick: function () { return goToSlide(index); } }, index)); }) })));
62
103
  };
63
- export default Slider;
104
+ SliderMain.Track = SliderTrack;
105
+ SliderMain.Button = SliderButton;
106
+ SliderMain.Dots = SliderDots;
107
+ export default SliderMain;
@@ -14,6 +14,6 @@ export declare const Dot: import("styled-components/dist/types").IStyledComponen
14
14
  }>> & string;
15
15
  export declare const Arrow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
16
16
  direction: 'left' | 'right' | 'up' | 'down';
17
- arrowStyle: 'minimal' | 'filled' | 'outlined';
17
+ arrowStyle: 'minimal' | 'filled' | 'outlined' | 'plain';
18
18
  arrowColor: 'black' | 'white';
19
19
  }>> & string;
@@ -3,55 +3,58 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  return cooked;
4
4
  };
5
5
  import styled from 'styled-components';
6
- export var SliderWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: 100%;\n overflow: hidden;\n height: ", "; // Ensure full height for vertical sliders\n\n ", "\n"], ["\n position: relative;\n width: 100%;\n overflow: hidden;\n height: ", "; // Ensure full height for vertical sliders\n\n ", "\n"])), function (_a) {
6
+ export var SliderWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n width: 100%;\n overflow: hidden;\n height: ", ";\n\n ", "\n"], ["\n position: relative;\n width: 100%;\n overflow: hidden;\n height: ", ";\n\n ", "\n"])), function (_a) {
7
7
  var direction = _a.direction;
8
8
  return (direction === 'vertical' ? '100%' : 'auto');
9
9
  }, function (_a) {
10
10
  var direction = _a.direction;
11
11
  return direction === 'vertical' && "\n display: flex;\n flex-direction: column;\n ";
12
12
  });
13
- export var SlideTrack = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n transition: transform 0.3s ease-in-out;\n"], ["\n display: flex;\n transition: transform 0.3s ease-in-out;\n"])));
14
- export var Slide = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n margin: 0; \n padding: 0; \n"], ["\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n margin: 0; \n padding: 0; \n"])));
15
- export var DotsWrapper = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n flex-direction: ", ";\n margin-top: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n margin-right: ", ";\n"], ["\n display: flex;\n justify-content: center;\n flex-direction: ", ";\n margin-top: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n margin-right: ", ";\n"])), function (_a) {
13
+ export var SlideTrack = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n transition: transform 0.3s ease-in-out;\n /* Track width will be set dynamically via inline styles */\n"], ["\n display: flex;\n transition: transform 0.3s ease-in-out;\n /* Track width will be set dynamically via inline styles */\n"])));
14
+ export var Slide = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n box-sizing: border-box;\n flex-shrink: 0; /* Important: prevents slides from squeezing */\n width: 100%;\n height: 100%;\n"], ["\n box-sizing: border-box;\n flex-shrink: 0; /* Important: prevents slides from squeezing */\n width: 100%;\n height: 100%;\n"])));
15
+ export var DotsWrapper = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: absolute;\n display: flex;\n justify-content: center;\n z-index: 5;\n flex-direction: ", ";\n \n ", "\n ", "\n ", "\n ", "\n"], ["\n position: absolute;\n display: flex;\n justify-content: center;\n z-index: 5;\n flex-direction: ", ";\n \n ", "\n ", "\n ", "\n ", "\n"])), function (_a) {
16
16
  var position = _a.position;
17
17
  return (position === 'left' || position === 'right' ? 'column' : 'row');
18
18
  }, function (_a) {
19
19
  var position = _a.position;
20
- return (position === 'top' ? '10px' : '0');
20
+ return position === 'top' && "top: 10px; left: 50%; transform: translateX(-50%);";
21
21
  }, function (_a) {
22
22
  var position = _a.position;
23
- return (position === 'bottom' ? '10px' : '0');
23
+ return position === 'bottom' && "bottom: 10px; left: 50%; transform: translateX(-50%);";
24
24
  }, function (_a) {
25
25
  var position = _a.position;
26
- return (position === 'left' ? '10px' : '0');
26
+ return position === 'left' && "left: 10px; top: 50%; transform: translateY(-50%);";
27
27
  }, function (_a) {
28
28
  var position = _a.position;
29
- return (position === 'right' ? '10px' : '0');
29
+ return position === 'right' && "right: 10px; top: 50%; transform: translateY(-50%);";
30
30
  });
31
- export var Dot = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: ", ";\n margin: 0 5px;\n cursor: pointer;\n"], ["\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: ", ";\n margin: 0 5px;\n cursor: pointer;\n"])), function (_a) {
31
+ export var Dot = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: ", ";\n margin: 5px;\n cursor: pointer;\n transition: background-color 0.2s;\n"], ["\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: ", ";\n margin: 5px;\n cursor: pointer;\n transition: background-color 0.2s;\n"])), function (_a) {
32
32
  var active = _a.active;
33
33
  return (active ? 'black' : 'lightgray');
34
34
  });
35
- export var Arrow = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 50%;\n font-size: 24px;\n cursor: pointer;\n z-index: 1;\n user-select: none;\n\n // Horizontal arrows\n ", "\n ", "\n\n // Vertical arrows\n ", "\n ", "\n\n // Minimal style: no background or border\n ", "\n\n // Filled style: solid background and white arrow\n ", "\n\n // Outlined style: transparent background with colored border and arrow\n ", "\n"], ["\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 50%;\n font-size: 24px;\n cursor: pointer;\n z-index: 1;\n user-select: none;\n\n // Horizontal arrows\n ", "\n ", "\n\n // Vertical arrows\n ", "\n ", "\n\n // Minimal style: no background or border\n ", "\n\n // Filled style: solid background and white arrow\n ", "\n\n // Outlined style: transparent background with colored border and arrow\n ", "\n"])), function (_a) {
35
+ export var Arrow = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 10;\n user-select: none;\n transition: all 0.2s ease-in-out;\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n"], ["\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 10;\n user-select: none;\n transition: all 0.2s ease-in-out;\n\n ", "\n ", "\n ", "\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n"])), function (_a) {
36
36
  var direction = _a.direction;
37
- return direction === 'left' && 'left: 10px; top: 50%; transform: translateY(-50%);';
37
+ return direction === 'left' && 'left: 15px; top: 50%; transform: translateY(-50%);';
38
38
  }, function (_a) {
39
39
  var direction = _a.direction;
40
- return direction === 'right' && 'right: 10px; top: 50%; transform: translateY(-50%);';
40
+ return direction === 'right' && 'right: 15px; top: 50%; transform: translateY(-50%);';
41
41
  }, function (_a) {
42
42
  var direction = _a.direction;
43
- return direction === 'up' && 'top: 10px; left: 50%; transform: translateX(-50%);';
43
+ return direction === 'up' && 'top: 15px; left: 50%; transform: translateX(-50%);';
44
44
  }, function (_a) {
45
45
  var direction = _a.direction;
46
- return direction === 'down' && 'bottom: 10px; left: 50%; transform: translateX(-50%);';
46
+ return direction === 'down' && 'bottom: 15px; left: 50%; transform: translateX(-50%);';
47
47
  }, function (_a) {
48
48
  var arrowStyle = _a.arrowStyle;
49
- return arrowStyle === 'minimal' && "\n background-color: transparent;\n border: none;\n ";
49
+ return arrowStyle !== 'plain' && "\n width: 45px;\n height: 45px;\n border-radius: 50%;\n font-size: 20px;\n box-shadow: 0 4px 6px rgba(0,0,0,0.1);\n &:hover { transform: scale(1.1) ".concat(function (props) { return props.direction === 'left' || props.direction === 'right' ? 'translateY(-45%)' : 'translateX(-45%)'; }, "; }\n ");
50
50
  }, function (_a) {
51
51
  var arrowStyle = _a.arrowStyle, arrowColor = _a.arrowColor;
52
- return arrowStyle === 'filled' && "\n background-color: ".concat(arrowColor === 'white' ? 'white' : 'black', ";\n color: ").concat(arrowColor === 'white' ? 'black' : 'white', ";\n ");
52
+ return arrowStyle === 'minimal' && "\n background-color: rgba(255, 255, 255, 0.8);\n backdrop-filter: blur(4px);\n color: ".concat(arrowColor === 'white' ? 'white' : '#333', ";\n ");
53
53
  }, function (_a) {
54
54
  var arrowStyle = _a.arrowStyle, arrowColor = _a.arrowColor;
55
- return arrowStyle === 'outlined' && "\n background-color: transparent;\n border: 2px solid ".concat(arrowColor === 'white' ? 'white' : 'black', ";\n color: ").concat(arrowColor === 'white' ? 'white' : 'black', ";\n ");
55
+ return arrowStyle === 'filled' && "\n background-color: ".concat(arrowColor === 'white' ? '#fff' : '#222', ";\n color: ").concat(arrowColor === 'white' ? '#222' : '#fff', ";\n ");
56
+ }, function (_a) {
57
+ var arrowStyle = _a.arrowStyle, arrowColor = _a.arrowColor;
58
+ return arrowStyle === 'plain' && "\n background: none;\n font-size: 32px;\n font-weight: bold;\n color: ".concat(arrowColor === 'white' ? '#fff' : '#222', ";\n &:hover { opacity: 0.7; transform: scale(1.2) ").concat(function (props) { return props.direction === 'left' || props.direction === 'right' ? 'translateY(-42%)' : 'translateX(-42%)'; }, "; }\n ");
56
59
  });
57
60
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default as Slider } from './components/Slider';
1
+ import './index.css';
package/dist/index.js CHANGED
@@ -1 +1,12 @@
1
- export { default as Slider } from './components/Slider';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import ReactDOM from 'react-dom/client';
4
+ import './index.css';
5
+ import App from './App';
6
+ import reportWebVitals from './reportWebVitals';
7
+ var root = ReactDOM.createRoot(document.getElementById('root'));
8
+ root.render(_jsx(React.StrictMode, { children: _jsx(App, {}) }));
9
+ // If you want to start measuring performance in your app, pass a function
10
+ // to log results (for example: reportWebVitals(console.log))
11
+ // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
12
+ reportWebVitals();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-styled-slider-component",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A customizable React slider component built with react ts and styled-components.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,6 +33,17 @@
33
33
  "web-vitals": "^2.1.4"
34
34
  },
35
35
  "devDependencies": {
36
+ "@testing-library/jest-dom": "^6.9.1",
37
+ "@testing-library/react": "^16.3.2",
38
+ "@testing-library/user-event": "^14.6.1",
39
+ "@types/jest": "^30.0.0",
40
+ "@types/node": "^16.18.0",
41
+ "@types/react": "^18.2.0",
42
+ "@types/react-dom": "^18.2.0",
43
+ "@types/styled-components": "^5.1.0",
44
+ "react": "^18.2.0",
45
+ "react-dom": "^18.2.0",
46
+ "styled-components": "^6.1.1",
36
47
  "typescript": "^4.9.5"
37
48
  },
38
49
  "peerDependencies": {