Skip to content

Commit 4459b14

Browse files
authored
feat: adjust table component (#92)
* feat: apply whitespace-nowrap to th and match table colors with CodeBlock * test: update thead/tbody test codes * chore: add changeset for table component update * test: adjust th test code
1 parent 7a128a2 commit 4459b14

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.changeset/new-masks-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"streamdown": patch
3+
---
4+
5+
apply whitespace-nowrap to th and match table colors with CodeBlock

packages/streamdown/__tests__/components.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ describe("Markdown Components", () => {
325325
);
326326
const thead = container.querySelector("thead");
327327
expect(thead).toBeTruthy();
328-
expect(thead?.className).toContain("bg-muted/50");
328+
expect(thead?.className).toContain("bg-muted/80");
329329
});
330330

331331
it("should render tbody with correct classes", () => {
@@ -341,6 +341,7 @@ describe("Markdown Components", () => {
341341
expect(tbody).toBeTruthy();
342342
expect(tbody?.className).toContain("divide-y");
343343
expect(tbody?.className).toContain("divide-border");
344+
expect(tbody?.className).toContain("bg-muted/40");
344345
});
345346

346347
it("should render tr with correct classes", () => {
@@ -361,6 +362,7 @@ describe("Markdown Components", () => {
361362
const { container } = render(<TH node={null as any}>Header</TH>);
362363
const th = container.querySelector("th");
363364
expect(th).toBeTruthy();
365+
expect(th?.className).toContain("whitespace-nowrap");
364366
expect(th?.className).toContain("px-4");
365367
expect(th?.className).toContain("py-2");
366368
expect(th?.className).toContain("text-left");

packages/streamdown/lib/components.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export const components: Options["components"] = {
214214
),
215215
thead: ({ node, children, className, ...props }) => (
216216
<thead
217-
className={cn("bg-muted/50", className)}
217+
className={cn("bg-muted/80", className)}
218218
data-streamdown="table-header"
219219
{...props}
220220
>
@@ -223,7 +223,7 @@ export const components: Options["components"] = {
223223
),
224224
tbody: ({ node, children, className, ...props }) => (
225225
<tbody
226-
className={cn("divide-y divide-border", className)}
226+
className={cn("divide-y bg-muted/40 divide-border", className)}
227227
data-streamdown="table-body"
228228
{...props}
229229
>
@@ -241,7 +241,7 @@ export const components: Options["components"] = {
241241
),
242242
th: ({ node, children, className, ...props }) => (
243243
<th
244-
className={cn("px-4 py-2 text-left font-semibold text-sm", className)}
244+
className={cn("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm", className)}
245245
data-streamdown="table-header-cell"
246246
{...props}
247247
>

0 commit comments

Comments
 (0)