├── .editorconfig ├── .eslintignore ├── .eslintrc.cjs ├── .github └── FUNDING.yml ├── .gitignore ├── CODEOWNERS ├── LICENSE ├── README.md ├── demo ├── App.tsx ├── FreeScrollSliderDemo │ └── index.tsx ├── MarqueeSliderDemo │ └── index.tsx ├── ResponsiveSlider │ └── index.tsx ├── ScrollSnapSliderDemo │ └── index.tsx ├── ThumbnailSliderDemo │ └── index.tsx ├── index.html └── index.tsx ├── jest.config.js ├── package.json ├── src ├── DotNav │ └── index.tsx ├── Slide │ ├── index.tsx │ └── useIntersection.ts ├── SliderButton │ └── index.tsx ├── SliderNav │ └── index.tsx ├── SliderProgress │ └── index.tsx ├── SliderProvider │ ├── context.tsx │ ├── index.tsx │ ├── reducer.ts │ ├── useAutoplay.ts │ ├── useBreakpoints.ts │ ├── useDragScroll.ts │ ├── useMarquee.ts │ └── useScrollToIndex.ts ├── SliderTrack │ ├── getGhostSlideWidth.ts │ └── index.tsx ├── index.test.js ├── index.ts ├── types.ts ├── useSlider │ └── index.tsx └── withSlider │ └── index.tsx ├── tsconfig.build.json ├── tsconfig.json ├── webpack.build-demo.config.js ├── webpack.dev.config.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | end_of_line = lf 10 | max_line_length = null -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | dist-demo 3 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | extends: [ 4 | 'eslint:recommended', 5 | 'plugin:react/recommended', 6 | 'plugin:react-hooks/recommended', 7 | 'plugin:@typescript-eslint/recommended', 8 | ], 9 | env: { 10 | node: true, 11 | browser: true, 12 | jest: true, 13 | }, 14 | plugins: [ 15 | 'react', 16 | "react-hooks", 17 | 'jest', 18 | 'jest-dom', 19 | ], 20 | rules: { 21 | 'react/prop-types': 'off', 22 | 'react/jsx-max-props-per-line': [ 23 | 1, 24 | { 25 | maximum: 1, 26 | }, 27 | ], 28 | 'react/jsx-first-prop-new-line': [ 29 | 1, 30 | 'multiline', 31 | ], 32 | 'react/jsx-closing-bracket-location': [ 33 | 1, 34 | 'tag-aligned', 35 | ], 36 | 'object-curly-newline': [ 37 | 1, 38 | { 39 | multiline: true, 40 | consistent: true, 41 | }, 42 | ], 43 | 'object-property-newline': [ 44 | 1, 45 | { 46 | allowAllPropertiesOnSameLine: false, 47 | }, 48 | ], 49 | 'no-unused-vars': [ 50 | 1, 51 | ], 52 | '@typescript-eslint/ban-ts-comment': 'off', 53 | }, 54 | settings: { 55 | react: { 56 | version: 'detect', 57 | }, 58 | 'import/resolver': { 59 | node: { 60 | extensions: ['.js', '.jsx', '.ts', '.tsx'], 61 | }, 62 | }, 63 | }, 64 | }; 65 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [jacobsfletch] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 2 | patreon: # Replace with a single Patreon username 3 | open_collective: # Replace with a single Open Collective username 4 | ko_fi: # Replace with a single Ko-fi username 5 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 6 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 7 | liberapay: # Replace with a single Liberapay username 8 | issuehunt: # Replace with a single IssueHunt username 9 | otechie: # Replace with a single Otechie username 10 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | package-lock.json 4 | dist 5 | dist-demo 6 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @jacobsfletch 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Faceless UI 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://www.npmjs.com/@faceless-ui/slider) 2 |  3 | 4 | # React Slider 5 | 6 | Read the full documentation [here](https://facelessui.com/docs/slider). 7 | 8 | ## Installation 9 | 10 | ```bash 11 | $ npm i @faceless-ui/slider 12 | $ # or 13 | $ yarn add @faceless-ui/slider 14 | ``` 15 | 16 | ## Development 17 | 18 | To develop this module locally, spin up the [demo app](./demo/App.demo.js): 19 | 20 | ```bash 21 | $ git clone git@github.com:faceless-ui/slider.git 22 | $ yarn 23 | $ yarn dev 24 | $ open http://localhost:3000 25 | ``` 26 | 27 | ## License 28 | 29 | [MIT](https://github.com/faceless-ui/slider/blob/master/LICENSE) Copyright (c) Faceless UI 30 | -------------------------------------------------------------------------------- /demo/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ResponsiveSlider from './ResponsiveSlider/index.js'; 3 | // import MarqueeSliderDemo from './MarqueeSliderDemo/index.js'; 4 | // import FreeScrollSliderDemo from './FreeScrollSliderDemo/index.js'; 5 | // import ThumbnailSliderDemo from './ThumbnailSliderDemo/index.js'; 6 | // import ScrollSnapSliderDemo from './ScrollSnapSliderDemo/index.js'; 7 | 8 | const App: React.FC = () => ( 9 |
14 |
15 | slidesToShow: 2
16 |
17 | scrollable: true
18 |
19 |
20 |
11 |
12 | slidesToShow: 2
13 |
14 | scrollable: true
15 |
16 |
17 |
15 |
16 | slidesToShow: 1
17 |
18 | {`autoPlay: ${autoPlay}`}
19 |
20 |
21 |
29 | >( 5 | PassedComponent: React.ComponentType
, 6 | ): React.FC
=> { 7 | const SliderContextWrap: React.FC
= (props) => {
8 | const sliderContext = useSlider();
9 |
10 | return (
11 |