dsh-theme-neumorph 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -7
- package/client.js +55 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,9 +35,14 @@
|
|
|
35
35
|
主题只动宿主自己画的界面,不碰第三方插件:
|
|
36
36
|
|
|
37
37
|
- 宿主同时用着**两套** CSS Module 命名:预构建样式表是 `_<local>_<hash>_<line>`(`_card_7gxqk_107`),组件从 JS 注入的样式是 `<hash>_<local>`(`wSkVaW_card`)。所以一个类名要同时锚定两次——`[class$="_card"]` 与 `[class*="_card_"]`——只写一种就会有一半界面纹丝不动。
|
|
38
|
-
-
|
|
39
|
-
- 每个类名锚定都带 `:not([class*="__"])`:宿主是**单**下划线,别人家的 BEM 是**双**下划线,这一条挡住的正是 `panel__card
|
|
40
|
-
-
|
|
38
|
+
- 凡是要**加**规则的地方,锚定的都是**完整的 local 名**,而且一定用下划线夹住(`[class*="_card_"]` 而不是 `[class*="_card"]`),否则会串到 `_cardContent_x_y`、`_labelChip` 这种更长的零件上,卡片的每一块又各得一层投影。只有**排除**项才允许宽泛的片段(`button:not([class*="_row"])` 这类),因为排除范围宽一点只会少上一条浮雕,不会多毁一块界面。
|
|
39
|
+
- 每个类名锚定都带 `:not([class*="__"])`:宿主是**单**下划线,别人家的 BEM 是**双**下划线,这一条挡住的正是 `panel__card`。
|
|
40
|
+
- 裸标签只出现在三处:宿主的表单与代码面(`textarea`、`input`、`select`、`pre`)、可编辑文本(`[contenteditable="true"]`),以及必须同时带宿主类名的控件(`button` / `[role="button"]` / `a` + `[class*="_"]`)。`span` 不被当成文字。
|
|
41
|
+
- 悬在内容**之上**的控件必须不透明。主题里表面只有一个颜色,所以"透明"对躺在表面上的控件是对的,对浮在滚动正文之上的那颗"回到最新"圆钮就是错的——它的底来自 `--dsw-alias-button-floating-fill`,透明时消息会从圆钮里穿过去。`floating-fill` / `elevated-fill` 现在是表面色,`floating-hover` 与 `--dsw-alias-interactive-bg-hover-solid` 是一层浅色(后者是十处控件唯一的悬停反馈)。
|
|
42
|
+
- 圆形的钮不给 12px 圆角:按钮形状规则用 `host()` 锚定把"回到最新"(34px)与附件删除(18px)两颗圆盘排除在外,而不是事后改回来——按钮选择器里每个 `:not()` 都加权重,后面再写一条压不过它。
|
|
43
|
+
- 不强制按钮底色。主题里所有表面是同一个颜色,透明按钮本来就与表面齐平;而宿主有些控件是**功能填充**(附件删除键的圆盘用 `--dsw-alias-button-contrast-fill`、叉号用 `--dsw-alias-label-primary-inverted`),一旦被灌成表面色,叉号就在近白底上消失了。所以按钮只加圆角与浮雕,填充留给宿主。
|
|
44
|
+
- 文本会被拍平,但表单控件不会:宿主的重命名输入框类名就叫 `ymsBma_name`,它在文字规则里必须被 `:not(input):not(textarea):not(select)` 放行,否则那块输入框看起来就是一行纯文本。
|
|
45
|
+
- 不是每个 token 都是"板子"。引用竖线(`--dsw-alias-markdown-citation`)、幽灵按钮的选中态(`--dsw-alias-button-ghost-active-fill`)、行内代码(`--dsw-alias-markdown-inline-code`)是宿主的**信号**,置成 `transparent` 等于把它们删掉,所以它们保留一层浅色,而不是跟其他表面一起消失。
|
|
41
46
|
- 文本框的焦点指示不用宿主的外扩轮廓(在软表面上像一圈多余的蓝边),改成画在框内侧的 1.5px 钢蓝内缘;`outline-offset: -2px` 与内凹阴影叠加而不是替换它。checkbox / radio / 原生控件完全不碰,宿主自己的焦点环留给它们。
|
|
42
47
|
|
|
43
48
|
## 目录结构
|
|
@@ -62,15 +67,15 @@
|
|
|
62
67
|
|
|
63
68
|
- Client 半通过 `window.__ModuleLoader__.load({ id, factory })` 注册,`factory` 返回 `{ inject: ['theme'], apply(ctx) }`。
|
|
64
69
|
- 所有副作用都包在 `ctx.effect()` 里并返回清理函数:样式表在 effect 内插入(effect 被拒就一张纸都不留),重复 apply 时先删掉自己上一张,停用时先移除样式表再撤销 token 覆盖层,界面立刻回到原生外观。
|
|
65
|
-
- 若宿主某天拒绝含 `--dsw-radius-*` 的 token
|
|
66
|
-
-
|
|
70
|
+
- 若宿主某天拒绝含 `--dsw-radius-*` 的 token 表,会退回只含颜色的 66 项重试一次;连重试也被拒时保留阴影层并告警,而不是把主题整个掀掉。这是一条防御路径——目前这版宿主只校验 token 值的形状(是否 `{ light, dark }`),不校验名字,所以实际上不会走到。
|
|
71
|
+
- 颜色层之外的一切都用宿主类名锚定 CSS Module,哈希前缀与文件名随版本变化都不会失效;只有上面那几个裸标签例外。
|
|
67
72
|
|
|
68
73
|
## 开发
|
|
69
74
|
|
|
70
75
|
不需要浏览器,也不需要安装依赖(`node --test` 自带):
|
|
71
76
|
|
|
72
77
|
```bash
|
|
73
|
-
npm test #
|
|
78
|
+
npm test # 19 项断言:调色板、样式表结构、生命周期、卸载路径
|
|
74
79
|
npm run check # 语法检查
|
|
75
80
|
node scripts/verify-manifest.mjs # 清单/打包自检
|
|
76
81
|
npm run verify # 以上全部
|
|
@@ -85,7 +90,10 @@ npm run verify # 以上全部
|
|
|
85
90
|
- 焦点环存在、画在框内、不吞掉内凹阴影、不碰 checkbox / radio,且全文没有一处 `outline: none`,
|
|
86
91
|
- 样式表在 `ctx.effect` 内插入:宿主拒绝注册 effect 时一张纸都不留,
|
|
87
92
|
- 连续 apply 两次只留下一张样式表,
|
|
88
|
-
-
|
|
93
|
+
- 浮雕落在卡片、输入区大板、菜单/对话框与会话行上,且各用各的阴影级;按钮、输入框、悬停态、发送胶囊各自保着圆角与阴影(只断言"字符串出现过"就够,因为这里保护的是"规则还在"),
|
|
94
|
+
- 没有任何按钮规则会强制底色(附件删除键上的叉号就是这样变成隐形的),且对比度圆盘还留着自己的填充,
|
|
95
|
+
- 信号类 token 不会被置成 `transparent`(引用竖线、幽灵按钮选中态、行内代码),
|
|
96
|
+
- 宿主拒绝插入样式表时,那张表会被撤回、异常照旧抛出。
|
|
89
97
|
|
|
90
98
|
## 许可
|
|
91
99
|
|
package/client.js
CHANGED
|
@@ -64,26 +64,30 @@ window.__ModuleLoader__.load({
|
|
|
64
64
|
'--dsw-alias-menu-group-header-fill': FLAT,
|
|
65
65
|
'--dsw-specific-bubble': FLAT,
|
|
66
66
|
'--dsw-specific-bubble-highlight': FLAT,
|
|
67
|
-
'--dsw-specific-sidebar-nav-item-active':
|
|
67
|
+
'--dsw-specific-sidebar-nav-item-active': HOVER,
|
|
68
68
|
'--dsw-specific-sidebar-nav-item-active-accent': FLAT,
|
|
69
69
|
|
|
70
|
-
// ---- button fills
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'--dsw-alias-button-
|
|
76
|
-
'--dsw-alias-button-
|
|
70
|
+
// ---- button fills ----------------------------------------------------
|
|
71
|
+
// Ghost fills vanish (the relief carries them), but a button that floats
|
|
72
|
+
// over content must be opaque: the "jump to latest" disc is painted from
|
|
73
|
+
// floating-fill, and a transparent disc lets the transcript scroll through
|
|
74
|
+
// it. Hover states keep a shade, or pressing feels like nothing happened.
|
|
75
|
+
'--dsw-alias-button-elevated-fill': SURFACE,
|
|
76
|
+
'--dsw-alias-button-floating-fill': SURFACE,
|
|
77
|
+
'--dsw-alias-button-floating-hover': HOVER,
|
|
78
|
+
'--dsw-alias-button-ghost-active-fill': HOVER,
|
|
79
|
+
'--dsw-alias-button-ghost-active-hover': HOVER,
|
|
80
|
+
'--dsw-alias-fill-tsp-secondary': SURFACE,
|
|
77
81
|
'--dsw-alias-button-contrast-fill': { light: '#3a4450', dark: '#c9d3de' },
|
|
78
|
-
'--dsw-alias-interactive-bg-hover-solid':
|
|
82
|
+
'--dsw-alias-interactive-bg-hover-solid': HOVER,
|
|
79
83
|
|
|
80
84
|
// ---- code and inline panels: recessed, not tinted --------------------
|
|
81
85
|
'--dsw-alias-markdown-code-block': FLAT,
|
|
82
86
|
'--dsw-alias-markdown-code-block-banner': FLAT,
|
|
83
|
-
'--dsw-alias-markdown-inline-code':
|
|
87
|
+
'--dsw-alias-markdown-inline-code': HOVER,
|
|
84
88
|
'--dsw-alias-markdown-code-segment-selected': FLAT,
|
|
85
89
|
'--dsw-alias-markdown-code-segment-unselected': FLAT,
|
|
86
|
-
'--dsw-alias-markdown-citation':
|
|
90
|
+
'--dsw-alias-markdown-citation': SCROLL_HOVER,
|
|
87
91
|
'--dsw-alias-markdown-tag': FLAT,
|
|
88
92
|
'--dsw-alias-markdown-placeholder': FLAT,
|
|
89
93
|
|
|
@@ -153,10 +157,6 @@ window.__ModuleLoader__.load({
|
|
|
153
157
|
*/
|
|
154
158
|
const guard = (anchor) => `${anchor}:not([class*="__"])`;
|
|
155
159
|
|
|
156
|
-
/** Anchors on a free-form class fragment (`_title`, `_label`). */
|
|
157
|
-
const sub = (...fragments) =>
|
|
158
|
-
fragments.map((fragment) => guard(`[class*="${fragment}"]`)).join(',\n ');
|
|
159
|
-
|
|
160
160
|
/** Anchors on a complete local name, in both host conventions. */
|
|
161
161
|
const host = (...locals) =>
|
|
162
162
|
locals
|
|
@@ -198,10 +198,22 @@ body[data-ds-dark-theme] {
|
|
|
198
198
|
/* ---- text is flat ------------------------------------------------------
|
|
199
199
|
Text never carries a plate of its own: a label sits on the surface, it does
|
|
200
200
|
not sit in a slightly different rectangle. Only host markup is touched, and
|
|
201
|
-
only by
|
|
202
|
-
own elements
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
only by a complete local name (see the host helper above), so neither a
|
|
202
|
+
plugin's own elements nor a longer host part ('_labelChip') is repainted.
|
|
203
|
+
Form controls are excluded even when their local reads like text, because a
|
|
204
|
+
rename field named '_name' is still a field with a plate of its own. Nothing
|
|
205
|
+
here targets a bare tag: a span is not text until the host says so. */
|
|
206
|
+
body :is(${host(
|
|
207
|
+
'label',
|
|
208
|
+
'title',
|
|
209
|
+
'value',
|
|
210
|
+
'text',
|
|
211
|
+
'name',
|
|
212
|
+
'desc',
|
|
213
|
+
'caption',
|
|
214
|
+
'hint',
|
|
215
|
+
'meta',
|
|
216
|
+
'timestamp',
|
|
205
217
|
'itemLabel',
|
|
206
218
|
'runStateLabel',
|
|
207
219
|
'dockHintLabel',
|
|
@@ -215,24 +227,35 @@ body :is(${sub('_label', '_title', '_value', '_text', '_name', '_desc', '_captio
|
|
|
215
227
|
'otherValue',
|
|
216
228
|
'keywordValue',
|
|
217
229
|
'popoverText',
|
|
218
|
-
)}) {
|
|
230
|
+
)}):not(input):not(textarea):not(select):not([contenteditable="true"]) {
|
|
219
231
|
background-color: transparent !important;
|
|
220
232
|
box-shadow: none !important;
|
|
221
233
|
}
|
|
222
234
|
|
|
223
235
|
/* ---- controls: soft, raised --------------------------------------------
|
|
224
|
-
Buttons are objects again: a
|
|
225
|
-
|
|
236
|
+
Buttons are objects again: a shape with the same paired light and shade as
|
|
237
|
+
the surface around it. The fill is deliberately not forced: every surface in
|
|
238
|
+
this theme is one colour, so a transparent button already sits flush on it,
|
|
239
|
+
while a host control that paints a functional disc (the attachment remove
|
|
240
|
+
button uses '--dsw-alias-button-contrast-fill') must keep it or its glyph
|
|
241
|
+
becomes invisible. Full-width rows and every control that
|
|
226
242
|
lives inside a menu, a tab strip or a picker are excluded, because a
|
|
227
243
|
shadow under a row that spans the panel reads as a stray line, and a
|
|
228
244
|
stack of them reads as alternating high and low. */
|
|
229
245
|
${BUTTON_SELECTOR} {
|
|
230
|
-
border-radius: 12px !important;
|
|
231
246
|
border-color: transparent !important;
|
|
232
|
-
background-color: var(--dsw-alias-bg-base) !important;
|
|
233
247
|
box-shadow: var(--qn-out-sm) !important;
|
|
234
248
|
}
|
|
235
249
|
|
|
250
|
+
/* The shape is a rounded rectangle, except where the host draws a ring: the
|
|
251
|
+
jump-to-latest disc is a 34px circle and the attachment remove disc an 18px
|
|
252
|
+
one, and a 12px corner turns either into a small rounded square. Their own
|
|
253
|
+
radius is left alone instead of being restored afterwards, because a later
|
|
254
|
+
rule here could not out-rank this one. */
|
|
255
|
+
${BUTTON_SELECTOR}:not(:is(${host('toBottom')})):not(:is(${host('remove')})) {
|
|
256
|
+
border-radius: 12px !important;
|
|
257
|
+
}
|
|
258
|
+
|
|
236
259
|
${BUTTON_SELECTOR}:hover:not(:disabled) {
|
|
237
260
|
box-shadow: var(--qn-out) !important;
|
|
238
261
|
}
|
|
@@ -338,9 +361,15 @@ body :where(
|
|
|
338
361
|
outline-offset: -2px !important;
|
|
339
362
|
}
|
|
340
363
|
|
|
364
|
+
/* Buttons and links keep a ring outside the shape, where it cannot be confused
|
|
365
|
+
with the relief, but it is declared important so that every control in the
|
|
366
|
+
product shows the same theme accent: the host draws its own ring inside
|
|
367
|
+
component-scoped rules (a business-blue ring with a positive offset), and
|
|
368
|
+
without the flag half the interface would stay blue while the fields are
|
|
369
|
+
steel. */
|
|
341
370
|
body :where(button, [role="button"], a):focus-visible {
|
|
342
|
-
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
343
|
-
outline-offset: 2px;
|
|
371
|
+
outline: 2px solid var(--dsw-alias-brand-primary) !important;
|
|
372
|
+
outline-offset: 2px !important;
|
|
344
373
|
}
|
|
345
374
|
`;
|
|
346
375
|
|