├── .gitignore ├── .npmignore ├── README.md ├── babel.config.js ├── jsconfig.json ├── package.json ├── public ├── favicon.ico └── index.html ├── rollup.config.js ├── src ├── App.vue ├── lib │ ├── assets │ │ └── images │ │ │ └── alpha-background.svg │ ├── components │ │ ├── ColorPicker │ │ │ ├── Area │ │ │ │ ├── Alpha │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── GradientPoints │ │ │ │ │ ├── GradientPoint │ │ │ │ │ │ ├── index.vue │ │ │ │ │ │ └── script.js │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── Hue │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── Picker │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── Preview │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── index.vue │ │ │ │ └── script.js │ │ │ ├── Gradient │ │ │ │ ├── GradientControls │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── index.vue │ │ │ │ └── script.js │ │ │ ├── Preview │ │ │ │ ├── Hex │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── RGB │ │ │ │ │ ├── RGBItem │ │ │ │ │ │ ├── index.vue │ │ │ │ │ │ └── script.js │ │ │ │ │ ├── index.vue │ │ │ │ │ └── script.js │ │ │ │ ├── index.vue │ │ │ │ └── script.js │ │ │ ├── Solid │ │ │ │ ├── index.vue │ │ │ │ └── script.js │ │ │ ├── index.vue │ │ │ └── script.js │ │ └── UI │ │ │ ├── Input │ │ │ ├── index.scss │ │ │ ├── index.vue │ │ │ └── script.js │ │ │ └── index.js │ ├── helpers │ │ ├── calculateDegree.js │ │ ├── changePicker.js │ │ ├── generateStyles.js │ │ ├── getAlpha.js │ │ ├── getHue.js │ │ ├── getRgbByHue.js │ │ ├── getRightValue.js │ │ ├── hexToRgb.js │ │ ├── hsvToRgb.js │ │ ├── index.js │ │ ├── rgbToHex.js │ │ ├── rgbToHsv.js │ │ ├── setRgba.js │ │ └── updateGradientActivePercent.js │ ├── hooks │ │ ├── index.js │ │ └── mouseEvents.js │ ├── index.js │ └── index.scss └── main.js ├── vue.config.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | /build 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | 15 | # Editor directories and files 16 | .idea 17 | .vscode 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw? 23 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | build 3 | src 4 | public 5 | babel.config.js 6 | jsconfig.json 7 | rollup.config.js 8 | vue.config.js 9 | yarn.lock 10 | yarn-error.lock 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue Color Gradient Picker 2 | 3 | ## Table of Contents 4 | 5 | * [Installation](#installation) 6 | * [Examples](#examples) 7 | * [Demos](#demo) 8 | 9 | ## Installation 10 | 11 | To install, you can use [npm](https://npmjs.org/) or [yarn](https://yarnpkg.com): 12 | 13 | 14 | $ npm install vue-color-gradient-picker 15 | $ yarn add vue-color-gradient-picker 16 | 17 | ## Examples 18 | 19 | Here is a simple examples of react-color-gradient-picker being used in an app: 20 | 21 | ### Color Picker 22 | ```vue 23 | 33 | 34 | 62 | 63 | 21 | -------------------------------------------------------------------------------- /src/lib/components/ColorPicker/Preview/RGB/RGBItem/script.js: -------------------------------------------------------------------------------- 1 | import { Input } from "@/lib/components/UI"; 2 | 3 | export default { 4 | name: "RGBItem", 5 | 6 | props: { 7 | value: String | Number, 8 | type: String, 9 | label: String, 10 | onChange: Function, 11 | }, 12 | 13 | components: { 14 | Input 15 | }, 16 | 17 | data() { 18 | return { 19 | inputValue: this.value, 20 | inProgress: false 21 | } 22 | }, 23 | 24 | watch: { 25 | value: "setValue" 26 | }, 27 | 28 | methods: { 29 | onChangeHandler(event) { 30 | const value = +event.target.value; 31 | 32 | if (Number.isNaN(value) || value.length > 3 || value < 0 || value > 255) { 33 | this.inputValue = this.value; 34 | 35 | this.$forceUpdate(); 36 | 37 | return; 38 | } 39 | 40 | this.inputValue = event.target.value; 41 | 42 | this.onChange(value); 43 | }, 44 | 45 | onBlur() { 46 | if (!this.inputValue && !this.inputValue !== 0) { 47 | this.inputValue = this.value; 48 | } 49 | 50 | this.inProgress = false; 51 | }, 52 | 53 | setValue() { 54 | if (this.value !== +this.inputValue && this.inputValue !== '') { 55 | this.inputValue = this.value; 56 | } 57 | } 58 | } 59 | }; 60 | -------------------------------------------------------------------------------- /src/lib/components/ColorPicker/Preview/RGB/index.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 |