Skip to content

Commit 42aa4be

Browse files
committed
Rename onPopoverRendered to onPopoverRender
1 parent 4e75205 commit 42aa4be

File tree

8 files changed

+24
-25
lines changed

8 files changed

+24
-25
lines changed

docs/src/content/guides/buttons.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ You can use the `onNextClick`, `onPreviousClick` and `onCloseClick` callbacks to
235235

236236
## Custom Buttons
237237

238-
You can add custom buttons using `onPopoverRendered` callback. This callback is called every time a popover is rendered. In the following example, we are adding a custom button that takes the user to the first step.
238+
You can add custom buttons using `onPopoverRender` callback. This callback is called before the popover is rendered. In the following example, we are adding a custom button that takes the user to the first step.
239239

240240

241241
<CodeSample
@@ -253,7 +253,7 @@ You can add custom buttons using `onPopoverRendered` callback. This callback is
253253
align: 'start',
254254
side: 'left',
255255
title: 'More Control with Hooks',
256-
description: 'You can use onPopoverRendered hook to modify the popover DOM. Here we are adding a custom button to the popover which takes the user to the first step.'
256+
description: 'You can use onPopoverRender hook to modify the popover DOM. Here we are adding a custom button to the popover which takes the user to the first step.'
257257
}
258258
},
259259
{
@@ -286,7 +286,7 @@ You can add custom buttons using `onPopoverRendered` callback. This callback is
286286
// Get full control over the popover rendering.
287287
// Here we are adding a custom button that takes
288288
// user to the first step.
289-
onPopoverRendered: (popover, { config, state }) => {
289+
onPopoverRender: (popover, { config, state }) => {
290290
const firstButton = document.createElement("button");
291291
firstButton.innerText = "Go to First";
292292
popover.footerButtons.appendChild(firstButton);

docs/src/content/guides/configuration.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type Config = {
6969
// PopoverDOM is an object with references to
7070
// the popover DOM elements such as buttons
7171
// title, descriptions, body, container etc.
72-
onPopoverRendered?: (popover: PopoverDOM, options: { config: Config; state: State }) => void;
72+
onPopoverRender?: (popover: PopoverDOM, options: { config: Config; state: State }) => void;
7373

7474
// Hooks to run before and after highlighting
7575
// each step. Each hook receives the following
@@ -163,7 +163,7 @@ type Popover = {
163163
// Parameter is an object with references to
164164
// the popover DOM elements such as buttons
165165
// title, descriptions, body, etc.
166-
onPopoverRendered?: (popover: PopoverDOM, options: { config: Config; state: State }) => void;
166+
onPopoverRender?: (popover: PopoverDOM, options: { config: Config; state: State }) => void;
167167

168168
// Callbacks for button clicks. You can use
169169
// these to add custom behavior to the buttons.

docs/src/content/guides/styling-popover.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { CodeSample } from "../../components/CodeSample.tsx";
88

99
You can either use the default class names and override the styles or you can pass a custom class name to the `popoverClass` option either globally or per step.
1010

11-
Alternatively, if want to modify the Popover DOM, you can use the `onPopoverRendered` callback to get the popover DOM element and do whatever you want with it.
11+
Alternatively, if want to modify the Popover DOM, you can use the `onPopoverRender` callback to get the popover DOM element and do whatever you want with it before popover is rendered.
1212

1313
We have added a few examples below but have a look at the [theming section](/docs/theming#styling-popover) for detailed guide including class names to target etc.
1414

@@ -155,7 +155,7 @@ Here is the CSS used for the above example:
155155
align: 'start',
156156
side: 'left',
157157
title: 'More Control with Hooks',
158-
description: 'You can use onPopoverRendered hook to modify the popover DOM. Here we are adding a custom button to the popover which takes the user to the first step.'
158+
description: 'You can use onPopoverRender hook to modify the popover DOM. Here we are adding a custom button to the popover which takes the user to the first step.'
159159
}
160160
},
161161
{
@@ -188,7 +188,7 @@ Here is the CSS used for the above example:
188188
// Get full control over the popover rendering.
189189
// Here we are adding a custom button that takes
190190
// the user to the first step.
191-
onPopoverRendered: (popover, { config, state }) => {
191+
onPopoverRender: (popover, { config, state }) => {
192192
const firstButton = document.createElement("button");
193193
firstButton.innerText = "Go to First";
194194
popover.footerButtons.appendChild(firstButton);

docs/src/content/guides/theming.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Visit the [example page](/docs/styling-popover) for an example that modifies the
5757

5858
## Modifying Popover DOM
5959

60-
Alternatively, you can also use the `onPopoverRendered` hook to modify the popover DOM before it is displayed. The hook is called with the popover DOM as the first argument.
60+
Alternatively, you can also use the `onPopoverRender` hook to modify the popover DOM before it is displayed. The hook is called with the popover DOM as the first argument.
6161

6262
```typescript
6363
type PopoverDOM = {
@@ -73,7 +73,7 @@ type PopoverDOM = {
7373
footerButtons: HTMLElement;
7474
};
7575

76-
onPopoverRendered?: (popover: PopoverDOM) => void;
76+
onPopoverRender?: (popover: PopoverDOM) => void;
7777
```
7878

7979
## Styling Page

index.html

+5-6
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,9 @@ <h2>Usage and Demo</h2>
452452
steps: basicTourSteps,
453453
showProgress: true,
454454
progressText: "{{current}} of {{total}} done",
455-
onPopoverRendered: (popover) => {
455+
onPopoverRender: (popover) => {
456456
popover.title.innerHTML = `${driverObj.getActiveIndex()} ${driverObj.hasNextStep() ? 'Yes' : 'No'} ${driverObj.hasPreviousStep() ? 'Yes' : 'No'}`
457457
popover.description.innerHTML = `${driverObj.isFirstStep() ? 'Yes' : 'No'} ${driverObj.isLastStep() ? 'Yes' : 'No'}`
458-
driverObj.refresh();
459458
}
460459
});
461460

@@ -662,7 +661,7 @@ <h2>Usage and Demo</h2>
662661

663662
document.getElementById("popover-hook").addEventListener("click", () => {
664663
const driverObj = driver({
665-
onPopoverRendered: popover => {
664+
onPopoverRender: popover => {
666665
popover.title.innerText = "Modified Parent";
667666
},
668667
});
@@ -673,7 +672,7 @@ <h2>Usage and Demo</h2>
673672
description: "Body of the popover",
674673
side: "bottom",
675674
align: "start",
676-
onPopoverRendered: popover => {
675+
onPopoverRender: popover => {
677676
popover.title.innerText = "Modified";
678677
},
679678
},
@@ -694,7 +693,7 @@ <h2>Usage and Demo</h2>
694693
description: "Body of the popover",
695694
side: "bottom",
696695
align: "start",
697-
onPopoverRendered: popover => {
696+
onPopoverRender: popover => {
698697
popover.title.innerText = "Modified";
699698
},
700699
},
@@ -777,7 +776,7 @@ <h2>Usage and Demo</h2>
777776

778777
document.getElementById("popover-hook-config").addEventListener("click", () => {
779778
const driverObj = driver({
780-
onPopoverRendered: popover => {
779+
onPopoverRender: popover => {
781780
const firstButton = document.createElement("button");
782781
firstButton.innerText = "First";
783782
popover.footerButtons.appendChild(firstButton);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "driver.js",
33
"private": false,
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"main": "./dist/driver.js.cjs",
66
"module": "./dist/driver.js.mjs",
77
"types": "./dist/driver.js.d.ts",

src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type Config = {
3131
doneBtnText?: string;
3232

3333
// Called after the popover is rendered
34-
onPopoverRendered?: (popover: PopoverDOM) => void;
34+
onPopoverRender?: (popover: PopoverDOM) => void;
3535

3636
// State based callbacks, called upon state changes
3737
onHighlightStarted?: DriverHook;

src/popover.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export type Popover = {
2828
prevBtnText?: string;
2929

3030
// Called after the popover is rendered
31-
onPopoverRendered?: (popover: PopoverDOM, opts: { config: Config; state: State }) => void;
31+
onPopoverRender?: (popover: PopoverDOM, opts: { config: Config; state: State }) => void;
3232

3333
// Button callbacks
3434
onNextClick?: DriverHook;
@@ -203,16 +203,16 @@ export function renderPopover(element: Element, step: DriveStep) {
203203

204204
setState("popover", popover);
205205

206-
repositionPopover(element, step);
207-
bringInView(popoverWrapper);
208-
209-
const onPopoverRendered = step.popover?.onPopoverRendered || getConfig("onPopoverRendered");
210-
if (onPopoverRendered) {
211-
onPopoverRendered(popover, {
206+
const onPopoverRender = step.popover?.onPopoverRender || getConfig("onPopoverRender");
207+
if (onPopoverRender) {
208+
onPopoverRender(popover, {
212209
config: getConfig(),
213210
state: getState(),
214211
});
215212
}
213+
214+
repositionPopover(element, step);
215+
bringInView(popoverWrapper);
216216
}
217217

218218
type PopoverDimensions = {

0 commit comments

Comments
 (0)