|
| 1 | +--- |
| 2 | +import { getManifest, hasPhonology } from "../data/loader"; |
| 3 | +
|
| 4 | +const schemas = Object.values(getManifest().schemas); |
| 5 | +const withPhonology = schemas.filter((schema) => hasPhonology(schema.schema_id)).length; |
| 6 | +const withoutPhonology = schemas.length - withPhonology; |
| 7 | +const rows = [ |
| 8 | + { |
| 9 | + label: "有方案表", |
| 10 | + description: "已整理聲母、韻母與聲調資料", |
| 11 | + count: withPhonology, |
| 12 | + kind: "ready" |
| 13 | + }, |
| 14 | + { |
| 15 | + label: "無方案表", |
| 16 | + description: "暫未能由碼表生成音系資料", |
| 17 | + count: withoutPhonology, |
| 18 | + kind: "pending" |
| 19 | + } |
| 20 | +]; |
| 21 | +const max = Math.max(...rows.map((row) => row.count), 1); |
| 22 | +--- |
| 23 | +<section class="phonology-chart" aria-labelledby="phonology-chart-title"> |
| 24 | + <div class="inner"> |
| 25 | + <div class="copy"> |
| 26 | + <h2 id="phonology-chart-title">方案表狀態</h2> |
| 27 | + <p>方案表由 schema 與碼表自動整理出聲母、韻母和聲調。若缺少必要檔案、碼表不適合拆分,或仍待人工補正,頁面便暫不顯示方案表。</p> |
| 28 | + </div> |
| 29 | + <div class="status-bars"> |
| 30 | + {rows.map((row) => { |
| 31 | + const pct = Math.max(6, Math.round((row.count / max) * 100)); |
| 32 | + return ( |
| 33 | + <div class:list={["status-row", row.kind]}> |
| 34 | + <span class="name"> |
| 35 | + <strong>{row.label}</strong> |
| 36 | + <small>{row.description}</small> |
| 37 | + </span> |
| 38 | + <span class="track" aria-hidden="true"><span style={`width:${pct}%`} /></span> |
| 39 | + <b>{row.count}</b> |
| 40 | + </div> |
| 41 | + ); |
| 42 | + })} |
| 43 | + </div> |
| 44 | + </div> |
| 45 | +</section> |
| 46 | + |
| 47 | +<style> |
| 48 | + .phonology-chart { |
| 49 | + padding: 0 var(--sp-section-x) 62px; |
| 50 | + background: var(--bg-panel); |
| 51 | + } |
| 52 | + .inner { |
| 53 | + display: grid; |
| 54 | + grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1fr); |
| 55 | + gap: 44px; |
| 56 | + border-top: 2px solid var(--ink); |
| 57 | + padding-top: 38px; |
| 58 | + } |
| 59 | + h2 { |
| 60 | + margin: 0; |
| 61 | + font-family: var(--ff-serif-tc); |
| 62 | + font-size: var(--fs-h2-section); |
| 63 | + letter-spacing: 0; |
| 64 | + } |
| 65 | + p { |
| 66 | + max-width: 620px; |
| 67 | + margin: 10px 0 0; |
| 68 | + color: var(--ink-meta-2); |
| 69 | + font-family: var(--ff-serif-tc); |
| 70 | + line-height: 1.7; |
| 71 | + } |
| 72 | + .status-bars { |
| 73 | + display: grid; |
| 74 | + align-content: start; |
| 75 | + gap: 18px; |
| 76 | + } |
| 77 | + .status-row { |
| 78 | + display: grid; |
| 79 | + grid-template-columns: 190px minmax(0, 1fr) 46px; |
| 80 | + gap: 16px; |
| 81 | + align-items: center; |
| 82 | + } |
| 83 | + .name { |
| 84 | + display: grid; |
| 85 | + gap: 3px; |
| 86 | + min-width: 0; |
| 87 | + font-family: var(--ff-sans-tc); |
| 88 | + } |
| 89 | + strong { |
| 90 | + color: var(--ink); |
| 91 | + font-size: 16px; |
| 92 | + font-weight: 600; |
| 93 | + line-height: 1.25; |
| 94 | + } |
| 95 | + small { |
| 96 | + color: var(--ink-meta-3); |
| 97 | + font-size: 12px; |
| 98 | + line-height: 1.35; |
| 99 | + } |
| 100 | + .track { |
| 101 | + height: 18px; |
| 102 | + background: var(--bg-elev); |
| 103 | + } |
| 104 | + .track span { |
| 105 | + display: block; |
| 106 | + height: 100%; |
| 107 | + background: var(--ink); |
| 108 | + } |
| 109 | + .pending .track span { |
| 110 | + background: var(--zhu); |
| 111 | + } |
| 112 | + b { |
| 113 | + font-family: var(--ff-sans); |
| 114 | + font-size: 17px; |
| 115 | + font-variant-numeric: tabular-nums; |
| 116 | + text-align: right; |
| 117 | + } |
| 118 | + @media (max-width: 900px) { |
| 119 | + .inner { |
| 120 | + grid-template-columns: 1fr; |
| 121 | + gap: 28px; |
| 122 | + } |
| 123 | + } |
| 124 | + @media (max-width: 620px) { |
| 125 | + .status-row { |
| 126 | + grid-template-columns: 1fr 42px; |
| 127 | + gap: 10px 12px; |
| 128 | + } |
| 129 | + .track { |
| 130 | + grid-column: 1 / -1; |
| 131 | + grid-row: 2; |
| 132 | + } |
| 133 | + b { |
| 134 | + align-self: start; |
| 135 | + } |
| 136 | + } |
| 137 | +</style> |
0 commit comments