@seanyeh77/ui 0.17.0 → 0.19.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/dist/bundle.js +13 -3
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-Bxd5-D9B.js → format-entry-madGv9m_.js} +2 -1
- package/dist/format-entry-madGv9m_.js.map +1 -0
- package/dist/format.js +1 -1
- package/dist/index.d.ts +93 -3
- package/dist/index.js +854 -65
- package/dist/index.js.map +1 -1
- package/dist/styles.css +413 -1
- package/docs/CodeView.md +2 -2
- package/docs/DetailList.md +6 -0
- package/docs/LayerGraph.md +1 -0
- package/docs/Markdown.md +121 -0
- package/docs/Section.md +42 -0
- package/docs/guidelines.md +3 -1
- package/docs/motion.md +1 -0
- package/package.json +2 -2
- package/dist/format-entry-Bxd5-D9B.js.map +0 -1
package/dist/styles.css
CHANGED
|
@@ -4902,6 +4902,48 @@ html.ui-theme-fade * {
|
|
|
4902
4902
|
color: var(--ink-muted);
|
|
4903
4903
|
white-space: nowrap;
|
|
4904
4904
|
}
|
|
4905
|
+
/* No line numbers: the code starts 16 px in, like the header text. */
|
|
4906
|
+
.ui-cv.no-nums .ui-cv-text {
|
|
4907
|
+
margin-left: var(--space-4);
|
|
4908
|
+
padding-right: var(--space-4);
|
|
4909
|
+
}
|
|
4910
|
+
/* KB: a Markdown code block has a low header (32 px) with no rule under it. */
|
|
4911
|
+
.ui-md-code .ui-cv-head {
|
|
4912
|
+
min-height: 32px;
|
|
4913
|
+
padding-left: var(--space-4);
|
|
4914
|
+
border-bottom: 0;
|
|
4915
|
+
}
|
|
4916
|
+
.ui-md-code .ui-cv-body {
|
|
4917
|
+
padding: 2px 0 10px;
|
|
4918
|
+
}
|
|
4919
|
+
/* A small copy icon at the right of the header, as in Suggestion; 48 px on phones. */
|
|
4920
|
+
.ui-cv-copy {
|
|
4921
|
+
flex: 0 0 auto;
|
|
4922
|
+
width: 32px;
|
|
4923
|
+
height: 32px;
|
|
4924
|
+
margin-right: calc(-1 * var(--space-1));
|
|
4925
|
+
border-color: transparent;
|
|
4926
|
+
}
|
|
4927
|
+
.ui-cv-lang + .ui-cv-copy {
|
|
4928
|
+
margin-left: 0;
|
|
4929
|
+
}
|
|
4930
|
+
.ui-cv-copy:first-child,
|
|
4931
|
+
.ui-cv-file + .ui-cv-copy,
|
|
4932
|
+
.ui-cv-title + .ui-cv-copy {
|
|
4933
|
+
margin-left: auto;
|
|
4934
|
+
}
|
|
4935
|
+
.ui-cv-copy:hover {
|
|
4936
|
+
background: var(--surface);
|
|
4937
|
+
}
|
|
4938
|
+
.ui-cv-copy.is-copied {
|
|
4939
|
+
color: var(--success-text);
|
|
4940
|
+
}
|
|
4941
|
+
@media (max-width: 599px) {
|
|
4942
|
+
.ui-cv-copy {
|
|
4943
|
+
width: var(--touch-target);
|
|
4944
|
+
height: var(--touch-target);
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4905
4947
|
.ui-cv-body {
|
|
4906
4948
|
margin: 0;
|
|
4907
4949
|
padding: 6px 0;
|
|
@@ -4933,7 +4975,8 @@ html.ui-theme-fade * {
|
|
|
4933
4975
|
.ui-cv-num {
|
|
4934
4976
|
flex: 0 0 auto;
|
|
4935
4977
|
box-sizing: border-box;
|
|
4936
|
-
|
|
4978
|
+
/* VA: off the left edge, and clear of the code. */
|
|
4979
|
+
padding: 0 var(--space-4) 0 var(--space-3);
|
|
4937
4980
|
text-align: right;
|
|
4938
4981
|
color: var(--ink-muted);
|
|
4939
4982
|
font-variant-numeric: tabular-nums;
|
|
@@ -5180,8 +5223,16 @@ html.ui-theme-fade * {
|
|
|
5180
5223
|
margin-bottom: var(--space-3);
|
|
5181
5224
|
}
|
|
5182
5225
|
.ui-lg-bar {
|
|
5226
|
+
align-items: center;
|
|
5227
|
+
flex-wrap: wrap;
|
|
5228
|
+
gap: var(--space-2);
|
|
5229
|
+
}
|
|
5230
|
+
/* The page's own controls at the left of the row, 「圖/清單」 at the right. */
|
|
5231
|
+
.ui-lg-toolbar {
|
|
5232
|
+
display: flex;
|
|
5183
5233
|
align-items: center;
|
|
5184
5234
|
gap: var(--space-2);
|
|
5235
|
+
margin-right: auto;
|
|
5185
5236
|
}
|
|
5186
5237
|
/* The line-label switch and its text, beside 「圖/清單」: the whole row is the 48 px target. */
|
|
5187
5238
|
.ui-lg-labels-switch {
|
|
@@ -6054,3 +6105,364 @@ html.ui-theme-fade * {
|
|
|
6054
6105
|
border-radius: var(--radius-sm);
|
|
6055
6106
|
box-shadow: 0 0 0 3px var(--focus-ring);
|
|
6056
6107
|
}
|
|
6108
|
+
|
|
6109
|
+
/* Section: a part of a page that closes to its title and a one-line summary (SLR4LANG). */
|
|
6110
|
+
.ui-sec + .ui-sec {
|
|
6111
|
+
border-top: 1px solid var(--line);
|
|
6112
|
+
}
|
|
6113
|
+
.ui-sec {
|
|
6114
|
+
container-type: inline-size;
|
|
6115
|
+
}
|
|
6116
|
+
.ui-sec-row {
|
|
6117
|
+
display: flex;
|
|
6118
|
+
align-items: center;
|
|
6119
|
+
gap: var(--space-2);
|
|
6120
|
+
}
|
|
6121
|
+
.ui-sec-h {
|
|
6122
|
+
flex: 1 1 auto;
|
|
6123
|
+
min-width: 0;
|
|
6124
|
+
margin: 0;
|
|
6125
|
+
font: inherit;
|
|
6126
|
+
}
|
|
6127
|
+
/* Actions right of the summary, outside the button: a click there does not open or close the section. */
|
|
6128
|
+
.ui-sec-actions {
|
|
6129
|
+
flex: none;
|
|
6130
|
+
display: flex;
|
|
6131
|
+
align-items: center;
|
|
6132
|
+
gap: var(--space-1);
|
|
6133
|
+
}
|
|
6134
|
+
/* AY: under 480 px the summary goes under the title, whole, lined up with it. */
|
|
6135
|
+
@container (max-width: 479px) {
|
|
6136
|
+
.ui-sec-btn {
|
|
6137
|
+
flex-wrap: wrap;
|
|
6138
|
+
row-gap: 0;
|
|
6139
|
+
}
|
|
6140
|
+
.ui-sec-sum {
|
|
6141
|
+
flex-basis: 100%;
|
|
6142
|
+
padding-left: 26px;
|
|
6143
|
+
white-space: normal;
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
.ui-sec-btn {
|
|
6147
|
+
display: flex;
|
|
6148
|
+
align-items: center;
|
|
6149
|
+
gap: var(--space-2);
|
|
6150
|
+
width: 100%;
|
|
6151
|
+
min-height: 48px;
|
|
6152
|
+
padding: var(--space-2) 0;
|
|
6153
|
+
border: 0;
|
|
6154
|
+
border-radius: var(--radius-sm);
|
|
6155
|
+
background: none;
|
|
6156
|
+
color: var(--ink);
|
|
6157
|
+
font: inherit;
|
|
6158
|
+
text-align: left;
|
|
6159
|
+
cursor: pointer;
|
|
6160
|
+
}
|
|
6161
|
+
.ui-sec-btn:focus-visible {
|
|
6162
|
+
outline: 2px solid var(--focus-ring, var(--accent));
|
|
6163
|
+
outline-offset: 2px;
|
|
6164
|
+
}
|
|
6165
|
+
.ui-sec-caret {
|
|
6166
|
+
flex: none;
|
|
6167
|
+
color: var(--ink-muted);
|
|
6168
|
+
transition: transform 260ms ease;
|
|
6169
|
+
}
|
|
6170
|
+
.ui-sec.is-open .ui-sec-caret {
|
|
6171
|
+
transform: rotate(90deg);
|
|
6172
|
+
}
|
|
6173
|
+
.ui-sec-title {
|
|
6174
|
+
flex: none;
|
|
6175
|
+
max-width: 100%;
|
|
6176
|
+
font-size: 20px;
|
|
6177
|
+
line-height: 28px;
|
|
6178
|
+
font-weight: 700;
|
|
6179
|
+
white-space: nowrap;
|
|
6180
|
+
overflow: hidden;
|
|
6181
|
+
text-overflow: ellipsis;
|
|
6182
|
+
}
|
|
6183
|
+
.ui-sec-sum {
|
|
6184
|
+
flex: 1 1 auto;
|
|
6185
|
+
min-width: 0;
|
|
6186
|
+
padding-left: var(--space-1);
|
|
6187
|
+
color: var(--ink-muted);
|
|
6188
|
+
font-size: 13px;
|
|
6189
|
+
line-height: 20px;
|
|
6190
|
+
font-weight: 400;
|
|
6191
|
+
white-space: nowrap;
|
|
6192
|
+
overflow: hidden;
|
|
6193
|
+
text-overflow: ellipsis;
|
|
6194
|
+
}
|
|
6195
|
+
.ui-sec-body {
|
|
6196
|
+
display: grid;
|
|
6197
|
+
grid-template-rows: 0fr;
|
|
6198
|
+
transition: grid-template-rows 260ms ease;
|
|
6199
|
+
}
|
|
6200
|
+
.ui-sec.is-open > .ui-sec-body {
|
|
6201
|
+
grid-template-rows: 1fr;
|
|
6202
|
+
}
|
|
6203
|
+
.ui-sec-in {
|
|
6204
|
+
min-height: 0;
|
|
6205
|
+
overflow: hidden;
|
|
6206
|
+
}
|
|
6207
|
+
.ui-sec-content {
|
|
6208
|
+
padding: var(--space-1) 0 var(--space-4);
|
|
6209
|
+
}
|
|
6210
|
+
.ui-sec-bar {
|
|
6211
|
+
display: flex;
|
|
6212
|
+
flex-wrap: wrap;
|
|
6213
|
+
justify-content: flex-end;
|
|
6214
|
+
gap: var(--space-2);
|
|
6215
|
+
padding-bottom: var(--space-2);
|
|
6216
|
+
}
|
|
6217
|
+
@media (prefers-reduced-motion: reduce) {
|
|
6218
|
+
.ui-sec-caret,
|
|
6219
|
+
.ui-sec-body {
|
|
6220
|
+
transition: none;
|
|
6221
|
+
}
|
|
6222
|
+
}
|
|
6223
|
+
|
|
6224
|
+
/* Markdown: project documents and code comments in the system's type; # is an h4 (20 px). */
|
|
6225
|
+
.ui-md {
|
|
6226
|
+
font-size: 16px;
|
|
6227
|
+
line-height: 1.65;
|
|
6228
|
+
color: var(--ink);
|
|
6229
|
+
overflow-wrap: anywhere;
|
|
6230
|
+
}
|
|
6231
|
+
.ui-md.is-small {
|
|
6232
|
+
font-size: 13px;
|
|
6233
|
+
line-height: 20px;
|
|
6234
|
+
}
|
|
6235
|
+
.ui-md > :first-child {
|
|
6236
|
+
margin-top: 0;
|
|
6237
|
+
}
|
|
6238
|
+
.ui-md > :last-child {
|
|
6239
|
+
margin-bottom: 0;
|
|
6240
|
+
}
|
|
6241
|
+
.ui-md p,
|
|
6242
|
+
.ui-md ul,
|
|
6243
|
+
.ui-md ol,
|
|
6244
|
+
.ui-md blockquote,
|
|
6245
|
+
.ui-md hr,
|
|
6246
|
+
.ui-md .ui-md-code,
|
|
6247
|
+
.ui-md .ui-md-table-wrap {
|
|
6248
|
+
margin: 0 0 var(--space-3);
|
|
6249
|
+
}
|
|
6250
|
+
.ui-md h4.ui-md-h {
|
|
6251
|
+
margin: var(--space-5) 0 var(--space-2);
|
|
6252
|
+
font-size: 20px;
|
|
6253
|
+
line-height: 28px;
|
|
6254
|
+
font-weight: 700;
|
|
6255
|
+
}
|
|
6256
|
+
.ui-md h5.ui-md-h,
|
|
6257
|
+
.ui-md h6.ui-md-h,
|
|
6258
|
+
.ui-md h3.ui-md-h {
|
|
6259
|
+
margin: var(--space-4) 0 var(--space-1);
|
|
6260
|
+
font-size: 1em;
|
|
6261
|
+
line-height: inherit;
|
|
6262
|
+
font-weight: 700;
|
|
6263
|
+
}
|
|
6264
|
+
.ui-md h3.ui-md-h {
|
|
6265
|
+
font-size: 25px;
|
|
6266
|
+
line-height: 32px;
|
|
6267
|
+
}
|
|
6268
|
+
.ui-md.is-small h4.ui-md-h {
|
|
6269
|
+
font-size: 13px;
|
|
6270
|
+
line-height: 20px;
|
|
6271
|
+
}
|
|
6272
|
+
.ui-md ul,
|
|
6273
|
+
.ui-md ol {
|
|
6274
|
+
padding-left: var(--space-6);
|
|
6275
|
+
}
|
|
6276
|
+
.ui-md li > ul,
|
|
6277
|
+
.ui-md li > ol,
|
|
6278
|
+
.ui-md li > p {
|
|
6279
|
+
margin: var(--space-1) 0 0;
|
|
6280
|
+
}
|
|
6281
|
+
.ui-md blockquote {
|
|
6282
|
+
padding-left: var(--space-3);
|
|
6283
|
+
border-left: 3px solid var(--line);
|
|
6284
|
+
color: var(--ink-muted);
|
|
6285
|
+
}
|
|
6286
|
+
.ui-md hr {
|
|
6287
|
+
height: 0;
|
|
6288
|
+
border: 0;
|
|
6289
|
+
border-top: 1px solid var(--line);
|
|
6290
|
+
}
|
|
6291
|
+
.ui-md-link {
|
|
6292
|
+
padding: 0;
|
|
6293
|
+
border: 0;
|
|
6294
|
+
background: none;
|
|
6295
|
+
color: var(--accent-text);
|
|
6296
|
+
font: inherit;
|
|
6297
|
+
text-decoration: underline;
|
|
6298
|
+
text-underline-offset: 2px;
|
|
6299
|
+
cursor: pointer;
|
|
6300
|
+
}
|
|
6301
|
+
.ui-md-table-wrap {
|
|
6302
|
+
max-width: 100%;
|
|
6303
|
+
overflow-x: auto;
|
|
6304
|
+
border-radius: var(--radius-sm);
|
|
6305
|
+
box-shadow: 0 0 0 1px var(--line);
|
|
6306
|
+
}
|
|
6307
|
+
.ui-md-table {
|
|
6308
|
+
border-collapse: collapse;
|
|
6309
|
+
min-width: 100%;
|
|
6310
|
+
font-size: 14px;
|
|
6311
|
+
line-height: 20px;
|
|
6312
|
+
}
|
|
6313
|
+
.ui-md-table th {
|
|
6314
|
+
background: var(--surface-sub);
|
|
6315
|
+
font-weight: 700;
|
|
6316
|
+
text-align: left;
|
|
6317
|
+
white-space: nowrap;
|
|
6318
|
+
}
|
|
6319
|
+
.ui-md-table th,
|
|
6320
|
+
.ui-md-table td {
|
|
6321
|
+
padding: 10px 12px;
|
|
6322
|
+
border-right: 1px solid var(--line);
|
|
6323
|
+
border-bottom: 1px solid var(--line);
|
|
6324
|
+
vertical-align: top;
|
|
6325
|
+
}
|
|
6326
|
+
.ui-md-table th:last-child,
|
|
6327
|
+
.ui-md-table td:last-child {
|
|
6328
|
+
border-right: 0;
|
|
6329
|
+
}
|
|
6330
|
+
.ui-md-table tbody tr:last-child td {
|
|
6331
|
+
border-bottom: 0;
|
|
6332
|
+
}
|
|
6333
|
+
.ui-md-table tbody tr:nth-child(even) {
|
|
6334
|
+
background: var(--surface-sub);
|
|
6335
|
+
}
|
|
6336
|
+
.ui-md-table td.is-num {
|
|
6337
|
+
font-family: var(--font-mono);
|
|
6338
|
+
font-variant-numeric: tabular-nums;
|
|
6339
|
+
white-space: nowrap;
|
|
6340
|
+
}
|
|
6341
|
+
|
|
6342
|
+
/* DA: a <details> block in Markdown: the summary is a button with a caret; closed content stays findable. */
|
|
6343
|
+
.ui-md-details {
|
|
6344
|
+
margin: 0 0 var(--space-3);
|
|
6345
|
+
}
|
|
6346
|
+
.ui-md-summary {
|
|
6347
|
+
display: flex;
|
|
6348
|
+
align-items: center;
|
|
6349
|
+
gap: 6px;
|
|
6350
|
+
min-height: 40px;
|
|
6351
|
+
padding: 0;
|
|
6352
|
+
border: 0;
|
|
6353
|
+
border-radius: var(--radius-sm);
|
|
6354
|
+
background: none;
|
|
6355
|
+
color: var(--ink);
|
|
6356
|
+
font: inherit;
|
|
6357
|
+
font-weight: 600;
|
|
6358
|
+
text-align: left;
|
|
6359
|
+
cursor: pointer;
|
|
6360
|
+
}
|
|
6361
|
+
.ui-md-caret {
|
|
6362
|
+
flex: none;
|
|
6363
|
+
color: var(--ink-muted);
|
|
6364
|
+
transition: transform 260ms ease;
|
|
6365
|
+
}
|
|
6366
|
+
.ui-md-details.is-open .ui-md-caret {
|
|
6367
|
+
transform: rotate(90deg);
|
|
6368
|
+
}
|
|
6369
|
+
.ui-md-details-body > :last-child {
|
|
6370
|
+
margin-bottom: 0;
|
|
6371
|
+
}
|
|
6372
|
+
.ui-md .ui-md-alert {
|
|
6373
|
+
margin: 0 0 var(--space-3);
|
|
6374
|
+
}
|
|
6375
|
+
.ui-md-alert .ui-alert-body > :last-child {
|
|
6376
|
+
margin-bottom: 0;
|
|
6377
|
+
}
|
|
6378
|
+
/* Tables in a narrow panel: the table scrolls inside its frame; code in a cell wraps instead of widening it. */
|
|
6379
|
+
.ui-md-table-wrap {
|
|
6380
|
+
container-type: inline-size;
|
|
6381
|
+
}
|
|
6382
|
+
.ui-md-table .ui-code {
|
|
6383
|
+
white-space: normal;
|
|
6384
|
+
overflow-wrap: anywhere;
|
|
6385
|
+
}
|
|
6386
|
+
.ui-md-table td:has(.ui-code) {
|
|
6387
|
+
min-width: 14em;
|
|
6388
|
+
}
|
|
6389
|
+
/* TB: under 480 px each row is a card: the column name above each value, rows divided by a line. */
|
|
6390
|
+
@container (max-width: 479px) {
|
|
6391
|
+
.ui-md-table,
|
|
6392
|
+
.ui-md-table tbody,
|
|
6393
|
+
.ui-md-table tr,
|
|
6394
|
+
.ui-md-table td {
|
|
6395
|
+
display: block;
|
|
6396
|
+
min-width: 0;
|
|
6397
|
+
}
|
|
6398
|
+
.ui-md-table thead {
|
|
6399
|
+
position: absolute;
|
|
6400
|
+
width: 1px;
|
|
6401
|
+
height: 1px;
|
|
6402
|
+
overflow: hidden;
|
|
6403
|
+
clip-path: inset(50%);
|
|
6404
|
+
}
|
|
6405
|
+
.ui-md-table tr {
|
|
6406
|
+
padding: var(--space-2) var(--space-3);
|
|
6407
|
+
border-bottom: 1px solid var(--line);
|
|
6408
|
+
}
|
|
6409
|
+
.ui-md-table tbody tr:last-child {
|
|
6410
|
+
border-bottom: 0;
|
|
6411
|
+
}
|
|
6412
|
+
.ui-md-table tbody tr:nth-child(even) {
|
|
6413
|
+
background: none;
|
|
6414
|
+
}
|
|
6415
|
+
.ui-md-table td,
|
|
6416
|
+
.ui-md-table td:has(.ui-code) {
|
|
6417
|
+
min-width: 0;
|
|
6418
|
+
padding: var(--space-1) 0;
|
|
6419
|
+
border: 0;
|
|
6420
|
+
text-align: left !important;
|
|
6421
|
+
}
|
|
6422
|
+
.ui-md-table td::before {
|
|
6423
|
+
content: attr(data-label);
|
|
6424
|
+
display: block;
|
|
6425
|
+
color: var(--ink-muted);
|
|
6426
|
+
font-family: var(--font-sans);
|
|
6427
|
+
font-size: 13px;
|
|
6428
|
+
line-height: 20px;
|
|
6429
|
+
}
|
|
6430
|
+
}
|
|
6431
|
+
/* Headings of Markdown inside a Section stay under the section's 20 px title. */
|
|
6432
|
+
.ui-sec-content .ui-md h4.ui-md-h {
|
|
6433
|
+
font-size: 16px;
|
|
6434
|
+
line-height: 24px;
|
|
6435
|
+
}
|
|
6436
|
+
|
|
6437
|
+
/* DetailList labelWidth="auto": the label column as wide as the longest label (at most 40 %), on every row. */
|
|
6438
|
+
.ui-dl.is-auto {
|
|
6439
|
+
display: grid;
|
|
6440
|
+
grid-template-columns: fit-content(40%) minmax(0, 1fr);
|
|
6441
|
+
column-gap: var(--space-6);
|
|
6442
|
+
}
|
|
6443
|
+
.ui-dl.is-auto > .ui-dl-item {
|
|
6444
|
+
grid-column: 1 / -1;
|
|
6445
|
+
grid-template-columns: subgrid;
|
|
6446
|
+
column-gap: var(--space-6);
|
|
6447
|
+
}
|
|
6448
|
+
.ui-dl.is-fixed > .ui-dl-item {
|
|
6449
|
+
grid-template-columns: var(--dl-label) minmax(0, 1fr);
|
|
6450
|
+
}
|
|
6451
|
+
/* labelSize="body": the label in the value's size and the ink color. */
|
|
6452
|
+
.ui-dl.is-body .ui-dl-item dt {
|
|
6453
|
+
color: var(--ink);
|
|
6454
|
+
font-size: inherit;
|
|
6455
|
+
line-height: inherit;
|
|
6456
|
+
}
|
|
6457
|
+
@container (max-width: 599px) {
|
|
6458
|
+
.ui-dl.is-auto > .ui-dl-item {
|
|
6459
|
+
display: block;
|
|
6460
|
+
}
|
|
6461
|
+
.ui-dl.is-fixed > .ui-dl-item {
|
|
6462
|
+
grid-template-columns: minmax(0, 1fr);
|
|
6463
|
+
}
|
|
6464
|
+
.ui-dl.is-body .ui-dl-item dt {
|
|
6465
|
+
font-size: 13px;
|
|
6466
|
+
line-height: 20px;
|
|
6467
|
+
}
|
|
6468
|
+
}
|
package/docs/CodeView.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
有行號的程式碼檢視,用在詳細卡片的原始碼、檢查筆記的引用。
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- 行號:灰色等寬數字靠右,沒有底色和分隔線;左邊留 12 px(和標題列的檔名對齊),和程式碼隔 16 px。可以選取複製程式碼,不會連行號一起複製。`lineNumbers={false}` 不顯示行號,給沒有人會引用行號的短片段用;螢幕閱讀器仍念「第 n 行」。
|
|
6
6
|
- 目標行(`target`,一行或 `[from, to]`):淡強調色底,左側 3 px 強調色細條,行號變粗。有 `maxHeight` 時會自動捲到目標行。
|
|
7
7
|
- 太長的行自動換行,續行縮排 4 個字元寬,縮排裡有一條 2 px 的灰色直線(`line-strong`),看得出是同一行的接續,不是下一行程式。優先在逗號、句點和左括號後面換行;`->`、`==`、`&&` 這類運算子不會從中間斷開。不用橫向捲動。
|
|
8
8
|
- 語法上色:關鍵字藍、常數與字串綠、註解灰色斜體,其他是文字顏色。語言看 `file` 的副檔名(c、h、cpp、js、ts、py、sh),或用 `language` 指定;`highlight={false}` 關掉。內建的上色只認這幾種語言;其他語言給 `tokenizer`,把每行切成 `[class, 文字]`(class 是 `is-keyword`、`is-constant`、`is-comment`、`is-string` 或空字串)。
|
|
9
9
|
- 手機上(寬度小於 600 px)只顯示目標行前後 2 行(`context`),下方「顯示全部 N 行」。
|
|
10
10
|
- 標題列:`file` 顯示路徑,給 `fileHref` 或 `onFile` 變成連結;右邊用次要文字色寫程式語言,是純文字不是按鈕,C 寫成「C 語言」(單一個「C」看起來像按鈕),螢幕閱讀器讀「程式語言:C 語言」。`languageLabel` 換掉這個字,`false` 不顯示。沒有檔案時可以給 `title`。
|
|
11
11
|
- 註解和字串裡的路徑可以變成連結:給 `refHref: (path) => 連結`(回傳 `undefined` 的不變)或 `onRef: (path, e) => …`,和 `CodeText` 一樣。算路徑的:有資料夾和副檔名的(`docs/design/ring-overrun.md`)、檔名加行號(`ring.c:42`、`src/app.c:86-90`);程式碼本身和只有檔名的(`printf.h`)不算。有連結時是 `<a>`,只有 `onRef` 時是按鈕;強調文字色、底線。
|
|
12
|
-
-
|
|
12
|
+
- 複製:`copy` 在標題列最右邊(語言標示的右側)放一個複製的小圖示(32 px,手機 48 px),複製整段程式碼後 2 秒變成勾,提示「已複製」;沒有 `file`、`title` 時也會顯示標題列。`onCopy`、`onCopyError` 接手結果,例如複製失敗時用 Toast 說明。預設不顯示;Markdown 的程式碼區塊預設顯示。
|
|
13
13
|
|
|
14
14
|
```js
|
|
15
15
|
h(UI.CodeView, {
|
package/docs/DetailList.md
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
- 寬度 600 px 以上:欄位名稱在左(13 px 次要文字,不換行)、值在右。
|
|
6
6
|
- 比較窄時:名稱在上、值在下,全部靠左,和手機表格卡片一致。依照元件本身的寬度切換。
|
|
7
7
|
- 值可以放任何元素:`UI.InlineCode` 連結、`UI.Tag`、`UI.Badge`。
|
|
8
|
+
- 寬面板(例如 1300 px 的側邊面板):設 `labelWidth: 'auto'` 與 `labelSize: 'body'`。左欄寬度依最長的名稱(最多 40%),每列對齊,名稱和值隔 24 px;名稱改成和值同字級(16 px)、ink 色。600 px 以下仍是名稱在上、值在下,名稱 13 px。
|
|
9
|
+
|
|
10
|
+
| Prop | 說明 |
|
|
11
|
+
| ------------ | ------------------------------------------------------------------------ |
|
|
12
|
+
| `labelWidth` | 左欄寬度。預設 30%(至少 96 px);`'auto'` 依最長的名稱;數字是固定 px。 |
|
|
13
|
+
| `labelSize` | `'small'`(預設)13 px 次要色;`'body'` 與值同字級、ink 色。 |
|
|
8
14
|
|
|
9
15
|
```js
|
|
10
16
|
h(UI.DetailList, {
|
package/docs/LayerGraph.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
- 線上的文字預設全部顯示。「圖/清單」左邊有一個開關(Switch),旁邊寫「線上文字」(英文 Line labels):開著時全部顯示,關掉改成滑過才顯示。點旁邊的文字也會切換;整排至少 48 px 高。畫面上看開關就知道狀態,手機沒有提示框也不會把名稱讀成動作。需要更精簡的工具列時給 `labelToggle="icon"`,改用原本的標籤圖示按鈕(40 px,沒有外框):切換按鈕,名稱固定「顯示線上文字」,按下時(強調淺底、實心圖示,`aria-pressed="true"`)表示正在顯示。只有圖上有推測或宣告的線時才出現,切到清單時隱藏;`labelToggle={false}` 拿掉它。使用者的選擇記在 `localStorage`(鍵名 `ui-lg-labels:` 加 `scrollKey`,預設是方框的 id),下次開同一張圖時維持;讀寫失敗時照常切換,只是不記住。`edgeLabels` 是一開始的狀態:給 `edgeLabels="hover"` 時一開始隱藏,滑鼠移到線或標籤上、用鍵盤移到線上(需要 `onSelectEdge`)、選到這條線,或選到它兩端的方框時,才顯示那一條的標籤。標籤的位置照樣保留,顯示時不會推動版面。沒有 `onSelectEdge` 時,線只能滑過,不能點也不能用鍵盤移到;觸控螢幕沒有滑過,要看標籤就選方框,或給 `onSelectEdge` 讓線可以點。螢幕閱讀器照樣念出每條線的標籤。
|
|
21
21
|
- 手機上圖比外框寬時(改成左右捲動),一開始捲到方框的最左邊(左側只有標籤的空白不算),最左邊的方框完整看得到;一開始就有選取的方框時捲到那個方框。之後選取的方框不在畫面內時,捲到剛好看得到它。回到同一張圖時維持上次捲動的位置。
|
|
22
22
|
- 短標籤(`tag`,例如「可修改」「受保護」):在名稱右邊同一行,12 px、次要文字色的小標籤。方框變窄時名稱先用「…」截斷,標籤一定完整,所以只寫幾個字。窄到有名稱只剩不到 8 個字時(例如手機),整張圖的標籤都改到名稱下一行,方框從 60 px 加高到 76 px,名稱可以用整個寬度。`tagTone: 'warning'` 改用 warning 文字色與淺底,前面加鎖頭圖示,用在不能改的項目。清單也在名稱後面顯示標籤,螢幕閱讀器念「名稱 標籤 大小」。不要把標示接在 `name` 後面:方框變窄時會和名稱一起被截掉。
|
|
23
|
+
- `toolbar`:頁面自己的控制項(例如「依元件/依檔案」Tabs),放在「圖/清單」同一列的左邊,兩個開關不會分在兩列。窄寬度時這一列換行。
|
|
23
24
|
- 「圖/清單」切換(右上角,`listView={false}` 關掉):清單列出每個方框(名稱,大小)和每條線(「A → B:標籤」),可以點,點了和點方框或線一樣選取。線的整行都是按鈕,畫面寫「A → B:說明」,念「A 到 B:說明」,同起訖的幾條線各有不同的名稱。每一條關係都能選,包括連到共用項目、圖上沒有畫成線的那些:有 `onSelectEdge` 時點一下、Enter 或空白鍵都會呼叫它,和點圖上的線一樣;選中的那一行 `aria-pressed="true"`、淺色底,再按一次取消。方框名稱有底線,說明是一般文字色。標題預設「項目」和「關係」(`listLabels`)。切回圖時保持選取。
|
|
24
25
|
- 捲動位置會記住:同一張圖(`scrollKey`,預設是方框的 id)切到別的區塊或清單再回來,回到上次的位置。
|
|
25
26
|
- 螢幕閱讀器:方框是按鈕,念名稱和大小;可以選的線也是按鈕,放在 `role="group"`(不是圖片)裡,念「起點 到 終點,標籤」(不用「→」:螢幕閱讀器會念成「右箭頭」或略過);畫面上的標籤不重複念。
|
package/docs/Markdown.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Markdown
|
|
2
|
+
|
|
3
|
+
顯示專案文件與程式註解裡的 Markdown,例如 README.md 的摘錄、檔案開頭的註解、側邊面板裡 .md 檔的預覽。
|
|
4
|
+
|
|
5
|
+
- 支援:段落與換行、標題、粗體、斜體、行內程式碼(`UI.InlineCode`)、程式碼區塊(`UI.CodeView`,依語言上色;32 px 的矮標題列只有語言名稱和複製的小圖示,沒有分隔線也沒有行號,程式碼左右留 16 px)、連結、項目與編號清單(可巢狀)、引用、表格、水平線。圖片只顯示替代文字,不載入。
|
|
6
|
+
- 標題降級:`#` 顯示成 h4(20 px),`##` 是 h5,`###` 以下是 h6(兩者都是 16 px 粗體)。用 `topLevel` 改 `#` 對應的層級。
|
|
7
|
+
- 字級:正文和周圍文字同字級(16 px);`size="small"` 是 13 px,給註記用。
|
|
8
|
+
- 表格:灰底粗體表頭(不換行)、斑馬紋加格線;全是數字的欄自動靠右、等寬數字,或依 GFM 的 `---:` 對齊。比容器寬時在表格框裡左右捲動(可以 Tab 到表格再用方向鍵),不會撐開面板;格子裡的行內程式碼換行,不撐寬欄位。表格寬度不到 480 px 時每列變成一張卡片:欄名在上、值在下,列與列之間一條線。
|
|
9
|
+
- 可收合的區塊:`<details><summary>另有 49 處呼叫</summary> … </details>`,和 GitHub 的寫法相同,複製到 GitHub、Notion 也能收合。一開始收合;標題列是按鈕,有 `aria-expanded`,Enter 與空白鍵切換。收合的內容留在頁面上,頁內搜尋(Ctrl+F)找到時自動展開,和 Section 一樣。`<details>` 和 `<summary>` 的屬性一律去掉(`open` 也是)。
|
|
10
|
+
- 提示框:GitHub 的 `> [!NOTE]`、`[!TIP]`、`[!IMPORTANT]`、`[!WARNING]`、`[!CAUTION]` 用 `UI.Alert` 顯示(info、success、info、warning、danger)。一般的 `>` 仍是引用:左邊一條線、次要文字色。
|
|
11
|
+
- 換行:同一段裡的換行接成空格,中文字或全形標點旁邊不加空格;行尾兩個空格或反斜線是強制換行。
|
|
12
|
+
|
|
13
|
+
## 安全
|
|
14
|
+
|
|
15
|
+
- 不執行任何 HTML。原文裡的 HTML 標籤與註解直接去掉,只留標籤之間的文字(`<b>粗</b>` 顯示成「粗」)。唯一的例外是 `<details>` 與 `<summary>`,屬性一律去掉。
|
|
16
|
+
- 連結只允許 http、https、mailto 與相對路徑;其他網址只顯示文字。`schemes` 列出的自訂 scheme(例如 `fn:`)交給 `linkHref` 與 `onLink` 決定;`javascript:`、`data:`、`vbscript:` 列在裡面也一律擋掉。
|
|
17
|
+
|
|
18
|
+
## 連結與路徑
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
h(
|
|
22
|
+
UI.Markdown,
|
|
23
|
+
{
|
|
24
|
+
linkHref: function (href) {
|
|
25
|
+
return '#open=' + href;
|
|
26
|
+
}, // 連結的網址;回傳 undefined 表示不做連結
|
|
27
|
+
onLink: function (href, e) {
|
|
28
|
+
openInPanel(href);
|
|
29
|
+
}, // 一般點擊(Ctrl、⌘、Shift 仍照 linkHref 開新分頁)
|
|
30
|
+
refHref: function (ref) {
|
|
31
|
+
return '#code=' + ref;
|
|
32
|
+
}, // 行內程式碼是路徑時,例如 `harness/routing.py:108`
|
|
33
|
+
onRef: function (ref, e) {
|
|
34
|
+
openInPanel(ref);
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
readme,
|
|
38
|
+
);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- 行內程式碼是路徑(有資料夾的檔名 `docs/a.md`,或檔名加行號 `routing.py:108`)時走 `refHref`、`onRef`,和 CodeView、CodeText 一致;`make` 這類一般程式碼不是連結。程式碼區塊裡註解與字串中的路徑也一樣。
|
|
42
|
+
- 沒有給 `linkHref` 時連結照原網址;外部網址在新分頁開啟。
|
|
43
|
+
- 自訂 scheme:`schemes={['fn']}` 之後,`[_sync_as](fn:harness/controller.py:VirtualRouter._sync_as)` 原樣交給 `linkHref` 與 `onLink`;`linkHref` 沒有回傳網址、也沒有 `onLink` 時只顯示文字。
|
|
44
|
+
|
|
45
|
+
## inline
|
|
46
|
+
|
|
47
|
+
只渲染行內語法、不產生段落,給一行摘要用,例如 README 的第一句:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
h(UI.Markdown, { inline: true }, '先跑 `make`,再用 **harness/run.sh** 啟動。');
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## .md 檔的「原始碼/預覽」
|
|
54
|
+
|
|
55
|
+
CodeView 不內建預覽:由使用的地方在面板上方放 `UI.Tabs`(「原始碼」「預覽」),原始碼用 CodeView,預覽用 Markdown。
|
|
56
|
+
|
|
57
|
+
- 預覽沒有行號。連到某一行的位置(`README.md:12`、CodeView 的 `target`)時,切回「原始碼」分頁再捲到那一行。
|
|
58
|
+
- 預覽裡的連結和路徑交給同一組 `onLink`、`onRef`,例如在側邊面板開啟另一個檔案。
|
|
59
|
+
|
|
60
|
+
## 標題層級與 topLevel
|
|
61
|
+
|
|
62
|
+
`topLevel` 是 `#` 對應的 HTML 層級:`#` 是 h`topLevel`,`##` 再低一層,依此類推(最多 h6)。預設 4。
|
|
63
|
+
|
|
64
|
+
| 放在哪裡 | 原文的最高標題 | `topLevel` | 結果 |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| 頁面裡、h2 或 h3 底下 | `#` | 4(預設) | `#` 是 h4 |
|
|
67
|
+
| Section 裡(Section 標題是 h3) | `#` | 4 | `#` 是 h4 |
|
|
68
|
+
| Section 裡,原文從 `###` 開始寫 | `###` | 2 | `###` 是 h4 |
|
|
69
|
+
|
|
70
|
+
- 大小跟著層級:h4 20 px,h5、h6 16 px 粗體。在 Section 裡,h4 改成 16 px 粗體,不比 Section 的 20 px 標題大。
|
|
71
|
+
|
|
72
|
+
## 範例:用 Markdown 顯示一份結構化報告
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
var report = [
|
|
76
|
+
'### harness/controller.py(可修改)',
|
|
77
|
+
'',
|
|
78
|
+
'| 指令 | 位置 | namespace | 逾時 |',
|
|
79
|
+
'|---|---|---|---|',
|
|
80
|
+
'| `ip netns exec l3-r1 ip -j route` | [`_sync_as`](fn:harness/controller.py:VirtualRouter._sync_as) `harness/controller.py:540` | l3-r1 | 5 秒 |',
|
|
81
|
+
'',
|
|
82
|
+
'<details><summary>另有 49 處呼叫</summary>',
|
|
83
|
+
'',
|
|
84
|
+
'| 指令 | 位置 |',
|
|
85
|
+
'|---|---|',
|
|
86
|
+
'| `ovs-vsctl show` | `harness/runtime.py:88` |',
|
|
87
|
+
'',
|
|
88
|
+
'</details>',
|
|
89
|
+
'',
|
|
90
|
+
'> [!WARNING]',
|
|
91
|
+
'> 3 個指令沒有設逾時。',
|
|
92
|
+
].join('\n');
|
|
93
|
+
|
|
94
|
+
h(UI.Markdown, {
|
|
95
|
+
topLevel: 2,
|
|
96
|
+
schemes: ['fn'],
|
|
97
|
+
linkHref: function (href) { return href.startsWith('fn:') ? '#flow=' + encodeURIComponent(href.slice(3)) : href; },
|
|
98
|
+
refHref: function (ref) { return '#code=' + encodeURIComponent(ref); },
|
|
99
|
+
}, report);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
畫面就是這份文字;「複製成 Markdown」直接複製 `report`,貼到 GitHub 或 Notion 時表格、收合區塊、提示框都還在。
|
|
103
|
+
|
|
104
|
+
## 範例:Section 裡放 Markdown
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
h(UI.SectionGroup, null,
|
|
108
|
+
h(UI.Section, {
|
|
109
|
+
id: 'external',
|
|
110
|
+
title: '外部指令',
|
|
111
|
+
summary: '29 個指令、4 個 namespace、3 個沒有逾時',
|
|
112
|
+
defaultOpen: true,
|
|
113
|
+
actions: h(UI.IconButton, { icon: 'copy', label: '複製這一段', onClick: function () { navigator.clipboard.writeText(report); } }),
|
|
114
|
+
},
|
|
115
|
+
h(UI.Markdown, { topLevel: 2, schemes: ['fn'], linkHref: linkHref, refHref: refHref }, report),
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- `report` 從 `###` 開始寫,所以 `topLevel: 2`,`###` 成為 h4,在 Section 的 h3 標題底下。
|
|
121
|
+
- 「複製這一段」放在 Section 的 `actions`,點它不會開合段落。
|
package/docs/Section.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Section
|
|
2
|
+
|
|
3
|
+
一頁裡可以收合的一段內容,例如程式碼地圖的「概觀」、設定頁或報告頁的分段。收合時仍看得到標題和一行摘要。
|
|
4
|
+
|
|
5
|
+
- 外觀:標題 20 px 粗體(h4 字級),比 16 px 的內容大;標題左邊有箭頭,展開時轉 90 度。標題右邊同一行是一行摘要(13 px、次要文字色),放不下時以「…」截斷。段落之間一條細線(`line`)。
|
|
6
|
+
- 動畫:展開與收合 260 ms,和 TreeList 子項目長出來一樣;`prefers-reduced-motion` 時不做動畫。
|
|
7
|
+
- 標題列是 `<h3>` 裡的 `<button>`,帶 `aria-expanded` 與 `aria-controls`;Enter 與空白鍵切換。螢幕閱讀器的標題清單找得到每一段。用 `level` 改標題層級,大小不變。
|
|
8
|
+
- 摘要是按鈕的一部分,會跟著標題念出來;不要放連結或按鈕。
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
h(UI.Section, { id: 'external', title: '外部指令', summary: '29 個指令、4 個 namespace、3 個沒有逾時', lazy: true }, h(UI.DataTable, {/* … */}));
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Props
|
|
15
|
+
|
|
16
|
+
| Prop | 說明 |
|
|
17
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| `title` | 段落標題。 |
|
|
19
|
+
| `summary` | 標題右邊的一行重點,收合時也顯示。可放 ReactNode,但不放互動元素。 |
|
|
20
|
+
| `defaultOpen` | 不受控:一開始是否展開,預設 `false`。有記住的狀態(`storageKey`)時以記住的為準。 |
|
|
21
|
+
| `open`、`onOpenChange` | 受控用法。點標題、網址跳到這段、「全部展開/全部收合」都會呼叫 `onOpenChange`。 |
|
|
22
|
+
| `id` | 錨點。網址 hash 是這個 id(載入時,或點了頁內的 `#id` 連結)時自動展開,並捲到標題。 |
|
|
23
|
+
| `lazy` | 收合時完全不渲染內容。預設 `false`:內容留在頁面上但隱藏(`hidden="until-found"`),瀏覽器的頁內搜尋(Ctrl+F)找到裡面的字時自動展開。很長的段落(例如上百筆的表格)再設 `lazy`。 |
|
|
24
|
+
| `storageKey` | 用這個 key 把開合狀態存在 localStorage(`ui-section:<key>`)。讀寫失敗時照常運作,只是不記住。 |
|
|
25
|
+
| `level` | 標題的 heading 層級,預設 3。 |
|
|
26
|
+
|
|
27
|
+
## SectionGroup
|
|
28
|
+
|
|
29
|
+
一組 Section,上方右側有「全部展開」與「全部收合」兩個按鈕,各帶圖示;全部已展開時「全部展開」停用,全部已收合時「全部收合」停用。
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
h(
|
|
33
|
+
UI.SectionGroup,
|
|
34
|
+
{ actions: h(UI.Button, { icon: 'link' }, '複製連結') },
|
|
35
|
+
h(UI.Section, { title: '元件', summary: '6 個元件、138 個函式', defaultOpen: true }, '…'),
|
|
36
|
+
h(UI.Section, { title: '進入與結束', summary: '2 個進入點', defaultOpen: true }, '…'),
|
|
37
|
+
h(UI.Section, { title: '外部指令', summary: '29 個指令', lazy: true }, '…'),
|
|
38
|
+
);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- `actions`:同一列、兩個按鈕左邊的其他控制項。
|
|
42
|
+
- 受控的 Section 也會收到「全部展開/全部收合」:由它的 `onOpenChange` 處理。
|
package/docs/guidelines.md
CHANGED
|
@@ -220,7 +220,9 @@
|
|
|
220
220
|
|
|
221
221
|
## 詳細資訊與操作
|
|
222
222
|
|
|
223
|
-
- 一個項目的詳細欄位用 `DetailList`:寬度 600 px
|
|
223
|
+
- 一個項目的詳細欄位用 `DetailList`:寬度 600 px 以上時欄位名稱在左、值在右;比較窄時名稱在上、值在下,和手機表格卡片一致。寬面板(約 1300 px)用 `labelWidth: 'auto'`(左欄依最長的名稱)與 `labelSize: 'body'`(名稱和值同字級、ink 色)。
|
|
224
|
+
- 可以收合的段落用 `Section`:標題 20 px 粗體,左邊箭頭,右邊同一行一行次要色的重點摘要(收合時也顯示);段落之間一條細線;展開與收合 260 ms。收合的內容留在頁面上,頁內搜尋找到時自動展開;很長的段落設 `lazy`。一組段落用 `SectionGroup`,上方右側有帶圖示的「全部展開」「全部收合」。
|
|
225
|
+
- 專案文件與程式註解的 Markdown 用 `Markdown`:正文 16 px,`#` 顯示成 h4;不執行 HTML,標籤去掉只留文字;程式碼區塊是 CodeView,右上有複製的小圖示;.md 檔的「原始碼/預覽」由頁面放 Tabs 切換。可收合的長清單用 `<details><summary>`;提示用 `> [!NOTE]` 這類 GitHub 提示框(Alert),一般 `>` 是引用。表格比面板寬時在表格內捲動,不到 480 px 時每列一張卡片。Section 的 `actions` 放「複製」這類按鈕;Section 不到 480 px 時摘要移到標題下一行。
|
|
224
226
|
- 卡片上的多個操作用 `ActionBar`:寬度小於 600 px 時,最常用的一個是全寬的主要按鈕,其他收進右邊的「⋯」選單;比較寬時並排。
|
|
225
227
|
|
|
226
228
|
## 文字語氣
|