1.2.10 • Published 1 year ago

web-assistant v1.2.10

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

web-assistant

A simple web component built with svelte, providing version introduction & guideline instruction UI.

  • dependency free
  • compatible with any javascript framework/UI library
  • light-weighted (gzipped: 76KB)
  • non-invasive design, drive the UI simply by javascript & json
  • auto switch languages(CN or EN) depends on your \<html lang="___">

Live demo

https://guidebook.topurl.cn

How to use

Install with npm:

npm install web-assistant --save

and import it in your code:

import 'web-assistant';

You can also load the package from a CDN such as jsdelivr (or unpkg):

<script src="https://cdn.jsdelivr.net/npm/web-assistant@latest/lib/index.min.js"></script>

Then you can call window.webAssistant.guideline(...) or window.webAssistant.intro(...) directly in your js code.

The guideline parameters example:

window.webAssistant.guideline({
  list: [
    {
      selector: 'h1',
      position: 'bottom-end',
      text: 'Line1\nLine2\nLine3\nThis is a title',
      width: '220px',
      onNext: () => console.log('next tips')
      // You can use async function here, and guideline won't go on until the async function finished
    },
    {
      selector: 'p.desc:nth-child(2)',
      position: 'top-end',
      text: 'This a testing paragraph...',
      maxWidth: '380px',
      onPrev: () => console.log('prev')
    },
    {
      selector: '.btn',
      position: 'right',
      text: 'This is the submit button, and the guideline ends here.'
    }
  ],
  canClose: false,
  showSteps: true,
  confirmText: 'I know',
  onConfirm: () => console.log('confirmed')
});

The introduction parameters example:

window.webAssistant.intro({
  title: 'v1.20 - New Feature',
  list: [
    {
      text: 'Surprise steepest recurred landlord mr wandered amounted of.\nContinuing devonshire but considered its.\nRose past oh shew roof is song neat.\nDo depend better praise do friend garden an wonder to.\nIntention age nay otherwise but breakfast.\nAround garden beyond to extent by.'
    },
    {
      text: 'Kindness to he horrible reserved ye. Effect twenty indeed beyond for not had county. The use him without greatly can private. Increasing it unpleasant no of contrasted no continuing. Nothing colonel my no removed in weather. It dissimilar in up devonshire inhabiting.'
    },
    {
      text: 'This is <b>an example of</b> rich text<img src="https://news-bos.cdn.bcebos.com/mvideo/log-news.png" alt="baidu" style="height: 36px" />'
    }
  ],
  dangerouslyUseHTMLString: true,
  showSteps: true,
  canClose: true,
  onClose: () => console.log('closed'),
  confirmText: 'I know',
  onConfirm: () => console.log('confirmed'),
  style: {
    width: '50vw',
    height: '40vh'
  }
});

The feedback parameters example:

window.webAssistant.feedback({
  title: 'Suggestion & Feedback',
  bottom: '12px',
  fullNameVisible: true,
  emailVisible: true,
  emailRequired: true,
  problemVisible: true,
  problemList: [
    {
      label: 'System features',
      value: 'system'
    },
    {
      label: 'User experience',
      value: 'uex'
    },
    {
      label: 'Others',
      value: 'other'
    }
  ],
  screenshotNeeded: true,
  callback: fd => {
    fetch('/some-api/feedback/submit', {
      method: 'POST',
      body: fd
    });
  }
});

Parameters

guideline params:

KeyDescriptionTypeDefault value
listRequired guideline listArray(See guideline list item ↓)
showStepsDecide whether shows steps in the "Next" button or notBooleanfalse
dangerouslyUseHTMLStringDecide the guideline content renders HTML tag or notBooleanfalse
canCloseDecide the guideline can be closed before it is finishedBooleanfalse
closeTextThe close button's textStringClose/关闭
onCloseFunction called after closedFunctionnoop
canPrevDecide the guideline can go previous step or notBooleantrue
prevTextThe prev button's textStringPrevious/上一条
nextTextThe next button's textStringNext/下一条
confirmTextThe confirm button's textStringConfirm/确定
onConfirmFunction called after confirmedFunctionnoop
popperStyleInline style string that attached to the popper elementString-

guideline list item:

KeyDescriptionTypeDefault value
selectorRequired CSS selector to find the DOMString-
positionThe popper's position: top-start/top/top-end/bottom-start/bottom/bottom-end/left-start/left/left-end/right-start/right/right-endStringbottom
textThe popper's content textString-
widthThe popper's widthString-
maxWidthThe popper's max-widthString-
onPrevFunction called when going previous stepFunctionnoop
onNextFunction called when going next stepFunctionnoop

intro params:

KeyDescriptionTypeDefault value
titleIntro's titleStringIntro
listRequired intro listArray(See intro list item ↓)
showStepsDecide whether shows steps in the "Next" button or notBooleanfalse
dangerouslyUseHTMLStringDecide the intro content renders HTML tag or notBooleanfalse
canCloseDecide the intro can be closed before it is finishedBooleanfalse
onCloseFunction called after closedFunctionnoop
prevTextThe prev button's textStringPrevious/上一条
nextTextThe next button's textStringNext/下一条
confirmTextThe confirm button's textStringConfirm/确定
onConfirmFunction called after confirmedFunctionnoop
styleStyle object that affects intro elementObject{}

intro list item:

KeyDescriptionTypeDefault value
textThe intro contentString-

feedback params:

KeyDescriptionTypeDefault value
titleThe title of feedback for displayString(i18n)
bottomThe distance to the bottom of viewportString15px
foldedIf the feedback panel is folded at the beginingBooleantrue
emailVisibleIf the email input is shownBooleantrue
emailRequiredIf the email is requiredBooleanfalse
nameVisibleIf the fullName input is shownBooleanfalse
nameRequiredIf the fullName is requiredBooleanfalse
problemVisibleIf the problem select is shownBooleanfalse
problemRequiredIf the problem is requiredBooleantrue
problemListThe problem listArray(See feedback problem list item ↓)
screenshotVisibleIf the email input is shownBooleantrue
screenshotNeededIf the email is requiredBooleanfalse
placeholderThe placeholder text of the suggestion textareaString-
callbackFunction called when submittingFunctionnoop

feedback problem list item:

KeyDescriptionTypeDefault value
labelThe problem descriptionString-
valueThe problem codeString-

cursor params:

KeyDescriptionTypeDefault value
typeCursor appearance: default/reverse/pointer/move/grabStringdefault
fromPosition where cursor moves from (can be x,y or css selector. i.e. 100,300 or button.submit or document.body)String or HTMLElement-
toRequired Position where cursor moves to (same as 'from')String or HTMLElement-
scaleCursor's scaleNumber1
durationCursor's moving durationNumber1500
stayCursor will stay at the end position for specified msNumber150
clickAfterMoveCursor will automatically click the to element after movingBooleanfalse
clickEffectCursor will show a red circle animation when clickingBooleanfalse
overlayA overlay will show when the cursor is displayed (prevent the other user's actions)Booleanfalse

mask params:

KeyDescriptionTypeDefault value
durationmilliseconds.empty or 0 means mask never dismiss,then you should call window.webAssistant.clear() to dismiss it manually.Number-

toast params:

KeyDescriptionTypeDefault value
textThe toast textString-
durationmillisecondsNumber3000
positionThe toast position: bottom/top/centerStringbottom

TODO

  • mobile compatible
  • ...
1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

2 years ago

1.2.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.12

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.50

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.40

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago