Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from fork #15

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
181476d
Upgrade AdaptiveHeight to functional component
Vogric Feb 6, 2021
994ce1c
Update FUNDING.yml
akiran Sep 17, 2021
06a607f
removed sass
akiran Dec 11, 2021
c923c95
updated eslint packages to fix #2078
akiran Dec 11, 2021
fd9de1a
Fixed issue with image click event
PaoloPia Apr 12, 2022
9eb7df7
add support for React18
jeffascript Apr 17, 2022
12e1fea
Merge pull request #2151 from jeffascript/react18
akiran Apr 17, 2022
c3e1684
released 0.29.0
akiran Apr 17, 2022
2a21315
Merge pull request #2149 from PaoloPia/fixImageClick
akiran Jul 21, 2022
9fa8781
Merge pull request #1981 from Vogric/patch-1
akiran Jul 23, 2022
2f7fdf5
remove old tests
akiran Jul 26, 2022
472c848
test setup with testing library
akiran Jul 26, 2022
4e6250b
wrote tests for basic slider example
akiran Jul 26, 2022
19b770e
Update README.md
akiran Aug 21, 2022
b9302d6
Update README.md
akiran Aug 21, 2022
89d1e89
Fixed broken link from CONTRIBUTING.md
pZacca Oct 15, 2022
7035d84
tests init
akiran May 15, 2023
34b4ca0
Merge branch 'master' into fix-2166
akiran May 15, 2023
0711da9
completed the simpleslider test and started centerMode test
pratyushbh May 15, 2023
c4f6fde
migrated all the test of examples from enezyme to react-testing-library
pratyushbh May 16, 2023
338201f
migrated all the tests to testing-library/react and removed Snapshots
pratyushbh May 18, 2023
83423c8
removed the console logs
pratyushbh May 19, 2023
b03b477
renamed few test utils
akiran May 21, 2023
e6b231a
fix current slide issue
akiran May 21, 2023
e45defb
added a comment
akiran May 21, 2023
90b1aff
Merge pull request #2238 from akiran/fix-2166-2
akiran May 21, 2023
9c52885
Fixed 2231: Move build script from prepublish -> prepublishOnly
akiran May 23, 2023
f3f3c3d
Merge pull request #2240 from akiran/fix-2221
akiran May 23, 2023
0d30a59
Merge pull request #2194 from pZacca/add-pzacca
akiran May 25, 2023
f880fba
wrote the tests of #1874 that came out to be successful
pratyushbh May 25, 2023
f5bb030
Converted the examples to Functional component and created new Slider…
pratyushbh May 30, 2023
882a01d
added node options to run docs
akiran Jun 5, 2023
e1e766f
remove other changes
akiran Jun 5, 2023
38f99c1
Merge branch 'master' into function-component-examples
akiran Jun 5, 2023
45e92f0
fixed some issues with component changes
akiran Jun 5, 2023
5558419
Merge pull request #2244 from akiran/function-component-examples
akiran Jun 5, 2023
76b833f
added an empty prettierrc file to use default prettier config
akiran Jan 19, 2024
bb355c2
added react-slick alias in webpack for examples
akiran Jan 19, 2024
d91bb58
running single demo on different port
akiran Jan 20, 2024
3669b0a
Fix: If the element (DOM element) and the value of 'slidesToShow' are…
rjsdnql123 Jan 24, 2024
15d93c5
Merge pull request #2329 from rjsdnql123/fix/element-slidesToShow-sam…
akiran Jan 24, 2024
5b2e405
added tests for #1813
akiran Jan 25, 2024
ff0cd50
release 0.30.0
akiran Jan 25, 2024
891f399
added node options to fix build issue
akiran Jan 25, 2024
358d8c0
created a generic slider component for tests
akiran Jan 25, 2024
dbae660
fixed #1874: slick-current is always on first slide despite initialSl…
akiran Jan 25, 2024
2420174
Merge pull request #2330 from akiran/fix-1874
akiran Jan 25, 2024
9d96291
Fixed #2315
akiran Jan 25, 2024
27870b7
Test for #2315
akiran Jan 26, 2024
8c9488f
check of NaN in props change detection
akiran Jan 26, 2024
02629d5
added tests for filterSettings util
akiran Jan 26, 2024
99adf6f
Merge pull request #2331 from akiran/fix-2315
akiran Jan 26, 2024
250f078
release 0.30.1
akiran Jan 26, 2024
0a66bd7
updated instructions for css loading
akiran Jan 26, 2024
1bd9c09
updated readme
akiran Jan 26, 2024
7710dc9
Move testing dependency to devDependencies
jorrit Feb 2, 2024
72ffb60
Merge pull request #2339 from jorrit/fixtestdep
akiran Feb 2, 2024
013f424
moved scripts from examples to docs
akiran Feb 3, 2024
5a99cd1
examples config to docs
akiran Feb 3, 2024
c0fde5e
cleanup examples
akiran Feb 3, 2024
e06967c
Added slider-container class to examples
akiran Feb 5, 2024
1a3f604
Replaced codesandbox with stackblitz playground link
akiran Feb 5, 2024
ec32089
Fixed #2076 click issue in Fade mode
akiran Feb 8, 2024
cf31307
Added regenerator-runtime for async jest tests
akiran Feb 9, 2024
372349a
updated jest config to run tests only with .test.js extension
akiran Feb 9, 2024
b9150c1
updated jest config to ignore playwright tests
akiran Feb 9, 2024
d4595b0
placeholder for test
akiran Feb 16, 2024
0f95c7a
Merge pull request #2343 from akiran/fix-2076
akiran Feb 16, 2024
23c6a47
add asNavFor for default prop
akiran Feb 17, 2024
9227178
remove empty test file
akiran Feb 17, 2024
5a7c0a8
Merge pull request #2349 from akiran/fix-2344
akiran Feb 17, 2024
5478d8d
released 0.30.2
akiran Feb 17, 2024
c7a9666
Fix: The unslick property is missing in the filterSettings, so the va…
rjsdnql123 Apr 8, 2024
bae8817
Merge pull request #2366 from rjsdnql123/unslick-is-missing-in-filter…
akiran Apr 11, 2024
4ef2ce1
Merge remote-tracking branch 'upstream/master' into update-from-fork
KoderFPV Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@
"react/prop-types": 0,
"react/no-find-dom-node": 0,
"react/display-name": 0,
"no-console": 0
"no-console": 0,
"no-prototype-builtins": 0
},
"env": {
"node": true,
"browser": true,
"es6": true,
"jasmine": true
},
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false
},
"plugins": [
"react",
"import"
"react",
"import"
],
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:react/recommended"
]
}
}
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github: akiran
open_collective: react-slick
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trailingComma: none
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We welcome any type of contribution, not only code. You can help with

## Your First Contribution

Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).

## Submitting code

Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### react-slick

[![Backers on Open Collective](https://opencollective.com/react-slick/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/react-slick/sponsors/badge.svg)](#sponsors) [![Join the chat at https://gitter.im/akiran/react-slick](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/akiran/react-slick?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Backers on Open Collective](https://opencollective.com/react-slick/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/react-slick/sponsors/badge.svg)](#sponsors)

##### Carousel component built with React. It is a react port of [slick carousel](http://kenwheeler.github.io/slick/)

Expand Down Expand Up @@ -37,16 +37,16 @@ or add cdn link in your html
rel="stylesheet"
type="text/css"
charset="UTF-8"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css"
/>
<link
rel="stylesheet"
type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css"
href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css"
/>
```

### [PlayGround](https://codesandbox.io/s/ppwkk5l6xx)
### [PlayGround](https://stackblitz.com/edit/vitejs-vite-ownrun?file=src%2FImageSlider.jsx)

### Example

Expand Down Expand Up @@ -107,6 +107,10 @@ npm start
open http://localhost:8080
```

## Community

Join our [discord channel](https://discord.gg/z7stRE4Cyb) to discuss react-slick bugs and ask for help

## Contributing

Please see the [contributing guidelines](./CONTRIBUTING.md)
1 change: 0 additions & 1 deletion __tests__/SimpleSlider.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// includes tests of
// SimpleSlider, MultipleItems
import { mount } from "enzyme";
import { testSlider } from "./testUtils";

describe("SimpleSlider with combinations of possibilities", function() {
Expand Down
13 changes: 13 additions & 0 deletions __tests__/TestComponents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import Slider from "../src/index";

export function GenericSliderComponent({ slidesCount, settings }) {
const slides = [...Array(slidesCount).keys()].map(item => (
<div key={item}>{item + 1}</div>
));
return <Slider {...settings}>{slides}</Slider>;
}

test("fake test", () => {
expect(1).toBe(1);
});
49 changes: 18 additions & 31 deletions __tests__/afterChange.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import React from "react";
import { mount } from "enzyme";
import { render, fireEvent } from "@testing-library/react";
import Slider from "../src/index";
import {
getActiveSlide,
clickNext,
clickPrevious,
getCurrentSlide
} from "../test-utils";

class SliderWithBeforeChange extends React.Component {
class SliderWithAfterChange extends React.Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -31,37 +37,18 @@ class SliderWithBeforeChange extends React.Component {

describe("After change Slider", function() {
it("should render", function() {
const wrapper = mount(<SliderWithBeforeChange />);
expect(wrapper.state()).toEqual({ currentSlide: null });
wrapper.find(".slick-next").simulate("click");
const { container } = render(<SliderWithAfterChange />);
clickNext(container);
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 1 });
}, 1);
wrapper.find(".slick-next").simulate("click");
expect(getActiveSlide(container).textContent).toEqual("slide2");
}, 1000);
clickNext(container);
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide3");
expect(wrapper.state()).toEqual({ currentSlide: 2 });
}, 1);
wrapper.find(".slick-prev").simulate("click");
expect(getActiveSlide(container).textContent).toEqual("slide3");
}, 1000);
clickPrevious(container);
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 1 });
}, 1);
expect(getActiveSlide(container).textContent).toEqual("slide2");
}, 1000);
});
});
68 changes: 36 additions & 32 deletions __tests__/arrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

sinon.stub(console, "error");

import { render, shallow } from "enzyme";
import { render } from "@testing-library/react";
import React from "react";
import sinon from "sinon";

Expand All @@ -22,48 +22,52 @@ function CustomArrow(props) {

describe("Previous arrows", () => {
it("should render arrow", () => {
const wrapper = shallow(<PrevArrow />);
expect(wrapper.find("button")).toHaveLength(1);
const { container } = render(<PrevArrow />);
expect(Array.from(container.getElementsByTagName("button"))).toHaveLength(
1
);
});

it("should not result in errors", () => {
shallow(<PrevArrow />);
render(<PrevArrow />);

expect(console.error.called).toBe(false);
});

// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />
//
// const wrapper = render(<PrevArrow currentSlide={3} prevArrow={arr} slideCount={5} />);
//
// elAttributes = wrapper.find('.sample')[0].attribs;
// expect(elAttributes['data-currentslide']).toBe('3');
// expect(elAttributes['data-slidecount']).toBe('5');
// });
// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />

// const {container}= render(<PrevArrow currentSlide={3} prevArrow={arr} slideCount={5} />);

// elAttributes =x=> container.querySelectorAll('.sample')[0].getAttribute(x);
// expect(elAttributes('data-currentslide')).toBe('3');
// expect(elAttributes('data-slidecount')).toBe('5');
// });
});

describe("Next arrows", () => {
it("should render arrow", () => {
const wrapper = shallow(<NextArrow />);
expect(wrapper.find("button")).toHaveLength(1);
const { container } = render(<NextArrow />);
expect(Array.from(container.getElementsByTagName("button"))).toHaveLength(
1
);
});

// it('should not result in errors', () => {
// shallow(<NextArrow />);
//
// expect(console.error.called).toBe(false);
// });

// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />
//
// const wrapper = render(<NextArrow currentSlide={6} nextArrow={arr} slideCount={9} />);
//
// elAttributes = wrapper.find('.sample')[0].attribs;
// expect(elAttributes['data-currentslide']).toBe('6');
// expect(elAttributes['data-slidecount']).toBe('9');
// });
// it('should not result in errors', () => {
// render(<NextArrow />);

// expect(console.error.called).toBe(false);
// });

// it('should pass slide data to custom arrow', () => {
// let elAttributes;
// let arr = <CustomArrow />

// const {container} = render(<NextArrow currentSlide={6} nextArrow={arr} slideCount={9} />);

// elAttributes =(x)=> container.querySelectorAll('.sample')[0].getAttribute(x);
// expect(elAttributes('data-currentslide')).toBe('6');
// expect(elAttributes('data-slidecount')).toBe('9');
// });
});
42 changes: 15 additions & 27 deletions __tests__/beforeChange.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import React from "react";
import { mount } from "enzyme";
import { render } from "@testing-library/react";
import Slider from "../src/index";
import {
getActiveSlide,
clickNext,
clickPrevious,
getCurrentSlide
} from "../test-utils";

class SliderWithBeforeChange extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -29,32 +35,14 @@ class SliderWithBeforeChange extends React.Component {
}
}

describe.skip("Slider", function() {
describe("Slider", function() {
it("should render", function() {
const wrapper = mount(<SliderWithBeforeChange />);
wrapper.find(".slick-next").simulate("click");
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 0, nextSlide: 1 });
wrapper.find(".slick-next").simulate("click");
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide3");
expect(wrapper.state()).toEqual({ currentSlide: 1, nextSlide: 2 });
wrapper.find(".slick-prev").simulate("click");
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 2, nextSlide: 1 });
const { container } = render(<SliderWithBeforeChange />);
clickNext(container);
expect(getActiveSlide(container).textContent).toEqual("slide2");
clickNext(container);
expect(getActiveSlide(container).textContent).toEqual("slide3");
clickPrevious(container);
expect(getActiveSlide(container).textContent).toEqual("slide2");
});
});
22 changes: 0 additions & 22 deletions __tests__/index.js

This file was deleted.

14 changes: 7 additions & 7 deletions __tests__/jQSlickUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ function simulateActions(actions) {

// takes an object of keys and returns those details
/* Possible keys can be one of the following
currentSlide(index and value), activeSlides(index and value),
allSlides(index and value), clonedSlides(index and value)
*/
currentSlide(index and value), activeSlides(index and value),
allSlides(index and value), clonedSlides(index and value)
*/
function fetchDetails(keys) {
let details = {};
let currentSlide = null,
Expand Down Expand Up @@ -96,10 +96,10 @@ function fetchDetails(keys) {
export function getJQuerySlickDetails(settings, actions, keys) {
// create new slider
document.body.innerHTML = `
<section class="regular slider">
${createJQuerySliderChildren(settings.noOfSlides)}
</section>
`;
<section class="regular slider">
${createJQuerySliderChildren(settings.noOfSlides)}
</section>
`;
$(".regular.slider").slick({
...settings
});
Expand Down
Loading