Skip to content

Commit

Permalink
backward compatibility API
Browse files Browse the repository at this point in the history
  • Loading branch information
binrysearch committed Jul 13, 2024
1 parent 7b9ec39 commit 06d2efe
Showing 1 changed file with 51 additions and 14 deletions.
65 changes: 51 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,65 @@ import { version } from "../package.json";
import { Hint } from "./packages/hint";
import { Tour } from "./packages/tour";

/**
* Intro.js module
*/
const introJs = {
class LegacyIntroJs extends Tour {
/**
* Create a new Intro.js Tour instance
* @param elementOrSelector Optional target element to start the Tour on
* @deprecated introJs().addHints() is deprecated, please use introJs.hint().addHints() instead
* @param args
*/
tour: (elementOrSelector?: string | HTMLElement) =>
new Tour(elementOrSelector),
addHints(..._: any[]) {
console.error(
"introJs().addHints() is deprecated, please use introJs.hint.addHints() instead."
);
}

/**
* Create a new Intro.js Hint instance
* @param elementOrSelector Optional target element to start the Hint on
* @deprecated introJs().addHint() is deprecated, please use introJs.hint.addHint() instead
* @param args
*/
hint: (elementOrSelector?: string | HTMLElement) =>
new Hint(elementOrSelector),
addHint(..._: any[]) {
console.error(
"introJs().addHint() is deprecated, please use introJs.hint.addHint() instead."
);
}

/**
* Current Intro.js version
* @deprecated introJs().removeHints() is deprecated, please use introJs.hint.hideHints() instead
* @param args
*/
version: version,
removeHints(..._: any[]) {
console.error(
"introJs().removeHints() is deprecated, please use introJs.hint.removeHints() instead."
);
}
}

/**
* Intro.js module
*/
const introJs = (elementOrSelector?: string | HTMLElement) => {
console.warn(
"introJs() is deprecated. Please use introJs.tour() or introJs.hint() instead."
);
return new LegacyIntroJs(elementOrSelector);
};

/**
* Create a new Intro.js Tour instance
* @param elementOrSelector Optional target element to start the Tour on
*/
introJs.tour = (elementOrSelector?: string | HTMLElement) =>
new Tour(elementOrSelector);

/**
* Create a new Intro.js Hint instance
* @param elementOrSelector Optional target element to start the Hint on
*/
introJs.hint = (elementOrSelector?: string | HTMLElement) =>
new Hint(elementOrSelector);

/**
* Current Intro.js version
*/
introJs.version = version;

export default introJs;

0 comments on commit 06d2efe

Please sign in to comment.