2.0.4 • Published 12 months ago

@avto-dev/bank-card-vue-component v2.0.4

Weekly downloads
66
License
MIT
Repository
github
Last release
12 months ago

Vue Bank Card (component)

Version (npm) Vue.js version Build Status Coverage License

Vue Component for user data entry of the bank card

Demonstration is available here.

Installation

npm i --save @avto-dev/bank-card-vue-component

or

yarn add @avto-dev/bank-card-vue-component

You can import the library and styles, then use it as a Vue plugin to enable the functionality globally on all components.

import Vue from "vue"
import VueBankCard from "@avto-dev/bank-card-vue-component"
import "@avto-dev/bank-card-vue-component/dist/bank-card-vue-component.css"

Vue.component("VueBankCard", VueBankCard)

Basic usage

<VueBankCard is-new />

Properties

NameRequiredTypeDefaultDescription
numbernoString, Object""Number of card
isSmallnoBooleanfalseView card controller: base or small
isNewnoBooleanfalseView card controller: saved or new
disableDeletenoBooleanfalseDisable delete option on small card
errorsnoObject{}Errors from outside the component. From server etc.
isResetnoBooleanfalseTrigger for reset form
isFocusnoBooleanfalseCard number field focus when component mounted (available if isNew is true)
imagesBasePathnoStringdefaultBase path and banks or payment systems logotypes

Events

NameTypeParametersDescription
enterFunctionevent - Event of keydownHandler of keydown on enter event
clear-errorsFunctionerrors - Object of errorsClearing errors from outside
resetFunctionisReset - State of isReset property, type BooleanTurn off isReset property
delete-cardFunctionevent - Event of clickHandler of click on trash button

Example

<template>
  <VueBankCard
    is-small
    is-new
    is-focus
    :errors="errors"
    :is-reset="resetForm"
    @enter="onEnter"
    @clear-errors="clearErrors"
    @reset="resetForm = $event"
  ></VueBankCard>
</template>

<script>
export default {
  data() {
    return {
      errors: {
          cardNumber: "Недостаточно средств на карте",
          expDateMonth: "Карта просрочена",
          cvv: "Неверный код cvv"
      },
      resetForm: false
    }
  },
  methods: {
    onEnter(event) {
      event.preventDefault();
      console.log(event);
    },
    clearErrors(errors) {
      this.errors = { ...errors };
    }
  }
}
</script>

Use your own logotypes

By default banks logos provided from CDN: https://cdn.jsdelivr.net/gh/avto-dev/bank-card-vue-component@%package_version%/public/images/%image_path%.

If you want to use your own logotypes you can pass base images path by prop images-base-path. For example:

<template>
  <VueBankCard
    is-new
    :images-base-path="imagesPath"
  ></VueBankCard>
</template>

<script>
export default {
  data() {
    return {
      imagesPath: "//your-own-cdn-or-host.com/path/to/assets/"
    }
  },
}
</script>

Now path to logotype would be //your-own-cdn-or-host.com/path/to/assets/banks-logos/ru-sberbank.png.

So you must have two folders in your defined path:

  • banks-logos - Must contain bank logos;
  • brands-logos - Must contain payment systems (VISA, Master Card, etc) logos.

Name of files with logotypes should be the same that come with this package.

Testing

For package testing we use jest framework and docker-ce + docker-compose as develop environment. So, just write into your terminal after repository cloning:

$ make install
$ make test

Changes log

Release date Commits since latest release

Changes log can be found here.

Support

Issues Issues

If you will find any package errors, please, make an issue in current repository.

License

This is open-sourced software licensed under the MIT License.

2.0.4

12 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.3.0

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago