@tangle-network/ui 11.50.1 → 11.50.2
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/CHANGELOG.md +6 -0
- package/dist/lib/code-presentation.js +1 -1
- package/dist/markdown/code-block.js +2 -2
- package/package.json +1 -1
- package/src/lib/code-presentation.ts +1 -1
- package/src/markdown/code-block.test.tsx +0 -6
- package/src/markdown/code-block.tsx +2 -2
- package/src/markdown/markdown.stories.tsx +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @tangle-network/ui
|
|
2
2
|
|
|
3
|
+
## 11.50.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 035f031: `codePresentation.header` carries the header's type (`font-sans text-sm`), so a server-rendered code block header built from it shows its label and a text copy button in the header type, not the code font. The React `CodeBlock` label takes it from the header.
|
|
8
|
+
|
|
3
9
|
## 11.50.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -189,7 +189,7 @@ const codePresentation = {
|
|
|
189
189
|
tabs: `tangle-code-tabs ${tabsPresentation.list.underline}`,
|
|
190
190
|
tab: tabsPresentation.trigger.underline,
|
|
191
191
|
root: "group relative min-w-0 overflow-hidden rounded-lg border font-mono bg-card border-border",
|
|
192
|
-
header: "flex flex-wrap items-center justify-between gap-3 border-b border-border px-3 py-1.5 bg-[var(--code-header-bg,hsl(var(--background)))]",
|
|
192
|
+
header: "flex flex-wrap items-center justify-between gap-3 border-b border-border px-3 py-1.5 font-sans text-sm bg-[var(--code-header-bg,hsl(var(--background)))]",
|
|
193
193
|
copy: "flex items-center justify-center min-w-8 min-h-8 pointer-coarse:min-w-11 pointer-coarse:min-h-11 rounded-md bg-muted border border-border hover:border-[var(--border-strong)] transition-colors data-[copy-loading=true]:after:content-['…'] data-[copy-loading=true]:gap-1",
|
|
194
194
|
copyStatus: "sr-only data-[copy-long-work=true]:not-sr-only data-[copy-long-work=true]:text-xs data-[copy-long-work=true]:text-muted-foreground"
|
|
195
195
|
};
|
|
@@ -58,7 +58,7 @@ const CodeBlock = memo(({ code: defaultCode, language: defaultLanguage, label, f
|
|
|
58
58
|
children: apiMetadataText(metadata)
|
|
59
59
|
}),
|
|
60
60
|
filename ? /* @__PURE__ */ jsxs("span", {
|
|
61
|
-
className: "flex min-w-0 items-center gap-2
|
|
61
|
+
className: "flex min-w-0 items-center gap-2",
|
|
62
62
|
children: [
|
|
63
63
|
/* @__PURE__ */ jsx(FileCode2, {
|
|
64
64
|
"aria-hidden": true,
|
|
@@ -75,7 +75,7 @@ const CodeBlock = memo(({ code: defaultCode, language: defaultLanguage, label, f
|
|
|
75
75
|
})
|
|
76
76
|
]
|
|
77
77
|
}) : /* @__PURE__ */ jsx("span", {
|
|
78
|
-
className: "font-
|
|
78
|
+
className: "font-medium text-muted-foreground",
|
|
79
79
|
children: headerLabel
|
|
80
80
|
}),
|
|
81
81
|
children,
|
package/package.json
CHANGED
|
@@ -142,7 +142,7 @@ export const codePresentation = {
|
|
|
142
142
|
tabs: `tangle-code-tabs ${tabsPresentation.list.underline}`,
|
|
143
143
|
tab: tabsPresentation.trigger.underline,
|
|
144
144
|
root: "group relative min-w-0 overflow-hidden rounded-lg border font-mono bg-card border-border",
|
|
145
|
-
header: "flex flex-wrap items-center justify-between gap-3 border-b border-border px-3 py-1.5 bg-[var(--code-header-bg,hsl(var(--background)))]",
|
|
145
|
+
header: "flex flex-wrap items-center justify-between gap-3 border-b border-border px-3 py-1.5 font-sans text-sm bg-[var(--code-header-bg,hsl(var(--background)))]",
|
|
146
146
|
copy: "flex items-center justify-center min-w-8 min-h-8 pointer-coarse:min-w-11 pointer-coarse:min-h-11 rounded-md bg-muted border border-border hover:border-[var(--border-strong)] transition-colors data-[copy-loading=true]:after:content-['…'] data-[copy-loading=true]:gap-1",
|
|
147
147
|
copyStatus: "sr-only data-[copy-long-work=true]:not-sr-only data-[copy-long-work=true]:text-xs data-[copy-long-work=true]:text-muted-foreground",
|
|
148
148
|
};
|
|
@@ -188,12 +188,6 @@ describe("CodeBlock", () => {
|
|
|
188
188
|
expect(screen.getByRole("button", { name: "Copied" })).toBeTruthy();
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
-
it("renders the header label at the 14px text-sm step", () => {
|
|
192
|
-
const { getByText } = render(<CodeBlock code={"x"} label="YAML" />);
|
|
193
|
-
expect(getByText("YAML").className).toContain("text-sm");
|
|
194
|
-
expect(getByText("YAML").className).not.toContain("calc(");
|
|
195
|
-
});
|
|
196
|
-
|
|
197
191
|
it("announces a failed copy", async () => {
|
|
198
192
|
const writeText = vi.fn().mockRejectedValue(new Error("denied"));
|
|
199
193
|
Object.defineProperty(navigator, "clipboard", { value: { writeText }, configurable: true });
|
|
@@ -83,13 +83,13 @@ export const CodeBlock = memo(
|
|
|
83
83
|
<div className={codePresentation.header}>
|
|
84
84
|
{metadata && <span className="tangle-api-meta">{apiMetadataText(metadata)}</span>}
|
|
85
85
|
{filename ? (
|
|
86
|
-
<span className="flex min-w-0 items-center gap-2
|
|
86
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
87
87
|
<FileCode2 aria-hidden className="size-4 shrink-0 text-muted-foreground" />
|
|
88
88
|
<span className="min-w-0 truncate font-mono font-medium text-foreground" title={filename}>{filename}</span>
|
|
89
89
|
{languageName && <span className="shrink-0 text-muted-foreground">{languageName}</span>}
|
|
90
90
|
</span>
|
|
91
91
|
) : (
|
|
92
|
-
<span className="font-
|
|
92
|
+
<span className="font-medium text-muted-foreground">{headerLabel}</span>
|
|
93
93
|
)}
|
|
94
94
|
{children}
|
|
95
95
|
{examples?.length ? <CopyButton text={code}/> : null}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
2
|
import { Markdown } from './markdown'
|
|
3
3
|
import { CodeBlock, CopyButton } from './code-block'
|
|
4
|
+
import { codePresentation } from '../lib/code-presentation'
|
|
4
5
|
|
|
5
6
|
// ─── Markdown ────────────────────────────────────────────────────────────────
|
|
6
7
|
|
|
@@ -228,6 +229,14 @@ export const CodeBlockLabelledCopy: Story = {
|
|
|
228
229
|
<CodeBlock code={`<script src="https://embed.tangle.tools/agent.js" data-agent="support"></script>`} language="html" label="HTML">
|
|
229
230
|
<CopyButton text={`<script src="https://embed.tangle.tools/agent.js" data-agent="support"></script>`} label="Copy embed code" />
|
|
230
231
|
</CodeBlock>
|
|
232
|
+
{/* A server-rendered host (tangle-router) builds the same header from codePresentation alone. */}
|
|
233
|
+
<div className={`${codePresentation.root} mt-4`}>
|
|
234
|
+
<div className={codePresentation.header}>
|
|
235
|
+
<span>bash</span>
|
|
236
|
+
<button type="button" className={codePresentation.copy}>Copy</button>
|
|
237
|
+
</div>
|
|
238
|
+
<pre className="p-3"><code>export TANGLE_API_KEY="sk-tan-..."</code></pre>
|
|
239
|
+
</div>
|
|
231
240
|
</div>
|
|
232
241
|
),
|
|
233
242
|
}
|