Giter Club home page Giter Club logo

vue-colorpicker's Introduction

vue-colorpicker

preview-dark preview-light

Install

$ yarn add @caohenghu/vue-colorpicker

Example

<template>
    <div :style="{background: color}">
        <color-picker
            theme="light"
            :color="color"
            :sucker-hide="false"
            :sucker-canvas="suckerCanvas"
            :sucker-area="suckerArea"
            @changeColor="changeColor"
            @openSucker="openSucker"
        />
    </div>
</template>

<script>
    import colorPicker from '@caohenghu/vue-colorpicker'

    export default {
        components: {
            colorPicker
        },
        data() {
            return {
                color: '#59c7f9',
                suckerCanvas: null,
                suckerArea: [],
                isSucking: false
            }
        },
        methods: {
            changeColor(color) {
                const { r, g, b, a } = color.rgba
                this.color = `rgba(${r}, ${g}, ${b}, ${a})`
            },
            openSucker(isOpen) {
                if (isOpen) {
                    // ... canvas be created
                    // this.suckerCanvas = canvas
                    // this.suckerArea = [x1, y1, x2, y2]
                } else {
                    // this.suckerCanvas && this.suckerCanvas.remove
                }
            }
        }
    }
</script>

Options

Name Type Default Description
theme String dark dark or light
color String #000000 rgba or hex
colors-default Array ['#000000', '#FFFFFF', '#FF1900', '#F47365', '#FFB243', '#FFE623', '#6EFF2A', '#1BC7B1', '#00BEFF', '#2E81FF', '#5D61FF', '#FF89CF', '#FC3CAD', '#BF3DCE', '#8E00A7', 'rgba(0,0,0,0)'] like ['#ff00ff', '#0f0f0f', ...]
colors-history-key String vue-colorpicker-history
sucker-hide Boolean true true or false
sucker-canvas HTMLCanvasElement null like document.createElement('canvas')
sucker-area Array [] like [x1, y1, x2, y2]

color is one-way data flow, so you can't use v-model. why? because you'll listen changeColor event do more things, so i think it's not necessary here.

Events

Name Type Args Description
changeColor Function color { rgba: {}, hsv: {}, hex: ''}
openSucker Function isOpen true or false

if you want use sucker, then openSucker, sucker-hide, sucker-canvas, sucker-area is necessary. when you click sucker button, you can click it again or press key of esc to exit.

vue-colorpicker's People

Contributors

caohenghu avatar cs09g avatar jbienesdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vue-colorpicker's Issues

Hide RGBA

It would be cool to have a option to hide and not use RGBA just RGB, i'm using this color picker in a polaroid printing system and people can choose the color of the polaroid, so transparency doesn't make sense in this case.

Support for Gradient colors

Hello,

At first I want to express my gratitude for your component. Its simple clean and straightforward!
I do have a question though. Can the component support gradient colors like starting color - ending color and generate gradient? Do you think the component can support that functionality?

Thanks in advance!

Hide opacity selector and RGBA input?

Hey! 👋
Thank you for this component. It's very useful and lightweight than other Vue alternatives.

Is it possible to hide the opacity selector (since my application doesn't support transparency) and the RGBA input?

渲染时有bug

第一次渲染会触发colorchange事件,这个能避免么??

Bundle version

Hi, thanks for this color-picker, I was wondering if theres a way to use it in a bundle by <script src="path/to/vue-colorpicker.js"></script>

Thanks for your time

手动输入颜色问题

你好!
我们在项目中引用了你的组件,当手动输入颜色的时候#000黑色并不能触发事件变更。并且我输入#fff的时候使用rgba颜色是红色
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.