LinkedInAttic / hopscotch

A framework to make it easy for developers to add product tours to their pages.
Apache License 2.0
4.2k stars 666 forks source link

Visibility for templating and `setRenderer` #377

Open ALJCepeda opened 5 years ago

ALJCepeda commented 5 years ago

Wondering why documentation for templates is hidden in https://github.com/linkedin/hopscotch/tree/master/src/tl and no mention within documentation at http://linkedin.github.io/hopscotch/

Are these methods not expected to be public?

It seems like providing templates for bubbles is a pretty typical use case. It would be useful to include a template property in the TourDefinition and StepDefinition interfaces. If a template isn't provided then should use default template.

Also setRenderer isn't defined on the type for Hopscotch https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/hopscotch/index.d.ts#L81-L161

ALJCepeda commented 5 years ago

I figure the types would look something like this:

export interface RenderOptions {
  i18n: {
    prevBtn: string,
    nextBtn: string,
    closeTooltip: string,
    stepNum: number,
    numSteps: number
  },
  buttons:{
    showPrev: boolean,
    showNext: boolean,
    showCTA: boolean,
    ctaLabel: string,
    showClose: boolean
  },
  step:{
    num: number,
    isLast: boolean,
    title: string,
    content: string,
    isRtl: boolean,
    placement: string,
    padding: string,
    width: string,
    customData: { [key:string]:any }
  },
  tour:{
    isTour: boolean,
    numSteps: number,
    unsafe: boolean,
    customData: { [key:string]:any }
  }
}

export interface HopscotchStatic {
  setRenderer: ( renderer:string | ((ops:RenderOptions) => void) ) => void
}