feat(image-annotate): v1.20.0 去色下移为常用色第一格 + 头部控件全部定宽(不再被 flex 抵掉)
- 去色:头部按钮 → 常用色网格第一格(20px 同尺寸、虚线圆 + 斜圈) - 不可用上下文(文字色 / 未闭合钢笔)不再 hidden,改 disabled + 42% 不透明度,title 说明原因 - 头部定宽:色值框 flex 0 0 124px(原 0 1 150)、加「底色」tab 后色值框与图钉位置不动 - 常用色 16 → 15(亮紫让位,深紫保留),去色 + 15 = 8 列 2 行 - 删掉 :has(...[hidden]) 隐藏竖线的规则,头部结构变纯静态 - harness 231 项 / 真站 e2e 40 项
This commit is contained in:
1 parent
00a2699e89
commit
d16e68bfa9
8 files changed
+209
-111
No files matched your search
@@ -1804,12 +1804,8 @@
|
||||
/* 竖线:分隔「调哪个槽 / 取色工具 / 去色·钉住」三组,比空白更清楚,又不加边框重量 */
|
||||
.iwb-color-pop-bar { width: 1px; height: 16px; background: #313244; flex: 0 0 auto; }
|
||||
/* 「去色 | 图钉」整组贴最右(margin-left:auto)。这样色值框不用拉成一条长条去填空,
|
||||
头部是「左边调色槽与工具 / 右边两个开关」两段式,扫视时不会把 HEX 当成主角。 */
|
||||
头部是「左边调色槽与工具 / 右边一个开关」两段式,扫视时不会把 HEX 当成主角。 */
|
||||
.iwb-color-pop-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
|
||||
/* 没有可去色的上下文(未选中对象 / 文字色这种单槽)时「去色」是隐藏的,
|
||||
它前面那条竖线要一起藏掉,否则头部右侧会留下一截悬空的「||」;
|
||||
两条都藏掉后整组只剩图钉,竖线也不再夹在「色值 | 图钉」之间显得多余 */
|
||||
.iwb-color-pop-tools:has(> .iwb-color-pop-none[hidden]) > .iwb-color-pop-bar { display: none; }
|
||||
|
||||
.iwb-color-pop-tab {
|
||||
display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
|
||||
@@ -1832,16 +1828,28 @@
|
||||
background-image: linear-gradient(135deg, transparent calc(50% - 1px), #f38ba8 calc(50% - 1px), #f38ba8 calc(50% + 1px), transparent calc(50% + 1px));
|
||||
}
|
||||
.iwb-color-pop-tab[hidden] { display: none; }
|
||||
/* 去色(v1.19):原来的「无」改名挪位。虚线框 + 红斜圈,和「实心色块」区分开;
|
||||
它是开关不是色块,所以不用填充色表达状态,只换边框/文字色。 */
|
||||
/* 去色(v1.20,用户 2026-11-10):头部那颗带文字的按钮下移到「常用色第一格」,
|
||||
尺寸、间距跟色块完全一致(20px 圆),只是画虚线边框 + 斜圈图标 ——
|
||||
它是开关不是色块,所以不用填充色表达状态,只换边框/图标色。
|
||||
永远显示(不可用时不 hidden,只 disabled + 变灰),位置才记得住、头部也不重排。 */
|
||||
.iwb-color-pop-none {
|
||||
flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px;
|
||||
border: 1px dashed #585b70; border-radius: 7px; background: transparent; color: #a6adc8;
|
||||
font: 500 11.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; cursor: pointer;
|
||||
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
|
||||
width: 20px; height: 20px; padding: 0; margin: 0; box-sizing: border-box;
|
||||
border: 1px dashed #585b70; border-radius: 50%; background: transparent; color: #a6adc8;
|
||||
cursor: pointer; transition: transform 0.08s ease, border-color 0.12s ease, color 0.12s ease;
|
||||
}
|
||||
.iwb-color-pop-none svg { flex: 0 0 auto; width: 12px; height: 12px; }
|
||||
/* hover 只对可用态生效:disabled 时不该有放大反馈,否则看着像能点 */
|
||||
.iwb-color-pop-none:not(:disabled):hover { border-color: #f38ba8; color: #f38ba8; transform: scale(1.14); }
|
||||
.iwb-color-pop-none.active { border-style: solid; border-color: #f38ba8; color: #f38ba8; background: rgba(243, 139, 168, 0.14); }
|
||||
/* 不可用:整颗压到 42% 不透明度 —— 灰到能看出「这里有个去色,但现在用不上」,
|
||||
但不至于淡到看不见(32% 时在深底上几乎消失,等于又变成了「消失」,只是慢一点)。
|
||||
cursor 保持 default,不给 pointer。 */
|
||||
.iwb-color-pop-none:disabled,
|
||||
.iwb-color-pop-none.is-disabled {
|
||||
opacity: 0.42; cursor: default; color: #8b8fa8; border-color: #4a4a5e;
|
||||
background: transparent; transform: none;
|
||||
}
|
||||
.iwb-color-pop-none svg { flex: 0 0 auto; }
|
||||
.iwb-color-pop-none:hover { border-color: #f38ba8; color: #f38ba8; }
|
||||
.iwb-color-pop-none.active { border-style: solid; border-color: #f38ba8; color: #f38ba8; background: rgba(243, 139, 168, 0.12); }
|
||||
.iwb-color-pop-none[hidden] { display: none; }
|
||||
.iwb-color-pop-body { display: flex; align-items: stretch; gap: 10px; }
|
||||
.iwb-color-pop-picker { display: flex; gap: 8px; flex: 0 0 auto; }
|
||||
@@ -1870,11 +1878,12 @@
|
||||
/* display:flex 会盖掉 [hidden] 的默认 display:none,必须显式写一条 */
|
||||
.iwb-color-group[hidden] { display: none; }
|
||||
|
||||
/* 色值输入固定 150px:够显示 #RRGGBB 还有余量,又不会被 flex-grow 拉成一条长条
|
||||
(拉长后视觉重心全跑到输入框上,色块反倒成了配角)。
|
||||
文字工具多出「底色」tab 时按 0 1 150 自动收缩,min-width 保证七个字符看得全。 */
|
||||
/* 色值输入定宽 124(v1.20 由 150 收窄、且不再可缩):#RRGGBB 七个字符 55px 出够,
|
||||
v1.19 用的是 flex:0 1 150px,文字工具多出「底色」tab 时它会自己缩到 147 ——
|
||||
头部宽度就跟着上下文抖,最后把「去色」整颗挤掉(用户截图里那次)。
|
||||
现在头部每个元素都定宽:只有 gap 吸收亚像素误差,切工具不再重排。 */
|
||||
.iwb-editor-color-pop .iwb-editor-color-hex-input {
|
||||
flex: 0 1 150px; width: 150px; min-width: 58px; height: 26px; padding: 0 5px; text-align: center;
|
||||
flex: 0 0 124px; width: 124px; height: 26px; padding: 0 5px; text-align: center;
|
||||
font: 600 12px monospace; border-radius: 6px; box-sizing: border-box;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-swatches {
|
||||
@@ -2248,7 +2257,8 @@
|
||||
#iwb-editor-overlay .iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-val,
|
||||
#iwb-editor-overlay .iwb-editor-left .iwb-editor-zoom .iwb-editor-zoom-fit { font-size: 12px; }
|
||||
|
||||
/* 调色面板本体 */
|
||||
#iwb-editor-overlay .iwb-color-pop-tab,
|
||||
#iwb-editor-overlay .iwb-color-pop-none { font-size: 12.5px; height: 26px; }
|
||||
/* 调色面板本体(v1.20:去色已下移到色块网格,这里只剩 tab 需要放大字号;
|
||||
去色是 20px 格子,高度必须跟色块一致,别被这条统一字号的规则顶成 26px) */
|
||||
#iwb-editor-overlay .iwb-color-pop-tab { font-size: 12.5px; height: 26px; }
|
||||
#iwb-editor-overlay .iwb-color-pop-none { width: 20px; height: 20px; }
|
||||
#iwb-editor-overlay .iwb-editor-color-pop .iwb-editor-color-hex-input { font-size: 13px; }
|
||||
@@ -17,20 +17,28 @@ import { bindEvents } from './events.js'
|
||||
* HEX 回填、常用色/最近色的 active 圈),events.js#updateColorUI 按
|
||||
* `[data-color-surface]` 逐个刷 —— 留着这层抽象,将来若再加一处面板不用重写联动。
|
||||
*/
|
||||
/* 16 个常用色 = 色板里 8 列 × 2 行(v1.19)。
|
||||
排布刻意成对:第一行是 8 个饱和亮色(红橙黄绿青蓝紫粉),
|
||||
/* 15 个常用色 + 第一格「去色」= 色板里 8 列 × 2 行(v1.20)。
|
||||
排布刻意成对:第一行是 7 个饱和亮色(红橙黄绿青蓝粉)+ 去色打头,
|
||||
第二行是 4 个中性色(白/浅灰/中灰/黑)+ 4 个同色系「深一档」,
|
||||
深红/深绿/深蓝/深紫 在浅色底图上比亮色稳,做描边不刺眼。 */
|
||||
深红/深绿/深蓝/深紫 在浅色底图上比亮色稳,做描边不刺眼。
|
||||
亮紫 #aa44ff 让位给第一格的「去色」(v1.20,用户 2026-11-10:去色放常用色第一个)——
|
||||
紫色还留着深一档的 #6b4fbb,色相不缺,8×2 的网格也不用改成 3 行。 */
|
||||
const COMMON_COLORS = [
|
||||
'#ff4444', '#ff8a00', '#ffd400', '#4cd964', '#00bfa5', '#4488ff', '#aa44ff', '#ff66aa',
|
||||
'#ff4444', '#ff8a00', '#ffd400', '#4cd964', '#00bfa5', '#4488ff', '#ff66aa',
|
||||
'#ffffff', '#d0d0d0', '#808080', '#000000', '#c0392b', '#0f9d58', '#1677ff', '#6b4fbb'
|
||||
]
|
||||
|
||||
/** 色板面板(v1.19 起只有工具栏弹层一份,右栏常驻面板已删)
|
||||
*
|
||||
* 头部一行:调哪个槽(描边/填充/底色)│ 吸管 + 色值 │ 去色 │ 图钉
|
||||
* 头部一行:调哪个槽(描边/填充/底色)│ 吸管 + 色值 │ 图钉
|
||||
* 把「吸管 + 色值」提到头部,是为了让下面整块高度都留给色块:
|
||||
* 常用色 2 排 + 最近色 2 排,一屏就能点到,不用滚动、也不用二次点开。
|
||||
*
|
||||
* v1.20(用户 2026-11-10):头部不再随上下文增减控件。
|
||||
* 原因是文字工具会多出「底色」tab,头部一行本来就贴着 440 的极限,
|
||||
* 再去掉/加上「去色」就会把色值框和吸管挤变形(甚至整颗按钮被 flex 抵没)。
|
||||
* 现在「去色」下移到常用色网格的第一格 —— 位置永远固定,不可用时只是变灰 + disabled,
|
||||
* 头部元素因此全是定宽,切工具时头部不再重排。
|
||||
*/
|
||||
function colorSurfaceHtml() {
|
||||
return `
|
||||
@@ -41,14 +49,7 @@ import { bindEvents } from './events.js'
|
||||
<span class="iwb-color-pop-bar"></span>
|
||||
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
||||
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
|
||||
<!-- 去色(v1.19,用户 2026-11-10):就是原来的「无」,挪到图钉左边并用竖线隔开。
|
||||
调色时「这一项我不上色」和「钉住」都是随手要按的开关,放在同一侧最顺。
|
||||
对描边 / 填充 / 底色都生效,具体含义随当前槽变(见 updateColorUI 的 title)。
|
||||
外面这层 .iwb-color-pop-tools 用 margin-left:auto 把整组推到最右:
|
||||
色值框因此不会被拉成一整条(见 CSS 的 max-width)。 -->
|
||||
<span class="iwb-color-pop-tools">
|
||||
<span class="iwb-color-pop-bar"></span>
|
||||
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="去色:当前这一项不上色(描边/填充/底色按上下文透明)"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m5.6 5.6 12.8 12.8"/></svg>去色</button>
|
||||
<span class="iwb-color-pop-bar"></span>
|
||||
<!-- 钉住(v1.18,用户 2026-11-10):调色常常要连着改好几处,每次点开色板太碎。
|
||||
钉住后点画布 / 点别处都不收起,只有再点一次图钉、按 Esc、或点吸管才收。
|
||||
@@ -69,6 +70,11 @@ import { bindEvents } from './events.js'
|
||||
<div class="iwb-color-group">
|
||||
<span class="iwb-color-group-label">常用色</span>
|
||||
<div class="iwb-editor-color-swatches">
|
||||
<!-- 去色(v1.20,用户 2026-11-10):原来是头部一颗带文字的按钮,现在占常用色第一格。
|
||||
好处有二:① 位置永远固定,切到文字/箭头这类「去不掉色」的上下文只是变灰,
|
||||
不会整颗消失;② 头部腾出一颗按钮的宽度,文字工具多出「底色」tab 也挤不坏色值框。
|
||||
含义随当前槽变(无描边 / 无填充 / 无底色),title 在 updateColorUI 里刷。 -->
|
||||
<button type="button" class="iwb-color-pop-none" data-color-none="1" title="去色:当前这一项不上色(描边/填充/底色按上下文透明)"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="m5.6 5.6 12.8 12.8"/></svg></button>
|
||||
${COMMON_COLORS.map(c => `<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="${c}" style="background:${c}" title="${c}"></button>`).join('')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1055,21 +1055,28 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
// 描边格:文字的「描边」是第二格(上面已处理),文字色/单槽上下文不允许「无」
|
||||
if (!isFill && !isBg) tab.classList.toggle('is-none', !isText && sl.strokeOn === false)
|
||||
})
|
||||
// 「去色」(v1.19 前叫「无」):形状/钢笔 = 无描边或无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
||||
// (文字色与箭头单槽没有「去色」—— 去掉就等于把对象删了,不该给这个按钮)
|
||||
// 按集合刷(原来是右栏 + 弹层各一个,现在只剩弹层一个,写法保持不变以免将来再加面板时漏刷)
|
||||
// 「去色」:形状/钢笔 = 无描边或无填充;文字描边 = 描边宽度 0;文字底色 = 关掉底色块
|
||||
// v1.20(用户 2026-11-10):它现在是常用色网格的第一格,**永远显示**。
|
||||
// 文字色 / 箭头这类「去掉就等于删掉对象」的上下文,改成置灰 + disabled,而不是整颗消失 ——
|
||||
// 消失会让色板每切一次工具就重排一次,位置记不住。
|
||||
const onBg = S.colorTarget === 'bg' && isText
|
||||
const onFill = S.colorTarget === 'fill' && second
|
||||
const onStroke = S.colorTarget === 'stroke' && !isText && strokeSlotCanBeNone()
|
||||
const showNone = onBg || onFill || onStroke
|
||||
const noneUsable = onBg || onFill || onStroke
|
||||
runtime.el.querySelectorAll('[data-color-none]').forEach(noneBtn => {
|
||||
noneBtn.hidden = !showNone
|
||||
noneBtn.classList.toggle('active', showNone && (onBg ? !sl.bgOn : (onFill ? !sl.fillOn : !sl.strokeOn)))
|
||||
noneBtn.title = onBg
|
||||
? '去色:文字后面完全透明(无底色)'
|
||||
: (onStroke
|
||||
? (sl.strokeOn === false ? '当前已是无描边;点选颜色可恢复描边' : '去色:去掉形状外框,只留内部填充')
|
||||
: (isText ? '去色:把描边宽度置 0,只留文字本身' : '去色:形状内部透明,只留描边'))
|
||||
noneBtn.hidden = false
|
||||
noneBtn.disabled = !noneUsable
|
||||
noneBtn.classList.toggle('is-disabled', !noneUsable)
|
||||
noneBtn.classList.toggle('active', noneUsable && (onBg ? !sl.bgOn : (onFill ? !sl.fillOn : !sl.strokeOn)))
|
||||
noneBtn.title = noneUsable
|
||||
? (onBg
|
||||
? '去色:文字后面完全透明(无底色)'
|
||||
: (onStroke
|
||||
? (sl.strokeOn === false ? '当前已是无描边;点选颜色可恢复描边' : '去色:去掉形状外框,只留内部填充')
|
||||
: (isText ? '去色:把描边宽度置 0,只留文字本身' : '去色:形状内部透明,只留描边')))
|
||||
: (isText && S.colorTarget === 'stroke'
|
||||
? '去色不可用:文字色去掉就等于把文字删了,要隐藏文字请用「清空标注」'
|
||||
: '去色不可用:这一格只有一种颜色,去掉就没有了')
|
||||
})
|
||||
|
||||
const cur = activeColor()
|
||||
|
||||
Reference in new issue
Block a user