From 297e731c1f56db2cdbb935240ccaea518fd24e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Mon, 14 Feb 2022 02:00:08 +0800 Subject: [PATCH] add color-picker component --- src/component/colorPicker/index.less | 18 ++- src/component/colorPicker/index.vue | 193 ++++++++++++++------------- 2 files changed, 112 insertions(+), 99 deletions(-) diff --git a/src/component/colorPicker/index.less b/src/component/colorPicker/index.less index ea9aa51f..97ff790c 100644 --- a/src/component/colorPicker/index.less +++ b/src/component/colorPicker/index.less @@ -1,7 +1,7 @@ .layui-color-picker { position: relative; user-select: none; - width: 100%; + width: 320px; background: #fff; padding: 10px; } @@ -75,8 +75,7 @@ position: relative; height: 10px; box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); - background: #fff - url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAWElEQVRIiWM8fubkfwYygKWJOSM5+mCAhRLNoxaPWjxq8ajFoxbTyeL/DAfJ0Xjs3Cl7Siwmu4Yht1aDgZEYx6MWj1o8avGoxaMWD3qLya5X//4nqx6HAQC7RBGFzolqTAAAAABJRU5ErkJggg=="); + background: #fff url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAWElEQVRIiWM8fubkfwYygKWJOSM5+mCAhRLNoxaPWjxq8ajFoxbTyeL/DAfJ0Xjs3Cl7Siwmu4Yht1aDgZEYx6MWj1o8avGoxaMWD3qLya5X//4nqx6HAQC7RBGFzolqTAAAAABJRU5ErkJggg=="); background-size: 10px 10px; } @@ -102,6 +101,14 @@ background-size: 10px 10px; } +.layui-colorpicker > span { + width: 26px; + height: 26px; + display: block; + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAWElEQVRIiWM8fubkfwYygKWJOSM5+mCAhRLNoxaPWjxq8ajFoxbTyeL/DAfJ0Xjs3Cl7Siwmu4Yht1aDgZEYx6MWj1o8avGoxaMWD3qLya5X//4nqx6HAQC7RBGFzolqTAAAAABJRU5ErkJggg=="); + background-size: 10px 10px; +} + /* 颜色的值 hex rgba */ .color-value { width: 100%; @@ -124,7 +131,7 @@ outline: none; text-align: center; border-radius: 2px; - border: 1px solid #ccc; + border: 1px solid #eee; } .color-value p { @@ -160,8 +167,9 @@ .preset li { width: 20px; height: 20px; + padding: 0px; margin-right: 6px; margin-bottom: 6px; - border: 1px solid #ccc; + border: 1px solid #eee; border-radius: 2px; } diff --git a/src/component/colorPicker/index.vue b/src/component/colorPicker/index.vue index fea1173e..a7a8e734 100644 --- a/src/component/colorPicker/index.vue +++ b/src/component/colorPicker/index.vue @@ -1,79 +1,93 @@ - - - - - - - - - - - - - - + + + - - - - - + + + + + + + class="saturation-value" + ref="saturationValue" + @mousedown="mousedownSV" + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - Hex - - - - - - R - - - - - - G - - - - - - B - - - - - - A - - - - - - + +
Hex
R
G
B
A