@manohub/ui 0.6.0
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 +141 -0
- package/dist/components/avatar/index.d.ts +283 -0
- package/dist/components/avatar/index.js +167 -0
- package/dist/components/badge/index.d.ts +132 -0
- package/dist/components/badge/index.js +99 -0
- package/dist/components/button/index.d.ts +578 -0
- package/dist/components/button/index.js +191 -0
- package/dist/components/capsule/index.d.ts +161 -0
- package/dist/components/capsule/index.js +101 -0
- package/dist/components/card/index.d.ts +456 -0
- package/dist/components/card/index.js +231 -0
- package/dist/components/checkbox/index.d.ts +331 -0
- package/dist/components/checkbox/index.js +165 -0
- package/dist/components/code/index.d.ts +134 -0
- package/dist/components/code/index.js +117 -0
- package/dist/components/code-editor/index.d.ts +163 -0
- package/dist/components/code-editor/index.js +98 -0
- package/dist/components/collapse/index.d.ts +125 -0
- package/dist/components/collapse/index.js +95 -0
- package/dist/components/control-size.d.ts +8 -0
- package/dist/components/dialog/index.d.ts +224 -0
- package/dist/components/dialog/index.js +194 -0
- package/dist/components/divider/index.d.ts +64 -0
- package/dist/components/divider/index.js +62 -0
- package/dist/components/drawer/index.d.ts +226 -0
- package/dist/components/drawer/index.js +190 -0
- package/dist/components/filter/index.d.ts +391 -0
- package/dist/components/filter/index.js +203 -0
- package/dist/components/form/index.d.ts +704 -0
- package/dist/components/form/index.js +329 -0
- package/dist/components/input/index.d.ts +980 -0
- package/dist/components/input/index.js +334 -0
- package/dist/components/layout/index.d.ts +162 -0
- package/dist/components/layout/index.js +100 -0
- package/dist/components/list-view/index.d.ts +563 -0
- package/dist/components/list-view/index.js +221 -0
- package/dist/components/loading/index.d.ts +77 -0
- package/dist/components/loading/index.js +40 -0
- package/dist/components/nav/index.d.ts +293 -0
- package/dist/components/nav/index.js +164 -0
- package/dist/components/notice/index.d.ts +137 -0
- package/dist/components/notice/index.js +101 -0
- package/dist/components/notification/index.d.ts +118 -0
- package/dist/components/notification/index.js +99 -0
- package/dist/components/page/index.d.ts +276 -0
- package/dist/components/page/index.js +351 -0
- package/dist/components/page/split-resize.d.ts +42 -0
- package/dist/components/page/split-resize.js +36 -0
- package/dist/components/pagination/index.d.ts +171 -0
- package/dist/components/pagination/index.js +226 -0
- package/dist/components/panel/index.d.ts +401 -0
- package/dist/components/panel/index.js +193 -0
- package/dist/components/part-padding.d.ts +27 -0
- package/dist/components/part-padding.js +23 -0
- package/dist/components/query-state/index.d.ts +207 -0
- package/dist/components/query-state/index.js +181 -0
- package/dist/components/radio/index.d.ts +473 -0
- package/dist/components/radio/index.js +250 -0
- package/dist/components/search/index.d.ts +167 -0
- package/dist/components/search/index.js +105 -0
- package/dist/components/select/index.d.ts +252 -0
- package/dist/components/select/index.js +281 -0
- package/dist/components/skeleton/index.d.ts +88 -0
- package/dist/components/skeleton/index.js +56 -0
- package/dist/components/steps/index.d.ts +199 -0
- package/dist/components/steps/index.js +117 -0
- package/dist/components/switch/index.d.ts +150 -0
- package/dist/components/switch/index.js +103 -0
- package/dist/components/table/index.d.ts +351 -0
- package/dist/components/table/index.js +286 -0
- package/dist/components/tabs/index.d.ts +179 -0
- package/dist/components/tabs/index.js +153 -0
- package/dist/components/tabset/index.d.ts +105 -0
- package/dist/components/tabset/index.js +68 -0
- package/dist/components/tag/index.d.ts +203 -0
- package/dist/components/tag/index.js +144 -0
- package/dist/components/toast/index.d.ts +271 -0
- package/dist/components/toast/index.js +116 -0
- package/dist/components/tooltip/index.d.ts +126 -0
- package/dist/components/tooltip/index.js +97 -0
- package/dist/components/tree/index.d.ts +317 -0
- package/dist/components/tree/index.js +251 -0
- package/dist/components/upload/index.d.ts +384 -0
- package/dist/components/upload/index.js +172 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +102 -0
- package/dist/services/base.d.ts +21 -0
- package/dist/services/base.js +42 -0
- package/dist/services/dialog.d.ts +41 -0
- package/dist/services/dialog.js +83 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/loading.d.ts +21 -0
- package/dist/services/loading.js +41 -0
- package/dist/services/toast.d.ts +40 -0
- package/dist/services/toast.js +74 -0
- package/dist/styles/components/avatar.css +128 -0
- package/dist/styles/components/avatar.tokens.css +24 -0
- package/dist/styles/components/badge.css +237 -0
- package/dist/styles/components/button.css +454 -0
- package/dist/styles/components/button.tokens.css +56 -0
- package/dist/styles/components/capsule.css +120 -0
- package/dist/styles/components/capsule.tokens.css +27 -0
- package/dist/styles/components/card.css +192 -0
- package/dist/styles/components/checkbox.css +145 -0
- package/dist/styles/components/checkbox.tokens.css +26 -0
- package/dist/styles/components/code-editor.css +91 -0
- package/dist/styles/components/code-editor.tokens.css +24 -0
- package/dist/styles/components/code.css +153 -0
- package/dist/styles/components/code.tokens.css +29 -0
- package/dist/styles/components/collapse.css +62 -0
- package/dist/styles/components/collapse.tokens.css +20 -0
- package/dist/styles/components/dialog.css +106 -0
- package/dist/styles/components/dialog.tokens.css +24 -0
- package/dist/styles/components/divider.css +71 -0
- package/dist/styles/components/divider.tokens.css +21 -0
- package/dist/styles/components/drawer.css +143 -0
- package/dist/styles/components/drawer.tokens.css +22 -0
- package/dist/styles/components/filter.css +41 -0
- package/dist/styles/components/filter.tokens.css +14 -0
- package/dist/styles/components/form.css +220 -0
- package/dist/styles/components/form.tokens.css +15 -0
- package/dist/styles/components/input.css +445 -0
- package/dist/styles/components/input.tokens.css +41 -0
- package/dist/styles/components/layout.css +198 -0
- package/dist/styles/components/list-view.css +244 -0
- package/dist/styles/components/loading.css +76 -0
- package/dist/styles/components/loading.tokens.css +23 -0
- package/dist/styles/components/nav.css +48 -0
- package/dist/styles/components/notice.css +153 -0
- package/dist/styles/components/notice.tokens.css +17 -0
- package/dist/styles/components/notification.css +159 -0
- package/dist/styles/components/notification.tokens.css +37 -0
- package/dist/styles/components/page.css +473 -0
- package/dist/styles/components/pagination.css +297 -0
- package/dist/styles/components/pagination.tokens.css +32 -0
- package/dist/styles/components/panel.css +77 -0
- package/dist/styles/components/query-state.css +88 -0
- package/dist/styles/components/radio.css +271 -0
- package/dist/styles/components/radio.tokens.css +26 -0
- package/dist/styles/components/search.css +30 -0
- package/dist/styles/components/select.css +242 -0
- package/dist/styles/components/select.tokens.css +33 -0
- package/dist/styles/components/skeleton.css +60 -0
- package/dist/styles/components/skeleton.tokens.css +27 -0
- package/dist/styles/components/steps.css +157 -0
- package/dist/styles/components/steps.tokens.css +42 -0
- package/dist/styles/components/switch.css +165 -0
- package/dist/styles/components/switch.tokens.css +26 -0
- package/dist/styles/components/table.css +439 -0
- package/dist/styles/components/table.tokens.css +41 -0
- package/dist/styles/components/tabs.css +234 -0
- package/dist/styles/components/tabs.tokens.css +30 -0
- package/dist/styles/components/tag.css +200 -0
- package/dist/styles/components/tag.tokens.css +30 -0
- package/dist/styles/components/toast.css +150 -0
- package/dist/styles/components/toast.tokens.css +26 -0
- package/dist/styles/components/tooltip.css +89 -0
- package/dist/styles/components/tooltip.tokens.css +25 -0
- package/dist/styles/components/tree.css +139 -0
- package/dist/styles/components/tree.tokens.css +20 -0
- package/dist/styles/components/upload.css +150 -0
- package/dist/styles/components/upload.tokens.css +27 -0
- package/dist/styles/index.css +149 -0
- package/dist/styles/operations/collapse.css +84 -0
- package/dist/styles/operations/popup.css +189 -0
- package/dist/styles/operations/tabset.css +57 -0
- package/dist/utils/state-illustration.d.ts +31 -0
- package/dist/utils/state-illustration.js +156 -0
- package/package.json +62 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card(卡片容器:底 / 弱描边 / 圆角 / 内距 / 悬浮与选中反馈)—— **卡片外观的唯一实现**。
|
|
3
|
+
*
|
|
4
|
+
* 依据:@aihub/theme 的 components/card.css(圆角 8 · 内距 20 · 弱描边)+ portal 技能市场卡片实测,见下方原注释。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* ===== Card(卡片容器:底 / 弱描边 / 圆角 / 内距 / 悬浮与选中反馈)=====
|
|
8
|
+
几何来源:portal 技能市场卡片实测(apps/portal/src/views/skills/index.tsx 的 SkillCard),
|
|
9
|
+
逐项落令牌:圆角 8(原型 rounded-lg)、内距 20(原型 p-5)、
|
|
10
|
+
底 Ne12/base-100、弱描边 base-300(原型 border-border)、
|
|
11
|
+
悬浮主色描边 + 主色 12% 阴影(原型 hover:border-primary + hover:shadow-[0_4px_10px_…])。
|
|
12
|
+
卡片外观在本仓**只有这一处定义**:消费方(含 ListView.CardItem)不得自绘这四类属性。 */
|
|
13
|
+
|
|
14
|
+
.mh-card {
|
|
15
|
+
/* 组件变量先铺一层,形态类只决定用哪几个(同 .mh-badge 手法) */
|
|
16
|
+
--mh-card-bg: var(--ui-base-100);
|
|
17
|
+
--mh-card-border: var(--ui-base-300);
|
|
18
|
+
--mh-card-radius: var(--ui-radius-md);
|
|
19
|
+
/* 卡片内距:**吃在各段上**(根件不出内距),故用同一个变量下发给分件与内建头 / 操作行 ——
|
|
20
|
+
整卡统一改它即可,单段微调传该段的 `padding` */
|
|
21
|
+
--mh-card-padding: var(--ui-space-5);
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
border: 1px solid var(--mh-card-border);
|
|
26
|
+
border-radius: var(--mh-card-radius);
|
|
27
|
+
background: var(--mh-card-bg);
|
|
28
|
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ===== 内距归属(改这几条规则前务必先读)=====
|
|
32
|
+
*
|
|
33
|
+
* 1. **根件不出内距**:根件只出面(底 / 描边 / 圆角),也不出段间距 ——
|
|
34
|
+
* 根件若也吃内距,就会与段的内距叠成两层留白(故面无「根件让出内距」的修饰类)。
|
|
35
|
+
* 2. **段的纵向只吃上边**(`padding-block-start`):一段只负责**与自己上方之间的距离**,
|
|
36
|
+
* 下一段的上内距就是「段间距」。于是头部 + body、body + footer 相邻时**不会**叠成两份
|
|
37
|
+
* (各吃四边就会变成 20 + 20 = 40,这正是要避免的)。
|
|
38
|
+
* 3. **卡片下沿由最后一段补**(下方那条 `:last-child` 规则):段不吃下边,底边得有人兜。
|
|
39
|
+
* 段的位置由组件保证(裸内容自动成段、封面不吃内距也不是段),故 `:last-child` 必定落在段上。
|
|
40
|
+
* 4. 横向每段恒吃 `--mh-card-padding`(`padding-inline`)。
|
|
41
|
+
*
|
|
42
|
+
* 直接写的内容(没包 `Card.Body` 的裸子节点)由组件自动补一层 Body,所以
|
|
43
|
+
* 「不给分件」(`<Card>正文</Card>`)与显式分段得到的是同一套几何。 */
|
|
44
|
+
|
|
45
|
+
/* 头部:**分件 `Card.Header` 与 `Card` 上的内建头共用这一类**(四件:图标 / 标题 / 副标题 + 右端 extra)。
|
|
46
|
+
行 + 两端对齐:左「左侧区域」、右「extra」;四个位一个都不给时退化为纯自排容器。 */
|
|
47
|
+
|
|
48
|
+
.mh-card__header {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex: none;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: space-between;
|
|
53
|
+
gap: var(--ui-space-2);
|
|
54
|
+
min-width: 0;
|
|
55
|
+
padding-block-start: var(--mh-card-padding);
|
|
56
|
+
padding-inline: var(--mh-card-padding);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* 左侧区域:图标 + 文字块(标题 / 副标题)+ 自排内容 */
|
|
60
|
+
|
|
61
|
+
.mh-card__header-main {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex: 1;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: var(--ui-space-3);
|
|
66
|
+
min-width: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* 图标位 36×36(与 ListView.CardItem 同一档),圆角取控件档 6;图片按方框自裁 */
|
|
70
|
+
|
|
71
|
+
.mh-card__header-icon {
|
|
72
|
+
flex: none;
|
|
73
|
+
display: inline-flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
width: 36px;
|
|
77
|
+
height: 36px;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
border-radius: var(--ui-radius-control);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.mh-card__header-icon-img {
|
|
83
|
+
display: block;
|
|
84
|
+
width: 100%;
|
|
85
|
+
height: 100%;
|
|
86
|
+
object-fit: cover;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* 文字块:标题在上、副标题在下(两行都单行省略) */
|
|
90
|
+
|
|
91
|
+
.mh-card__header-text {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
gap: var(--ui-space-1);
|
|
95
|
+
min-width: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.mh-card__header-title {
|
|
99
|
+
min-width: 0;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
text-overflow: ellipsis;
|
|
102
|
+
white-space: nowrap;
|
|
103
|
+
font-size: var(--ui-font-heading);
|
|
104
|
+
line-height: var(--ui-line-heading);
|
|
105
|
+
font-weight: var(--ui-weight-medium);
|
|
106
|
+
color: var(--ui-base-content);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.mh-card__header-subtitle {
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
text-overflow: ellipsis;
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
font-size: var(--ui-font-caption);
|
|
114
|
+
line-height: var(--ui-line-caption);
|
|
115
|
+
color: var(--ui-base-content-muted);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* 右端:状态胶囊 / 行内按钮 / 统计(不抢左侧宽度) */
|
|
119
|
+
|
|
120
|
+
.mh-card__header-extra {
|
|
121
|
+
flex: none;
|
|
122
|
+
font-size: var(--ui-font-caption);
|
|
123
|
+
color: var(--ui-base-content-muted);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.mh-card__body {
|
|
127
|
+
display: flex;
|
|
128
|
+
flex: 1;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
/* 卡内纵向间距 16(原型 gap-4):内容段落的节奏原来由根件的 gap 给,内距下放到段后归这里 */
|
|
131
|
+
gap: var(--ui-space-4);
|
|
132
|
+
min-width: 0;
|
|
133
|
+
min-height: 0;
|
|
134
|
+
padding-block-start: var(--mh-card-padding);
|
|
135
|
+
padding-inline: var(--mh-card-padding);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* 尾部贴卡片底部:卡片被拉伸(网格等高 / min-height)时尾部不悬空 */
|
|
139
|
+
|
|
140
|
+
.mh-card__footer {
|
|
141
|
+
display: flex;
|
|
142
|
+
flex: none;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
gap: var(--ui-space-2);
|
|
145
|
+
min-width: 0;
|
|
146
|
+
margin-top: auto;
|
|
147
|
+
padding-block-start: var(--mh-card-padding);
|
|
148
|
+
padding-inline: var(--mh-card-padding);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* 卡片下沿:纵向只吃上边(见上),底边由**最后一段**补,否则内容贴卡片边 */
|
|
152
|
+
|
|
153
|
+
.mh-card > .mh-card__header:last-child,
|
|
154
|
+
.mh-card > .mh-card__body:last-child,
|
|
155
|
+
.mh-card > .mh-card__footer:last-child,
|
|
156
|
+
.mh-card > .mh-card__actions:last-child {
|
|
157
|
+
padding-block-end: var(--mh-card-padding);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.mh-card--plain {
|
|
161
|
+
border-color: transparent;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.mh-card--interactive {
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.mh-card--interactive:hover {
|
|
169
|
+
border-color: var(--ui-primary);
|
|
170
|
+
box-shadow: var(--ui-shadow-card-hover);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.mh-card--selected {
|
|
174
|
+
border-color: var(--ui-primary);
|
|
175
|
+
background: var(--ui-primary-subtle);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.mh-card--disabled {
|
|
179
|
+
cursor: not-allowed;
|
|
180
|
+
opacity: 0.5;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* ===== 底部操作行(与段同族,头部那一类的规则见上)=====
|
|
184
|
+
* 内距与段同口径:各吃一份段内距,`margin-top: auto` 贴卡片底部。 */
|
|
185
|
+
.mh-card__actions {
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
gap: var(--ui-space-2);
|
|
189
|
+
margin-top: auto;
|
|
190
|
+
padding-block-start: var(--mh-card-padding);
|
|
191
|
+
padding-inline: var(--mh-card-padding);
|
|
192
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox —— 复选框(真实 input 负责可访问性,方块自绘,状态走 data-state 协议)。
|
|
3
|
+
*
|
|
4
|
+
* 几何取自设计稿《MH后台-0911》`控件` 画布的三枚原子件(逐个实测):
|
|
5
|
+
* - `表单/checkbox/0`(`0:4101`):14×14 / 白底 / 边 `#dcdcdc` / **r3**;
|
|
6
|
+
* - `表单/checkbox/1`(`0:4098`):14×14 / `#2660ff` 实底 / 白勾;
|
|
7
|
+
* - `表单/checkbox/0.5`(`0:4095`):14×14 / `#2660ff` 实底 / 白横杠(半选)。
|
|
8
|
+
*
|
|
9
|
+
* **标准档是 14**(改前为 16 —— 设计稿那枚 14 正好是本包原来的 `sm` 档,档位整体挪了一格)。
|
|
10
|
+
* 勾图标 **10px**:白勾在设计里占 8×6,其对角线 ≈ 10,恰好是 14 框体内的视觉满宽。
|
|
11
|
+
*
|
|
12
|
+
* **框体圆角走主题的 `--ui-radius-xs`(3px)**,不再是本件写死的字面量 ——
|
|
13
|
+
* 改前这里硬编码 4px,把 `farris` 主题声明的 3px 彻底挡住(该主题注释还写着「复选框框体 3px ✓」,
|
|
14
|
+
* 实际从未生效)。框体边取 `--ui-base-400`:设计让勾选框比容器线深一档(`#dcdcdc` vs `#e6e6e6`),
|
|
15
|
+
* 否则 14px 的小方块在浅底上看不见。
|
|
16
|
+
*
|
|
17
|
+
* 档位只覆盖令牌、不复制规则体(与 `Switch` 同一口径)。
|
|
18
|
+
* 勾 / 横杠一律由内容承载,框体只管底与边:勾取 `@manohub/icon` 的 `check` 字形,
|
|
19
|
+
* 半选取一条横杠;**未选态靠框体的 `color: transparent` 让 currentColor 图标隐形** ——
|
|
20
|
+
* 不需要 `::after` 描画,也不需要为三态各备一套 DOM。
|
|
21
|
+
*/
|
|
22
|
+
.mh-checkbox {
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: var(--ui-checkbox-label-gap);
|
|
26
|
+
font-size: var(--ui-font-body);
|
|
27
|
+
line-height: var(--ui-line-body);
|
|
28
|
+
color: var(--ui-base-content);
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
user-select: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.mh-checkbox__input {
|
|
34
|
+
position: absolute;
|
|
35
|
+
width: 1px;
|
|
36
|
+
height: 1px;
|
|
37
|
+
margin: -1px;
|
|
38
|
+
padding: 0;
|
|
39
|
+
border: 0;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
clip-path: inset(50%);
|
|
43
|
+
appearance: none;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.mh-checkbox__box {
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
flex: none;
|
|
52
|
+
width: var(--ui-checkbox-size);
|
|
53
|
+
height: var(--ui-checkbox-size);
|
|
54
|
+
border: 1px solid var(--ui-base-400);
|
|
55
|
+
border-radius: var(--ui-checkbox-radius);
|
|
56
|
+
background: var(--ui-base-100);
|
|
57
|
+
/* 未选:字色透明 → currentColor 的勾与横杠自然隐形(同一份 DOM 覆盖三态) */
|
|
58
|
+
color: transparent;
|
|
59
|
+
transition-property: background-color, border-color, color, box-shadow;
|
|
60
|
+
transition-duration: 0.15s;
|
|
61
|
+
transition-timing-function: ease;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.mh-checkbox__icon {
|
|
65
|
+
flex: none;
|
|
66
|
+
width: var(--ui-checkbox-icon-size);
|
|
67
|
+
height: var(--ui-checkbox-icon-size);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ===== 尺寸档(只覆盖令牌) ===== */
|
|
71
|
+
.mh-checkbox--sm {
|
|
72
|
+
--ui-checkbox-size: var(--ui-checkbox-size-sm);
|
|
73
|
+
--ui-checkbox-icon-size: var(--ui-checkbox-icon-size-sm);
|
|
74
|
+
font-size: var(--ui-font-caption);
|
|
75
|
+
}
|
|
76
|
+
.mh-checkbox--lg {
|
|
77
|
+
--ui-checkbox-size: var(--ui-checkbox-size-lg);
|
|
78
|
+
--ui-checkbox-icon-size: var(--ui-checkbox-icon-size-lg);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
* 选中 / 半选:填充**主色**,勾与横杠用 currentColor 绘制。
|
|
83
|
+
*
|
|
84
|
+
* 全库"选中"只有主色一种表达 —— 一屏里会出现「蓝色开关 + 蓝色表格勾选列(复用本件)
|
|
85
|
+
* + 蓝色勾选框」同一种叫法;`@aihub/theme` 的 checkbox 口径也是「已选择背景取主色」。
|
|
86
|
+
* 要再引入中性面填充,做成 `tone` 的第二档(如 `tone="neutral"`),**不要**把默认改回深色。
|
|
87
|
+
*/
|
|
88
|
+
.mh-checkbox__box[data-state='checked'],
|
|
89
|
+
.mh-checkbox__box[data-state='indeterminate'] {
|
|
90
|
+
background: var(--ui-primary);
|
|
91
|
+
border-color: var(--ui-primary);
|
|
92
|
+
color: var(--ui-primary-content);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.mh-checkbox__dash {
|
|
96
|
+
width: 8px;
|
|
97
|
+
height: 2px;
|
|
98
|
+
border-radius: 1px;
|
|
99
|
+
background: currentColor;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* 滑过:未选才补边色(选中态已经有满色底,再变色只会闪) */
|
|
103
|
+
.mh-checkbox:hover .mh-checkbox__box {
|
|
104
|
+
border-color: var(--ui-primary);
|
|
105
|
+
}
|
|
106
|
+
.mh-checkbox__box[data-state='checked'],
|
|
107
|
+
.mh-checkbox__box[data-state='indeterminate'] {
|
|
108
|
+
border-color: var(--ui-primary);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* 键盘焦点环画在可见框体上(隐身开关没有可见焦点)。
|
|
112
|
+
必须是 `:focus-visible`(与 `.mh-radio` / `.mh-switch` 的轨道同一写法):用 `:focus-within` 的话
|
|
113
|
+
鼠标点一下也会亮 —— 在表格勾选列里就表现为「框体 1px 边框 + 外面再一圈」,看着像两层 border。 */
|
|
114
|
+
.mh-checkbox > .mh-checkbox__input:focus-visible + .mh-checkbox__box {
|
|
115
|
+
outline: 2px solid var(--ui-primary-weak);
|
|
116
|
+
outline-offset: 2px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.mh-checkbox.is-disabled {
|
|
120
|
+
cursor: not-allowed;
|
|
121
|
+
color: var(--ui-base-content-subtle);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.mh-checkbox.is-disabled .mh-checkbox__box {
|
|
125
|
+
background: var(--ui-base-200);
|
|
126
|
+
border-color: var(--ui-base-300);
|
|
127
|
+
color: var(--ui-base-content-subtle);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.mh-checkbox.is-disabled:hover .mh-checkbox__box {
|
|
131
|
+
border-color: var(--ui-base-300);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* ===== 多选组(表驱动;横向缺省换行,vertical 走纵向) ===== */
|
|
135
|
+
.mh-checkbox__group {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-wrap: wrap;
|
|
138
|
+
gap: var(--ui-space-2) var(--ui-space-4);
|
|
139
|
+
align-items: center;
|
|
140
|
+
}
|
|
141
|
+
.mh-checkbox__group--vertical {
|
|
142
|
+
flex-direction: column;
|
|
143
|
+
align-items: flex-start;
|
|
144
|
+
gap: var(--ui-space-2);
|
|
145
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* checkbox —— 单件令牌(**基础值**)。
|
|
3
|
+
*
|
|
4
|
+
* 本件自己的几何 / 尺寸 / 色彩槽位;只服务本件,故不随主题进 `@manohub/theme`。
|
|
5
|
+
*
|
|
6
|
+
* ## 抽出说明
|
|
7
|
+
* 本文件从面文件里抽出(原先混写在 `checkbox.css` 顶部):这些是**基础值**,锚在
|
|
8
|
+
* `[data-manohub-ui]` —— 跨包唯一作用域锚,由入口层无条件写在应用容器上,因此**任何落在
|
|
9
|
+
* 容器里的分件都取得到值**,不再依赖「声明在某个组件根类上」这条脆弱假设
|
|
10
|
+
* (历史症状:跨件消费的 `--ui-*-group-*` 取不到值,组内间距变 0)。
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ `.mh-<件>--<档>` 这类**档位改写**留在面文件的修饰符块里 —— 它们靠「同一元素上两个
|
|
13
|
+
* 选择器改写同一个令牌」生效,搬到本文件会让档位失效。
|
|
14
|
+
* ⚠️ 新增组件要登记两处:本文件 + `src/styles/index.css`(见其文件头「五处齐备」)。
|
|
15
|
+
*/
|
|
16
|
+
[data-manohub-ui] {
|
|
17
|
+
/* 单件令牌(标准档 14 / 小 12 / 大 20;圆角取主题的 xs 档) */
|
|
18
|
+
--ui-checkbox-size: 14px;
|
|
19
|
+
--ui-checkbox-size-sm: 12px;
|
|
20
|
+
--ui-checkbox-size-lg: 20px;
|
|
21
|
+
--ui-checkbox-icon-size: 10px;
|
|
22
|
+
--ui-checkbox-icon-size-sm: 8px;
|
|
23
|
+
--ui-checkbox-icon-size-lg: 14px;
|
|
24
|
+
--ui-checkbox-radius: var(--ui-radius-xs);
|
|
25
|
+
--ui-checkbox-label-gap: var(--ui-space-2);
|
|
26
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CodeEditor —— 可编辑代码区(等宽多行 + 按行自适应 + 可限高内滚 + 只读/禁用态)。
|
|
3
|
+
*
|
|
4
|
+
* 与 `Code`(只读展示)**视觉同源**:同一份底(`--ui-base-200`)、同一个圆角档(`--ui-radius-control`)、
|
|
5
|
+
* 同一族等宽字与字号(`--ui-font-mono` / `--ui-font-caption`)—— 两件互切时块体不"跳"。
|
|
6
|
+
*
|
|
7
|
+
* 两处**有意**的差别(改之前先读):
|
|
8
|
+
*
|
|
9
|
+
* 1. 本件**画框的是容器**(`.mh-code-editor`),内部 `textarea` 透明、无边框、无 outline ——
|
|
10
|
+
* 原生 `textarea` 的框模型(内距 / 滚动条 / 聚焦轮廓)会把框画歪,收归容器才能与只读块对齐;
|
|
11
|
+
* 2. 代码块缺省**横向滚动**,本件是**软换行**(`textarea` 的原生行为):编辑态不折行会让长行看不见尾巴。
|
|
12
|
+
*
|
|
13
|
+
* 状态一律走**原生属性**(`[readonly]` / `:disabled` / `:focus-within`),组件不下发 `data-*`:
|
|
14
|
+
* 只读与禁用本就有原生表达,多一套协议就多一处会漂的真相。
|
|
15
|
+
*
|
|
16
|
+
* ⚠️ 令牌**不复用** `code.css` 的 `--ui-code-*`:那些只服务 `Code` 单件,跨件复用按硬约束要迁进
|
|
17
|
+
* `theme/`(跨件共用令牌单一来源)。本件只有几何,色 / 圆角 / 字族一律直接取 theme 令牌。
|
|
18
|
+
*/
|
|
19
|
+
.mh-code-editor {
|
|
20
|
+
|
|
21
|
+
position: relative;
|
|
22
|
+
display: block;
|
|
23
|
+
border-radius: var(--ui-code-editor-radius);
|
|
24
|
+
background: var(--ui-base-200); /* 与只读块同底 */
|
|
25
|
+
font-family: var(--ui-font-mono);
|
|
26
|
+
font-size: var(--ui-code-editor-font-size);
|
|
27
|
+
line-height: var(--ui-code-editor-line);
|
|
28
|
+
color: var(--ui-base-content);
|
|
29
|
+
transition: box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
|
|
30
|
+
}
|
|
31
|
+
/* 聚焦环:与输入框族同一句(主色弱底当环,不新造阴影令牌) */
|
|
32
|
+
.mh-code-editor:focus-within {
|
|
33
|
+
box-shadow: 0 0 0 2px var(--ui-primary-weak);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* 编辑区:透明底 + 无框 + 无 outline(框与聚焦环都画在容器上) */
|
|
37
|
+
.mh-code-editor__area {
|
|
38
|
+
display: block;
|
|
39
|
+
width: 100%;
|
|
40
|
+
margin: 0;
|
|
41
|
+
padding: var(--ui-code-editor-padding-y) var(--ui-code-editor-padding-x);
|
|
42
|
+
border: 0;
|
|
43
|
+
border-radius: inherit;
|
|
44
|
+
background: transparent;
|
|
45
|
+
font: inherit;
|
|
46
|
+
line-height: inherit;
|
|
47
|
+
color: inherit;
|
|
48
|
+
outline: none;
|
|
49
|
+
resize: none; /* 高度由 autoSize / maxHeight 决定,不留拖拽把手(同只读块:不被用户拖变形) */
|
|
50
|
+
overflow: auto;
|
|
51
|
+
tab-size: 2;
|
|
52
|
+
}
|
|
53
|
+
.mh-code-editor__area::placeholder {
|
|
54
|
+
color: var(--ui-base-content-subtle);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* 语言角标(可选):与只读块的角标同槽位。本件**不叠在文字上**(编辑区内容会折行,压住就看不见了),
|
|
58
|
+
而是让首行右端**预留**出它的宽度 —— 预留只影响折行位置,短行看不见任何变化 */
|
|
59
|
+
.mh-code-editor__lang {
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: var(--ui-code-editor-padding-y);
|
|
62
|
+
right: var(--ui-code-editor-padding-x);
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
height: var(--ui-code-editor-line);
|
|
66
|
+
font-family: var(--ui-font-mono);
|
|
67
|
+
font-size: var(--ui-code-editor-font-size);
|
|
68
|
+
line-height: 1;
|
|
69
|
+
color: var(--ui-base-content-subtle);
|
|
70
|
+
user-select: none;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
}
|
|
73
|
+
.mh-code-editor:has(> .mh-code-editor__lang) > .mh-code-editor__area {
|
|
74
|
+
padding-right: calc(var(--ui-code-editor-padding-x) + var(--ui-code-editor-lang-reserve));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* 只读态(原生 `readonly`:仍可选中、可滚动、可复制,只是不可改)——不弱化字色,
|
|
78
|
+
代码是拿来读的;与只读块观感一致 */
|
|
79
|
+
.mh-code-editor:has(> .mh-code-editor__area[readonly]) {
|
|
80
|
+
cursor: default;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* 禁用态:底与字色弱化 + 内描边(本件没有外描边,靠内描边表达"锁住") */
|
|
84
|
+
.mh-code-editor:has(> .mh-code-editor__area:disabled) {
|
|
85
|
+
background: var(--ui-base-100);
|
|
86
|
+
color: var(--ui-base-content-subtle);
|
|
87
|
+
box-shadow: inset 0 0 0 1px var(--ui-base-300);
|
|
88
|
+
}
|
|
89
|
+
.mh-code-editor:has(> .mh-code-editor__area:disabled) > .mh-code-editor__area {
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* code-editor —— 单件令牌(**基础值**)。
|
|
3
|
+
*
|
|
4
|
+
* 本件自己的几何 / 尺寸 / 色彩槽位;只服务本件,故不随主题进 `@manohub/theme`。
|
|
5
|
+
*
|
|
6
|
+
* ## 抽出说明
|
|
7
|
+
* 本文件从面文件里抽出(原先混写在 `code-editor.css` 顶部):这些是**基础值**,锚在
|
|
8
|
+
* `[data-manohub-ui]` —— 跨包唯一作用域锚,由入口层无条件写在应用容器上,因此**任何落在
|
|
9
|
+
* 容器里的分件都取得到值**,不再依赖「声明在某个组件根类上」这条脆弱假设
|
|
10
|
+
* (历史症状:跨件消费的 `--ui-*-group-*` 取不到值,组内间距变 0)。
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ `.mh-<件>--<档>` 这类**档位改写**留在面文件的修饰符块里 —— 它们靠「同一元素上两个
|
|
13
|
+
* 选择器改写同一个令牌」生效,搬到本文件会让档位失效。
|
|
14
|
+
* ⚠️ 新增组件要登记两处:本文件 + `src/styles/index.css`(见其文件头「五处齐备」)。
|
|
15
|
+
*/
|
|
16
|
+
[data-manohub-ui] {
|
|
17
|
+
/* 单件令牌(只服务本件:几何) */
|
|
18
|
+
--ui-code-editor-radius: var(--ui-radius-control); /* 6:与只读块同档(原注释写 8,是旧稿残留) */
|
|
19
|
+
--ui-code-editor-padding-x: var(--ui-space-3); /* 12 */
|
|
20
|
+
--ui-code-editor-padding-y: var(--ui-space-2); /* 8 */
|
|
21
|
+
--ui-code-editor-font-size: var(--ui-font-caption); /* 13:与只读块同档 */
|
|
22
|
+
--ui-code-editor-line: var(--ui-line-caption); /* 20:行高(角标也吃它) */
|
|
23
|
+
--ui-code-editor-lang-reserve: 56px; /* 角标位:首行右端预留宽度(只影响折行位置) */
|
|
24
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code —— 代码(行内 chip + 代码块 + 语言角标 + 复制位)。
|
|
3
|
+
*
|
|
4
|
+
* 观感基准:**无边框浅底块 + 方圆角 + 右上角语言角标 + 悬浮/聚焦让位后出现的方形图标复制按钮**。
|
|
5
|
+
* 出处:`@aihub/theme` 的 `playground/components/code.css` 与 `src/components/code.css`
|
|
6
|
+
* (行内 chip 主色字 + 浅底、圆角全;`--plain` 档中性底 + 小圆角;代码块 = 页面底 + 等宽字 + 内距 12)。
|
|
7
|
+
*
|
|
8
|
+
* 三件结构决定(照规范的分工,不另创):
|
|
9
|
+
*
|
|
10
|
+
* - **复制按钮的面仍归按钮族**(`.mh-button--icon`),本族只补「浮在代码块上需要自己的底与定位」;
|
|
11
|
+
* 故标记是 `class="mh-button mh-button--icon mh-code__copy"`。
|
|
12
|
+
* - **复制按钮与语言角标都不能放进代码块里**:代码块是 `overflow-x: auto` 的滚动容器,
|
|
13
|
+
* 会裁掉外挂的绝对定位件 —— 故两者都挂在宿主 `.mh-code__wrap` 上(宿主只做 `position: relative`)。
|
|
14
|
+
* - **隐藏用 `opacity` + `pointer-events`**(不是 `visibility` / `display`):键盘仍能 Tab 到它,
|
|
15
|
+
* `:focus-within` 会把它显出来,且隐藏时不残留一块看不见的可点区。
|
|
16
|
+
*
|
|
17
|
+
* **本族与按钮族的层序**(改这几条规则前先读):`styles/index.css` 里 `code.css` 在 `button.css`
|
|
18
|
+
* **之前**导入,故 `background` / `color` / `box-shadow` 这些**同特异性的声明会被按钮族的档位规则压掉**
|
|
19
|
+
* (历史 bug:`.mh-code__copy` 的白底被 `.mh-button--text { background: transparent }` 压成透明,
|
|
20
|
+
* 复制位看起来像一段悬空文字)。修法不是调层序,而是让本族的声明**升一档特异性**
|
|
21
|
+
* (`.mh-code__wrap > .mh-code__copy`,悬停 / 成功态再各叠一层)—— 按钮族日后换皮肤也压不掉它。
|
|
22
|
+
*
|
|
23
|
+
* 零 JS 可表达:全部皮肤 + 角标让位 + 复制位的显隐。**真正的复制动作归组件层**(要 `navigator.clipboard`)。
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/* 几何只挂在行内 chip 上:令牌在同名 `.tokens.css`(锚 `[data-manohub-ui]`),几何若跟着挂会把壳与块级元素也画成 chip */
|
|
27
|
+
.mh-code {
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
padding: 1px var(--ui-space-3);
|
|
31
|
+
border-radius: var(--ui-radius-full);
|
|
32
|
+
background: var(--ui-code-chip-bg);
|
|
33
|
+
color: var(--ui-primary);
|
|
34
|
+
font-family: var(--ui-font-mono);
|
|
35
|
+
font-size: var(--ui-code-font-size);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* 中性档(规范 `.chip--plain`:规则 ID 这类不强调的短标识) */
|
|
39
|
+
.mh-code--plain {
|
|
40
|
+
background: var(--ui-code-block-bg);
|
|
41
|
+
color: var(--ui-base-content);
|
|
42
|
+
border-radius: var(--ui-code-radius);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* 代码块:无边框浅底 + 方圆角;**缺省不折行**(保持 `pre` 的横向滚动,缩进与列对齐不被破坏),
|
|
46
|
+
`--wrap` 档才软换行 */
|
|
47
|
+
.mh-code--block {
|
|
48
|
+
display: block;
|
|
49
|
+
margin: var(--ui-space-2) 0 0;
|
|
50
|
+
padding: var(--ui-code-block-padding);
|
|
51
|
+
border: 0;
|
|
52
|
+
border-radius: var(--ui-code-radius);
|
|
53
|
+
background: var(--ui-code-block-bg);
|
|
54
|
+
font-family: var(--ui-font-mono);
|
|
55
|
+
font-size: var(--ui-code-font-size);
|
|
56
|
+
line-height: var(--ui-code-line);
|
|
57
|
+
color: var(--ui-base-content);
|
|
58
|
+
overflow-x: auto;
|
|
59
|
+
white-space: pre;
|
|
60
|
+
overflow-wrap: normal;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* 宿主:给复制位与语言角标一个不受裁切的定位上下文;同时把「缺省不折行」的代价收在块内 ——
|
|
64
|
+
`min-width: 0` 让它在 flex / grid 里能被压到容器宽度(否则长行的 min-content 会把轨道撑宽、
|
|
65
|
+
页面跟着横向溢出),长行改为块内横向滚动。 */
|
|
66
|
+
.mh-code__wrap {
|
|
67
|
+
position: relative;
|
|
68
|
+
min-width: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* 语言角标(可选):与复制位**同槽位**,悬浮/聚焦时淡出让位(零 JS 互斥)。
|
|
72
|
+
装饰位:不吃指针事件,否则它会挡住复制位的悬停热区 */
|
|
73
|
+
.mh-code__lang {
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: var(--ui-code-copy-inset);
|
|
76
|
+
right: var(--ui-code-copy-inset);
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
height: var(--ui-code-copy-size); /* 与复制位等高:让位互换时基线不跳 */
|
|
80
|
+
font-family: var(--ui-font-mono);
|
|
81
|
+
font-size: var(--ui-code-font-size);
|
|
82
|
+
line-height: 1;
|
|
83
|
+
color: var(--ui-base-content-subtle);
|
|
84
|
+
user-select: none;
|
|
85
|
+
pointer-events: none;
|
|
86
|
+
transition: opacity 0.15s ease;
|
|
87
|
+
}
|
|
88
|
+
.mh-code__wrap:hover > .mh-code__lang,
|
|
89
|
+
.mh-code__wrap:focus-within > .mh-code__lang,
|
|
90
|
+
.mh-code__wrap.is-hover > .mh-code__lang {
|
|
91
|
+
opacity: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* 复制位(面归按钮族,这里只给定位、浮底、方形几何、显隐)。
|
|
95
|
+
选择器**刻意升一档**(`.mh-code__wrap >`):同特异性下按钮族的档位规则会压掉这几条(见文件头) */
|
|
96
|
+
.mh-code__wrap > .mh-code__copy {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: var(--ui-code-copy-inset);
|
|
99
|
+
right: var(--ui-code-copy-inset);
|
|
100
|
+
width: var(--ui-code-copy-size);
|
|
101
|
+
height: var(--ui-code-copy-size);
|
|
102
|
+
padding: 0;
|
|
103
|
+
border: 1px solid var(--ui-code-block-line);
|
|
104
|
+
border-radius: var(--ui-radius-sm);
|
|
105
|
+
background: var(--ui-base-100);
|
|
106
|
+
color: var(--ui-base-content);
|
|
107
|
+
box-shadow: none; /* 压掉图标按钮 hover 档的卡片光晕(本件浮在块上,再加影会脏) */
|
|
108
|
+
opacity: 0;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
|
|
111
|
+
}
|
|
112
|
+
/* 显形:宿主悬停 / 键盘聚焦进入(`.is-hover` 是**静态档**,供静态页与读图对状态,与全库同款三源等价) */
|
|
113
|
+
.mh-code__wrap:hover > .mh-code__copy,
|
|
114
|
+
.mh-code__wrap:focus-within > .mh-code__copy,
|
|
115
|
+
.mh-code__wrap.is-hover > .mh-code__copy {
|
|
116
|
+
opacity: 1;
|
|
117
|
+
pointer-events: auto;
|
|
118
|
+
}
|
|
119
|
+
/* 悬停 / 键盘聚焦的加深档(再叠一层,压过 `.mh-button--icon:hover` 的字色与光晕) */
|
|
120
|
+
.mh-code__wrap > .mh-code__copy:hover,
|
|
121
|
+
.mh-code__wrap > .mh-code__copy:focus-visible,
|
|
122
|
+
.mh-code__wrap.is-hover > .mh-code__copy {
|
|
123
|
+
border-color: var(--ui-base-content-subtle);
|
|
124
|
+
color: var(--ui-primary);
|
|
125
|
+
box-shadow: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* 复制成功态(组件下发 `data-state`;原生无此态,静态档 `.is-copied` 供读图) */
|
|
129
|
+
.mh-code__wrap > .mh-code__copy.is-copied,
|
|
130
|
+
.mh-code__wrap > .mh-code__copy[data-state='copied'] {
|
|
131
|
+
border-color: var(--ui-success);
|
|
132
|
+
color: var(--ui-success);
|
|
133
|
+
opacity: 1;
|
|
134
|
+
pointer-events: auto;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* 无悬停能力的设备(触屏):复制位常显;角标让位(`display: none` 而非透明 —— 它只是装饰,
|
|
138
|
+
不占焦点序列,隐藏掉才不会与常显的复制位叠在一起) */
|
|
139
|
+
@media (hover: none) {
|
|
140
|
+
.mh-code__wrap > .mh-code__copy {
|
|
141
|
+
opacity: 1;
|
|
142
|
+
pointer-events: auto;
|
|
143
|
+
}
|
|
144
|
+
.mh-code__lang {
|
|
145
|
+
display: none;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* ===== 软换行档(缺省保持 `pre` 的横向不换行 + 横向滚动) ===== */
|
|
150
|
+
.mh-code--wrap {
|
|
151
|
+
white-space: pre-wrap;
|
|
152
|
+
overflow-wrap: anywhere;
|
|
153
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* code —— 单件令牌(**基础值**)。
|
|
3
|
+
*
|
|
4
|
+
* 本件自己的几何 / 尺寸 / 色彩槽位;只服务本件,故不随主题进 `@manohub/theme`。
|
|
5
|
+
*
|
|
6
|
+
* ## 抽出说明
|
|
7
|
+
* 本文件从面文件里抽出(原先混写在 `code.css` 顶部):这些是**基础值**,锚在
|
|
8
|
+
* `[data-manohub-ui]` —— 跨包唯一作用域锚,由入口层无条件写在应用容器上,因此**任何落在
|
|
9
|
+
* 容器里的分件都取得到值**,不再依赖「声明在某个组件根类上」这条脆弱假设
|
|
10
|
+
* (历史症状:跨件消费的 `--ui-*-group-*` 取不到值,组内间距变 0)。
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ `.mh-<件>--<档>` 这类**档位改写**留在面文件的修饰符块里 —— 它们靠「同一元素上两个
|
|
13
|
+
* 选择器改写同一个令牌」生效,搬到本文件会让档位失效。
|
|
14
|
+
* ⚠️ 新增组件要登记两处:本文件 + `src/styles/index.css`(见其文件头「五处齐备」)。
|
|
15
|
+
*/
|
|
16
|
+
[data-manohub-ui] {
|
|
17
|
+
/* 单件令牌(也挂到外层容器与块级元素上:块级 `<pre>` 是 `.mh-code__wrap` 的子元素、
|
|
18
|
+
并不带 `.mh-code`(行内 chip)类,只在 `.mh-code` 上声明会让块级与复制位全部取不到值) */
|
|
19
|
+
--ui-code-chip-bg: var(--ui-primary-weak); /* 规范 Au02 行内底 */
|
|
20
|
+
--ui-code-block-bg: var(--ui-base-200); /* 规范代码块底(页面底 Ne11) */
|
|
21
|
+
--ui-code-block-line: var(--ui-base-300); /* 描边色:块自身已去边框,本令牌现服务复制位按钮 */
|
|
22
|
+
--ui-code-radius: var(--ui-radius-control);
|
|
23
|
+
--ui-code-font-size: var(--ui-font-caption); /* 规范等宽字号档对位 */
|
|
24
|
+
--ui-code-line: var(--ui-line-caption); /* 等宽行高:角标与复制位的行高同源 */
|
|
25
|
+
--ui-code-block-padding: var(--ui-space-3); /* 12:代码块内距 */
|
|
26
|
+
--ui-code-copy-size: var(--ui-control-height-md); /* 32:复制位方形热区(与按钮族标准档同高) */
|
|
27
|
+
/* 复制位是 `Button`(`mh-button__icon`):字形尺寸归按钮族的图标槽(常规图标档),本件不另设令牌 */
|
|
28
|
+
--ui-code-copy-inset: var(--ui-space-2); /* 8:复制位 / 角标距块边 */
|
|
29
|
+
}
|