Socket
Socket
Sign inDemoInstall

vue-contribution

Package Overview
Dependencies
10
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-contribution

> 基于Vue的类github contribution组件


Version published
Maintainers
1
Install size
11.9 MB
Created

Readme

Source

vue-contribution

基于Vue的类github contribution组件

截图

vue-contribution

安装

$ npm install vue-contribution -S

使用

main.js 文件中引入插件并注册

# main.js
import contribution from 'vue-contribution'
import 'vue-contribution/dist/vue-contribution.css';
Vue.use(contribution)

在项目中使用 vue-contribution

<template>
  <contribution
    :data="data"
    :year="2019"
    :rectWidth="12"
    :rectHeight="12"
    :fontSize="10"
    :click="click"
    monthText="en"
  />
</template>
<script>
  export default {
    data () {
      return {
        data: {
          '2019-1-1':6,
          '2019-1-2':1,
          '2019-1-3':2,
          '2019-2-2':23,
          '2019-2-3':13,
          '2019-2-4':7,
          '2019-4-1':6,
          '2019-4-2':1,
          '2019-5-3':2,
          '2019-6-2':23,
          '2019-6-3':13,
          '2019-6-4':7,
          '2019-12-20':3,
          '2019-12-21':0,
          '2019-12-22':9,
          '2019-12-23':5
      	}
      }
    },
    methods: {
      click(date){
        console.log(date)
      }
    }
  }
</script>

特点

  1. 使用简单,只需简单配置或者只传递一个数据就能立即看到效果
  2. 可定制化程度高

props属性

通过以下属性来个性化你的contribution

属性说明类型默认值必须
year指定显示的年份Number本年
fontSize字体大小,单位为px(无需输入单位)Number10
spacing元素之间的间隔,单位为px(无需输入单位)Number2
rectWidth单个元素的宽度,单位为px(无需输入单位)Number12
rectHeight单个元素的高度,单位为px(无需输入单位)Number12
fontColor字体颜色String#767676
monthText月份文本,可选参数为zh-cn,en,当然还可以自定义一个数组,例:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']String, Arrayzh-cn
click点击监听事件,返回当前点击日期,例:2019-1-16Function-
conditions根据当前条件显示不同颜色Array参见下面的conditions默认值
data数据对象,格式参见下面的data值Object
conditions默认值

每个数组对象分别有三个属性condition,value,color。该数组对象可根据自己情况设置任意数量,无数量限制。

  1. condition 就是条件表达式,支持6种运算符> < == != >= <=
  2. value 是条件值
  3. color 为颜色值

例:{'condition':'<','value':1,'color':'#ebedf0'} 表示当数据值小于1时元素的颜色为#ebedf0

[
  {'condition':'<','value':1,'color':'#ebedf0'},
  {'condition':'<','value':3,'color':'#c6e48b'},
  {'condition':'<','value':5,'color':'#7bc96f'},
  {'condition':'<','value':7,'color':'#239a3b'},
  {'condition':'>=','value':7,'color':'#196127'},
]
data值

通过返回如下格式数据来显示contribution的内容,对应日期=>值 的关系。

{
  '2019-1-1':6,
  '2019-1-2':1,
  '2019-1-3':2,
  '2019-2-2':23,
  '2019-2-3':13,
  '2019-2-4':7,
  '2019-4-1':6,
  '2019-4-2':1,
  '2019-5-3':2,
  '2019-6-2':23,
  '2019-6-3':13,
  '2019-6-4':7,
  '2019-12-20':3,
  '2019-12-21':0,
  '2019-12-22':9,
  '2019-12-23':5
}

Keywords

FAQs

Last updated on 19 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc