From bdc2eb2a177f751d8c9857557dce30db6907d979 Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 16 Dec 2025 09:31:14 +0800 Subject: [PATCH 1/4] feat(colorPicker): fix eslint problem --- .../component/component/colorPicker/index.vue | 369 +++++++++--------- 1 file changed, 195 insertions(+), 174 deletions(-) diff --git a/packages/component/component/colorPicker/index.vue b/packages/component/component/colorPicker/index.vue index 270d8ad0..105093d9 100644 --- a/packages/component/component/colorPicker/index.vue +++ b/packages/component/component/colorPicker/index.vue @@ -1,14 +1,15 @@ -- Gitee From 706dc6c7f373da8ff211a1afcd22b1cab365f8f9 Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 16 Dec 2025 10:00:53 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat(colorPicker):=20=E6=96=B0=E5=A2=9Eallo?= =?UTF-8?q?wOpacity=E5=B1=9E=E6=80=A7=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E6=98=AF=E5=90=A6=E5=90=AF=E7=94=A8=E9=80=8F=E6=98=8E?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/colorPicker/index.less | 12 ++++++++--- .../component/component/colorPicker/index.vue | 21 ++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/component/component/colorPicker/index.less b/packages/component/component/colorPicker/index.less index a3ef2076..2ef05562 100644 --- a/packages/component/component/colorPicker/index.less +++ b/packages/component/component/colorPicker/index.less @@ -76,9 +76,8 @@ } .hue-slider { + flex: 1; position: relative; - margin-bottom: 6px; - height: 10px; background: linear-gradient( 90deg, red 0, @@ -93,8 +92,9 @@ } .alpha-slider { + flex: 1; position: relative; - height: 10px; + margin-top: 6px; box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1); background: #fff url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAWElEQVRIiWM8fubkfwYygKWJOSM5+mCAhRLNoxaPWjxq8ajFoxbTyeL/DAfJ0Xjs3Cl7Siwmu4Yht1aDgZEYx6MWj1o8avGoxaMWD3qLya5X//4nqx6HAQC7RBGFzolqTAAAAABJRU5ErkJggg=="); @@ -110,6 +110,12 @@ background-color: #fff; } +.slider-wrap { + flex: auto; + display: flex; + flex-direction: column; +} + .color-diamond { position: relative; margin-left: 5px; diff --git a/packages/component/component/colorPicker/index.vue b/packages/component/component/colorPicker/index.vue index 105093d9..286931c4 100644 --- a/packages/component/component/colorPicker/index.vue +++ b/packages/component/component/colorPicker/index.vue @@ -14,13 +14,14 @@ import "../button/index.less"; export interface ColorPicker { modelValue?: any; - preset?: any; + preset?: Array; disabled?: boolean; eyeDropper?: boolean; contentClass?: string | Array | object; contentStyle?: StyleValue; size?: string; allowClear?: boolean; + allowOpacity?: boolean; simple?: boolean; teleportProps?: DropdownTeleportProps; } @@ -30,10 +31,11 @@ defineOptions({ }); const props = withDefaults(defineProps(), { - modelValue: { r: 255, g: 255, b: 255, a: 1 }, - preset: ["#16BAAA", "#1e9fff", "#ffb800", "#ff5722", "#16B777"], + modelValue: () => ({ r: 255, g: 255, b: 255, a: 1 }), + preset: () => ["#16BAAA", "#1e9fff", "#ffb800", "#ff5722", "#16B777"], disabled: false, allowClear: false, + allowOpacity: true, simple: true, }); @@ -461,8 +463,12 @@ function rgba2hex(r: any, g: any, b: any, a = 1) { const g1 = g.toString(16).length !== 2 ? `0${g.toString(16)}` : g.toString(16); b = Number.parseInt(b); const b1 = b.toString(16).length !== 2 ? `0${b.toString(16)}` : b.toString(16); - - a = Number.parseFloat(String(a)); + if (props.allowOpacity) { + a = Number.parseFloat(String(a)); + } + else { + a = 1; + } let a1 = ""; if (a !== 1) { const temp = Math.floor(256 * a); @@ -548,11 +554,12 @@ function hex2rgba(s: any): { r: number; g: number; b: number; a: number } | null
-
+
-
+
-- Gitee From 991d5f17328bf881a5305a5e47b31f4df892434f Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 16 Dec 2025 10:40:24 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat(colorPicker):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E9=A2=9C=E8=89=B2=E5=8F=8A=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=8C=BA=E5=9F=9F=E6=A0=B7=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=96=B0=E5=A2=9Epreset=E6=8F=92=E6=A7=BD=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E5=9C=A8=E7=BB=84=E4=BB=B6=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E9=A2=84=E8=AE=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/colorPicker/index.less | 25 +++++--- .../component/component/colorPicker/index.vue | 62 ++++++++++++------- 2 files changed, 57 insertions(+), 30 deletions(-) diff --git a/packages/component/component/colorPicker/index.less b/packages/component/component/colorPicker/index.less index 2ef05562..d0a14831 100644 --- a/packages/component/component/colorPicker/index.less +++ b/packages/component/component/colorPicker/index.less @@ -147,6 +147,10 @@ text-align: center; } +.color-value div:last-child { + padding-right: 0; +} + .color-value input { font-size: 12px; box-sizing: border-box; @@ -165,10 +169,6 @@ margin: 3px 0 0; } -.color-value .rgba-a { - padding-right: 0; -} - .color-value .hex { flex: 1; padding-left: 0; @@ -182,7 +182,6 @@ .preset { width: 100%; padding: 0; - margin: 10px 0 0; list-style: none; display: flex; flex-wrap: wrap; @@ -192,11 +191,12 @@ .preset li { width: 20px; height: 20px; - padding: 0px; + padding: 0; margin-right: 6px; margin-bottom: 6px; border: 1px solid #eee; border-radius: 2px; + cursor: pointer; } .layui-colorpicker { @@ -420,7 +420,16 @@ cursor: not-allowed !important; } -.layui-color-picker__footer{ +.layui-color-picker-footer { display: flex; - justify-content: flex-end; + align-items: flex-end; +} + +.layui-color-picker-footer__left { + flex: 1; +} + +.layui-color-picker-footer__left, +.layui-color-picker-footer__right { + margin-top: 10px; } diff --git a/packages/component/component/colorPicker/index.vue b/packages/component/component/colorPicker/index.vue index 286931c4..c26f015a 100644 --- a/packages/component/component/colorPicker/index.vue +++ b/packages/component/component/colorPicker/index.vue @@ -14,7 +14,7 @@ import "../button/index.less"; export interface ColorPicker { modelValue?: any; - preset?: Array; + preset?: Array | boolean; disabled?: boolean; eyeDropper?: boolean; contentClass?: string | Array | object; @@ -32,7 +32,7 @@ defineOptions({ const props = withDefaults(defineProps(), { modelValue: () => ({ r: 255, g: 255, b: 255, a: 1 }), - preset: () => ["#16BAAA", "#1e9fff", "#ffb800", "#ff5722", "#16B777"], + preset: true, disabled: false, allowClear: false, allowOpacity: true, @@ -65,6 +65,18 @@ const dropdownRef = ref(); const currentColor = ref(""); const openState = ref(false); +const presetList = computed(() => { + if (Array.isArray(props.preset)) { + return props.preset; + } + else if (props.preset) { + return ["#16BAAA", "#1e9fff", "#ffb800", "#ff5722", "#16B777"]; + } + else { + return []; + } +}); + function openEyeDropper() { if (isSupported) { open(); @@ -614,26 +626,32 @@ function hex2rgba(s: any): { r: number; g: number; b: number; a: number } | null
-
    -
  • -
- -- Gitee From 369fbe2236ab9451752d416ca0cf956f80d6966e Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 16 Dec 2025 11:01:14 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat(colorPicker):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/zh-CN/components/colorPicker.md | 67 ++++++++++++++----- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/docs/src/document/zh-CN/components/colorPicker.md b/docs/src/document/zh-CN/components/colorPicker.md index 028c90f5..17f42b3d 100644 --- a/docs/src/document/zh-CN/components/colorPicker.md +++ b/docs/src/document/zh-CN/components/colorPicker.md @@ -29,7 +29,7 @@ export default { ::: title 禁止选择 ::: -::: demo 使用 `lay-color-picker` 标签, 创建颜色选择器。 +::: demo 通过 `disabled` 属性, 禁用颜色选择。