Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contributors panel. #13

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@hookform/resolvers": "^3.4.2",
"@nextui-org/react": "^2.4.1",
"@notionhq/client": "^2.2.15",
"@radix-ui/react-avatar": "^1.1.0",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
Expand Down
28 changes: 28 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 5 additions & 1 deletion src/app/topics/mpox/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from "@/components/ui/hover-card";
import Image from "next/image";
import ReferencesPanel, { Reference } from "@/components/references-panel";
import ContributorsPanel from "@/components/contributors-panel";

const references: Reference[] = [
{
Expand Down Expand Up @@ -34,7 +35,10 @@ export default function MpoxPage() {
return (
<div className="relative min-h-screen">
<div className="fixed right-12 top-32 z-10">
<ReferencesPanel references={references} className="py-2" />
<div className="flex flex-col space-y-2">
<ReferencesPanel references={references} className="py-2" />
<ContributorsPanel contributors={["terje"]} />
</div>
</div>
<section className="flex flex-col space-y-6 p-2">
<h1 className="text-3xl font-bold">Overview</h1>
Expand Down
104 changes: 104 additions & 0 deletions src/components/contributors-panel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet";
import { Button } from "@/components/ui/button";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";

interface Contributor {
name: string;
alias: string;
email: string;
github?: string;
twitter?: string;
linkedin?: string;
}

export const CONTRIBUTORS: Contributor[] = [
{
name: "Erik Hjerde",
alias: "erik",
email: "[email protected]",
},
{
name: "Espen Åberg",
alias: "espen",
email: "[email protected]",
},
{
name: "Terje Klemetsen",
alias: "terje",
email: "[email protected]",
},
{
name: "Peter Wilfred Kovachich",
alias: "peter",
email: "[email protected]",
},
{
name: "Sebastian Petters",
alias: "sebastian",
email: "[email protected]",
},
{
name: "Dorota Julia Buczek",
alias: "dorota",
email: "[email protected]",
},
] as const;

function getEmailByAlias(alias: string) {
const contributor = CONTRIBUTORS.find((it) => it.alias === alias);
return contributor ? contributor.email : null;
}

function getNameByAlias(alias: string) {
const contributor = CONTRIBUTORS.find((it) => it.alias === alias);
return contributor ? contributor.name : null;
}

export default function ContributorsPanel({
contributors,
}: {
contributors: string[];
}) {
return (
<Sheet>
<SheetTrigger asChild>
<Button variant="outline">Contributors</Button>
</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle className="text-xl font-bold">Contributors</SheetTitle>
<SheetDescription></SheetDescription>
</SheetHeader>
<div className="flex flex-col space-y-6">
{contributors.map((contributor) => (
<div
key={contributor}
className="flex flex-row items-center justify-start space-x-6"
>
<Avatar>
<AvatarImage src={`/people/${contributor}.jpg`} />
<AvatarFallback>{contributor[0]}</AvatarFallback>
</Avatar>
<div className="flex flex-col">
<p className="font-bold">{getNameByAlias(contributor)}</p>
<a
className="italic text-primary hover:underline"
href={`mailto:${getEmailByAlias(contributor)}`}
>
{getEmailByAlias(contributor)}
</a>
</div>
</div>
))}
</div>
</SheetContent>
</Sheet>
);
}
51 changes: 51 additions & 0 deletions src/components/ui/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"use client";

import * as React from "react";
import * as AvatarPrimitive from "@radix-ui/react-avatar";

import { cn } from "@/lib/utils";

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
className
)}
{...props}
/>
));
Avatar.displayName = AvatarPrimitive.Root.displayName;

const AvatarImage = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
className={cn("aspect-square h-full w-full", className)}
{...props}
/>
));
AvatarImage.displayName = AvatarPrimitive.Image.displayName;

const AvatarFallback = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
"flex h-full w-full items-center justify-center rounded-full bg-muted",
className
)}
{...props}
/>
));
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;

// @ts-ignore
export { Avatar, AvatarImage, AvatarFallback };