Refactor UI components, add notification bell icon and count

This commit is contained in:
Pattadon 2024-09-13 13:56:58 +07:00
parent c2c81ac08b
commit 72d72a550e
2 changed files with 90 additions and 32 deletions

View File

@ -1,6 +1,7 @@
"use client"; "use client";
import { Card, CardContent } from "@/components/ui/card"; import { Card, CardContent } from "@/components/ui/card";
import { BellIcon } from "lucide-react";
export default function Notification() { export default function Notification() {
const sampleNotifications = [ const sampleNotifications = [
@ -17,7 +18,24 @@ export default function Notification() {
<Card className=" border-slate-800 w-3/4 p-6"> <Card className=" border-slate-800 w-3/4 p-6">
<CardContent> <CardContent>
<Card> <Card>
<CardContent>1</CardContent> <CardContent>
{sampleNotifications.map((notification, index) => (
<div key={index} className="flex items-center justify-between p-4 bg-white border-b border-gray-200">
<div className="flex items-center">
<BellIcon className="w-5 h-5 text-blue-500 mr-3" />
<div>
<p className="text-sm font-medium text-gray-900">
{notification.message}
</p>
<p className="text-xs text-gray-500">{notification.time}</p>
</div>
</div>
<button className="text-sm text-blue-500 hover:text-blue-600">
Mark as read
</button>
</div>
))}
</CardContent>
</Card> </Card>
</CardContent> </CardContent>
</Card> </Card>

View File

@ -45,27 +45,31 @@ const landings = [
route: "/crm-landing", route: "/crm-landing",
}, },
]; ];
const ListItem = React.forwardRef<React.ElementRef<"a">, React.ComponentPropsWithoutRef<"a">>( const ListItem = React.forwardRef<
({ className, title, children, ...props }, ref) => { React.ElementRef<"a">,
return ( React.ComponentPropsWithoutRef<"a">
<li> >(({ className, title, children, ...props }, ref) => {
<NavigationMenuLink asChild> return (
<a <li>
ref={ref} <NavigationMenuLink asChild>
className={cn( <a
"block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground", ref={ref}
className className={cn(
)} "block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
{...props}> className
<div className="text-sm font-medium leading-none">{title}</div> )}
<hr /> {...props}
<p className="line-clamp-2 text-sm leading-snug text-muted-foreground">{children}</p> >
</a> <div className="text-sm font-medium leading-none">{title}</div>
</NavigationMenuLink> <hr />
</li> <p className="line-clamp-2 text-sm leading-snug text-muted-foreground">
); {children}
} </p>
); </a>
</NavigationMenuLink>
</li>
);
});
ListItem.displayName = "ListItem"; ListItem.displayName = "ListItem";
const unAuthenticatedComponents = () => { const unAuthenticatedComponents = () => {
@ -82,14 +86,28 @@ const unAuthenticatedComponents = () => {
}; };
const authenticatedComponents = () => { const authenticatedComponents = () => {
let notifications = 100;
const displayValue = notifications >= 100 ? "..." : notifications;
return ( return (
<div className="flex gap-3 pl-2 items-center"> <div className="flex gap-3 pl-2 items-center">
<Bell /> <Link href={"/notification"}>
{" "}
<div className="relative inline-block">
<Bell className="h-6 w-6" />
<span className="absolute -top-1 -right-1 inline-flex items-center justify-center w-4 h-4 text-xs font-bold text-white bg-red-600 rounded-full">
{displayValue}
</span>
</div>
</Link>
<Heart /> <Heart />
<Wallet /> <Wallet />
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button variant="outline" size="icon" className="overflow-hidden rounded-full"> <Button
variant="outline"
size="icon"
className="overflow-hidden rounded-full"
>
<Avatar> <Avatar>
<AvatarImage src="https://api.dicebear.com/9.x/pixel-art/svg" /> <AvatarImage src="https://api.dicebear.com/9.x/pixel-art/svg" />
<AvatarFallback>1</AvatarFallback> <AvatarFallback>1</AvatarFallback>
@ -153,7 +171,8 @@ export function NavigationBar() {
<Link <Link
className="flex-none text-xl font-semibold dark:text-white focus:outline-none focus:opacity-80" className="flex-none text-xl font-semibold dark:text-white focus:outline-none focus:opacity-80"
href="/" href="/"
aria-label="Brand"> aria-label="Brand"
>
<span className="inline-flex items-center gap-x-2 text-xl font-semibold dark:text-white"> <span className="inline-flex items-center gap-x-2 text-xl font-semibold dark:text-white">
<Image src="./logo.svg" alt="logo" width={50} height={50} /> <Image src="./logo.svg" alt="logo" width={50} height={50} />
B2DVentures B2DVentures
@ -165,11 +184,17 @@ export function NavigationBar() {
<NavigationMenu> <NavigationMenu>
<NavigationMenuList> <NavigationMenuList>
<NavigationMenuItem> <NavigationMenuItem>
<NavigationMenuTrigger className="text-base">Businesses</NavigationMenuTrigger> <NavigationMenuTrigger className="text-base">
Businesses
</NavigationMenuTrigger>
<NavigationMenuContent> <NavigationMenuContent>
<ul className="grid w-[400px] "> <ul className="grid w-[400px] ">
{businessComponents.map((component) => ( {businessComponents.map((component) => (
<ListItem key={component.title} title={component.title} href={component.href}> <ListItem
key={component.title}
title={component.title}
href={component.href}
>
{component.description} {component.description}
</ListItem> </ListItem>
))} ))}
@ -178,11 +203,17 @@ export function NavigationBar() {
</NavigationMenuItem> </NavigationMenuItem>
<NavigationMenuItem> <NavigationMenuItem>
<NavigationMenuTrigger className="text-base font-medium ">Projects</NavigationMenuTrigger> <NavigationMenuTrigger className="text-base font-medium ">
Projects
</NavigationMenuTrigger>
<NavigationMenuContent> <NavigationMenuContent>
<ul className="grid w-[400px] "> <ul className="grid w-[400px] ">
{projectComponents.map((component) => ( {projectComponents.map((component) => (
<ListItem key={component.title} title={component.title} href={component.href}> <ListItem
key={component.title}
title={component.title}
href={component.href}
>
{component.description} {component.description}
</ListItem> </ListItem>
))} ))}
@ -191,11 +222,17 @@ export function NavigationBar() {
</NavigationMenuItem> </NavigationMenuItem>
<NavigationMenuItem> <NavigationMenuItem>
<NavigationMenuTrigger className="text-base">Blogs</NavigationMenuTrigger> <NavigationMenuTrigger className="text-base">
Blogs
</NavigationMenuTrigger>
<NavigationMenuContent> <NavigationMenuContent>
<ul className="grid w-[400px] "> <ul className="grid w-[400px] ">
{blogComponents.map((component) => ( {blogComponents.map((component) => (
<ListItem key={component.title} title={component.title} href={component.href}> <ListItem
key={component.title}
title={component.title}
href={component.href}
>
{component.description} {component.description}
</ListItem> </ListItem>
))} ))}
@ -204,7 +241,10 @@ export function NavigationBar() {
</NavigationMenuItem> </NavigationMenuItem>
<NavigationMenuItem> <NavigationMenuItem>
<NavigationMenuLink className="text-base font-medium" href="docs"> <NavigationMenuLink
className="text-base font-medium"
href="docs"
>
Docs Docs
</NavigationMenuLink> </NavigationMenuLink>
</NavigationMenuItem> </NavigationMenuItem>