-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the carousel to use hooks and add new features
- Loading branch information
1 parent
3627601
commit 4be20ce
Showing
83 changed files
with
5,350 additions
and
7,043 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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: | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
--- | ||
sidebar_position: 3 | ||
sidebar_position: 5 | ||
--- | ||
|
||
# API (v7 and Below) | ||
# API (v7) | ||
|
||
## Carousel Props | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
sidebar_position: 6 | ||
--- | ||
|
||
import { Carousel } from 'nuka-carousel'; | ||
|
||
# Accessibility | ||
|
||
| Prop Name | Type | Default Value | | ||
| :----------------- | :------ | :------------ | | ||
| `keyboard` | boolean | `true` | | ||
| `title` | string | `undefined` | | ||
|
||
### Keyboard | ||
|
||
By default the carousel can be navigated using the keyboard. The `keyboard` prop can be used to disable the keyboard navigation. | ||
|
||
<Carousel showDots showArrows keyboard={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 showDots showArrows keyboard={false}> | ||
<img src="pexels-01.jpg" /> | ||
<img src="pexels-02.jpg" /> | ||
<img src="pexels-03.jpg" /> | ||
</Carousel> | ||
``` | ||
|
||
### Title | ||
|
||
The carousel has a `title` prop that can be used to provide a title for the carousel. The value of the title will be rendered as a hidden `h3` tag for the carousel targeted with the `aria-labeledby` attribute. This will help screen readers to announce the title of the carousel when it is focused. | ||
|
||
<Carousel showDots showArrows title="Carousel"> | ||
<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 showDots showArrows title="Carousel"> | ||
<img src="pexels-01.jpg" /> | ||
<img src="pexels-02.jpg" /> | ||
<img src="pexels-03.jpg" /> | ||
</Carousel> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
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. | ||
For accessibility, the carousel will pause when the user is interacting with it. | ||
|
||
| Prop Name | Type | Default Value | | ||
| :----------------- | :------ | :------------ | | ||
| `autoplay` | boolean | `false` | | ||
| `autoplayInterval` | number | `3000` | | ||
|
||
### Example | ||
|
||
<Carousel autoplay={true} autoplayInterval={1000} wrapMode="wrap"> | ||
<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} wrapMode="wrap"> | ||
<img src="pexels-01.jpg" /> | ||
<img src="pexels-02.jpg" /> | ||
<img src="pexels-03.jpg" /> | ||
</Carousel> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
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 | ||
|
||
```tsx | ||
<Carousel beforeSlide={() => myCustomBeforeFunction()}> | ||
{/* Cards */} | ||
</Carousel> | ||
``` | ||
|
||
```tsx | ||
<Carousel afterSlide={() => myCustomAfterFunction()}> | ||
{/* Cards */} | ||
</Carousel> | ||
``` |
Oops, something went wrong.