feat: 新增 ColorPicker 颜色选择器#163
Open
Xiaohua-sky wants to merge 1 commit into
Open
Conversation
新增 u-color-picker(弹窗模式)和 u-color-select-panel(内联面板模式)两个组件,支持单色、渐变、透明度、历史记录、预设颜色、吸管等功能。
✅ Deploy Preview for h5-uview-pro ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ColorPicker 颜色选择器
该组件用于颜色选择,包含弹窗模式(
u-color-picker)和内联面板模式(u-color-select-panel)两个组件,支持单色、渐变色、透明度调节、历史记录、预设颜色、吸管取色等功能,可根据场景灵活使用。平台差异说明
基本使用
弹窗模式
使用
u-color-picker组件,通过v-model:show控制弹窗显隐,v-model双向绑定颜色值。内联模式
使用
u-color-select-panel组件直接嵌入页面,无需弹窗。自定义样式
通过
customStyle和customClass可自定义组件根节点的样式。API
u-color-picker Props
#000000falsepopuppopup,inline选择颜色确定取消squaresquare,circle60rpx10075bothsolid,gradient,bothtruetrue,falsetruetrue,falsetruetrue,falsetruetrue,false[...]HEXHEX,RGBfalse{}''u-color-picker Events
color: stringcolor: stringcolor: stringcolor: stringshow: booleanu-color-select-panel Props
#000000bothsolid,gradient,bothtruetrue,falsetruetrue,falsetruetrue,falsetruetrue,false[...]HEXHEX,RGBfalse{}''u-color-select-panel Events
color: stringcolor: stringcolor: stringu-color-select-panel Methods
可通过
ref调用组件内部方法。color: stringColorObjectcolor: stringColorObject 类型定义
功能特性详解
1. 渐变色支持
当
colorMode设置为gradient或both时,组件支持 CSS 线性渐变(linear-gradient)。linear-gradient(90deg, #fff 0%, #000 100%)格式2. 颜色格式切换
点击输入框左侧的格式标签可以切换颜色显示格式。
#RRGGBB)和 8 位(#RRGGBBAA)格式rgba(r, g, b, a)格式3. 吸管工具 (EyeDropper)
在支持
EyeDropper API的 H5 环境(桌面端 Chrome/Edge),点击吸管图标可以吸取屏幕上任意位置的颜色。移动端 H5 或小程序环境暂不支持此 API,吸管按钮会自动隐藏。4. 历史记录
组件会自动保存最近使用的 10 个颜色到本地存储,方便快速复用。可通过
showHistory控制是否显示历史记录区域,通过saveRecentColor方法手动保存颜色。5. 预设颜色
支持通过
presets属性自定义预设颜色列表,组件内置了 15 种常用颜色作为默认值。可通过showPresets控制是否显示预设颜色区域。6. 暗黑模式适配
组件内置了对暗黑模式的支持,会自动感知当前应用的主题设置并切换相应的背景色和文字颜色。无需额外配置。