-
Notifications
You must be signed in to change notification settings - Fork 315
Expand file tree
/
Copy pathcommitParts.tsx
More file actions
90 lines (81 loc) · 2.72 KB
/
Copy pathcommitParts.tsx
File metadata and controls
90 lines (81 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import type { ReactNode } from "react";
import Link from "next/link";
import { MoreHorizontal } from "lucide-react";
import { AvatarGroup, AvatarGroupCount } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { Toggle } from "@/components/ui/toggle";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { UserAvatar } from "@/components/userAvatar";
import { cn } from "@/lib/utils";
import type { Author } from "./commitAuthors";
interface AuthorsAvatarGroupProps {
authors: Author[];
className?: string;
}
export const AuthorsAvatarGroup = ({ authors, className }: AuthorsAvatarGroupProps) => {
const displayed = authors.slice(0, 2);
const overflow = Math.max(0, authors.length - 2);
return (
<AvatarGroup className={cn("flex-shrink-0", className)}>
{displayed.map((a) => (
<UserAvatar
key={a.email}
email={a.email}
title={a.email}
className="h-5 w-5"
/>
))}
{overflow > 0 && (
<AvatarGroupCount className="size-5 text-xs">
+{overflow}
</AvatarGroupCount>
)}
</AvatarGroup>
);
};
interface CommitBodyToggleProps {
pressed: boolean;
onPressedChange: (pressed: boolean) => void;
}
export const CommitBodyToggle = ({ pressed, onPressedChange }: CommitBodyToggleProps) => (
<Tooltip>
<TooltipTrigger asChild>
<Toggle
pressed={pressed}
onPressedChange={onPressedChange}
aria-label="Open commit details"
>
<MoreHorizontal />
</Toggle>
</TooltipTrigger>
<TooltipContent>Open commit details</TooltipContent>
</Tooltip>
);
interface CommitBodyProps {
body: string;
className?: string;
}
export const CommitBody = ({ body, className }: CommitBodyProps) => (
<div className={cn("px-3 py-2 bg-muted/30", className)}>
<pre className="text-sm font-mono text-foreground whitespace-pre-wrap break-words">
{body.trim()}
</pre>
</div>
);
interface CommitActionLinkProps {
href: string;
label: string;
icon: ReactNode;
}
export const CommitActionLink = ({ href, label, icon }: CommitActionLinkProps) => (
<Tooltip>
<TooltipTrigger asChild>
<Button asChild variant="ghost" size="sm" className="h-6 w-6 text-muted-foreground">
<Link href={href} aria-label={label}>
{icon}
</Link>
</Button>
</TooltipTrigger>
<TooltipContent>{label}</TooltipContent>
</Tooltip>
);