import { Card, CardContent, CardDescription, CardHeader, CardTitle, CodeBlock, } from "@godxjp/ui/data-display"; import { Flex, PageContainer } from "@godxjp/ui/layout"; const responseBody = `{ "data": { "id": 2, "key": "EXSELI-2", "title": "見積画面で合計が更新されない", "attachments": [ { "id": 7, "name": "trace.har", "size": 65536 }, { "id": 8, "name": "screenshot.png", "size": 240113 } ] } }`; const consoleLog = `[12:04:11.203] warn Deprecated: estimate.total is read before hydrate() [12:04:11.209] error TypeError: Cannot read properties of undefined (reading 'total') at EstimateSummary (estimate-summary.tsx:41:17) [12:04:11.210] info retry 1/3`; const longHeader = 'report-to: {"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=' + "x".repeat(200) + '"}],"group":"cf-nel","max_age":604800}'; /** * CodeBlock — a block of preformatted text: request and response bodies, console output, * snippets. Wraps long lines by default and scrolls inside the block past `maxHeight`. * Composed only from real @godxjp/ui components. */ export default function Demo() { return ( Response body (maxHeight="sm") 64 KB のレスポンスでもページを押し下げない。上限を超えるとブロック内でスクロールする。 {responseBody} Console (size="xs", maxHeight="md") ログは xs で密に。行の折り返しは既定で有効。 {consoleLog} Long line: wrap (default) vs wrap={"{false}"} 241 文字のヘッダー値。既定はカード内で折り返す。wrap=false は横スクロールになる (maxHeight="lg" / "none")。 {longHeader} {longHeader} Syntax colour · the package owns the palette (gh#784) CodeBlock bundles no highlighter. Bring your own, then tag each span with data-code-token and the package colours it. The twelve names are Shiki createCssVariablesTheme's verbatim, so mapping is a rename rather than a translation. Note what the consumer never writes: no style attribute, no palette class. Every knob is a role-mirror, so this follows the theme into dark with no second palette. {"// resolve the active tenant\n"} export{" "} async{" "} function{" "} loadTenant ( slug :{" "} string ){" "} {"{"} {"\n "} const res{" "} ={" "} await{" "} fetch ( {"`/api/tenants/"} {"${slug}"} {"`"} ) ; {"\n "} return res . json () ; {"\n"} {"}"} Diff tokens · inserted and deleted The same vocabulary carries a diff. inserted, deleted and changed default to the success, destructive and warning roles, so they agree with every other affirmative and destructive mark in the system rather than inventing a second green and red. {"--- a/tokens.css\n+++ b/tokens.css\n"} {"- --code-block-foreground: #111;\n"} {"+ --code-block-foreground: initial;\n"} {"! --code-block-token-changed-color: initial;\n"} {" /* role-mirror: the default moved to the call site */"} ); }