0.1.2-c • Published 5 years ago

vuetton v0.1.2-c

Weekly downloads
24
License
-
Repository
-
Last release
5 years ago

Vuetton Build Status

Vuetton is a simple library which lets you configure your button in the most feasible way. It supports click events, asynchronous operations, icons, loaders, custom classes etc.

https://www.npmjs.com/package/vuetton

Installation via npm

npm install --save vuetton

Options

Below are the options which can be used in order to customise the button as per your needs.

PropertyTypeDescription
actionFunctionThis is a required property which accepts the reference of a function.
align-iconStringIcon's slot can be aligned by either left or right. Default is set to left
asyncBooleanWhen async is true, the button will be disabled while still showing the loading icon until promise wrapped around the action is resolved.
colorStringThis property determines the background-color of button.
custom-classStringThis property assigns additional custom class to the button component.
disabledBooleanIf this property is true, then the particular button will be disabled.
loader-textStringThis property accepts text which will be loaded during an asynchronous call.
loader-imageStringThis property accepts path of an image which will be loaded during an asynchronous call.
rippleThis property adds a ripple effect on clicking on the button.
sizeStringThis property determines the size of a button; possible values taken are lg,md, sm and xs. If not provided, default size i.e medium is rendered.
stopBooleanThis property doesn't let the click event propogate to its parent. This works similar to how .stop modifier works in vue.
textStringThis is a required property which defines a value.
typeStringThis property determines the usage of button; possible values used are submit,button reset.

Events

  • Use any event directly on the component and the same will be propogated to the actual button.
  • Special case in terms of :async=true - where action prop is mandatory which will be called on click event in order to show the loading animation and track the asynchronous call.

Attributes

  • Attributes can be passed normally to the component and all the attributes gets copied to actual button. This is particularly useful to add accessibility attributes, id, name etc.

Usage

  • Import the Vuetton component from node_modules.
import Vuetton from 'vuetton';
  • Use in your template
<Vuetton size="lg" type="button" text="lg" :async="true" :action="submitData"></Vuetton>

Size variations

lg - Large md - Medium (default) sm - Small xs - Extra small

Customization via CSS

Any custom class can be attached to the button through custom-class prop

<Vuetton size="lg" type="button" text="Submit" :action="submitData" custom-class="bg--red text--white"></Vuetton>

Asynchronous support

Component supports asynchronous methods during which button would remain disabled till the function completes its execution.

Keeping the prop async="true" will make sure button remains disabled during the function provided in onclick listener.

To add the text during async call, pass the prop loader-text.

To change the default loader image, pass the prop loader-image which must be an image path.

<Vuetton size="md" text="Submit" :async="true" :action="submitData" loader-text="Submitting..."></Vuetton>

Type

You can specify the type of button via type prop be it, button, reset, submit. type="button" will be the default behaviour if not provided.

Event Listeners

You can use all the button listener events on the Vuetton component and pass on the methods.

<Vuetton size="md" text="Submit" @mouseover="doSomething" @blur="removeSomething"></Vuetton>

Slot for icon

Default slot takes elements or anything which will be rendered on the button before the button's text.

<Vuetton size="md" text="Submit" @mouseover="doSomething" @blur="removeSomething" align-icon="right">
    <i class="material-icons">save</i>
</Vuetton>

Full Example

    <Vuetton 
      text="Submit Data" 
      type="submit"
      size="sm"
      custom-class="primary" 
      :action="callApi"
      :async="true"
      loader-text="Loading..."
      loader-image="https://example.com/loader.svg"
      @mouseover="toggleOn"
      @mouseout="toggleOff"
      ripple
      id="btnSubmit"
      aria-expanded="false"
    >
      <i class="material-icons">submit</i>
    </Vuetton>
  • Documentation link is coming soon
0.1.2-c

5 years ago

0.1.2-b

5 years ago

0.1.2-a

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago