项目作者: avto-dev

项目描述 :
[NO OWNER] Vue.js component with bank card
高级语言: JavaScript
项目地址: git://github.com/avto-dev/bank-card-vue-component.git
创建时间: 2019-07-03T06:15:41Z
项目社区:https://github.com/avto-dev/bank-card-vue-component

开源协议:MIT License

下载




Vue Bank Card (component)

@avto-dev/bank-card-vue-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

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

or

  1. 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.

  1. import Vue from "vue"
  2. import VueBankCard from "@avto-dev/bank-card-vue-component"
  3. import "@avto-dev/bank-card-vue-component/dist/bank-card-vue-component.css"
  4. Vue.component("VueBankCard", VueBankCard)

Basic usage

  1. <VueBankCard is-new ></VueBankCard>

Properties

Name Required Type Default Description
number no String, Object "" Number of card
isSmall no Boolean false View card controller: base or small
isNew no Boolean false View card controller: saved or new
disableDelete no Boolean false Disable delete option on small card
errors no Object {} Errors from outside the component. From server etc.
isReset no Boolean false Trigger for reset form
isFocus no Boolean false Card number field focus when component mounted (available if isNew is true)
imagesBasePath no String @master/public/images/`">default Base path and banks or payment systems logotypes

Events

Name Type Parameters Description
enter Function event - Event of keydown Handler of keydown on enter event
clear-errors Function errors - Object of errors Clearing errors from outside
reset Function isReset - State of isReset property, type Boolean Turn off isReset property
delete-card Function event - Event of click Handler of click on trash button

Example

  1. <template>
  2. <VueBankCard
  3. is-small
  4. is-new
  5. is-focus
  6. :errors="errors"
  7. :is-reset="resetForm"
  8. @enter="onEnter"
  9. @clear-errors="clearErrors"
  10. @reset="resetForm = $event"
  11. ></VueBankCard>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. errors: {
  18. cardNumber: "Недостаточно средств на карте",
  19. expDateMonth: "Карта просрочена",
  20. cvv: "Неверный код cvv"
  21. },
  22. resetForm: false
  23. }
  24. },
  25. methods: {
  26. onEnter(event) {
  27. event.preventDefault();
  28. console.log(event);
  29. },
  30. clearErrors(errors) {
  31. this.errors = { ...errors };
  32. }
  33. }
  34. }
  35. </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:

  1. <template>
  2. <VueBankCard
  3. is-new
  4. :images-base-path="imagesPath"
  5. ></VueBankCard>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. imagesPath: "//your-own-cdn-or-host.com/path/to/assets/"
  12. }
  13. },
  14. }
  15. </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:

  1. $ make install
  2. $ 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.