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

v8 Rewrite #1043

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
e507904
Remove old carousel package, add basic children rendering and test stubs
Feb 1, 2024
efc3871
Add next and previous slide hooks
Feb 3, 2024
d09e8bf
Next and previous buttons by slide width
melvin-chen Feb 7, 2024
2658ca0
Add autoplay, fix scroll distance
melvin-chen Feb 8, 2024
a6c7d4d
Add back index.tsx
melvin-chen Feb 8, 2024
f0c08ee
Scroll by screen width
melvin-chen Feb 8, 2024
111c8af
Refactor scroll handling based on page indices
melvin-chen Feb 13, 2024
5fae4f2
Fix scroll by screen width, update jsx in tsconfig
melvin-chen Feb 13, 2024
dd02cf9
Set index for on button clicks
melvin-chen Feb 14, 2024
ca23f2b
Wrap around, fix index issue, fix autoplay bug
melvin-chen Feb 14, 2024
3724ab7
Use es2022 methods
melvin-chen Feb 16, 2024
13624e3
Add api docs
melvin-chen Feb 16, 2024
0556406
Add examples into docs
melvin-chen Feb 16, 2024
90160fa
Add mock for css files
melvin-chen Feb 20, 2024
87577a0
Fix lint in mock
melvin-chen Feb 20, 2024
5eedae8
Fix style mock path, comment out tests
melvin-chen Feb 20, 2024
aa4669f
Cleanup tests
melvin-chen Feb 20, 2024
909e3a4
Add storybook test workflow
melvin-chen Feb 20, 2024
85438c0
Storybook test CI update
melvin-chen Feb 20, 2024
49e3429
Update storybook build command
melvin-chen Feb 20, 2024
d3d6e83
Test manually adding wait-on
melvin-chen Feb 21, 2024
7ebe168
update wait on tcp address
melvin-chen Feb 21, 2024
1db7dcc
update wait on tcp address
melvin-chen Feb 21, 2024
5bcf9ea
Add tests into storybook stories, update function for website examples
melvin-chen Feb 21, 2024
64437cc
Add focusable example
melvin-chen Feb 21, 2024
63031b8
Docs for methods and upgrade guide
melvin-chen Feb 22, 2024
ce84a45
Link v8 to docs
melvin-chen Feb 22, 2024
717f4d3
Go to index function
melvin-chen Feb 22, 2024
f3e55fe
use separate named component for custom render
melvin-chen Feb 23, 2024
50e3aab
Update test script for storybook testing, comment out cypress tests
melvin-chen Feb 26, 2024
d8eb4e0
Use matrix node version
melvin-chen Feb 26, 2024
83c8a14
Use all pnpm commands for storybook-tests
melvin-chen Feb 26, 2024
a910126
Use all yarn commands for storybook-tests
melvin-chen Feb 26, 2024
8225b60
Add pnpm action-steup line
melvin-chen Feb 26, 2024
54fc328
Add testing packages to devDependencies
melvin-chen Feb 26, 2024
e1ad237
Fix indefinite hang on wait
melvin-chen Feb 26, 2024
638b378
Remove cypress tests, remove cypress workflow, add to storybook inter…
melvin-chen Feb 26, 2024
bcf2cf1
Upgrade node versions, remove side effect, use named exports
melvin-chen Feb 28, 2024
3f4df56
Add side effects back in, use named export, add resize listener
melvin-chen Feb 28, 2024
2ab32e1
Add before/after slide hooks, docs, and tests
melvin-chen Feb 29, 2024
9bd5d8e
Add missing useeffect dependencies
melvin-chen Feb 29, 2024
bc36817
Rename prop type to capital, Remove buttons by default on demos, add …
melvin-chen Feb 29, 2024
495b25f
Add info about built in buttons into docs
melvin-chen Mar 1, 2024
c2e59d2
Round numbers to fix page indicator and scrolling bugs
melvin-chen Mar 1, 2024
b8ae41f
Cleanup CI and add chromatic
carbonrobot Mar 13, 2024
a2bd014
Need duplicate command for chromatic
carbonrobot Mar 13, 2024
3b433b7
Rename container class and improve doc page
carbonrobot Mar 13, 2024
6dfa9b7
Remove old storybook test workflow
carbonrobot Mar 13, 2024
8df4843
Use images instead of Formidable logos
carbonrobot Mar 13, 2024
9437cf8
Namespace css to avoid collisions
carbonrobot Mar 15, 2024
33a587f
Reduce demo image sizes
carbonrobot Mar 15, 2024
3394b93
Change layout of documentation
carbonrobot Mar 15, 2024
fa72093
Remove cypress leftovers
carbonrobot Mar 16, 2024
61033de
Add more slides for better testing
carbonrobot Mar 16, 2024
864bd24
Refactor effects and hooks
carbonrobot Mar 16, 2024
7df950d
Re-enable support for multiple width slides
carbonrobot Mar 16, 2024
4bbfa39
Create default page indicator styling
carbonrobot Mar 16, 2024
56f9915
Move styling API to container to avoid gap bug
carbonrobot Mar 16, 2024
2a6bdab
Add wraparound option to API
carbonrobot Mar 16, 2024
9ad5c30
Refactor measurements into hook
carbonrobot Mar 16, 2024
fb2337a
Recalculate dimensions on resize
carbonrobot Mar 16, 2024
7d030cd
Add swiping property
carbonrobot Mar 16, 2024
3b818da
Add nav buttons
carbonrobot Mar 16, 2024
356e710
Improve doc page main demo
carbonrobot Mar 16, 2024
5cacb02
Fix slide page count
carbonrobot Mar 17, 2024
db05774
Namespace to avoid conflicts with consumer app
carbonrobot Mar 17, 2024
623dee3
Cleanup and simplify hooks
carbonrobot Mar 17, 2024
1952505
Update website branding
carbonrobot Mar 17, 2024
8c14687
Add basic docs landing page
carbonrobot Mar 18, 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
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:cypress/recommended",
"plugin:react/recommended"
],
"env": {
Expand Down Expand Up @@ -45,6 +44,7 @@
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/no-var-requires": 0
"@typescript-eslint/no-var-requires": 0,
"react/react-in-jsx-scope": "off"
}
}
23 changes: 23 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Setup
description: Setup Build Step
inputs:
node-version:
required: true
default: '18.x'

runs:
using: "composite"
steps:
- uses: pnpm/action-setup@v3
with:
version: 7

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: 'pnpm'

- name: Install dependencies
shell: bash
run: pnpm install
32 changes: 32 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Chromatic

on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- 'packages/**'

jobs:
chromatic:
name: Storybook Publish
runs-on: ubuntu-latest
steps:
# requires all branches and tags to be fetched for chromatic
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup

- name: Build
run: pnpm build

- name: Publish to Chromatic
uses: chromaui/action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
32 changes: 4 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,12 @@ jobs:
build:
name: Check and build codebase
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x, 18.x ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- uses: pnpm/[email protected]
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('./pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Check Code ${{ matrix.node-version }}
- name: Check Code
run: pnpm check:ci

- name: Build ${{ matrix.node-version }}
- name: Build
run: pnpm build
53 changes: 0 additions & 53 deletions .github/workflows/cypress.yml

This file was deleted.

32 changes: 2 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,8 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x

- uses: pnpm/[email protected]
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- name: Build packages
run: pnpm run build
Expand All @@ -53,9 +28,6 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
# Note: Our `package.json:scripts.version` currently doesn't have `--fix-lockfile` for
# `pnpm install` because of a PNPM bug of some kind.
# https://github.com/FormidableLabs/spectacle/issues/1156
version: pnpm run version
publish: pnpm changeset publish
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ cypress/screenshots
cypress/videos
/packages/nuka/cypress/screenshots
/packages/nuka/cypress/videos
/packages/nuka/storybook-static
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013 - 2018 Formidable Labs, Inc.
Copyright (c) 2013-2024 Formidable Labs, Inc.

Copyright (c) 2018 Roman Charugin, Alex Smith, Matt Sungwook, and potentially
other DefinitelyTyped contributors.
Expand All @@ -20,4 +20,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Nuka Carousel — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/nuka-carousel/main/Nuka-Hero.png)](https://formidable.com/open-source/nuka-carousel)
[![Nuka Carousel](https://raw.githubusercontent.com/FormidableLabs/nuka-carousel/main/Nuka-Hero.png)](https://commerce.nearform.com/open-source/nuka-carousel)

[![Maintenance Status][maintenance-image]](#maintenance-status)

Expand All @@ -15,11 +15,11 @@ To add `nuka-carousel` to your project run the following command in your project
$ yarn add nuka-carousel
```

Come learn more and see a live demo at our [docs site](https://formidable.com/open-source/nuka-carousel)!
Come learn more and see a live demo at our [docs site](https://commerce.nearform.com/open-source/nuka-carousel)!

## Support

Have a question about react-live? Submit an issue in this repository using the
Have a question about nuka-carousel? Submit an issue in this repository using the
["Question" template](https://github.com/FormidableLabs/nuka-carousel/issues/new?template=question.md).

Notice something inaccurate or confusing? Feel free to [open an issue](https://github.com/FormidableLabs/nuka-carousel/issues/new/choose) or [make a pull request](https://github.com/FormidableLabs/nuka-carousel/pulls) to help improve the documentation for everyone!
Expand All @@ -33,6 +33,6 @@ See the [Contribution Docs](CONTRIBUTING.md).

### Maintenance Status

**Active:** Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.
**Active:** Nearform is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.

[maintenance-image]: https://img.shields.io/badge/maintenance-active-green.svg?color=brightgreen&style=flat
4 changes: 2 additions & 2 deletions docs/api.mdx → docs/api-v7.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
sidebar_position: 3
sidebar_position: 5
---

# API
# API (v7)

## Carousel Props

Expand Down
34 changes: 34 additions & 0 deletions docs/api/autoplay.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
sidebar_position: 3
---

import { Carousel } from 'nuka-carousel';

# Autoplay

The carousel can advance on its own with a specified interval measured in milliseconds. An `autoplayInterval` without the `autoplay` prop being true will not do anything.

### Details

| Prop Name | Type | Default Value |
| :----------------- | :------ | :------------ |
| `autoplay` | boolean | `false` |
| `autoplayInterval` | number | `3000` |

### Example

<Carousel autoplay={true} autoplayInterval={1000}>
<img src="/open-source/nuka-carousel/img/pexels-01.jpg" />
<img src="/open-source/nuka-carousel/img/pexels-02.jpg" />
<img src="/open-source/nuka-carousel/img/pexels-03.jpg" />
</Carousel>

#### Code

```tsx
<Carousel autoplay={true} autoplayInterval={1000}>
<img src="pexels-01.jpg" />
<img src="pexels-02.jpg" />
<img src="pexels-03.jpg" />
</Carousel>
```
53 changes: 53 additions & 0 deletions docs/api/buttons.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
sidebar_position: 2
---

import { Carousel } from 'nuka-carousel';

# Navigation

The carousel can show buttons to navigate between slides.

### Details

| Prop Name | Type | Default Value |
| :----------------- | :------- | :------------ |
| `showButtons` | boolean | `false` |

### Example

<Carousel showButtons>
<img src="/open-source/nuka-carousel/img/pexels-01.jpg" />
<img src="/open-source/nuka-carousel/img/pexels-02.jpg" />
<img src="/open-source/nuka-carousel/img/pexels-03.jpg" />
</Carousel>

#### Code

```tsx
<Carousel showButtons>
<img src="pexels-01.jpg" />
<img src="pexels-02.jpg" />
<img src="pexels-03.jpg" />
</Carousel>
```

### Wraparound

When the `wrapAround` prop is set to `false`, the buttons will be hidden when the first or last slide is active.

<Carousel showButtons wrapAround={false}>
<img src="/open-source/nuka-carousel/img/pexels-01.jpg" />
<img src="/open-source/nuka-carousel/img/pexels-02.jpg" />
<img src="/open-source/nuka-carousel/img/pexels-03.jpg" />
</Carousel>

#### Code

```tsx
<Carousel showButtons wrapAround={false}>
<img src="pexels-01.jpg" />
<img src="pexels-02.jpg" />
<img src="pexels-03.jpg" />
</Carousel>
```
35 changes: 35 additions & 0 deletions docs/api/callbacks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
sidebar_position: 90
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';

# Callbacks

## Before/After Slide

Functions that are invoked when the progression methods (goBack()/goForward()) are called or when carousel changes its scroll position.

### Details

| Prop Name | Type | Default Value |
| :------------ | :--------- | :------------ |
| `beforeSlide` | () => void | `undefined` |
| `afterSlide` | () => void | `undefined` |

- `beforeSlide` - Runs a given function before scrolling when a progression method is called. It will also run right before the carousel registers that it has been scrolled on if manually scrolled.
- `afterSlide` - Runs a given function after scrolling when a progression method is called or after manually scrolling.

### Example

This is a code usage example. Docusaurus will not run passed functions because the components are converted to static HTML at build time.

```tsx
<Carousel beforeSlide={() => myCustomBeforeFunction()}>{/* Cards */}</Carousel>
```

```tsx
<Carousel afterSlide={() => myCustomAfterFunction()}>{/* Cards */}</Carousel>
```
Loading
Loading