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

Updates #1005

Merged
merged 5 commits into from
Feb 22, 2024
Merged

Updates #1005

Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ jobs:
timezone: America/Sao_Paulo

- name: Setup repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: Cache Packages
id: cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -56,7 +56,8 @@ jobs:
run: npm run validate
timeout-minutes: 5

- uses: actions/upload-artifact@v3
- name: Save Playwright Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
Expand Down
11 changes: 9 additions & 2 deletions docs/callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ It will receive an object with the current state.
controlled: true,
index: 0,
lifecycle: 'init',
origin: null,
size: 4,
status: 'running',
step: { the.current.step },
Expand All @@ -24,6 +25,7 @@ It will receive an object with the current state.
controlled: true,
index: 0,
lifecycle: 'beacon',
origin: null,
size: 4,
status: 'running',
step: { the.current.step },
Expand All @@ -37,6 +39,7 @@ It will receive an object with the current state.
controlled: true,
index: 0,
lifecycle: 'complete',
origin: null,
size: 4,
status: 'running',
step: { the.current.step },
Expand All @@ -47,7 +50,7 @@ It will receive an object with the current state.
## Usage

```jsx
import Joyride, { ACTIONS, EVENTS, STATUS } from 'react-joyride';
import Joyride, { ACTIONS, EVENTS, ORIGIN, STATUS } from 'react-joyride';

export class App extends React.Component {
state = {
Expand All @@ -62,7 +65,11 @@ export class App extends React.Component {
};

handleJoyrideCallback = data => {
const { action, index, status, type } = data;
const { action, index, origin, status, type } = data;

if (action === ACTIONS.CLOSE && origin === ORIGIN.KEYBOARD) {
// do something
}

if ([EVENTS.STEP_AFTER, EVENTS.TARGET_NOT_FOUND].includes(type)) {
// Update state to advance the tour
Expand Down
4 changes: 3 additions & 1 deletion docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Joyride uses a few constants to keep its state and lifecycle.
You should use them in your component for the callback events.

```javascript
import Joyride, { ACTIONS, EVENTS, LIFECYCLE, STATUS } from 'react-joyride';
import Joyride, { ACTIONS, EVENTS, LIFECYCLE, ORIGIN, STATUS } from 'react-joyride';
```

ACTIONS - The action that updated the state.
Expand All @@ -13,6 +13,8 @@ EVENTS - The type of the event.

LIFECYCLE - The step lifecycle.

ORIGIN - The origin of the `CLOSE` action.

STATUS - The tour's status.

Consult the [source code](https://github.com/gilbarbara/react-joyride/blob/main/src/literals/index.ts) for more information.
1 change: 1 addition & 0 deletions e2e/controlled.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Controlled from '../test/__fixtures__/Controlled';
function formatCallbackResponse(input: Partial<CallBackProps>) {
return {
controlled: true,
origin: null,
size: 6,
status: STATUS.RUNNING,
...input,
Expand Down
1 change: 1 addition & 0 deletions e2e/scroll.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Scroll from '../test/__fixtures__/Scroll';
function formatCallbackResponse(input: Partial<CallBackProps>) {
return {
controlled: false,
origin: null,
size: 5,
status: STATUS.RUNNING,
...input,
Expand Down
1 change: 1 addition & 0 deletions e2e/standard.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Standard from '../test/__fixtures__/Standard';
function formatCallbackResponse(input: Partial<CallBackProps>) {
return {
controlled: false,
origin: null,
size: 6,
status: STATUS.RUNNING,
...input,
Expand Down
Loading
Loading