2.3.0 • Published 12 months ago

todovue-card v2.3.0

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

TvCard

The TvCard is a component that allows you to display a card with a title, a subtitle, a description, an image and a button.

npm Netlify Status Pipeline npm npm GitHub GitHub Release Date

Table of Contents

Installation

Install with npm or yarn

npm install todovue-card
yarn add todovue-card

Import

import { TvCard } from 'todovue-card'

You can also import it directly in the main.js file, so you don't have to import it in the pages

import { createApp } from "vue";
import App from "./App.vue";
import TvCard from "todovue-card";

const app = createApp(App);
app.component("TvCard", TvCard);
app.mount("#app");

Usage

<template>
  <tv-card
    @click-button="handleButton"
    :configCard="configCard"
  />
</template>

<script>
import { ref } from "vue";
import TvCard from "todovue-card";

export default {
  name: "Demo",
  components: {
    TvCard,
  },
  setup() {
    const configCard = ref({
      title: "Create Vue.js",
      description: "Vue.js (commonly known as Vue; pronounced /vjuː/...",
      alt: "Card Image",
      image: "https://todovue.com/vue.webp",
      primaryButtonText: "View more",
    });
    
    const handleButton = () => {
      console.log("Button clicked");
    }
    
    return {
      configCard,
      handleButton
    }
  }
};
</script>

Props

NameTypeDefaultDescription
configCardObjectSee belowObject with the card configuration

configCard

NameTypeDefaultDescriptionrequired
titleString""Card titletrue
descriptionString""Card descriptiontrue
imageString""Card imagetrue
altString""Card image alttrue
primaryButtonTextString""Card primary button texttrue
secondaryButtonTextString""Card secondary button textfalse
labelsArray[]Card labelsfalse
limitLabelsNumber3Card limit labelsfalse
backgroundColorString#0E131FCard custom background colorfalse
colorString#AFDEDCCard custom colorfalse
backgroundButtonColorString#EF233CCard custom background primary button colorfalse
buttonColorString#F4FAFFCard custom primary button colorfalse
backgroundButtonSecondaryColorString#2F80EDCard custom background secondary button colorfalse
colorButtonSecondaryString#F4FAFFCard custom secondary button colorfalse

Events

NameDescription
clickButtonEvent emitted when the primary button is clicked, returns the button's value
clickSecondaryButtonEvent emitted when the secondary button is clicked, returns the button's value
clickLabelEvent emitted when the label is clicked, returns the label's value

Customize

You can customize the card by cardConfig, you can see the props section to see the available options

const configCard = ref({
  backgroundColor: "#000000", // Card custom background color
  color: "#ffffff", // Card custom color
  backgroundButtonColor: "#ffffff", // Card custom background primary button color
  buttonColor: "#000000", // Card custom primary button color
  backgroundButtonSecondaryColor: "#ffffff", // Card custom background secondary button color
  colorButtonSecondary: "#000000", // Card custom secondary button color
});
<template>
  <tv-card
    @click-button="handleButton"
    :configCard="configCard"
  />
</template>

<script>
import { ref } from "vue";
import TvCard from "todovue-card";

export default {
  name: "Demo",
  components: {
    TvCard,
  },
  setup() {
    const configCard = ref({
      title: "Create Vue.js",
      description: "Vue.js (commonly known as Vue; pronounced /vjuː/...",
      alt: "Card Image",
      image: "https://todovue.com/vue.webp",
      primaryButtonText: "View more",
      backgroundColor: "#000000",
      color: "#ffffff",
      backgroundButtonColor: "#ffffff",
      buttonColor: "#000000",
    });
    
    const handleButton = () => {
      console.log("Button clicked");
    }
    
    return {
      configCard,
      handleButton
    }
  }
};
</script>

Development

Clone the repository and install the dependencies

git clone https://github.com/TODOvue/todovue-card.git
cd todovue-card

Install the dependencies

yarn install

Run the project

yarn demo

Run the tests

yarn test:unit

Run the linter

yarn lint

Run the build It is not necessary to generate build, since it is generated when you do PR to the master branch

yarn build

License

MIT