74 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-04-30 22:48:36 -04:00
"use client"
import Image from "next/image"
import Logo from "@/assets/logo.svg"
2024-04-30 22:48:36 -04:00
import { Pencil, Users } from "lucide-react"
2024-04-11 05:14:10 -04:00
import Link from "next/link"
2024-04-27 00:28:00 -04:00
import { Sandbox, User } from "@/lib/types"
2024-04-18 15:32:27 -04:00
import UserButton from "@/components/ui/userButton"
2024-04-30 22:48:36 -04:00
import { Button } from "@/components/ui/button"
import { useState } from "react"
import EditSandboxModal from "./edit"
import ShareSandboxModal from "./share"
2024-05-03 14:58:56 -07:00
import { Avatars } from "../live/avatars"
2024-04-08 23:40:42 -04:00
2024-04-27 00:28:00 -04:00
export default function Navbar({
userData,
sandboxData,
2024-05-01 01:53:49 -04:00
shared,
2024-04-27 00:28:00 -04:00
}: {
userData: User
sandboxData: Sandbox
2024-05-01 01:53:49 -04:00
shared: {
id: string
name: string
}[]
2024-04-27 00:28:00 -04:00
}) {
2024-04-30 22:48:36 -04:00
const [isEditOpen, setIsEditOpen] = useState(false)
const [isShareOpen, setIsShareOpen] = useState(false)
2024-04-08 23:40:42 -04:00
return (
2024-04-30 22:48:36 -04:00
<>
<EditSandboxModal
open={isEditOpen}
setOpen={setIsEditOpen}
data={sandboxData}
/>
<ShareSandboxModal
open={isShareOpen}
setOpen={setIsShareOpen}
data={sandboxData}
2024-05-01 01:53:49 -04:00
shared={shared}
2024-04-30 22:48:36 -04:00
/>
<div className="h-14 px-2 w-full flex items-center justify-between border-b border-border">
<div className="flex items-center space-x-4">
<Link
href="/"
className="ring-offset-2 transition-all ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-md"
>
<Image src={Logo} alt="Logo" width={36} height={36} />
</Link>
<div className="text-sm font-medium flex items-center">
{sandboxData.name}
<button
onClick={() => setIsEditOpen(true)}
className="h-7 w-7 ml-2 flex items-center justify-center bg-transparent hover:bg-muted-foreground/25 cursor-pointer rounded-md ring-offset-2 transition-all ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
<Pencil className="w-4 h-4" />
</button>
</div>
</div>
2024-04-30 22:48:36 -04:00
<div className="flex items-center space-x-4">
2024-05-03 14:58:56 -07:00
<Avatars />
2024-04-30 22:48:36 -04:00
<Button variant="outline" onClick={() => setIsShareOpen(true)}>
<Users className="w-4 h-4 mr-2" />
Share
</Button>
<UserButton userData={userData} />
</div>
2024-04-08 23:40:42 -04:00
</div>
2024-04-30 22:48:36 -04:00
</>
2024-04-08 23:40:42 -04:00
)
}