1.1.11 • Published 4 years ago

v-cpicker v1.1.11

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

v-cpicker (a vue colorpicker) npm version License: MIT

alt text Live Demo

Installation

npm i --save v-cpicker

Initialize in main.js

import colorpicker from "v-cpicker";
Vue.use(colorpicker);

Options (set as :options="optionsObject")

  • compact: (default=false) Compact layout
  • light: (default=true) Use light theme
  • allowModeChange: (default=true) Allow simple/advanced mode change (checkbox on UI)
  • advanced:(default=false) Start in advanced mode
  • previewBars: (default=true) Preview gradient bars next to channel values
  • formatsPopup: (default=true) Show link to all formats
  • hslToggle: (default=true) Show HSL/HSV toggle

Events

  • preview: Fires continuously whenever the preview color is modified.
  • picked: Fires when the user clicks ok.

Usage example

<template>
  <div>
    <div class="float-right picked">
      Preview <span class="swatch" :style="{background:modelColor.css}"></span> ({{modelColor}})
    </div>
    <colorpicker v-model="modelColor" />

  </div>
</template>
<script>
export default {
  data: () => {
    return {
      modelColor:'blue'//will become a Color object. See npm modern_color
    };
  }
};
</script>
<style>
  .swatch {
    margin-left: 5px;
    display: inline-block;
    vertical-align: middle;
    height: 15px;
    width: 15px;
  }
</style>

Note on input / output color

The v-model can be any css color (it will parse almost anything). Under the hood it uses the modern-color package which will convert the input to a Color instance and expose getters like css, hex, and hsl. You can import the module and set the model as a Color.parse('red') if you prefer.

Also note that the color returned can be type-coerced into its rgba(r,g,b,a) css string, but it can also be used as a color object and mutated or output in various formats. Documentation.

Disclaimer

I have not written a turn-key solution for a flyout version bound to a color input or another element. I welcome pull requests from someone who wants to write an implementation similar to how bootstrap-vue.js handles popovers and the various placement options.

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3-beta.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0-beta.0

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2-beta.3

5 years ago

1.0.2-beta.2

5 years ago

1.0.2-beta.1

5 years ago

1.0.2-beta.0

5 years ago

1.0.1

5 years ago

1.0.0-beta.4

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

1.0.0-beta.3

5 years ago

0.3.0

5 years ago

0.2.20

5 years ago

0.2.19

5 years ago

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.14

5 years ago

0.2.13

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

1.0.0-beta.2

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

1.0.0-beta.1

5 years ago

1.0.0-beta.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago