Skip to content

Commit 542593a

Browse files
Fix button type, cancel link
1 parent ff7359c commit 542593a

4 files changed

Lines changed: 22 additions & 286 deletions

File tree

README.md

Lines changed: 8 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ It will be an object of a form something like:
9292
this.shepherdService.defaultStepOptions = {
9393
classes: 'custom-class-name-1 custom-class-name-2',
9494
scrollTo: false,
95-
showCancelLink: true
95+
cancelIcon: {
96+
enabled: true
97+
}
9698
};
9799
```
98100

@@ -176,10 +178,12 @@ this.shepherdService.addSteps([
176178
type: 'next'
177179
}
178180
],
181+
cancelIcon: {
182+
enabled: true
183+
},
179184
classes: 'custom-class-name-1 custom-class-name-2',
180185
highlightClass: 'highlight',
181186
scrollTo: false,
182-
showCancelLink: true,
183187
title: 'Welcome to Angular-Shepherd!',
184188
text: ['Angular-Shepherd is a JavaScript library for guiding users through your Angular app.'],
185189
when: {
@@ -196,144 +200,6 @@ this.shepherdService.addSteps([
196200
]);
197201
```
198202

199-
A lot of the options are the same as Shepherd options, but I will go through each of them for reference.
200-
201-
##### attachTo
202-
203-
The selector and position for the tour popup to attach to, of the format 'selector position'.
204-
Position options are: top, bottom, left, and right. Can also be an object formatted like
205-
206-
```js
207-
{
208-
element: '.myElement',
209-
on: 'top'
210-
}
211-
```
212-
213-
Where `.myElement` is any valid jQuery selector.
214-
215-
> **default value:** `''`
216-
217-
218-
##### beforeShowPromise
219-
220-
A function that returns a promise. When the promise resolves, the rest of the `show` code for the step will execute.
221-
222-
> **default value:** `null`
223-
224-
225-
##### buttons
226-
227-
There are some standard button types supported by angular-shepherd. Just set `type` to `'next'`, `'back'`, or `'cancel'`,
228-
then set the `text` and `classes` as normal. These will automatically be bound to the Shepherd functions. If
229-
no type is passed, a normal Shepherd button will be created.
230-
231-
##### classes
232-
233-
Extra classes to apply to the step, for styling purposes and such.
234-
235-
> **default value:** `''`
236-
237-
238-
#### canClickTarget
239-
240-
Whether or not the target element being attached to should be "clickable". If set to `false`, Angular Shepherd
241-
sets the element's [`pointerEvents` style](https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events) to
242-
`none` while the step is active.
243-
244-
> **default value:** `true`
245-
246-
247-
##### highlightClass
248-
249-
This is an extra class to apply to the attachTo element when it is highlighted (that is, when its step is active).
250-
It can be any string. Just style that class name in your CSS.
251-
252-
> **default value:** ``
253-
254-
#### id
255-
256-
The name to give this step of the tour
257-
258-
##### scrollTo
259-
260-
This sets whether or not the screen should be scrolled to get to the element when the step becomes active.
261-
262-
> **default value:** `false`
263-
264-
265-
##### scrollToHandler
266-
267-
For custom scrolling actions, pass a function to this option. For example:
268-
269-
```js
270-
271-
let scrollHandler = (el) => {
272-
let winHeight = $(window).height();
273-
// Target vertical middle scroll position
274-
let targetPos = ($(el).offset().top + $(el).position().top) - (winHeight / 2);
275-
// Animate scrolling with Velocity.js, for example.
276-
$('#main-scroll-container').velocity({ top: targetPos }, 1000, "swing");
277-
};
278-
279-
let steps = [
280-
{id: 'intro',
281-
options: {
282-
attachTo: '#first-item left',
283-
title: 'Welcome!',
284-
text: ["Have we met before?"],
285-
scrollTo: true,
286-
scrollToHandler: scrollHandler
287-
}
288-
}
289-
];
290-
```
291-
292-
> **default value:** `null`
293-
294-
295-
##### showCancelLink
296-
297-
When true, an x will appear in the top right of the popup, for canceling the tour.
298-
299-
> **default value:** `false`
300-
301-
302-
##### title
303-
304-
The step's title. It becomes an h3 at the top of the step.
305-
306-
> **default value:** `''`
307-
308-
309-
##### tippyOptions
310-
311-
Extra options to pass to [Tippy](https://atomiks.github.io/tippyjs/#all-options).
312-
313-
> **default value:** `null`
314-
315-
316-
##### text
317-
318-
The text content to display in the tour popup. Can be:
319-
+ a string
320-
+ an HTML element
321-
+ a function returning any of the above
322-
323-
> **default value:** `null`
324-
325-
326-
##### when
327-
328-
An object containing functions to be executed when events occur on the step.
329-
Supported events are `before-show`, `show`, `before-hide`, `hide`, `complete`, `cancel`, and `destroy`.
330-
331-
```js
332-
when: {
333-
show: function() {
334-
window.scrollTo(0, 0);
335-
}
336-
}
337-
```
203+
## Step Options
338204

339-
> **default value:** `null`
205+
See the [Step docs](https://shepherdjs.dev/docs/Step.html) for all available Step options.

projects/shepherd-tester/src/app/data.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const builtInButtons = {
1212
},
1313
back: {
1414
classes: 'back-button',
15+
secondary: true,
1516
text: 'Back',
1617
type: 'back'
1718
}
@@ -20,7 +21,9 @@ export const builtInButtons = {
2021
export const defaultStepOptions = {
2122
classes: 'shepherd-theme-arrows custom-default-class',
2223
scrollTo: true,
23-
showCancelLink: true,
24+
cancelIcon: {
25+
enabled: true
26+
},
2427

2528
tippyOptions: {
2629
duration: 500

projects/shepherd/README.md

Lines changed: 8 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ It will be an object of a form something like:
9292
this.shepherdService.defaultStepOptions = {
9393
classes: 'custom-class-name-1 custom-class-name-2',
9494
scrollTo: false,
95-
showCancelLink: true
95+
cancelIcon: {
96+
enabled: true
97+
}
9698
};
9799
```
98100

@@ -176,10 +178,12 @@ this.shepherdService.addSteps([
176178
type: 'next'
177179
}
178180
],
181+
cancelIcon: {
182+
enabled: true
183+
},
179184
classes: 'custom-class-name-1 custom-class-name-2',
180185
highlightClass: 'highlight',
181186
scrollTo: false,
182-
showCancelLink: true,
183187
title: 'Welcome to Angular-Shepherd!',
184188
text: ['Angular-Shepherd is a JavaScript library for guiding users through your Angular app.'],
185189
when: {
@@ -196,144 +200,6 @@ this.shepherdService.addSteps([
196200
]);
197201
```
198202

199-
A lot of the options are the same as Shepherd options, but I will go through each of them for reference.
200-
201-
##### attachTo
202-
203-
The selector and position for the tour popup to attach to, of the format 'selector position'.
204-
Position options are: top, bottom, left, and right. Can also be an object formatted like
205-
206-
```js
207-
{
208-
element: '.myElement',
209-
on: 'top'
210-
}
211-
```
212-
213-
Where `.myElement` is any valid jQuery selector.
214-
215-
> **default value:** `''`
216-
217-
218-
##### beforeShowPromise
219-
220-
A function that returns a promise. When the promise resolves, the rest of the `show` code for the step will execute.
221-
222-
> **default value:** `null`
223-
224-
225-
##### buttons
226-
227-
There are some standard button types supported by angular-shepherd. Just set `type` to `'next'`, `'back'`, or `'cancel'`,
228-
then set the `text` and `classes` as normal. These will automatically be bound to the Shepherd functions. If
229-
no type is passed, a normal Shepherd button will be created.
230-
231-
##### classes
232-
233-
Extra classes to apply to the step, for styling purposes and such.
234-
235-
> **default value:** `''`
236-
237-
238-
#### canClickTarget
239-
240-
Whether or not the target element being attached to should be "clickable". If set to `false`, Angular Shepherd
241-
sets the element's [`pointerEvents` style](https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events) to
242-
`none` while the step is active.
243-
244-
> **default value:** `true`
245-
246-
247-
##### highlightClass
248-
249-
This is an extra class to apply to the attachTo element when it is highlighted (that is, when its step is active).
250-
It can be any string. Just style that class name in your CSS.
251-
252-
> **default value:** ``
253-
254-
#### id
255-
256-
The name to give this step of the tour
257-
258-
##### scrollTo
259-
260-
This sets whether or not the screen should be scrolled to get to the element when the step becomes active.
261-
262-
> **default value:** `false`
263-
264-
265-
##### scrollToHandler
266-
267-
For custom scrolling actions, pass a function to this option. For example:
268-
269-
```js
270-
271-
let scrollHandler = (el) => {
272-
let winHeight = $(window).height();
273-
// Target vertical middle scroll position
274-
let targetPos = ($(el).offset().top + $(el).position().top) - (winHeight / 2);
275-
// Animate scrolling with Velocity.js, for example.
276-
$('#main-scroll-container').velocity({ top: targetPos }, 1000, "swing");
277-
};
278-
279-
let steps = [
280-
{id: 'intro',
281-
options: {
282-
attachTo: '#first-item left',
283-
title: 'Welcome!',
284-
text: ["Have we met before?"],
285-
scrollTo: true,
286-
scrollToHandler: scrollHandler
287-
}
288-
}
289-
];
290-
```
291-
292-
> **default value:** `null`
293-
294-
295-
##### showCancelLink
296-
297-
When true, an x will appear in the top right of the popup, for canceling the tour.
298-
299-
> **default value:** `false`
300-
301-
302-
##### title
303-
304-
The step's title. It becomes an h3 at the top of the step.
305-
306-
> **default value:** `''`
307-
308-
309-
##### tippyOptions
310-
311-
Extra options to pass to [Tippy](https://atomiks.github.io/tippyjs/#all-options).
312-
313-
> **default value:** `null`
314-
315-
316-
##### text
317-
318-
The text content to display in the tour popup. Can be:
319-
+ a string
320-
+ an HTML element
321-
+ a function returning any of the above
322-
323-
> **default value:** `null`
324-
325-
326-
##### when
327-
328-
An object containing functions to be executed when events occur on the step.
329-
Supported events are `before-show`, `show`, `before-hide`, `hide`, `complete`, `cancel`, and `destroy`.
330-
331-
```js
332-
when: {
333-
show: function() {
334-
window.scrollTo(0, 0);
335-
}
336-
}
337-
```
203+
## Step Options
338204

339-
> **default value:** `null`
205+
See the [Step docs](https://shepherdjs.dev/docs/Step.html) for all available Step options.

projects/shepherd/src/lib/utils/buttons.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @param button.action The action to call
88
*/
99
export function makeButton(button) {
10-
const { type, classes, text } = button;
10+
const { classes, secondary, type, text } = button;
1111
const builtInButtonTypes = ['back', 'cancel', 'next'];
1212

1313
if (!type) {
@@ -21,6 +21,7 @@ export function makeButton(button) {
2121
return {
2222
action: this[type].bind(this),
2323
classes,
24+
secondary,
2425
text
2526
};
2627
}

0 commit comments

Comments
 (0)