0.1.2 • Published 5 years ago

vue-card-element v0.1.2

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

| vue-card-element

vue-card-element is a Vue component to create a multipurpose card. vue-card-element has many options and can be used in different situations like:

  • dashboard statistic information
  • business card
  • product card

See demo for details.

Features

  • default size works on desktop, laptop, mobile (max width 320px), but each canvas can be set with custom width and height (px,%,em,rem accepted)
  • 3 actions slots ($emit(...))
  • custom options for visual impact (colors, icons, images, etc.)
  • flip effect available (onclick) with a new configurable canvas
  • HTML injection available for almost all elements

Demo

Demo

For full demo examples code SandBox

Installation

npm install vue-card-element

Usage

Import component

import VCardElement from 'vue-card-element'

In template (for options and configuration see Docs below)

...
  <v-card-element
    title="your title"
    label="your label"
    ....
  />
...

Docs

js-card-element has many options that you can control in order to fit with your template/layout/app.

We designed the component in order to make compatible with a clean project so we decided to not include any dependency. For this reason you can add to any Vue project as is, without depending on third libraries, or simply using yours.

For any issue please open an issue on github repository.

GitHub

Props

PropRequiredDescriptionTypeDefaultNotes
nameYESname or ID of canvasStringUsed to assign $emit events
widthNOcanvas widthString320pxstandard CSS values (px,%, rem, ecc,)
heightNOcanvas widthString10.5remstandard CSS value
titleNOcanvas titleStringTitleHTML injection available
labelNOcanvas labelStringLabelHTML injection available
contentNOcanvas contentStringabstractHTML injection available
colorNObackground color/imageString#FFFCSS or url(image_url) or image_uri
text_colorNOcolor for all text elementsString#555standard CSS value
icon_boxNObackground color of icon boxString#fffstandard CSS value
icon_colorNOcolor of icon box iconString#555standard CSS value
iconNOiconStringHTML injection available
imageNOimage to set in the icon boxStringurl(your image) or image uri
elevationNObox shadow settingString'0'1 thru 3 elevations available
dividerNOset a divider line between content and footerString'0'set the px border height as divider
flipNOenable/disable flipping canvasBooleanfalse
flip_textNOhelp text to click for flipString'more'
back_colorNObackground color of the flipped canvasString#fffstandard CSS value
back_contentNOcontent of the flipped canvasStringany HTML code
slot_1NOleft button slot of the footerStringHTML injection available
slot_2NOcenter button slot of the footerStringHTML injection available
slot_3NOright button slot of the footerStringHTML injection available

Events

vue-card-element emits 1 event (this.$emit(...)) in order to get the following user actions:

  • click on the footer left button/link
  • click on the footer center button/link
  • click on the footer right button/link

Since there are 3 clickable area available in the canvas footer that you can customize with your HTML code a click on each of this area emits one event with the following info:

  • function ( name , slot ) where name is the canvas name and slot the slot clicked You need at least 1 slot option set in order to use the emit event.
EventRequiredDescriptionTypeReturn
@slotClickNOclick on one of the three clickable areaFunction-name of canvas(String)-slot clicked(Number)

In your template you have to set a function that get the emitted event. Example

<template>
  ...
  <v-card-element
    name="box3"
    color="#e91e63"
    label="New orders"
    title="<h1>+110</h1>"
    content=""
    ...
    slot_2="<button class='btn'>Click to get info</button>"
    @slotClick="myFunction"
  />
  ...
</template>
<script>
export default {
  ...
  methods:{
    myFunction(card,slot){
      //@card: card name
      //@slot: slot clicked (1,2 or 3)
      //set your logic here
    }
  }
  ...
}
</script>

Notes

Development or demo Component uses Google Material Design icons. If you don't have any icons library you can add to your index.html

<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet">

License

Released under MIT license.