fix(native): ellipsize start-page card descriptions
Long subtitles were clamped to two lines and grew the card; keep them on one line with a text-overflow ellipsis, and pin the rule with a CSS regression test.
This commit is contained in:
1 parent
95270afa2f
commit
91e3ee8970
4 files changed
+23
-3
No files matched your search
@@ -6,6 +6,7 @@
|
||||
|
||||
- 🧭 **开始页由插件接管,支持两列自适应、可配置行数和「更多」收纳**:右侧栏展开时不再用宿主自带的单列卡片页。宽屏(≥520px)每行两张、窄屏一张;默认最多 6 行(可在设置或「调整顺序」弹窗中改为 ≥1 行),超出容量的入口收进「更多」卡片,菜单行统一为图标 + 标题,可直接打开,也可打开「调整顺序」。开始页内容默认垂直居中,可切换为靠上;设置中新增「接管开始页」开关(默认开),关闭后恢复宿主自带开始页。开始页卡片点击后用新页面替换指南页,和宿主原行为一致。
|
||||
- 🧪 测试:`tests/guide-layout.spec.ts`(排序 / 隐藏 / 列数与容量 / More 占格 / 最小容量)、`tests/native-guide.spec.tsx`(卡片、More、终端 Shell 菜单、catalog 订阅、chain 注册与释放)。
|
||||
- 卡片副标题固定为一行,宽度不足时以省略号截断,长描述不再把卡片撑成两行。
|
||||
- 🗂 **设置里的「开始页」清单接管所有已注册到官方侧边栏的入口**:本插件、宿主终端和第三方 tab 都按 `providerId::entryId` 列出,默认显示;本插件自己的 tab 使用与「侧边栏内容」功能卡片相同的 `tabsEnabled` 功能开关(关闭即禁用并移出开始页,清单行保留以便重新打开);宿主/第三方入口的开关只控制开始页显示,不注销 tab 类型,也不影响快捷键、资源打开或已打开页签。支持上移/下移和恢复默认顺序,排序持久化。
|
||||
- 🧪 测试:`tests/side-card-section.spec.tsx`(原生入口清单、默认开启、顺序与隐藏状态)、`tests/prefs.spec.ts`(行数 / 顺序 / 可见性校验)。
|
||||
- 🖥 **终端卡片保留原生 Shell 菜单**:开始页的终端卡片右侧有「…」,菜单通过宿主 `webTerminals.launchShells` 读取 Shell 列表,选择后写入宿主偏好并以该 Shell 打开终端;宿主没有这些能力时卡片退化为普通入口。修复 `launchShells` / `selectShell` 丢失 `this` 导致「Shell 加载失败:Cannot read properties of undefined (reading 'remote')」的问题,并加回归测试。其他第三方自定义开始页卡片组件无法在 chain 接管页中复用,会显示为通用卡片(原因见 `docs/host-contracts.md` §9)。
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
- 🧭 **The start page is now plugin-owned, with a responsive two-column grid, a configurable row budget, and a More card for overflow.** Expanding the right sidebar no longer shows the host's single-column card page. Wide panes (>= 520px) put two cards on a row and narrow panes one; 6 rows by default (configurable to any value >= 1 in settings or in the Reorder dialog), and entries beyond the budget move into a More card whose rows all carry an icon plus a title and open the entry or the Reorder dialog. The grid is vertically centered by default and can be pinned to the top; settings gain a default-on "Take over the start page" switch that restores the host's page when off. Picking a card replaces the guide tab with the chosen page, exactly like the host did.
|
||||
- 🧪 Tests: `tests/guide-layout.spec.ts` (ordering / visibility / columns and capacity / More occupancy / minimum capacity) and `tests/native-guide.spec.tsx` (cards, More, the terminal shell menu, catalog subscription, chain registration and release).
|
||||
- Card subtitles stay on one line and end in an ellipsis when the card is narrower than the copy, so a long description no longer grows the card to two lines.
|
||||
- 🗂 **The settings "Start page" inventory now covers every entry registered with the official sidebar.** Plugin tabs, the host terminal, and third-party tabs are listed by `providerId::entryId`, visible by default; Better Sidebar's own tabs use the same `tabsEnabled` feature switch as their sidebar-content card (turning it off disables the tab and removes its start-page card, while the inventory row stays so it can be turned back on); host/third-party entries only have the start-page visibility switch, which never unregisters a tab type or affects shortcuts, resource opens, or already-open tabs. Move up/down and reset order are supported and persisted.
|
||||
- 🧪 Tests: `tests/side-card-section.spec.tsx` (native inventory, default-on, order and visibility) and `tests/prefs.spec.ts` (rows / order / visibility validation).
|
||||
- 🖥 **The terminal card keeps its native shell menu.** The start page's terminal card has a "..." trigger whose menu reads the shell list through the host's `webTerminals.launchShells`, remembers the choice through the host, and opens the terminal with that shell; without those host capabilities the card degrades to a plain entry. Fixed a lost receiver in `launchShells` / `selectShell` that surfaced as "Shell failed to load: Cannot read properties of undefined (reading 'remote')", with a regression test. Other third-party custom start-page card components cannot be reused inside a chain takeover and render as generic cards (see `docs/host-contracts.md` §9 for why).
|
||||
|
||||
@@ -118,13 +118,12 @@
|
||||
}
|
||||
|
||||
.cardDesc {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cardMenuButton {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Start-page card subtitles are a single line: descriptions longer than the
|
||||
* card width must end in an ellipsis instead of wrapping to a second line.
|
||||
*/
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const css = readFileSync('src/client/native/guide.module.css', 'utf8')
|
||||
|
||||
describe('start-page card description', () => {
|
||||
it('uses one-line ellipsis instead of a two-line clamp', () => {
|
||||
const rule = css.match(/\.cardDesc\s*\{([\s\S]*?)\n\}/)?.[1]
|
||||
expect(rule).toBeDefined()
|
||||
expect(rule).toMatch(/white-space:\s*nowrap/)
|
||||
expect(rule).toMatch(/text-overflow:\s*ellipsis/)
|
||||
expect(rule).toMatch(/overflow:\s*hidden/)
|
||||
expect(rule).not.toContain('line-clamp')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user