@seanyeh77/ui 0.37.0 → 0.39.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/styles.css CHANGED
@@ -4613,29 +4613,28 @@ html.ui-theme-fade * {
4613
4613
  color: var(--ink-muted);
4614
4614
  white-space: nowrap;
4615
4615
  }
4616
- /* Tag variant="forecast": a forecast (not measured) value, beside it or on a ui-forecast area. */
4617
- .ui-tag.is-forecast {
4616
+ /* Tag variant="forecast" and "demo": an icon and words, no fill, the size of the text beside them (a mark beside the
4617
+ brand is as large as the brand). Forecast is in the accent text color; demo keeps the color of the text around it. */
4618
+ .ui-tag.is-forecast,
4619
+ .ui-tag.is-demo {
4618
4620
  display: inline-flex;
4619
4621
  align-items: center;
4620
- height: 22px;
4621
- padding: 0 var(--space-2);
4622
- border-radius: var(--radius-sm);
4623
- background: var(--accent-soft);
4622
+ gap: 0.3em;
4623
+ font-size: inherit;
4624
+ font-weight: 600;
4625
+ line-height: inherit;
4626
+ }
4627
+ .ui-tag.is-forecast {
4624
4628
  color: var(--accent-text);
4625
- line-height: 20px;
4626
4629
  }
4627
- /* Tag variant="demo": the whole page shows sample values; beside the brand, one per page. */
4628
4630
  .ui-tag.is-demo {
4629
- display: inline-flex;
4630
- align-items: center;
4631
- height: 24px;
4632
- padding: 0 var(--space-2);
4633
- border-radius: var(--radius-sm);
4634
- background: var(--warning-soft);
4635
- color: var(--warning-text);
4636
- font-size: 13px;
4637
- font-weight: 700;
4638
- line-height: 20px;
4631
+ color: inherit;
4632
+ }
4633
+ .ui-tag.is-forecast > svg,
4634
+ .ui-tag.is-demo > svg {
4635
+ flex: none;
4636
+ width: 1em;
4637
+ height: 1em;
4639
4638
  }
4640
4639
  /* A forecast (not measured) area: 45 deg stripes over its fill (4 px line, 9 px period). Put it on the element that
4641
4640
  has the fill; it adds a layer on top, the fill and text stay. */
@@ -8440,3 +8439,436 @@ a.ui-wb-brand:focus-visible {
8440
8439
  .ui-meter-marks.is-stacked > span.is-danger {
8441
8440
  top: 18px;
8442
8441
  }
8442
+
8443
+ /* KpiCard size="compact": a 22 px number for a top bar, no sparkline, a target line; a verdict that is not success
8444
+ takes the target line's place in its color. */
8445
+ .ui-kpi.is-compact {
8446
+ gap: 2px;
8447
+ padding: 10px 14px;
8448
+ }
8449
+ .ui-kpi.is-compact .ui-kpi-value {
8450
+ font-size: 22px;
8451
+ line-height: 30px;
8452
+ }
8453
+ .ui-kpi-target {
8454
+ font-size: 13px;
8455
+ line-height: 20px;
8456
+ color: var(--ink-muted);
8457
+ }
8458
+ .ui-kpi-verdict {
8459
+ font-weight: 600;
8460
+ }
8461
+ .ui-kpi-verdict.is-warning {
8462
+ color: var(--warning-text);
8463
+ }
8464
+ .ui-kpi-verdict.is-danger {
8465
+ color: var(--danger-text);
8466
+ }
8467
+ .ui-zone[data-fill='heat-1'] {
8468
+ color: #ffffff;
8469
+ }
8470
+ .ui-zone[data-fill='heat-2'] {
8471
+ color: #171512;
8472
+ }
8473
+ .ui-zone[data-fill='heat-3'] {
8474
+ color: #171512;
8475
+ }
8476
+ .ui-zone[data-fill='heat-4'] {
8477
+ color: #171512;
8478
+ }
8479
+ .ui-zone[data-fill='heat-5'] {
8480
+ color: #171512;
8481
+ }
8482
+ .ui-zone[data-fill='heat-6'] {
8483
+ color: #171512;
8484
+ }
8485
+ .ui-zone[data-fill='heat-7'] {
8486
+ color: #ffffff;
8487
+ }
8488
+ .ui-zone[data-fill='diverge-neg-strong'] {
8489
+ color: #ffffff;
8490
+ }
8491
+ .ui-zone[data-fill='diverge-neg'] {
8492
+ color: #171512;
8493
+ }
8494
+ .ui-zone[data-fill='diverge-zero'] {
8495
+ color: #171512;
8496
+ }
8497
+ .ui-zone[data-fill='diverge-pos'] {
8498
+ color: #171512;
8499
+ }
8500
+ .ui-zone[data-fill='diverge-pos-strong'] {
8501
+ color: #ffffff;
8502
+ }
8503
+ .ui-zone[data-fill='chart-1'] {
8504
+ color: #ffffff;
8505
+ }
8506
+ .ui-zone[data-fill='chart-2'] {
8507
+ color: #171512;
8508
+ }
8509
+ .ui-zone[data-fill='chart-3'] {
8510
+ color: #171512;
8511
+ }
8512
+ .ui-zone[data-fill='chart-4'] {
8513
+ color: #171512;
8514
+ }
8515
+ [data-theme='dark'] .ui-zone[data-fill='heat-1'] {
8516
+ color: #ffffff;
8517
+ }
8518
+ [data-theme='dark'] .ui-zone[data-fill='heat-2'] {
8519
+ color: #171512;
8520
+ }
8521
+ [data-theme='dark'] .ui-zone[data-fill='heat-3'] {
8522
+ color: #171512;
8523
+ }
8524
+ [data-theme='dark'] .ui-zone[data-fill='heat-4'] {
8525
+ color: #ffffff;
8526
+ }
8527
+ [data-theme='dark'] .ui-zone[data-fill='heat-5'] {
8528
+ color: #171512;
8529
+ }
8530
+ [data-theme='dark'] .ui-zone[data-fill='heat-6'] {
8531
+ color: #171512;
8532
+ }
8533
+ [data-theme='dark'] .ui-zone[data-fill='heat-7'] {
8534
+ color: #171512;
8535
+ }
8536
+ [data-theme='dark'] .ui-zone[data-fill='diverge-neg-strong'] {
8537
+ color: #171512;
8538
+ }
8539
+ [data-theme='dark'] .ui-zone[data-fill='diverge-neg'] {
8540
+ color: #171512;
8541
+ }
8542
+ [data-theme='dark'] .ui-zone[data-fill='diverge-zero'] {
8543
+ color: #ffffff;
8544
+ }
8545
+ [data-theme='dark'] .ui-zone[data-fill='diverge-pos'] {
8546
+ color: #171512;
8547
+ }
8548
+ [data-theme='dark'] .ui-zone[data-fill='diverge-pos-strong'] {
8549
+ color: #171512;
8550
+ }
8551
+ [data-theme='dark'] .ui-zone[data-fill='chart-1'] {
8552
+ color: #171512;
8553
+ }
8554
+ [data-theme='dark'] .ui-zone[data-fill='chart-2'] {
8555
+ color: #171512;
8556
+ }
8557
+ [data-theme='dark'] .ui-zone[data-fill='chart-3'] {
8558
+ color: #171512;
8559
+ }
8560
+ [data-theme='dark'] .ui-zone[data-fill='chart-4'] {
8561
+ color: #171512;
8562
+ }
8563
+
8564
+ /* ZoneMap: zones on a grid, filled by value. Name 16 px and state on one line, the figure 31 px with a 16 px unit,
8565
+ one 13 px detail line. Selected: an ink outline 4 px outside; attention: a 4 px warning or danger border. */
8566
+ .ui-zonemap {
8567
+ --zone-gap: var(--space-3);
8568
+ display: grid;
8569
+ grid-template-columns: repeat(auto-fill, minmax(max(150px, calc((100% - (var(--zone-cols, 4) - 1) * var(--zone-gap)) / var(--zone-cols, 4))), 1fr));
8570
+ gap: var(--zone-gap);
8571
+ padding: 6px;
8572
+ container-type: inline-size;
8573
+ }
8574
+ /* Too narrow for the columns asked: zones flow in order instead of their grid places. */
8575
+ @container (max-width: 640px) {
8576
+ .ui-zonemap > .ui-zone {
8577
+ grid-row: auto !important;
8578
+ grid-column: auto !important;
8579
+ }
8580
+ }
8581
+ .ui-zone {
8582
+ position: relative;
8583
+ display: flex;
8584
+ flex-direction: column;
8585
+ min-width: 0;
8586
+ padding: 10px 12px;
8587
+ border: 0;
8588
+ border-radius: var(--radius-md);
8589
+ font: inherit;
8590
+ text-align: left;
8591
+ color: var(--ink);
8592
+ cursor: pointer;
8593
+ }
8594
+ .ui-zone:focus-visible {
8595
+ outline: none;
8596
+ box-shadow: 0 0 0 3px var(--focus-ring);
8597
+ }
8598
+ .ui-zone.is-warning {
8599
+ box-shadow: inset 0 0 0 4px var(--warning);
8600
+ }
8601
+ .ui-zone.is-danger {
8602
+ box-shadow: inset 0 0 0 4px var(--danger);
8603
+ }
8604
+ .ui-zone.is-selected::before {
8605
+ content: '';
8606
+ position: absolute;
8607
+ inset: -6px;
8608
+ border: 2px solid var(--ink);
8609
+ border-radius: calc(var(--radius-md) + 4px);
8610
+ pointer-events: none;
8611
+ }
8612
+ .ui-zone-head {
8613
+ display: flex;
8614
+ justify-content: space-between;
8615
+ align-items: baseline;
8616
+ gap: var(--space-2);
8617
+ min-width: 0;
8618
+ }
8619
+ .ui-zone-name {
8620
+ font-size: 16px;
8621
+ font-weight: 600;
8622
+ line-height: 22px;
8623
+ white-space: nowrap;
8624
+ overflow: hidden;
8625
+ text-overflow: ellipsis;
8626
+ }
8627
+ .ui-zone-state {
8628
+ flex: none;
8629
+ font-size: 13px;
8630
+ font-weight: 600;
8631
+ line-height: 20px;
8632
+ white-space: nowrap;
8633
+ }
8634
+ .ui-zone-value {
8635
+ margin-top: auto;
8636
+ font-family: var(--font-mono);
8637
+ font-size: 31px;
8638
+ font-weight: 700;
8639
+ line-height: 1.1;
8640
+ font-variant-numeric: tabular-nums;
8641
+ white-space: nowrap;
8642
+ }
8643
+ .ui-zone-unit {
8644
+ margin-left: 4px;
8645
+ font-family: var(--font-sans);
8646
+ font-size: 16px;
8647
+ font-weight: 500;
8648
+ }
8649
+ .ui-zone-detail {
8650
+ font-size: 13px;
8651
+ line-height: 20px;
8652
+ white-space: nowrap;
8653
+ overflow: hidden;
8654
+ text-overflow: ellipsis;
8655
+ }
8656
+ .ui-zone.is-empty {
8657
+ gap: 2px;
8658
+ border: 1px dashed var(--line-strong);
8659
+ color: var(--ink-muted);
8660
+ cursor: default;
8661
+ }
8662
+ .ui-zone.is-empty .ui-zone-name {
8663
+ color: var(--ink);
8664
+ }
8665
+
8666
+ /* EventTimeline: newest first; time, kind icon (no fill), what happened. */
8667
+ .ui-events {
8668
+ margin: 0;
8669
+ padding: 0;
8670
+ list-style: none;
8671
+ }
8672
+ .ui-events > li {
8673
+ display: grid;
8674
+ grid-template-columns: auto 20px minmax(0, 1fr);
8675
+ gap: var(--space-3);
8676
+ align-items: baseline;
8677
+ padding: var(--space-2) 4px;
8678
+ border-bottom: 1px solid var(--line);
8679
+ }
8680
+ .ui-events > li:last-child {
8681
+ border-bottom: 0;
8682
+ }
8683
+ .ui-events-time {
8684
+ font-family: var(--font-mono);
8685
+ font-size: 13px;
8686
+ color: var(--ink-muted);
8687
+ font-variant-numeric: tabular-nums;
8688
+ }
8689
+ .ui-events-kind {
8690
+ display: inline-flex;
8691
+ align-self: center;
8692
+ color: var(--ink-muted);
8693
+ }
8694
+ .ui-events > li.is-alert .ui-events-kind {
8695
+ color: var(--warning-text);
8696
+ }
8697
+ .ui-events > li.is-switch .ui-events-kind {
8698
+ color: var(--accent-text);
8699
+ }
8700
+ .ui-events-empty {
8701
+ margin: 0;
8702
+ padding: var(--space-4) 4px;
8703
+ color: var(--ink-muted);
8704
+ }
8705
+
8706
+ /* TimeControl: a column for a side panel: the clock, two lines, two buttons. */
8707
+ .ui-timecontrol {
8708
+ display: flex;
8709
+ flex-direction: column;
8710
+ gap: 4px;
8711
+ }
8712
+ .ui-timecontrol-clock {
8713
+ font-family: var(--font-mono);
8714
+ font-size: 28px;
8715
+ font-weight: 700;
8716
+ line-height: 36px;
8717
+ font-variant-numeric: tabular-nums;
8718
+ }
8719
+ .ui-timecontrol-status {
8720
+ margin: 0;
8721
+ }
8722
+ .ui-timecontrol-detail {
8723
+ margin: 0;
8724
+ font-size: 13px;
8725
+ line-height: 20px;
8726
+ color: var(--ink-muted);
8727
+ }
8728
+ .ui-timecontrol-actions {
8729
+ display: flex;
8730
+ flex-wrap: wrap;
8731
+ gap: var(--space-2);
8732
+ margin-top: var(--space-2);
8733
+ }
8734
+
8735
+ /* ConsoleLayout: a full-screen monitoring layout. Top bar, main view with a side panel and a bottom row, no page
8736
+ scroll; the frame zooms 1 to 1.5x from 1440 x 900 up (inline zoom, width and height from the component). */
8737
+ .ui-console {
8738
+ container-type: inline-size;
8739
+ height: 100dvh;
8740
+ overflow: hidden;
8741
+ background: var(--bg);
8742
+ color: var(--ink);
8743
+ }
8744
+ .ui-console-frame {
8745
+ box-sizing: border-box;
8746
+ width: 100%;
8747
+ height: 100%;
8748
+ display: grid;
8749
+ grid-template-columns: minmax(0, 1fr) 400px;
8750
+ grid-template-rows: auto minmax(0, 1fr) auto;
8751
+ gap: 12px;
8752
+ padding: 12px;
8753
+ }
8754
+ @container (max-width: 1279px) {
8755
+ .ui-console-frame {
8756
+ grid-template-columns: minmax(0, 1fr) 360px;
8757
+ }
8758
+ }
8759
+ .ui-console-top {
8760
+ grid-column: 1 / -1;
8761
+ display: flex;
8762
+ align-items: center;
8763
+ justify-content: space-between;
8764
+ gap: var(--space-4);
8765
+ min-height: 64px;
8766
+ padding: 0 var(--space-4);
8767
+ border-radius: var(--radius-lg);
8768
+ background: var(--surface);
8769
+ box-shadow: var(--shadow-card);
8770
+ font-size: 16px;
8771
+ line-height: 1.5;
8772
+ }
8773
+ .ui-console-start,
8774
+ .ui-console-end {
8775
+ display: flex;
8776
+ align-items: center;
8777
+ gap: var(--space-3);
8778
+ min-width: 0;
8779
+ }
8780
+ .ui-console-title {
8781
+ margin: 0;
8782
+ font-size: inherit;
8783
+ line-height: inherit;
8784
+ font-weight: 700;
8785
+ white-space: nowrap;
8786
+ }
8787
+ .ui-console-status,
8788
+ .ui-console-clock {
8789
+ white-space: nowrap;
8790
+ }
8791
+ .ui-console-kpis {
8792
+ display: flex;
8793
+ align-items: stretch;
8794
+ }
8795
+ .ui-console-kpis > .ui-kpi {
8796
+ padding: 6px var(--space-4);
8797
+ border-radius: 0;
8798
+ background: transparent;
8799
+ box-shadow: none;
8800
+ border-left: 1px solid var(--line);
8801
+ }
8802
+ .ui-console-kpis > .ui-kpi:last-child {
8803
+ border-right: 1px solid var(--line);
8804
+ }
8805
+ .ui-console-main {
8806
+ grid-column: 1;
8807
+ grid-row: 2;
8808
+ min-width: 0;
8809
+ min-height: 0;
8810
+ display: flex;
8811
+ flex-direction: column;
8812
+ }
8813
+ .ui-console-main > * {
8814
+ flex: 1 1 auto;
8815
+ min-height: 0;
8816
+ overflow: auto;
8817
+ }
8818
+ .ui-console-side {
8819
+ grid-column: 2;
8820
+ grid-row: 2 / 4;
8821
+ min-height: 0;
8822
+ overflow-y: auto;
8823
+ display: flex;
8824
+ flex-direction: column;
8825
+ gap: 12px;
8826
+ /* room for the cards' shadows inside the scrolling column */
8827
+ margin: -12px;
8828
+ padding: 12px;
8829
+ }
8830
+ .ui-console-side > * {
8831
+ flex: none;
8832
+ }
8833
+ .ui-console-bottom {
8834
+ grid-column: 1;
8835
+ grid-row: 3;
8836
+ min-width: 0;
8837
+ min-height: 0;
8838
+ display: flex;
8839
+ flex-direction: column;
8840
+ }
8841
+ /* Phones: one scrolling column, top bar first, then the main view, side cards, bottom row and extra cards. */
8842
+ .ui-console.is-stacked {
8843
+ height: auto;
8844
+ min-height: 100dvh;
8845
+ overflow: visible;
8846
+ }
8847
+ .ui-console.is-stacked .ui-console-frame {
8848
+ display: flex;
8849
+ flex-direction: column;
8850
+ height: auto;
8851
+ }
8852
+ .ui-console.is-stacked .ui-console-top {
8853
+ flex-wrap: wrap;
8854
+ padding: var(--space-3) var(--space-4);
8855
+ }
8856
+ .ui-console.is-stacked .ui-console-end {
8857
+ flex-wrap: wrap;
8858
+ row-gap: var(--space-2);
8859
+ }
8860
+ .ui-console.is-stacked .ui-console-kpis {
8861
+ order: 1;
8862
+ width: 100%;
8863
+ overflow-x: auto;
8864
+ }
8865
+ .ui-console.is-stacked .ui-console-kpis > .ui-kpi:first-child {
8866
+ border-left: 0;
8867
+ padding-left: 0;
8868
+ }
8869
+ .ui-console.is-stacked .ui-console-kpis > .ui-kpi:last-child {
8870
+ border-right: 0;
8871
+ }
8872
+ .ui-console.is-stacked .ui-console-main {
8873
+ min-height: 320px;
8874
+ }
@@ -0,0 +1,31 @@
1
+ # ConsoleLayout
2
+
3
+ 全螢幕監控畫面的版面:頂列、左邊主視覺、右邊側欄、主視覺下方的底列,填滿整個畫面、整頁不捲動。給常駐在大螢幕上、遠看的監控畫面;一般後台頁用 AppShell。
4
+
5
+ - 頂列:左邊 `title`(整頁唯一的標題)和 `tags`(例如 `Tag variant="demo"`「示範資料」);右邊依序是 `status`、`kpis`、`clock`、全螢幕按鈕。頂列的字都是 16 px、同一個顏色:`status` 傳一般文字(例如「AI 最佳化中」),不要用 Badge 或狀態色。
6
+ - `kpis` 放 `KpiCard size="compact"`,在頂列裡去掉卡片底色和陰影,中間用 1 px 線分開。
7
+ - `main`:主視覺,例如裝 ZoneMap 的 Card;填滿左邊的格子,放不下時在卡片裡捲動。
8
+ - `side`:側欄的卡片,由上到下,例如 TimeControl、EventTimeline。側欄 400 px(版面寬度小於 1280 px 時 360 px),放不下時側欄自己捲動。
9
+ - `bottom`:主視覺下方一列,高度跟著內容,例如裝 LineChart 的 Card;主視覺拿剩下的高度。
10
+ - `extras: [{ id, minHeight, node }]`:螢幕夠高才出現的卡片,加在側欄最後面。`minHeight` 比的是「邏輯高度」,也就是畫面高度 ÷ 放大倍數,例如 1040。
11
+ - 放大:1440 × 900 以上整個版面等比放大,倍數 = 寬 ÷ 1440 和 高 ÷ 900 的較小者,最多 1.5 倍(`consoleZoom(w, h)`);以下維持原大小、不縮小。
12
+ - 全螢幕按鈕(「全螢幕」/「離開全螢幕」)讓版面佔滿整個螢幕;瀏覽器沒有全螢幕功能時不顯示,`fullscreen={false}` 可以拿掉。
13
+ - 手機(寬度小於 600 px):排成一欄可以捲動的長頁:頂列(KPI 換到第二行,可以左右捲動)、主視覺、側欄的卡片、底列、`extras` 的卡片全部顯示。
14
+ - 卡片由頁面自己放(Card),版面本身只有頂列有底色和陰影。
15
+
16
+ ```js
17
+ h(UI.ConsoleLayout, {
18
+ title: '機房監控',
19
+ tags: h(UI.Tag, { variant: 'demo' }, '示範資料'),
20
+ status: 'AI 最佳化中',
21
+ kpis: [
22
+ h(UI.KpiCard, { key: 'e', size: 'compact', label: '預測誤差', value: 0.4, decimals: 1, unit: '°C', target: '目標 ≤ 0.5 °C' }),
23
+ h(UI.KpiCard, { key: 'p', size: 'compact', label: 'PUE', value: 1.42, decimals: 2, target: '目標 ≤ 1.45' }),
24
+ ],
25
+ clock: '即時',
26
+ main: h(UI.Card, { title: '機房分區' }, h(UI.ZoneMap, { label: '機房分區', zones: zones })),
27
+ side: [h(UI.Card, { key: 't' }, h(UI.TimeControl, timeProps)), h(UI.Card, { key: 'e', title: '事件' }, h(UI.EventTimeline, eventProps))],
28
+ bottom: h(UI.Card, null, h(UI.LineChart, chartProps)),
29
+ extras: [{ id: 'meters', minHeight: 1040, node: h(UI.Card, { title: '各區進氣溫度' }, meters) }],
30
+ });
31
+ ```
@@ -0,0 +1,16 @@
1
+ # EventTimeline
2
+
3
+ 事件列表,由新到舊:每一列是時間、類型圖示和一句說明。
4
+
5
+ - 時間用 Geist Mono 13 px 灰字(24 小時制);說明是內文大小。
6
+ - 類型(`kind`):`alert` 告警(warning 圖示、`warning-text` 色)、`switch` 切換(左右箭頭、`accent-text`)、`ai` AI(星芒、灰)、`manual` 人工(人像、灰)。圖示 20 px、沒有底色,螢幕閱讀器念類型名稱。
7
+ - 依 `time` 由新到舊排,傳入的順序不影響。
8
+ - 沒有事件時顯示 `empty`,例如「近 4 小時沒有事件」。
9
+
10
+ ```js
11
+ h(UI.EventTimeline, {
12
+ label: '近 4 小時的事件',
13
+ empty: '近 4 小時沒有事件',
14
+ events: [{ time: new Date(), kind: 'alert', text: 'F 區進氣溫度超過上限 29 °C' }],
15
+ });
16
+ ```
package/docs/KpiCard.md CHANGED
@@ -9,3 +9,21 @@ KPI 卡片,放在 Dashboard 最上方。
9
9
  - 卡片太窄、最終數字放不下時,字級自動從 31 px 縮小,最小 20 px。
10
10
  - 變化:▲/▼ 加百分比,後面接灰色「較上週」(`compareLabel` 可改)。顏色看好壞:`good` 預設為 `delta > 0`,像錯誤率這種上升是壞事的指標要設 `good={false}`;回應時間下降是好事,設 `good`。
11
11
  - 百分比的指標,變化用 `deltaUnit="pt"` 顯示「個百分點」。
12
+
13
+ ## 緊湊版(`size="compact"`)
14
+
15
+ 放進監控畫面頂列的小卡:標籤、22 px 數字、一行 13 px 灰字目標(`target`,例如「目標 ≤ 0.5 °C(示意)」)。不畫迷你折線。
16
+
17
+ - `verdict: { tone, text }`:判定。`success`(例如「預測準確」)時畫面上只有目標那一行,螢幕閱讀器仍會念判定;`warning`(「偏差變大」)或 `danger`(「需要校正」)時,目標那一行換成那個顏色的半粗字「偏差變大(目標 ≤ 0.5 °C(示意))」。不加符號,用文字說出狀態。
18
+
19
+ ```js
20
+ h(UI.KpiCard, {
21
+ size: 'compact',
22
+ label: '近 1 小時誤差',
23
+ value: 0.9,
24
+ decimals: 1,
25
+ unit: '°C',
26
+ verdict: { tone: 'warning', text: '偏差變大' },
27
+ target: '目標 ≤ 0.5 °C(示意)',
28
+ });
29
+ ```
package/docs/LineChart.md CHANGED
@@ -8,6 +8,7 @@
8
8
  - 滑過時出現垂直參考線、各組的點,以及浮起卡片顯示日期和數值(加單位)。
9
9
  - 鍵盤:圖可以用 Tab 移到,← → 在時間點之間移動、Home/End 到兩端,和滑過一樣顯示參考線和數值卡片,螢幕閱讀器念「時間點:各組數值」。
10
10
  - 進場時一條接一條畫出,間隔 150 ms。
11
+ - 圖依實際寬度畫,軸標和線上的字不論圖多寬都是原本的大小;圖高預設 240 px,`height` 可以改。x 軸標籤會擠在一起時自動隔幾個才寫一個(是 `labelEvery` 的倍數)。
11
12
  - `label` 必填,作為圖表的 `aria-label`。
12
13
 
13
14
  ## 監控畫面:預測與實際、節能
package/docs/Tag.md CHANGED
@@ -4,10 +4,9 @@
4
4
 
5
5
  - 只有小字:12 px、粗體、`ink-muted`,沒有框也沒有底色。
6
6
  - 一律灰色,不用顏色區分類別;要表示進度或結果(完成、失敗、要確認)用 Badge。
7
- - 兩個例外說明數字的來源,有底色:
8
- - `variant="forecast"`:預測、非實測的值,`accent-soft` 底、`accent-text` 字,高 22 px。放在預測值旁邊,或疊了斜線紋理(class `ui-forecast`)的區塊裡。
9
- - `variant="demo"`:整頁都是示範值,`warning-soft` 底、`warning-text` 13 px 粗體字,高 24 px。放在頂列品牌旁,一頁一個。
10
- - 放在名稱後面,同一列可以有多個。
7
+ - 兩個例外說明數字的來源,加圖示和顏色,沒有底色;字級跟著旁邊的文字(放在品牌旁就和品牌一樣大),半粗:
8
+ - `variant="forecast"`:預測、非實測的值,趨勢線圖示,`accent-text` 色。放在預測值旁邊,或疊了斜線紋理(class `ui-forecast`)的區塊裡。
9
+ - `variant="demo"`:整頁都是示範值,資訊圖示,顏色和旁邊的文字相同。放在頂列品牌旁,一頁一個。
11
10
 
12
11
  ```js
13
12
  h(UI.Tag, null, '編譯器');
@@ -17,4 +16,3 @@ h(UI.Tag, null, '編譯器');
17
16
  h(UI.Tag, { variant: 'forecast' }, '預測');
18
17
  h(UI.Tag, { variant: 'demo' }, '示範資料');
19
18
  ```
20
-
@@ -0,0 +1,21 @@
1
+ # TimeControl
2
+
3
+ 監控畫面的時間控制:時鐘、兩行說明,以及「回放」和「回到現在」兩個按鈕;直排,適合放在 400 px 的側欄。
4
+
5
+ - 時鐘 28 px Geist Mono(24 小時制),即時時是現在,回放時是回放到的時間。
6
+ - 第一行 `status`(內文)說明目前看的是什麼,例如「即時:每 10 秒更新一次。」;第二行 `detail`(13 px 灰字),例如紀錄範圍或最後更新時間。
7
+ - 「回放」是次要按鈕,回放中變成「停止回放」;「回到現在」只有回放中可以按。
8
+ - 回放中要移到某個時間點,用 LineChart 的播放頭(`playhead`)。
9
+
10
+ ```js
11
+ h(UI.TimeControl, {
12
+ time: replaying ? replayAt : now,
13
+ replaying: replaying,
14
+ onReplayChange: setReplaying,
15
+ onNow: function () {
16
+ setReplaying(false);
17
+ },
18
+ status: replaying ? '回放中:14:10 起的紀錄。' : '即時:每 10 秒更新一次。',
19
+ detail: '紀錄範圍 2026/11/20(五)12:00 到 16:24',
20
+ });
21
+ ```
@@ -0,0 +1,27 @@
1
+ # ZoneMap
2
+
3
+ 分區平面圖:分區是格線上的矩形,依數值填熱度色階,每區寫名稱、狀態、主數值和一行次要資訊。
4
+
5
+ - 排法:第一行名稱(16 px 半粗)靠左、狀態(13 px 半粗)靠右;中間是主數值(31 px Geist Mono),單位縮成 16 px 一般粗細;最下一行次要資訊(13 px)。
6
+ - 填色:沒給 `fill` 時,用 `value` 在 `min`~`max`(預設 20~30)之間對應 `heat-1`…`heat-7`;字的顏色自動選深色或白色(`textOn()`),跟著主題切換。
7
+ - 選取:`ink` 色 2 px 外框,在分區外 4 px。需要注意:`tone: 'warning'`/`'danger'` 畫 4 px 內框,狀態前加「⚠」。兩者樣子不同,可以同時出現。
8
+ - 預測:`forecast` 疊上預測斜線,狀態預設「預測」。
9
+ - 沒有資料(`value` 是 `null`):虛線框,名稱加「沒有資料」,不能選。
10
+ - 位置:`area: { row, col, rows, cols }`(從 1 開始);沒給時依序排入 `columns` 欄(預設 4)、每列 `rowHeight` px(預設 120)。目前只有矩形。
11
+ - 鍵盤:每個分區是按鈕,Tab 依序經過,Enter 或空白鍵選取(`aria-pressed`)。螢幕閱讀器念「B 區,28.4 °C,注意,進氣 26.1 °C」。
12
+
13
+ ```js
14
+ h(UI.ZoneMap, {
15
+ label: '機房分區',
16
+ selectedId: sel,
17
+ onSelect: function (z) {
18
+ setSel(z.id);
19
+ },
20
+ zones: [
21
+ { id: 'a', name: 'A 區', value: 23.1, unit: '°C', detail: '進氣 21.8 °C' },
22
+ { id: 'b', name: 'B 區', value: 28.4, unit: '°C', tone: 'warning', state: '注意', detail: '進氣 26.1 °C' },
23
+ { id: 'd', name: 'D 區', value: 25.8, unit: '°C', forecast: true, detail: '下一回合' },
24
+ { id: 'h', name: 'H 區', value: null },
25
+ ],
26
+ });
27
+ ```
@@ -175,9 +175,15 @@
175
175
  - 數字進場:從 0 數上來(900 ms)。
176
176
  - 圖表配色:多色,依序 `chart-1` 藍、`chart-2` 青、`chart-3` 橘、`chart-4` 暖灰;只有一組資料時用 `chart-1`。`chart-4` 給「其他」「人工」這類次要的一類。類別超過 3 時,圖例一定有文字,色帶旁有標籤。
177
177
  - 熱度色階:`heat-1`…`heat-7`,冷 → 熱,藍 → 中性暖灰 → 橘紅;數值對應哪一段由頁面決定(`heatToken(value, min, max)`),例如 20 → 30 °C。差值用發散色階:`diverge-neg-strong`、`diverge-neg`、`diverge-zero`、`diverge-pos`、`diverge-pos-strong`(負藍、0 灰、正橘;`divergeToken(diff, { zero, strong })`)。色階只用在資料的填色;上面的字用 `textOn(fill)` 選深色(#171512)或白色,取對比較高的,每一段都有 4.5:1。狀態不只靠顏色:數值一定寫出來,告警加「⚠」文字與邊框。
178
- - 預測、非實測的數值:填色上疊 45° 斜線(`ui-forecast`:線 4 px、間距 9 px,`forecast-stripe` 是文字色 14% 不透明),旁邊加 `Tag variant="forecast"`「預測」(`accent-soft` 底、`accent-text` 字)。
179
- - 整頁都是示範值時,頂列品牌旁放一個 `Tag variant="demo"`「示範資料」(`warning-soft` 底、`warning-text` 粗體)。
178
+ - 預測、非實測的數值:填色上疊 45° 斜線(`ui-forecast`:線 4 px、間距 9 px,`forecast-stripe` 是文字色 14% 不透明),旁邊加 `Tag variant="forecast"`「預測」(趨勢線圖示加 `accent-text` 字,沒有底色)。
179
+ - 整頁都是示範值時,頂列品牌旁放一個 `Tag variant="demo"`「示範資料」(資訊圖示加 `warning-text` 字,沒有底色)。「預測」「示範資料」的字級跟著旁邊的文字,半粗。
180
+ - 分區平面圖(ZoneMap):名稱 16 px 和狀態同一行,主數值 31 px、單位 16 px,次要資訊 13 px;選取是分區外 4 px 的 `ink` 外框,需要注意是 4 px 的 `warning`/`danger` 內框加「⚠」。
181
+ - 事件列表(EventTimeline):由新到舊,一列一筆:時間、類型圖示(沒有底色)、說明。
182
+ - 時間控制(TimeControl):直排,時鐘 28 px、兩行說明、「回放」(回放中是「停止回放」)和「回到現在」。
183
+ - 監控畫面頂列的 KPI 用 `KpiCard size="compact"`:數字 22 px,一行灰字目標;判定只在需要注意時取代目標那一行,用文字和狀態色,不加符號、不加底色。
180
184
  - 監控畫面(全螢幕、常駐、遠看):最小字 13 px,SVG 軸標 12 px。大螢幕依視窗等比放大:倍數 = 視窗寬 ÷ 1440 和 視窗高 ÷ 900 的較小者,下限 1、上限 1.5;1440 × 900 以下不縮小,改用斷點。
185
+ - 全螢幕監控畫面用 `ConsoleLayout`:頂列左邊標題和示範資料,右邊狀態、KPI、時間、全螢幕按鈕;主視覺在左、側欄在右、圖表在主視覺下方;整頁不捲動,放不下時側欄自己捲動;螢幕夠高才多出的卡片加在側欄最後面;手機排成一欄的長頁。
186
+ - 頂列的「示範資料」和狀態文字(例如「AI 最佳化中」)和旁邊的字同樣大小、同樣顏色,不另外上色。
181
187
  - 監控畫面上的危險動作照一般規則:按鈕用實心紅色,按下後先跳確認對話框(例如「切回 PID 控制?」);不用卡片內的行內確認,也沒有紅色外框的按鈕。
182
188
  - 折線:平滑曲線,不填色。例外只有兩組資料之間的差額帶(LineChart `band`):預測與實際依正負填 `diverge-pos`/`diverge-neg` 30%,實際與基準之間(省下的量)填 `success` 28%;不用在三組以上的圖。
183
189
  - 預測與實際的圖:實際是實線,預測是虛線(`chart-3`);「現在」是一條實線,之後的未來區疊預測斜線;注意線和上限是 1.5 px 的 `warning`/`danger` 虛線,標籤靠右寫在線上方;下一回合的單點預測是空心圓加標籤。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seanyeh77/ui",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "description": "SeanYeh's design system: typed React components on Base UI, styled with design tokens.",
5
5
  "license": "MIT",
6
6
  "author": "Hsiu-An Yeh",
@@ -49,7 +49,7 @@
49
49
  "react-dom": "^19.3.1",
50
50
  "tsdown": "^0.23.7",
51
51
  "vitest": "^5.1.0",
52
- "@seanyeh77/tokens": "^0.37.0"
52
+ "@seanyeh77/tokens": "^0.39.0"
53
53
  },
54
54
  "dependencies": {
55
55
  "@base-ui/react": "^1.9.0"