1.0.3 • Published 5 years ago

@quanzo/vue-step v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Step - component for Vue.js

The component is intended for serial output of information. For example, you can consistently display a questionnaire or a psychological test.

Other components act as blocks.

Such a component must have the displayed property, which controls whether or not to display this component on the screen. If this property is absent, then it (the component without `displayed`) does not participate in the switch. It is displayed as usual. May use methods of the Step component.

The condition for the further transition must be defined in the component and the method provided by the Step component must be called. The condition for the transition may be a correctly completed form or the selected option from the list.

--------------------------------------------------------

Компонент предназначен для последовательного вывода информации. Например, можно последовательно выводить анкету или психологический тест.

В качестве блоков выступают другие компоненты.

Такой компонент должен иметь свойство displayed, которое управляет отображать или нет этот компонент на экране. Если это свойство отсутствует, то он (компонент без displayed) не учавствует в переключении. Выводится как обычно. Может использовать методы компонента Step.

В компоненте должно быть определено условие для дальнейшего перехода и вызван метод, предоставленный компонентом Step. Условием перехода может являться правильно заполненная форма или выбранный вариант из списка.

Install via NPM

npm i --save-dev @quanzo/vue-step

Load from CDN

You can load specific version of package from jsDelivr CDN.

<script src="https://cdn.jsdelivr.net/npm/@quanzo/vue-step"></script>

Methods provided by the component Step

providecomponent methodreturn
nextStep()next()forward one step
prevStep()prev()one step back
toStep(index)to(index)go to slide by number
toStepAttr(atributeName, attributeValue)toAttr(atributeName, attributeValue)
countSteps()count()integertotal number of elements
possiblePrevStep()possiblePrev()booleanis it possible to step back
possibleNextStep()possibleNext()booleanis it possible to step forward
stopAutoStep()stop()stop auto switch
currentStep()integercurrent step number
registerEventListener(eventName, func)Registers a function on an event. function(params={})

Events

event\$emitevent params
event-step-toyes{to: ..., from: ..., count: ..., component: ...}The event will be triggered after going to another step.

Options

paramtypedefaultdescription
auto-startbooleanfalsestart auto switch
timeoutinteger15000automatic switching time, in milliseconds
roundbooleantrueswitch slides in a circle
incinteger1step increment
indexStartinteger0display starts from this index
beforeTofunction(to, from, obj)true
afterTofunction(to, from, obj)

How to use

Connect script

<script src="../dist/bundle.js"></script>

Register Vue.js component

Vue.component("step", VueStep.Step());

Create with tag (example)

<div id="choose">
    <step :auto-start="false" :round="false" name="stepbystep">
        <choose-tarif :tarifs="tarifs"></choose-tarif>
        <choose-option :tarifs="tarifs"></choose-option>
        <result-choise :tarifs="tarifs"></result-choise>
    </step>
</div>

Additional

Additional components available

Vue.component("block", VueStep.Test("test-block-2"));
Vue.component("bimg", VueStep.Image());
Vue.component("block-content", VueStep.Content());
Vue.component("block-load-content", VueStep.LoadContent());

VueStep.Image

Image output

<bimg classes="content content-image" styles="display:block" src="https://data.1freewallpapers.com/thumb/i-m-hungry.jpg" url="http://ya.ru"></bimg>
paramsdefaulttypedescription
srcstring
url“”stringIf present, the picture will be wrapped in a link.
title“”stringattribute image
alt“”stringattribute image
transitionfadestring
styles“”stringcss styles
classescontentstringcss classes
onShowfunction(component) {}functionWill be called when this block is shown.
onHidefunction(component) {}functionWill be called when this block is hidden.

VueStep.Content

Display specified content

<block-content style="background-color:black;color:antiquewhite" classes="content">
    <h2>Content from block</h2>
</block-content>
paramsdefaulttypedescription
onShowfunction(component) {}functionWill be called when this block is shown.
onHidefunction(component) {}functionWill be called when this block is hidden.
transitionfadestring
styles“”stringcss styles
classescontentstringcss classes

Use all provided step-component methods in content

<block-content style="background-color:black;color:antiquewhite">
    <template v-slot="{ nextStep }">
        <h2>This content</h2>
        <button @click="nextStep()">Next</button>
    </template>
</block-content>

or

<block-content style="background-color:black;color:antiquewhite">
    <template v-slot="params">
        <button @click="params.nextStep()">Next</button>
    </template>
</block-content>

VueStep.LoadContent

Download content from a source and display it. Content is only loaded when displayed.

<block-load-content url="content.html" reqmethod="GET"></block-load-content>
paramdefaulttypedescription
urlstring
reqmethodGETstringmethod of request
reqparams{}objectadditional params of request
beforeRequestfunction(component, reqParams) { return true; }functionIt will be called before an ajax request. If it returns false, the request will not take place.
successRequestfunction(component) {}functionWill be called after a successful ajax request.
onShowfunction(component) {}functionWill be called when this block is shown.
onHidefunction(component) {}functionWill be called when this block is hidden.
transitionfadestring
styles“”stringcss styles
classescontentstringcss classes
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago