feat(grouplib): 分类胶囊改为适应面板宽度自动换行 v1.0.3
- 宿主 .iwb-lib-chips 是 nowrap(配 .iwb-lib-chips-scroll 才单行滚动),分组多时右侧胶囊被裁掉看不见 - 去掉滚动容器,胶囊行加 .iwb-glp-chips,自带 styles.css 用双类选择器改 flex-wrap: wrap(不依赖样式注入顺序) - 顺带修 1.0.2 的真 bug:分组名胶囊曾被 append 到外层容器、其余在滚动容器里,等于分组既拿不到滚动也被裁 - +/⚙ 归到 .iwb-glp-add,不参与压缩并与分组名稍作分隔
This commit is contained in:
1 parent
da0c3f35c2
commit
ceb97aecee
3 files changed
+29
-13
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/grouplib",
|
||||
"private": true,
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "节点组:左栏收藏的节点组列表(分组/改名/删除/拖入画布实例化),数据由宿主 grouplib 能力提供",
|
||||
"ibwPlugin": {
|
||||
"id": "grouplib",
|
||||
|
||||
+11
-12
@@ -281,11 +281,10 @@
|
||||
}
|
||||
fixed.appendChild(topRow)
|
||||
|
||||
// 分类胶囊:宿主的 .iwb-lib-chips-scroll 负责「单行 + 横向滚动 + 右侧渐隐」,
|
||||
// 直接铺在 .iwb-lib-chips 里会被 nowrap 裁掉(分组多时右侧分类看不见)
|
||||
var chips = el('div', { class: 'iwb-lib-chips' })
|
||||
var chipsScroll = el('div', { class: 'iwb-lib-chips-scroll' })
|
||||
chips.appendChild(chipsScroll)
|
||||
// 分类胶囊:宿主 .iwb-lib-chips 是 nowrap(配 .iwb-lib-chips-scroll 才单行滚动),
|
||||
// 分组多时右侧胶囊会被面板宽度裁掉看不见 ⇒ 这里改成「适应面板宽度自动换行」,
|
||||
// 换行规则在插件自带 styles.css 的 .iwb-glp-chips 里(样式随插件发,不用等客户端发版)
|
||||
var chips = el('div', { class: 'iwb-lib-chips iwb-glp-chips' })
|
||||
function chip (label, value, count, extra) {
|
||||
var b = el('button', { class: 'iwb-chip' + (filter === value ? ' iwb-chip-active' : '') + (extra || ''), title: value === '__none__' ? '未分组;拖拽节点组卡片到此 = 移出分组' : (value === 'all' ? '' : '拖拽节点组卡片到此 = 移动到该分组') })
|
||||
b.appendChild(document.createTextNode(label))
|
||||
@@ -300,15 +299,15 @@
|
||||
})
|
||||
return b
|
||||
}
|
||||
chipsScroll.appendChild(chip('全部', 'all', list.length))
|
||||
chipsScroll.appendChild(chip('未分组', '__none__', countOf('__none__'), ' iwb-chip-drop'))
|
||||
chips.appendChild(chip('全部', 'all', list.length))
|
||||
chips.appendChild(chip('未分组', '__none__', countOf('__none__'), ' iwb-chip-drop'))
|
||||
gs.forEach(function (g) { chips.appendChild(chip(g.name, g.name, countOf(g.name), ' iwb-chip-drop')) })
|
||||
var addChip = el('button', { class: 'iwb-chip iwb-chip-add', title: '新建分组', text: '+' })
|
||||
var addChip = el('button', { class: 'iwb-chip iwb-glp-add iwb-chip-add', title: '新建分组', text: '+' })
|
||||
addChip.addEventListener('click', function () { newOpen = !newOpen; render() })
|
||||
chipsScroll.appendChild(addChip)
|
||||
var mgChip = el('button', { class: 'iwb-chip iwb-chip-add', title: '管理分组(重命名 / 排序 / 删除)', text: '⚙' })
|
||||
chips.appendChild(addChip)
|
||||
var mgChip = el('button', { class: 'iwb-chip iwb-glp-add iwb-chip-add', title: '管理分组(重命名 / 排序 / 删除)', text: '⚙' })
|
||||
mgChip.addEventListener('click', openManager)
|
||||
chipsScroll.appendChild(mgChip)
|
||||
chips.appendChild(mgChip)
|
||||
fixed.appendChild(chips)
|
||||
|
||||
if (newOpen) {
|
||||
@@ -435,7 +434,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'grouplib',
|
||||
name: '节点组',
|
||||
version: '1.0.2',
|
||||
version: '1.0.3',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'grouplib'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/* grouplib(节点组)自带样式
|
||||
作用域全部带 .iwb-glp-*,不影响宿主与其他插件;样式随插件发布,不必等客户端发版。 */
|
||||
|
||||
/* 分类胶囊「适应面板宽度」自动换行。
|
||||
宿主的 .iwb-lib-chips 是 flex-wrap: nowrap(配合 .iwb-lib-chips-scroll 才做单行横向滚动),
|
||||
分组多时右侧胶囊会被面板宽度裁掉、看不见也用不了。
|
||||
这里用双类选择器提高优先级(不依赖样式注入顺序),让它按宽度折行。 */
|
||||
.iwb-lib-chips.iwb-glp-chips {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 6px;
|
||||
}
|
||||
|
||||
/* + / ⚙ 是动作按钮,不是分组名:不参与压缩,并与最后一个分组稍作分隔 */
|
||||
.iwb-glp-chips .iwb-glp-add {
|
||||
flex: 0 0 auto;
|
||||
margin-left: 2px;
|
||||
}
|
||||
Reference in new issue
Block a user