feat(chart): add @hm-design/chart package with Bar, Line, Donut, Pie, Radar, Area and Radial charts
- new workspace package packages/chart (shadcn/ui Chart + Recharts, HM Theme tokens), examples entry with sample data - Storybook Chart group (src/chart), consumer example (examples/chart), build:chart / build:chart-example scripts - README rewritten as the AI usage guide (install, CSS wiring, chart selection, data rules, verification) - docs: package count/list, Submodule guide (chart workspace, React dedupe), shared AI_GUIDE row, MAINTAINING, story inventory
This commit is contained in:
1 parent
228944a06b
commit
dc9258599c
56 files changed
+3979
-28
No files matched your search
@@ -7,7 +7,7 @@ import { build } from "vite"
|
||||
|
||||
const root = fileURLToPath(new URL("../", import.meta.url))
|
||||
const name = process.argv[2]
|
||||
if (!["ui", "center-graphic"].includes(name)) throw new Error("Expected ui or center-graphic")
|
||||
if (!["ui", "center-graphic", "chart"].includes(name)) throw new Error("Expected ui, center-graphic or chart")
|
||||
const packageRoot = path.join(root, "packages", name)
|
||||
const output = path.join(packageRoot, "dist")
|
||||
const manifest = JSON.parse(await readFile(path.join(packageRoot, "package.json"), "utf8"))
|
||||
@@ -26,7 +26,9 @@ await build({
|
||||
lib: {
|
||||
entry: name === "ui"
|
||||
? { index: path.join(packageRoot, "src/index.ts"), "theme/index": path.join(packageRoot, "src/theme/index.ts") }
|
||||
: { index: path.join(packageRoot, "src/index.ts"), reference: path.join(packageRoot, "src/reference.ts") },
|
||||
: name === "chart"
|
||||
? { index: path.join(packageRoot, "src/index.ts"), examples: path.join(packageRoot, "src/examples/index.ts") }
|
||||
: { index: path.join(packageRoot, "src/index.ts"), reference: path.join(packageRoot, "src/reference.ts") },
|
||||
formats: ["es"],
|
||||
fileName: (_format, entry) => `${entry}.js`,
|
||||
cssFileName: "style",
|
||||
@@ -35,7 +37,7 @@ await build({
|
||||
external: id => externals.some(dep => id === dep || id.startsWith(`${dep}/`)),
|
||||
onwarn(warning, warn) {
|
||||
// The UI component entrypoint retains the directive below; source directives are redundant.
|
||||
if (name === "ui" && warning.code === "MODULE_LEVEL_DIRECTIVE") return
|
||||
if ((name === "ui" || name === "chart") && warning.code === "MODULE_LEVEL_DIRECTIVE") return
|
||||
warn(warning)
|
||||
},
|
||||
},
|
||||
@@ -89,6 +91,15 @@ if (name === "ui") {
|
||||
.replace('/fonts/NotoSansKR-variable.ttf', './fonts/NotoSansKR-variable.ttf')
|
||||
await writeFile(path.join(output, "theme.css"), theme)
|
||||
await cp(path.join(packageRoot, "src/patterns/dashboard-status/dashboard-status.css"), path.join(output, "dashboard-status.css"))
|
||||
} else if (name === "chart") {
|
||||
// The chart stylesheet loads with the component entry. Tailwind utilities used by the shadcn Chart markup
|
||||
// are generated in the consumer app, so ship the same @source entry as @hm-design/ui/tailwind.css.
|
||||
// Both entries share one chunk, so each loads the stylesheet and keeps the client directive Rolldown drops.
|
||||
for (const entry of ["index.js", "examples.js"]) {
|
||||
const file = path.join(output, entry)
|
||||
await writeFile(file, `"use client";\nimport "./style.css";\n${await readFile(file, "utf8")}`)
|
||||
}
|
||||
await cp(path.join(packageRoot, "src/tailwind.css"), path.join(output, "tailwind.css"))
|
||||
} else {
|
||||
// Preserve CENTER's existing automatic component CSS behavior for both public entrypoints.
|
||||
for (const entry of ["index.js", "reference.js"]) {
|
||||
|
||||
Reference in new issue
Block a user