@squadbase/vantage-template 0.1.0-dev.a6b88b8 → 0.1.0-dev1.f48cfad
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 +7 -7
- package/base-template/.squadbase/skills/vantage-app/SKILL.md +6 -6
- package/base-template/.squadbase/skills/vantage-design/SKILL.md +137 -0
- package/base-template/.squadbase/skills/vantage-design/references/extract.md +110 -0
- package/base-template/.squadbase/skills/vantage-design/references/format.md +172 -0
- package/base-template/.squadbase/skills/vantage-design/references/presets.md +110 -0
- package/base-template/.squadbase/skills/vantage-design/scripts/contrast.mjs +166 -0
- package/base-template/AGENTS.md +35 -0
- package/base-template/DESIGN.md +108 -0
- package/base-template/agents/doc.md +73 -0
- package/base-template/agents/page.md +2 -0
- package/base-template/agents/slide.md +7 -0
- package/base-template/bun.lock +907 -0
- package/base-template/package.json +2 -2
- package/base-template/squadbase.yml +1 -0
- package/base-template/src/index.tsx +53 -8
- package/dist/index.js +15 -6
- package/package.json +2 -2
- package/ui-templates/chart-grid/pages/index.tsx +1 -1
- package/ui-templates/chart-grid-ja/pages/index.tsx +1 -1
- package/ui-templates/funnel/pages/index.tsx +2 -2
- package/ui-templates/funnel-ja/pages/index.tsx +2 -2
- package/base-template/package-lock.json +0 -5841
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// WCAG 2.x contrast ratio between two CSS colours. No dependencies.
|
|
3
|
+
//
|
|
4
|
+
// node contrast.mjs <foreground> <background>
|
|
5
|
+
// node contrast.mjs '#ffffff' 'oklch(0.205 0 0)'
|
|
6
|
+
// node contrast.mjs 'oklch(0.985 0 0)' 'var(--color-sky-700)'
|
|
7
|
+
//
|
|
8
|
+
// Accepts: #rgb / #rgba / #rrggbb / #rrggbbaa, rgb()/rgba(), oklch(), and
|
|
9
|
+
// Tailwind palette references `var(--color-<name>-<step>)` (resolved from
|
|
10
|
+
// node_modules/tailwindcss/theme.css, searched upward from the cwd).
|
|
11
|
+
// A translucent foreground is composited over the background first; the
|
|
12
|
+
// background is treated as opaque.
|
|
13
|
+
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs"
|
|
15
|
+
import { dirname, join } from "node:path"
|
|
16
|
+
|
|
17
|
+
function usage(message) {
|
|
18
|
+
if (message) console.error(`error: ${message}`)
|
|
19
|
+
console.error("usage: node contrast.mjs <foreground> <background>")
|
|
20
|
+
console.error(" colours: #hex, rgb(), oklch(), var(--color-<name>-<step>)")
|
|
21
|
+
process.exit(2)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// --- parsing ---------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
function parseNumber(token, percentScale = 1) {
|
|
27
|
+
const t = token.trim()
|
|
28
|
+
if (t === "none") return 0
|
|
29
|
+
if (t.endsWith("%")) return (Number.parseFloat(t) / 100) * percentScale
|
|
30
|
+
const n = Number.parseFloat(t)
|
|
31
|
+
if (Number.isNaN(n)) throw new Error(`not a number: ${token}`)
|
|
32
|
+
return n
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function splitArgs(body) {
|
|
36
|
+
const [main, alpha] = body.split("/")
|
|
37
|
+
const parts = main.trim().split(/[\s,]+/).filter(Boolean)
|
|
38
|
+
return { parts, alpha: alpha === undefined ? 1 : parseNumber(alpha, 1) }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function srgbToLinear(c) {
|
|
42
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function linearToSrgb(c) {
|
|
46
|
+
const v = Math.min(1, Math.max(0, c))
|
|
47
|
+
return v <= 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Returns gamma-encoded sRGB channels in [0, 1] plus alpha.
|
|
51
|
+
function parseHex(input) {
|
|
52
|
+
let hex = input.slice(1)
|
|
53
|
+
if (![3, 4, 6, 8].includes(hex.length) || /[^0-9a-f]/i.test(hex)) {
|
|
54
|
+
throw new Error(`bad hex colour: ${input}`)
|
|
55
|
+
}
|
|
56
|
+
if (hex.length <= 4) hex = [...hex].map((c) => c + c).join("")
|
|
57
|
+
const n = (i) => Number.parseInt(hex.slice(i, i + 2), 16) / 255
|
|
58
|
+
return { r: n(0), g: n(2), b: n(4), a: hex.length === 8 ? n(6) : 1 }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parseRgb(body) {
|
|
62
|
+
const { parts, alpha } = splitArgs(body)
|
|
63
|
+
if (parts.length === 4) return parseRgb(`${parts.slice(0, 3).join(" ")} / ${parts[3]}`)
|
|
64
|
+
if (parts.length !== 3) throw new Error(`bad rgb(): ${body}`)
|
|
65
|
+
const [r, g, b] = parts.map((p) => parseNumber(p, 255) / 255)
|
|
66
|
+
return { r, g, b, a: alpha }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parseOklch(body) {
|
|
70
|
+
const { parts, alpha } = splitArgs(body)
|
|
71
|
+
if (parts.length !== 3) throw new Error(`bad oklch(): ${body}`)
|
|
72
|
+
const L = parseNumber(parts[0], 1)
|
|
73
|
+
const C = parseNumber(parts[1], 0.4)
|
|
74
|
+
const H = (Number.parseFloat(parts[2]) || 0) * (Math.PI / 180)
|
|
75
|
+
const a = C * Math.cos(H)
|
|
76
|
+
const bb = C * Math.sin(H)
|
|
77
|
+
const l_ = (L + 0.3963377774 * a + 0.2158037573 * bb) ** 3
|
|
78
|
+
const m_ = (L - 0.1055613458 * a - 0.0638541728 * bb) ** 3
|
|
79
|
+
const s_ = (L - 0.0894841775 * a - 1.291485548 * bb) ** 3
|
|
80
|
+
const r = 4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_
|
|
81
|
+
const g = -1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_
|
|
82
|
+
const b = -0.0041960863 * l_ - 0.7034186147 * m_ + 1.707614701 * s_
|
|
83
|
+
return { r: linearToSrgb(r), g: linearToSrgb(g), b: linearToSrgb(b), a: alpha }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let tailwindTheme
|
|
87
|
+
function findTailwindTheme() {
|
|
88
|
+
if (tailwindTheme !== undefined) return tailwindTheme
|
|
89
|
+
tailwindTheme = null
|
|
90
|
+
let dir = process.cwd()
|
|
91
|
+
for (;;) {
|
|
92
|
+
for (const rel of [
|
|
93
|
+
"node_modules/tailwindcss/theme.css",
|
|
94
|
+
"node_modules/@squadbase/vantage/node_modules/tailwindcss/theme.css",
|
|
95
|
+
]) {
|
|
96
|
+
const file = join(dir, rel)
|
|
97
|
+
if (existsSync(file)) {
|
|
98
|
+
tailwindTheme = readFileSync(file, "utf8")
|
|
99
|
+
return tailwindTheme
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const parent = dirname(dir)
|
|
103
|
+
if (parent === dir) return tailwindTheme
|
|
104
|
+
dir = parent
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function resolveVar(input) {
|
|
109
|
+
const name = input.match(/^var\(\s*(--color-[a-z]+-\d+)\s*\)$/)?.[1]
|
|
110
|
+
if (!name) throw new Error(`only var(--color-<name>-<step>) can be resolved: ${input}`)
|
|
111
|
+
const theme = findTailwindTheme()
|
|
112
|
+
if (!theme) throw new Error(`tailwindcss/theme.css not found from ${process.cwd()}; pass the value instead`)
|
|
113
|
+
const value = theme.match(new RegExp(`${name}:\\s*([^;]+);`))?.[1]
|
|
114
|
+
if (!value) throw new Error(`${name} is not in tailwindcss/theme.css`)
|
|
115
|
+
return value.trim()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function parseColor(raw) {
|
|
119
|
+
const input = raw.trim().toLowerCase()
|
|
120
|
+
if (input.startsWith("#")) return parseHex(input)
|
|
121
|
+
if (input.startsWith("var(")) return parseColor(resolveVar(input))
|
|
122
|
+
const fn = input.match(/^([a-z]+)\((.*)\)$/)
|
|
123
|
+
if (fn) {
|
|
124
|
+
if (fn[1] === "rgb" || fn[1] === "rgba") return parseRgb(fn[2])
|
|
125
|
+
if (fn[1] === "oklch") return parseOklch(fn[2])
|
|
126
|
+
}
|
|
127
|
+
throw new Error(`unsupported colour: ${raw}`)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// --- contrast --------------------------------------------------------------
|
|
131
|
+
|
|
132
|
+
function composite(fg, bg) {
|
|
133
|
+
const mix = (f, b) => f * fg.a + b * (1 - fg.a)
|
|
134
|
+
return { r: mix(fg.r, bg.r), g: mix(fg.g, bg.g), b: mix(fg.b, bg.b), a: 1 }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function luminance({ r, g, b }) {
|
|
138
|
+
return 0.2126 * srgbToLinear(r) + 0.7152 * srgbToLinear(g) + 0.0722 * srgbToLinear(b)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function toHex({ r, g, b }) {
|
|
142
|
+
const h = (c) => Math.round(Math.min(1, Math.max(0, c)) * 255).toString(16).padStart(2, "0")
|
|
143
|
+
return `#${h(r)}${h(g)}${h(b)}`
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const [fgArg, bgArg] = process.argv.slice(2)
|
|
147
|
+
if (!fgArg || !bgArg) usage()
|
|
148
|
+
|
|
149
|
+
let fg
|
|
150
|
+
let bg
|
|
151
|
+
try {
|
|
152
|
+
bg = { ...parseColor(bgArg), a: 1 }
|
|
153
|
+
fg = composite(parseColor(fgArg), bg)
|
|
154
|
+
} catch (error) {
|
|
155
|
+
usage(error.message)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const [hi, lo] = [luminance(fg), luminance(bg)].sort((x, y) => y - x)
|
|
159
|
+
const ratio = (hi + 0.05) / (lo + 0.05)
|
|
160
|
+
const verdict = (min) => (ratio >= min ? "PASS" : "FAIL")
|
|
161
|
+
|
|
162
|
+
console.log(`foreground ${fgArg} (${toHex(fg)})`)
|
|
163
|
+
console.log(`background ${bgArg} (${toHex(bg)})`)
|
|
164
|
+
console.log(`contrast ${ratio.toFixed(2)}:1`)
|
|
165
|
+
console.log(`AA normal text (>= 4.5:1): ${verdict(4.5)}`)
|
|
166
|
+
console.log(`AA large text / UI (>= 3:1): ${verdict(3)}`)
|
package/base-template/AGENTS.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
> このファイルと `agents/*.md` は、いずれも **Vantage フレームワークが所有する正本**の
|
|
8
8
|
> コピーです。手で書き換えても、`vantage upgrade` を実行するとフレームワーク同梱の正本から
|
|
9
9
|
> 再同期されて上書きされます。アプリ固有のメモは別ファイル(例: `README.md`)に書いてください。
|
|
10
|
+
> 例外はプロジェクトルートの `DESIGN.md` で、これは**ユーザーが所有**します(`vantage upgrade` も
|
|
11
|
+
> `vantage add agents` も触らない。→「デザインの意図(DESIGN.md)」)。
|
|
10
12
|
>
|
|
11
13
|
> 手順を伴う踏み込んだワークフローは、同梱の Claude Code Skill に分かれています。このファイルは
|
|
12
14
|
> 「地図」、`agents/*.md` は「種類ごとの静的リファレンス」、Skill は「手順書」という役割分担です。
|
|
@@ -94,6 +96,7 @@ root/
|
|
|
94
96
|
| `@squadbase/vantage/components` | 複合パーツ(`PageShell`・`DashboardCardPreset`・`DataTablePreset`・`EChart` ほか) |
|
|
95
97
|
| `@squadbase/vantage/table` | `FilePageView`・`TableViewer`(データファイルページの表ビューア) |
|
|
96
98
|
| `@squadbase/vantage/slide` | `SlideDeck`・`Slide`・`Steps`・`Step`・`MorphElement`・`useSlideNumber`・`useIsActiveSlide`(スライド専用。1920×1080 の固定キャンバス) |
|
|
99
|
+
| `@squadbase/vantage/doc` | `Document`(ドキュメント専用。中の素の HTML 要素に見出し・表などのスタイルが当たる) |
|
|
97
100
|
| `@squadbase/vantage/markdown` | `MarkdownRenderer`(Shiki を隔離するための専用サブパス) |
|
|
98
101
|
| `@squadbase/vantage/server` | `ApiContext`・`ApiHandler`・`HttpError`・`isHttpError`・`json`(server/ 側でのみ使う) |
|
|
99
102
|
|
|
@@ -108,6 +111,18 @@ root/
|
|
|
108
111
|
- `server/` が**無い** → 外部 API を直接叩くなら `useQuery`(→ `agents/page.md`)。自前の API が
|
|
109
112
|
要るようになったら `server/api/*.ts` を足すだけでよい(設定変更は不要)。
|
|
110
113
|
|
|
114
|
+
## デザインの意図(DESIGN.md)
|
|
115
|
+
|
|
116
|
+
プロジェクトルートに `DESIGN.md` があれば、**UI(ページ・スライド・コンポーネント)を書く前に
|
|
117
|
+
読む。** 色・チャート・書体・レイアウトの使い分けがトークン名で書いてあるので、それに従って
|
|
118
|
+
トークンで書く(値は `styles.css` にあり、`DESIGN.md` には色コードを書かない)。
|
|
119
|
+
|
|
120
|
+
- **会話中の指示は `DESIGN.md` より優先する。** 同じ指示が繰り返されたら、`DESIGN.md` への
|
|
121
|
+
反映をユーザーに提案する。
|
|
122
|
+
- **「色を変えて」「ブランドに合わせて」などデザイン全体の変更は、ファイルごとに直さない。**
|
|
123
|
+
Skill `vantage-design` の手順で `DESIGN.md` と `styles.css` をまとめて更新する。
|
|
124
|
+
- `DESIGN.md` はユーザーの持ち物。`vantage upgrade` は書き換えない。
|
|
125
|
+
|
|
111
126
|
## 何を書くか → どのファイルを読むか
|
|
112
127
|
|
|
113
128
|
**書こうとしている種類のファイルだけを開けばよい。** まず該当する 1 ファイルを readFiles で
|
|
@@ -118,6 +133,7 @@ root/
|
|
|
118
133
|
| ダッシュボード / 通常ページ(`.tsx`) | `agents/page.md` |
|
|
119
134
|
| API(`server/`) | `agents/api.md` |
|
|
120
135
|
| スライド(`.slide.tsx`) | `agents/slide.md` |
|
|
136
|
+
| ドキュメント(`.doc.tsx`) | `agents/doc.md` |
|
|
121
137
|
| `.xlsx` ページ | `agents/xlsx.md` |
|
|
122
138
|
| `.csv` ページ | `agents/csv.md` |
|
|
123
139
|
|
|
@@ -173,6 +189,7 @@ body・レスポンスの status と形)まで出る。`vantage check --json` /
|
|
|
173
189
|
- **`vantage-app`** — アプリを一から作る / 構成を広げるときの進め方と検証の順序
|
|
174
190
|
- **`vantage-add-feature`** — 既存アプリに page / api / ui を 1 つ足す定型
|
|
175
191
|
- **`vantage-slide`** — `.slide.tsx` でスライドデッキを書く(キャンバスの予算・段階表示・pptx 書き出し)
|
|
192
|
+
- **`vantage-design`** — `DESIGN.md` と `styles.css` をまとめて作る / 直す(配色・書体・ブランド合わせ)
|
|
176
193
|
- **`vantage-pitfalls`** — Base UI(≠ Radix)の癖など、静かに壊れる落とし穴のリファレンス
|
|
177
194
|
- **`project-storage`** — Squadbase の Project Storage(アップロード済みファイル)をブラウザから読み書きする
|
|
178
195
|
|
|
@@ -314,3 +331,21 @@ const res = await fetch(`${baseUrl}/queries/${QUERY_ID}?since=2026-01-01`, {
|
|
|
314
331
|
- **データ取得の失敗は各ページが `ErrorState` で出す。** `BuildRecovery` が拾うのは
|
|
315
332
|
「レンダリングが throw した」場合だけで、`useApiQuery` の `isError` はページの責任
|
|
316
333
|
(→ `agents/page.md` の「データ取得」)。
|
|
334
|
+
|
|
335
|
+
## 依存の追加とスクリプトの実行は bun で
|
|
336
|
+
|
|
337
|
+
このプロジェクトの package manager は **bun** です(`squadbase.yml` の `package_manager: bun`、
|
|
338
|
+
lockfile は `bun.lock`)。Squadbase のサンドボックスは bun と依存のキャッシュを持っており、
|
|
339
|
+
`bun install` はキャッシュだけで終わります。上のフレームワーク規約に出てくる
|
|
340
|
+
`pnpm install` / `pnpm dev` / `pnpm check` は、そのまま `bun install` / `bun run dev` /
|
|
341
|
+
`bun run check` に読み替えてください。
|
|
342
|
+
|
|
343
|
+
### 追加の不変条件
|
|
344
|
+
|
|
345
|
+
- **依存を足すときは `bun add <pkg>`(開発用は `bun add -d <pkg>`)。** `npm install` や
|
|
346
|
+
`pnpm add` を使わない — `package-lock.json` / `pnpm-lock.yaml` が生えて `bun.lock` と別の断面に
|
|
347
|
+
なり、次回起動時の install が lockfile を作り直す。
|
|
348
|
+
- **`bun.lock` を消さない・手で編集しない。** `package.json` の依存を直接書き換えたときは
|
|
349
|
+
`bun install` を一度走らせて `bun.lock` を追従させ、両方を同じコミットに入れる。
|
|
350
|
+
- スクリプトは `bun run <script>`(`bun run dev` / `bun run build` / `bun run check` /
|
|
351
|
+
`bun run routes`)。`npm run <script>` でも動くが、install に npm を使わないこと。
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
DESIGN.md — このアプリの「見た目の意図」を書くファイルです。
|
|
3
|
+
|
|
4
|
+
- 実際の色・角丸・書体の値は src/styles.css にあります。ここにはトークン名(--primary など)と
|
|
5
|
+
使い分けのルールだけを書き、色コードは書きません。
|
|
6
|
+
- エージェントはページ・スライド・コンポーネントを書く前にこのファイルを読みます。
|
|
7
|
+
会話の中での指示はこのファイルより優先されます。
|
|
8
|
+
- 「このサイトに合わせて」「色を落ち着いた感じに」と頼めば、このファイルと styles.css を
|
|
9
|
+
まとめて更新します。
|
|
10
|
+
- このファイルはあなたのものです。`vantage upgrade` が書き換えることはありません。
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
# デザイン
|
|
14
|
+
|
|
15
|
+
## 全体のトーン (Overview)
|
|
16
|
+
|
|
17
|
+
- 落ち着いた無彩色のベースに、データだけが色を持つ業務ダッシュボード。
|
|
18
|
+
- 装飾より読みやすさを優先する。影・グラデーション・アニメーションは最小限。
|
|
19
|
+
- 数字が主役。1 画面で伝えたいことを 1 つに絞り、補足は小さく添える。
|
|
20
|
+
- ブランド素材: なし(ロゴを使う場合は `public/brand/logo.svg` のように `public/` 配下のパスで書く)
|
|
21
|
+
|
|
22
|
+
## 色 (Colors)
|
|
23
|
+
|
|
24
|
+
色は必ずトークン(Tailwind のセマンティッククラス)で指定する。素のパレット(`bg-blue-600` など)や
|
|
25
|
+
色コードを直接書かない。
|
|
26
|
+
|
|
27
|
+
| 役割 | トークン | 使う場所 |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| 主色 (Primary) | `--primary` / `--primary-foreground` | 主要ボタン、選択中の状態。既定は無彩色 |
|
|
30
|
+
| 強調 (Accent) | `--chart-1` | 1 つだけ目立たせたい数値・系列・リンク的な強調 |
|
|
31
|
+
| 良い (Positive) | `--chart-2` | 前期比のプラスなど、良い変化の小さな印 |
|
|
32
|
+
| 悪い (Negative) | `--destructive` | 前期比のマイナス、エラー、削除操作 |
|
|
33
|
+
| 注意 (Warning) | 専用トークンなし | 文言とアイコンで示し、色は `--muted-foreground` |
|
|
34
|
+
| 背景の段階 | `--background` → `--card` → `--muted` | ページ → カード → カード内の区画・ホバー |
|
|
35
|
+
| 境界 | `--border` / `--input` / `--ring` | 罫線、入力欄、フォーカス |
|
|
36
|
+
| 文字 | `--foreground` / `--muted-foreground` | 本文 / 補足・ラベル・単位 |
|
|
37
|
+
|
|
38
|
+
- `--muted`・`--accent`・`--secondary`・`--border` は背景・境界用。文字色に使わない。
|
|
39
|
+
- 増減(▲▼・前期比)は向きで色を分ける: 増加・プラスは `--chart-2`(または `--primary`)、
|
|
40
|
+
減少・マイナスは `--destructive`。下向きの矢印やマイナスを `--primary` で塗らない。
|
|
41
|
+
- ライトとダークの両方がトークンで決まるので `dark:` を並べない。
|
|
42
|
+
|
|
43
|
+
## チャート (Charts)
|
|
44
|
+
|
|
45
|
+
- 系列の順番は `--chart-1` → `--chart-2` → `--chart-3` → `--chart-4` → `--chart-5`
|
|
46
|
+
(現在はプリセット `blue`: 青 → ティール → フクシア → バイオレット → グレー)。
|
|
47
|
+
- 1 系列だけを目立たせるときは、その系列を `--chart-1`、残りをすべて `--chart-5`(グレー)にする。
|
|
48
|
+
- 良い / 悪いを色で塗り分けるときは `--chart-2` / `--destructive`。色だけに頼らず ▲▼ や符号も添える。
|
|
49
|
+
- 系列は 5 つまで。それ以上はグループ化するか「その他」にまとめる。
|
|
50
|
+
- 禁止: 同じチャートで `--destructive` を普通の系列色として使う(悪い値に見える)。
|
|
51
|
+
- 禁止: 隣り合う系列に `--chart-3` と `--chart-4` を並べて細い線で描く(見分けにくい)。
|
|
52
|
+
- 配色を丸ごと変えるときは `npx @squadbase/vantage-template chart <preset>` を使う
|
|
53
|
+
(`blue` / `ocean` / `sunset` / `forest` / `berry` / `mono`)。
|
|
54
|
+
|
|
55
|
+
## 書体 (Typography)
|
|
56
|
+
|
|
57
|
+
| 用途 | 指定 | 備考 |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| 見出し・本文 | システムフォント(`body` の `font-family`) | Web フォントは使わない |
|
|
60
|
+
| 数字 | 同上 + `tabular-nums` | 桁がそろうように必ず付ける |
|
|
61
|
+
| スライドの見出し | `--slide-font-display` | 既定は日本語を含むシステムフォント |
|
|
62
|
+
| スライドの本文 | `--slide-font-body` | 既定は見出しと同じ |
|
|
63
|
+
|
|
64
|
+
サイズの段階(ダッシュボード):
|
|
65
|
+
|
|
66
|
+
- ページ見出し: `text-2xl font-bold`
|
|
67
|
+
- カード見出し・ラベル: `text-sm font-medium text-muted-foreground`
|
|
68
|
+
- KPI の数値: `text-3xl font-semibold tabular-nums`
|
|
69
|
+
- 本文・表: `text-sm`
|
|
70
|
+
- 注釈・出典: `text-xs text-muted-foreground`
|
|
71
|
+
|
|
72
|
+
スライドのサイズは `--slide-size-hero`(表紙・大きな数字)と `--slide-size-body`(本文)を基準にする。
|
|
73
|
+
|
|
74
|
+
## レイアウトと密度 (Layout)
|
|
75
|
+
|
|
76
|
+
- 情報はカード(`bg-card` + `border-border`)で区切る。角丸は `--radius` に従う(個別に変えない)。
|
|
77
|
+
- グリッドの間隔は `gap-4`。セクション間は `gap-6` 程度。
|
|
78
|
+
- KPI は 1 行に 2〜4 枚。その下にチャート、最後に明細の表。
|
|
79
|
+
- 密度は「中」。余白を削って詰め込むより、ページを分ける。
|
|
80
|
+
|
|
81
|
+
## 成果物の種類ごとの規則 (Per-artifact)
|
|
82
|
+
|
|
83
|
+
### ダッシュボード
|
|
84
|
+
|
|
85
|
+
- 先頭に KPI カード、次にトレンドのチャート、最後に明細の表。
|
|
86
|
+
- 各 KPI には比較対象(前月比・目標比など)を 1 つ添える。
|
|
87
|
+
- チャートのタイトルは結論を書く(「売上推移」より「売上は 3 か月連続で増加」)。
|
|
88
|
+
|
|
89
|
+
### スライド
|
|
90
|
+
|
|
91
|
+
- 1 枚に 1 メッセージ。見出しに結論を書く。
|
|
92
|
+
- 色は `--slide-bg` / `--slide-fg` / `--slide-accent` / `--slide-muted` を使う
|
|
93
|
+
(既定では `--background` / `--foreground` / `--primary` / `--muted-foreground` に連動)。
|
|
94
|
+
- 強調色は 1 枚につき 1 か所まで。
|
|
95
|
+
|
|
96
|
+
## Do / Don't
|
|
97
|
+
|
|
98
|
+
Do:
|
|
99
|
+
|
|
100
|
+
- トークンと Tailwind のセマンティッククラスで色を指定する。
|
|
101
|
+
- 数値には単位と比較対象を付ける。
|
|
102
|
+
- 色の意味(良い / 悪い / 強調)をアプリ全体でそろえる。
|
|
103
|
+
|
|
104
|
+
Don't:
|
|
105
|
+
|
|
106
|
+
- 色コードや素のパレットクラスを直接書く。
|
|
107
|
+
- 1 画面で強調色を何か所にも使う。
|
|
108
|
+
- 3D チャート・円グラフの多用・装飾目的のグラデーション。
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# ドキュメント(.doc.tsx)
|
|
2
|
+
|
|
3
|
+
フレームワーク所有の知識ファイルで、`vantage upgrade` で再同期されます。`.doc.tsx` で
|
|
4
|
+
ドキュメントを書くときに読んでください。不変条件・ディレクトリ構造は `AGENTS.md` を
|
|
5
|
+
先に読んでいる想定です。
|
|
6
|
+
|
|
7
|
+
## ドキュメントは `.doc.tsx` で書く
|
|
8
|
+
|
|
9
|
+
`src/june-summary.doc.tsx` → `/june-summary`。上から下へ読む文章のページで、表やチャートを
|
|
10
|
+
文中に置けます。中身は `<Document>` を返す普通の React コンポーネントで、`definePage` もナビも
|
|
11
|
+
通常のページと同じように効きます。
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { definePage } from "@squadbase/vantage"
|
|
15
|
+
import { EChart } from "@squadbase/vantage/components"
|
|
16
|
+
import { Document } from "@squadbase/vantage/doc"
|
|
17
|
+
|
|
18
|
+
export const page = definePage({ title: "6月度サマリー", navLabel: "6月度サマリー" })
|
|
19
|
+
export default function JuneSummary() {
|
|
20
|
+
return (
|
|
21
|
+
<Document>
|
|
22
|
+
<h1>6月度サマリー</h1>
|
|
23
|
+
<p>6月の売上は <strong>5,250 万円</strong>で、目標を 5% 上回りました。</p>
|
|
24
|
+
<h2>週次の売上</h2>
|
|
25
|
+
<figure>
|
|
26
|
+
<EChart option={option} height={280} ariaLabel="6月の週次売上" />
|
|
27
|
+
<figcaption>第4週はキャンペーン初週</figcaption>
|
|
28
|
+
</figure>
|
|
29
|
+
<table>…</table>
|
|
30
|
+
</Document>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 書き方
|
|
36
|
+
|
|
37
|
+
- **素の HTML 要素で書く。** `<Document>` の中の `h1`〜`h4`・`p`・`ul`/`ol`/`li`・`table`・
|
|
38
|
+
`blockquote`・`pre`/`code`・`hr`・`a`・`figure`/`figcaption`・`img` には、見出しの大きさ・余白・
|
|
39
|
+
罫線などが最初から当たっています。クラスは要りません。
|
|
40
|
+
- **Tailwind のユーティリティは、その要素だけ見た目を変えたいときに使う。** 要素の既定の
|
|
41
|
+
スタイルはユーティリティより弱いので、`className` を付ければそちらが勝ちます。ドキュメント全体の
|
|
42
|
+
見た目を変えたいときはユーティリティを並べず、下の `--doc-*` を変えます。
|
|
43
|
+
- **数値はコードに直接書く。** ドキュメントは書いた時点の内容を残すページです。
|
|
44
|
+
`useApiQuery` などで読み込むと、開くたびに値が変わります。
|
|
45
|
+
- **チャートは `EChart`(`@squadbase/vantage/components`)を文中に置く。** `figure` で囲めば
|
|
46
|
+
`figcaption` がキャプションになります。
|
|
47
|
+
- **ページ全体を包むのは `<Document>` だけ。** `PageShell` などのダッシュボード用の枠で包まない
|
|
48
|
+
(本文の幅と余白は `<Document>` が決めます)。
|
|
49
|
+
|
|
50
|
+
## 見た目を変える
|
|
51
|
+
|
|
52
|
+
配色・書体・本文の幅は `--doc-*` の CSS 変数です。既定値はアプリのトークンへの別名なので、
|
|
53
|
+
ダークモードにもそのまま追従します。
|
|
54
|
+
|
|
55
|
+
| 変数 | 既定値 | 何に効くか |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `--doc-fg` | `var(--foreground)` | 本文の文字色 |
|
|
58
|
+
| `--doc-muted` | `var(--muted-foreground)` | 引用・キャプション |
|
|
59
|
+
| `--doc-accent` | `var(--primary)` | リンク |
|
|
60
|
+
| `--doc-border` | `var(--border)` | 表・`h2` の下線・引用・`hr` |
|
|
61
|
+
| `--doc-subtle` | `var(--muted)` | コード・表の見出し行の背景 |
|
|
62
|
+
| `--doc-font-body` / `--doc-font-heading` / `--doc-font-mono` | アプリの書体 | 本文 / 見出し / コード |
|
|
63
|
+
| `--doc-size-body` | `1rem` | 本文の文字サイズ(見出しはこれに比例) |
|
|
64
|
+
| `--doc-line-height` | `1.8` | 本文の行間 |
|
|
65
|
+
| `--doc-max-width` | `48rem` | 本文の幅 |
|
|
66
|
+
|
|
67
|
+
アプリのすべてのドキュメントに効かせるなら `styles.css` の `:root` で定義し直します。1 つの
|
|
68
|
+
ドキュメントだけなら `<Document theme={{ accent: "#2563eb", maxWidth: "56rem" }}>` のように
|
|
69
|
+
`theme` で渡します(`theme` のキーは変数名から `--doc-` を外してキャメルケースにしたもの)。
|
|
70
|
+
|
|
71
|
+
`.doc` を付けられるのはルートになるページモジュールだけで、`_layout.doc.tsx` などは
|
|
72
|
+
`INVALID_PAGE_VARIANT` エラーになります。`june.doc.tsx` と `june.tsx` は同じ URL に解決するので
|
|
73
|
+
`ROUTE_CONFLICT` です。
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
スライドデッキを書くときに読んでください。不変条件・ディレクトリ構造は `AGENTS.md` を
|
|
5
5
|
先に読んでいる想定です。
|
|
6
6
|
|
|
7
|
+
プロジェクトルートに `DESIGN.md` があれば、書き始める前に読んで「スライド」の節と配色・書体の規則に従う。
|
|
8
|
+
|
|
7
9
|
## スライドは `.slide.tsx` で書く
|
|
8
10
|
|
|
9
11
|
`src/monthly-report.slide.tsx` → `/monthly-report`。中身は `<SlideDeck>` を返す普通の React
|
|
@@ -23,6 +25,11 @@ export default function Deck() {
|
|
|
23
25
|
}
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
**`<Slide>` は `<SlideDeck>` の直接の子に書く。** `SlideDeck` は直下の `<Slide>` 要素だけを数えるので、
|
|
29
|
+
`<Slide>` を自作コンポーネント(`<Slide1 />` など)や Fragment で包むと 1 枚も数えられず「1 / 0」に
|
|
30
|
+
なります(`{items.map((x) => <Slide key={x.id}>…</Slide>)}` のような配列は可)。共通の部品は
|
|
31
|
+
`<Slide>` の**中**に置くコンポーネントとして切り出します(`<Slide><CoverPage /></Slide>`)。
|
|
32
|
+
|
|
26
33
|
1920×1080 の固定キャンバスに絶対 px で書き、画面サイズに合わせて縮小されます。キー / クリックで
|
|
27
34
|
送れ、左のスライド一覧(サムネイル列)は `L` で開閉、`F` で全画面、ツールバーから pptx を
|
|
28
35
|
書き出せます。**書き方の作法は同梱 Skill の
|