npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-colour-block

v1.0.0

Published

A multi-dimensional selector composed of four color blocks based on react

Downloads

4

Readme

ColourBlock

  • Created By ancf - (博客地址)[https://kafeihaoka.github.io/myBlog.html#/welcome]

  • ColourBlock 为一款基于react由4个彩色块组成的多维度选择器,一般与图表搭配结合使用,通过控制彩色块的选择 动态改变图表的数据展现形式。

gras

API 介绍

| Property | Description | Type | Default | | --- | --- | --- | --- | | data | 设置组件数据 | array | - | | onShow | 点击彩色块的操作,返回最新的data数据,注意将返回的数据设置为最新的data数据 | function(e){} | - | | onChange | 点击彩色块里的下拉框维度选择的操作,返回最新的data数据,注意将返回的数据设置为最新的data数据 | function(e){} | - | | onMouseEnter | 移入彩色块的操作,返回移入的彩色块索引 | function(e){} | - | | onMouseLeave | 移出彩色块的操作,返回移出的彩色块索引 | function(e){} | - |

彩色块数据

data: [],  注入组件数据

data数据模型 ==>

        [{
                 value:{
                     label:'',
                     value:0
                 },//彩色块里下拉框所选择的value值
                 options:[{
                     label:'',
                     value:0
                 },{},....],//彩色块里下拉框options值
                 isShow:true,//为true彩色块背景色为彩色,false默认白色
                 disabled:false,//为true代表彩色块的下拉框可点击,false不可点击
                 total:''//彩色块里的标题文字部分
          },
          {
              ...同上
          },
           {
              ...同上
           },
           {
              ...同上
           }
        ]

function 展示

onShow: ()=> {},  返回最新的data数据已更改data里的相应的isShow的值,注意在此方法里将返回的data数据设置为最新的data数据;

function 选择

onChange: ()=> {},  返回最新的data数据已更改data里的相应的value的值,注意在此方法里将返回的data数据设置为最新的data数据;

function 鼠标移入事件

onMouseEnter: (e)=> {}, 鼠标移入任一彩色块时触发,返回彩色块索引

function 鼠标移出事件

onMouseLeave: ()=> {}, 鼠标移出任一彩色块时触发,返回彩色块索引

用法示例


import ColourBlock from "react-colour-block";

class ColourBlockDemo extends React.Component {
      state = {
        data :[
             {
                  "value": {
                      "label": "点击",
                      "value": "1"
                  },
                  "options": [
                      {
                          "label": "点击",
                          "value": "1"
                      },
                      {
                          "label": "曝光",
                          "value": "2"
                      },
                      {
                          "label": "留存",
                          "value": "3"
                      }
                  ],
                  "isShow": true,
                  "disabled": false,
                  "total": "19.23M"
              },
              {
                  "value": {
                      "label": "点击率",
                      "value": "1"
                  },
                  "options": [
                      {
                          "label": "点击率",
                          "value": "1"
                      },
                      {
                          "label": "曝光率",
                          "value": "2"
                      },
                      {
                          "label": "留存率",
                          "value": "3"
                      }
                  ],
                  "isShow": true,
                  "disabled": false,
                  "total": "1.20%"
              },
              {
                  "value": {
                      "label": "实际cpc",
                      "value": "1"
                  },
                  "options": [
                      {
                          "label": "实际cpc",
                          "value": "1"
                      },
                      {
                          "label": "实际cpl",
                          "value": "2"
                      },
                      {
                          "label": "到达率",
                          "value": "3"
                      }
                  ],
                  "isShow": false,
                  "disabled": true,
                  "total": "¥3.0"
              },
              {
                  "value": {
                      "label": "线索",
                      "value": "1"
                  },
                  "options": [
                      {
                          "label": "曝光",
                          "value": "2"
                      },
                      {
                          "label": "会话/到达",
                          "value": "3"
                      },
                      {
                          "label": "线索",
                          "value": "4"
                      },
                      {
                          "label": "实际CPM",
                          "value": "5"
                      }
                  ],
                  "isShow": false,
                  "disabled": true,
                  "total": "¥68.84M"
              }
          ]
      };

      handleShow = (e) => {
          // console.log(e)
          this.setState({
              data:e
          })
      }
  
      handleChange = (e) => {
          console.log(e)
          this.setState({
              data:e
          })
      }
  
      handleMouseEnter = (e) => {
          // console.log(e)
      }
  
      handleMouseLeave = (e) => {
          // console.log(e)
      }

  render() {
    const { data } = this.state;
    return (
      <div>
        <ColourBlock
           data={data}
           onShow={this.handleShow}
           onChange={this.handleChange}
           onMouseEnter={this.handleMouseEnter}
           onMouseLeave={this.handleMouseLeave}
        />
      </div>
    );
  }
}

ReactDOM.render(<ColourBlockDemo />, mountNode);