1.8.0 • Published 1 year ago

ng-enjoyhint v1.8.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Ng-EnjoyHint

EnjoyHint is a web-tool that provides the simplest way to create interactive tutorials and hints for your site or web-application. It can also be used to highlight and sign application elements.

Ng-EnjoyHint is an rewrite of EnjoyHint that removes jQuery and brings a native Angular experience.

Installation

npm install ng-enjoyhint

Usage

  • Inject the NgEnjoyHintService into your component.
    private readonly enjoyHintService = inject(NgEnjoyHintService);
  • Call runTutorial() to run the tutorial.
    await this.enjoyHintService.runTutorial(
      [
        {
          selector: ".my-element",
          event: "click",
          description: "Click on this element",
        },
        {
          selector: ".my-other-element",
          event: "click",
          description: "Now click over here",
        },
      ]
    );

How it works

When running a tutorial, an overlay is added to the page. Four semi-transparent elements, one on each side of the target element, de-emphasize the rest of the page and block user input. A description is shown on the side of the target element. The user can complete the configured event (normally a click) on the target element to advance to the next step of the tutorial. When the last step is completed, the overlay is removed.

License

MIT

API

EnjoyHintService

Methods

runTutorial()

runTutorial(steps, options?): Promise\<boolean>

Run an interactive tutorial

Parameters
ParameterTypeDescription
stepsITutorialStep[]the tutorial steps to run
options?Partial\<IEnjoyHintOptions>optional object to override the default behavior
Returns

Promise\<boolean>

a promise resolving when the tutorial is closed; resolves to true if the tutorial was completed, false if it was skipped

Source

lib/enjoyhint.service.ts:35


IButtonOptions

Custom settings for a tutorial button

Properties

PropertyTypeDescription
className?stringCustom CSS class to apply to the button
textstringText to display on the button

IEnjoyHintOptions

Properties

PropertyTypeDescription
backdropColorstringColor of the backdrop overlay. Accepts any valid CSS color value.Default'black'
backdropOpacitynumberOpacity of the backdrop overlay. Higher values makes text more readable.Default0.75
fontFamilystringFont family to use for the tutorial text and buttons.Default'sans-serif'
foregroundColorstringColor of text and arrow elements.Default'white'
nextButtonIButtonOptionsCustom settings for the "Next" button.Default{ text: 'Next' }
overlayZIndex?numberZ-index of the backdrop.Default1000 (from @angular/cdk/overlay)
paddingnumberAmount of space between the edge of the current step's target element and the backdrop (in pixels)Default5
previousButtonIButtonOptionsCustom settings for the "Previous" button.Default{ text: 'Previous' }
skipButtonIButtonOptionsCustom settings for the "Skip" button.Default{ text: 'Skip' }

ITemplateWithContext\<T>

Type parameters

Type parameterValue
Tunknown

Properties

PropertyType
contextT
templateTemplateRef\<T>

ITutorialStep

Properties

PropertyTypeDescription
descriptionstring | TemplateRef\<any>The main instructions for the step. Keep this short.
details?string | TemplateRef\<any> | ITemplateWithContext\<unknown>Additional text displayed in a smaller font under the description. May be longer (but not too long).
eventstringThe event to listen for on the element to move onto the next step. Accepts any valid DOM event name, or 'next' to move on when the "Next" button is clicked.
hidePrevious?booleanWhether or not to hide the "Previous" button.Defaultfalse
hideSkip?booleanWhether or not to hide the "Skip" button.Defaultfalse
nextButton?IButtonOptionsCustom settings for the "Next" button.
previousButton?IButtonOptionsCustom settings for the "Previous" button.
selector?stringThe CSS selector for the element to focus on. If not specified, the provided instructions will display in the center of the screen.
shouldSkip?() => boolean | Promise\<boolean>Callback to determine if the step should be skipped.
skipButton?IButtonOptionsCustom settings for the "Skip" button.
stepEnd?() => void | Promise\<void>Callback to execute when the step is ended.
stepStart?() => void | Promise\<void>Callback to execute when the step is started.
1.8.0

1 year ago

1.7.0

1 year ago

1.6.0

1 year ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago