@remit/ui 0.0.210 → 0.0.211
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/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import { renderToString } from "react-dom/server";
|
|
5
|
+
import { PaneHeader, type PaneHeaderProps } from "./pane-header.js";
|
|
6
|
+
|
|
7
|
+
const html = (props: PaneHeaderProps): string =>
|
|
8
|
+
renderToString(createElement(PaneHeader, props));
|
|
9
|
+
|
|
10
|
+
describe("PaneHeader", () => {
|
|
11
|
+
it("names the pane in its heading", () => {
|
|
12
|
+
assert.match(html({ title: "Outbox" }), /<h1[^>]*>Outbox<\/h1>/);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("draws no heading when the pane has no title", () => {
|
|
16
|
+
assert.doesNotMatch(html({}), /<h1/);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("sits on the pane-header datum", () => {
|
|
20
|
+
assert.match(html({ title: "Outbox" }), /h-pane-header/);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Decorator, Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { ArrowLeft, Menu } from "lucide-react";
|
|
3
|
+
import { expect, within } from "storybook/test";
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
import { PaneHeader } from "./pane-header.js";
|
|
6
|
+
|
|
7
|
+
const listPaneFrame: Decorator = (Story) => (
|
|
8
|
+
<div
|
|
9
|
+
className="overflow-hidden rounded-lg border border-line bg-canvas"
|
|
10
|
+
style={{ width: 360 }}
|
|
11
|
+
>
|
|
12
|
+
<Story />
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const meta: Meta<typeof PaneHeader> = {
|
|
17
|
+
title: "Design System/Mail/PaneHeader",
|
|
18
|
+
component: PaneHeader,
|
|
19
|
+
parameters: { layout: "centered" },
|
|
20
|
+
decorators: [listPaneFrame],
|
|
21
|
+
args: { title: "Outbox" },
|
|
22
|
+
};
|
|
23
|
+
export default meta;
|
|
24
|
+
|
|
25
|
+
type Story = StoryObj<typeof PaneHeader>;
|
|
26
|
+
|
|
27
|
+
export const Title: Story = {
|
|
28
|
+
play: async ({ canvasElement }) => {
|
|
29
|
+
await expect(
|
|
30
|
+
within(canvasElement).getByRole("heading", { level: 1, name: "Outbox" }),
|
|
31
|
+
).toBeVisible();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const WithMenuAndCount: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
leading: (
|
|
38
|
+
<Button
|
|
39
|
+
variant="ghost"
|
|
40
|
+
size="sm"
|
|
41
|
+
aria-label="Menu"
|
|
42
|
+
icon={<Menu className="size-4" />}
|
|
43
|
+
/>
|
|
44
|
+
),
|
|
45
|
+
children: (
|
|
46
|
+
<span className="shrink-0 text-2xs text-fg-subtle">3 messages</span>
|
|
47
|
+
),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const BackOnly: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
title: undefined,
|
|
54
|
+
leading: (
|
|
55
|
+
<Button
|
|
56
|
+
variant="ghost"
|
|
57
|
+
size="sm"
|
|
58
|
+
icon={<ArrowLeft className="size-3.5" />}
|
|
59
|
+
>
|
|
60
|
+
Back to Inbox
|
|
61
|
+
</Button>
|
|
62
|
+
),
|
|
63
|
+
},
|
|
64
|
+
play: async ({ canvasElement }) => {
|
|
65
|
+
await expect(within(canvasElement).queryByRole("heading")).toBeNull();
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Blank: Story = { args: { title: undefined } };
|
|
70
|
+
|
|
71
|
+
export const LongTitle: Story = {
|
|
72
|
+
args: {
|
|
73
|
+
title:
|
|
74
|
+
"Consolidated quarterly reconciliation of the shared drive migration",
|
|
75
|
+
},
|
|
76
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
|
|
4
|
+
export interface PaneHeaderProps {
|
|
5
|
+
title?: string;
|
|
6
|
+
leading?: ReactNode;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function PaneHeader({
|
|
12
|
+
title,
|
|
13
|
+
leading,
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
}: PaneHeaderProps) {
|
|
17
|
+
return (
|
|
18
|
+
<header
|
|
19
|
+
className={cn(
|
|
20
|
+
"flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset",
|
|
21
|
+
className,
|
|
22
|
+
)}
|
|
23
|
+
>
|
|
24
|
+
{leading}
|
|
25
|
+
{title !== undefined && (
|
|
26
|
+
<h1 className="min-w-0 flex-1 truncate text-sm font-semibold text-fg">
|
|
27
|
+
{title}
|
|
28
|
+
</h1>
|
|
29
|
+
)}
|
|
30
|
+
{children}
|
|
31
|
+
</header>
|
|
32
|
+
);
|
|
33
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -645,6 +645,7 @@ export {
|
|
|
645
645
|
type OutboxStatusBadgeProps,
|
|
646
646
|
outboxStatusConfig,
|
|
647
647
|
} from "./components/outbox-status-badge.js";
|
|
648
|
+
export { PaneHeader, type PaneHeaderProps } from "./components/pane-header.js";
|
|
648
649
|
export {
|
|
649
650
|
PasswordInput,
|
|
650
651
|
type PasswordInputProps,
|