feat(github): unify workspace GitHub access (#2084)
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
"use client";
|
||||
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { IconInfoCircle } from "@tabler/icons-react";
|
||||
import { Button } from "@kandev/ui/button";
|
||||
import {
|
||||
Drawer,
|
||||
DrawerContent,
|
||||
DrawerDescription,
|
||||
DrawerHeader,
|
||||
DrawerTitle,
|
||||
DrawerTrigger,
|
||||
} from "@kandev/ui/drawer";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip";
|
||||
import { useTouchDrawer } from "@/hooks/use-compact-task-chrome";
|
||||
|
||||
export function GitHubAccessHelp({
|
||||
label,
|
||||
title,
|
||||
description,
|
||||
content,
|
||||
}: {
|
||||
label: string;
|
||||
title: string;
|
||||
description: string;
|
||||
content?: ReactNode;
|
||||
}) {
|
||||
const usesTouchDrawer = useTouchDrawer();
|
||||
const [open, setOpen] = useState(false);
|
||||
const button = (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-11 w-11 shrink-0 cursor-pointer text-muted-foreground sm:h-6 sm:w-6"
|
||||
aria-haspopup={usesTouchDrawer ? "dialog" : undefined}
|
||||
aria-expanded={usesTouchDrawer ? open : undefined}
|
||||
aria-label={label}
|
||||
>
|
||||
<IconInfoCircle className="h-4 w-4" />
|
||||
</Button>
|
||||
);
|
||||
const trigger = usesTouchDrawer ? (
|
||||
<DrawerTrigger asChild>{button}</DrawerTrigger>
|
||||
) : (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
||||
<TooltipContent side="top" align="start" className="max-w-[320px] text-xs leading-relaxed">
|
||||
{content ?? description}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
return (
|
||||
<Drawer open={open} onOpenChange={setOpen}>
|
||||
{trigger}
|
||||
<DrawerContent>
|
||||
<DrawerHeader>
|
||||
<DrawerTitle>{title}</DrawerTitle>
|
||||
<DrawerDescription className={content ? "sr-only" : undefined}>
|
||||
{description}
|
||||
</DrawerDescription>
|
||||
</DrawerHeader>
|
||||
{content && <div className="px-4 pb-4">{content}</div>}
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user