Skip to content

Commit

Permalink
Rename Tour.options.defaults to Tour.options.defaultStepOptions.
Browse files Browse the repository at this point in the history
Closes [#240](#240).
  • Loading branch information
BrianSipple committed Sep 12, 2018
1 parent f22f994 commit e230ea9
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ yarn add shepherd.js

```javascript
let tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-arrows'
}
});
Expand Down
2 changes: 1 addition & 1 deletion docs/welcome/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h3>Example</h3>
<pre id="hero-example-code">
<code class="language-javascript">
const tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-arrows'
}
});
Expand Down
2 changes: 1 addition & 1 deletion docs/welcome/js/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
setupShepherd = function() {
var shepherd;
shepherd = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
showCancelLink: true
}
});
Expand Down
16 changes: 8 additions & 8 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ First create a new `Tour` instance for your tour:

```javascript
const tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-arrows',
scrollTo: true
}
});
```

The `defaults` option allows you to specify any options which should be applied
The `defaultStepOptions` option allows you to specify any options which should be applied
to all this tour's steps by default.

Next, add your steps:
Expand Down Expand Up @@ -116,7 +116,7 @@ const myTour = new Shepherd.Tour(options);
##### Tour Options

- `steps`: An array of Step instances to initialize the tour with
- `defaults`: Default options for Steps created through `addStep`
- `defaultStepOptions`: Default options for Steps created through `addStep`
- `confirmCancel`: If true, will issue a window.confirm before cancelling
- `confirmCancelMessage`: The message to display in the confirm dialog

Expand Down Expand Up @@ -173,10 +173,10 @@ to disable. Each button in the array is an object of the format:
already have an `action` specified is not supported.
You can use `events` to skip steps or navigate to specific steps, with something like:
```javascript
events: {
click: function() {
return Shepherd.activeTour.show('some_step_name');
}
events: {
click: function() {
return Shepherd.activeTour.show('some_step_name');
}
}
```
- `advanceOn`: An action on the page which should advance shepherd to the next step. It can be of the form `"selector event"`, or an object with those
Expand Down Expand Up @@ -276,7 +276,7 @@ Individual customizations to the standard themes must be made within the CSS fil

```javascript
let tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-custom'
}
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"rewrite-paths": "replace 'SF:.*src' 'SF:src' coverage/lcov.info",
"start": "yarn watch",
"start-test-server": "http-server",
"test": "test:ci",
"test:build": "cross-env NODE_ENV=test yarn build",
"test:ci": "yarn test:unit:ci && yarn test:cy:ci",
"test:cy:ci": "yarn test:build && start-server-and-test start-test-server http://localhost:8080 cy:run",
Expand Down
6 changes: 3 additions & 3 deletions src/js/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Tour extends Evented {
/**
*
* @param {Object} options The options for the tour
* @param {Object} options.defaults Default options for Steps created through `addStep`
* @param {Object} options.defaultStepOptions Default options for Steps created through `addStep`
* @param {Step[]} options.steps An array of Step instances to initialize the tour with
* @returns {Tour}
*/
Expand Down Expand Up @@ -198,7 +198,7 @@ export class Tour extends Evented {
stepOptions.id = name.toString();
}

stepOptions = Object.assign({}, this.options.defaults, stepOptions);
stepOptions = Object.assign({}, this.options.defaultStepOptions, stepOptions);

return new Step(this, stepOptions);
}
Expand Down Expand Up @@ -271,4 +271,4 @@ export class Tour extends Evented {
}
}

export { Shepherd };
export { Shepherd };
2 changes: 1 addition & 1 deletion test/cypress/integration/test.acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Shepherd Acceptance Tests', () => {
});
});

it.skip('Defaults classes applied', () => {
it.skip('Default classes applied', () => {
const tour = setupTour(Shepherd, {
classes: 'test-defaults test-more-defaults'
});
Expand Down
8 changes: 4 additions & 4 deletions test/cypress/utils/setup-tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import defaultSteps from './default-steps';
/**
* Setup a tour
* @param {Shepherd} Shepherd The Shepherd instance
* @param {Object} globalDefaults A hash of the `defaults`
* @param {Object} globalDefaults A hash of the `defaultStepOptions`
* @param {[Object]} customSteps An array of the steps to add to the tour
*/
export default function(Shepherd, globalDefaults, customSteps) {
const defaults = Object.assign({}, {
const defaultStepOptions = Object.assign({}, {
showCancelLink: true
}, globalDefaults);

let shepherd = new Shepherd.Tour({
defaults
defaultStepOptions
});

const steps = typeof customSteps === 'function' ? customSteps(shepherd) : defaultSteps(shepherd);
Expand All @@ -23,4 +23,4 @@ export default function(Shepherd, globalDefaults, customSteps) {
});

return shepherd;
}
}
2 changes: 1 addition & 1 deletion test/dummy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h3>Example</h3>
<pre id="hero-example-code">
<code class="language-javascript">
const tour = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-arrows'
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test.step.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ window.Shepherd = Shepherd;
describe('Step', () => {
describe('Shepherd.Step()', () => {
const instance = new Shepherd.Tour({
defaults: {
defaultStepOptions: {
classes: 'shepherd-theme-arrows',
scrollTo: true
}
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test.tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ window.Shepherd = Shepherd;

describe('Tour', function() {
let instance, shouldShowStep;
const defaults = {
const defaultStepOptions = {
classes: 'shepherd-theme-arrows',
scrollTo: true
};

beforeEach(() => {
shouldShowStep = false;
instance = new Shepherd.Tour({
defaults
defaultStepOptions
});

instance.addStep('test', {
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('Tour', function() {
});

it('returns the default options on the instance', function() {
assert.deepEqual(instance.options.defaults, {
assert.deepEqual(instance.options.defaultStepOptions, {
classes: 'shepherd-theme-arrows',
scrollTo: true
});
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('Tour', function() {
describe('.cancel()', function() {
it('shows confirm dialog when confirmCancel is true', function() {
instance = new Shepherd.Tour({
defaults,
defaultStepOptions,
confirmCancel: true,
confirmCancelMessage: 'Confirm cancel?'
});
Expand Down

0 comments on commit e230ea9

Please sign in to comment.