feat: implement staff directory list view with search and filters

This commit is contained in:
dhinesh-m24
2026-01-29 16:26:08 +05:30
parent 7133e59e57
commit 9e19ee7592
22 changed files with 2379 additions and 39 deletions

View File

@@ -0,0 +1,35 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "../../../lib/utils"
const badgeVariants = cva(
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
)
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
)
}
export { Badge, badgeVariants }

View File

@@ -1,40 +1,83 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
"inline-flex items-center justify-center transition-premium gap-2 whitespace-nowrap rounded-xl text-base font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 active:scale-[0.98]",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground hover:opacity-90",
destructive:
"bg-destructive text-destructive-foreground hover:opacity-90",
outline:
"border border-primary text-primary bg-transparent hover:bg-primary/5 hover:text-primary/90 hover:border-primary/90",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-10 px-5 py-6",
sm: "h-9 rounded-md px-3 text-xs",
lg: "h-11 rounded-lg px-8 text-base",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link"
size?: "default" | "sm" | "lg" | "icon"
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
leadingIcon?: React.ReactNode
trailingIcon?: React.ReactNode
}
/**
* Button component based on Shadcn UI.
* Supports variants (default, destructive, outline, secondary, ghost, link)
* and sizes (default, sm, lg, icon).
* Now supports leadingIcon and trailingIcon props.
*/
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant = "default", size = "default", ...props }, ref) => {
const baseStyles = "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
const variants = {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
}
({ className, variant, size, asChild = false, leadingIcon, trailingIcon, children, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
const sizes = {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3 text-xs",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
// If asChild is true, we just render children as per standard Slot behavior
if (asChild) {
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
>
{children}
</Comp>
)
}
return (
<button
className={`${baseStyles} ${variants[variant]} ${sizes[size]} ${className || ''}`}
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
>
{leadingIcon && <span className="w-4 h-4 shrink-0">{leadingIcon}</span>}
{children}
{trailingIcon && <span className="w-4 h-4 shrink-0">{trailingIcon}</span>}
</Comp>
)
}
)
Button.displayName = "Button"
export { Button }
export { Button }

View File

@@ -0,0 +1,80 @@
import * as React from "react"
import { cn } from "../../../lib/utils"
/**
* Card component family based on Shadcn UI.
* Used for grouping content in a contained area.
*/
const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-2xl border border-slate-200 bg-white transition-all duration-300",
className
)}
{...props}
/>
))
Card.displayName = "Card"
const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-8", className)}
{...props}
/>
))
CardHeader.displayName = "CardHeader"
const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn("text-xl font-bold leading-none tracking-tight text-slate-900", className)}
{...props}
/>
))
CardTitle.displayName = "CardTitle"
const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-slate-500/90 leading-relaxed", className)}
{...props}
/>
))
CardDescription.displayName = "CardDescription"
const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-8 pt-0", className)} {...props} />
))
CardContent.displayName = "CardContent"
const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-8 pt-0", className)}
{...props}
/>
))
CardFooter.displayName = "CardFooter"
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }

View File

@@ -0,0 +1,21 @@
import * as React from "react"
import { cn } from "@/lib/utils"
const Checkbox = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(
({ className, ...props }, ref) => {
return (
<input
type="checkbox"
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
ref={ref}
{...props}
/>
)
}
)
Checkbox.displayName = "Checkbox"
export { Checkbox }

View File

@@ -1,18 +1,49 @@
import * as React from "react"
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
import { cn } from "@/lib/utils"
/**
* Input component based on Shadcn UI.
* A basic input field with consistent styling.
*/
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
leadingIcon?: React.ReactNode
trailingIcon?: React.ReactNode
}
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => (
<input
type={type}
className={`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm transition-colors ${className || ''}`}
ref={ref}
{...props}
/>
)
({ className, type, leadingIcon, trailingIcon, ...props }, ref) => {
return (
<div className="relative w-full group">
{leadingIcon && (
<div className="absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center pointer-events-none text-muted-foreground/60 group-focus-within:text-primary transition-colors">
<div className="w-4 h-4 flex items-center justify-center">
{leadingIcon}
</div>
</div>
)}
<input
type={type}
className={cn(
"flex h-12 w-full rounded-xl border border-input bg-white/70 px-4 py-3 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:border-primary focus-visible:bg-white transition-all duration-300 disabled:cursor-not-allowed disabled:opacity-50",
leadingIcon && "pl-11",
trailingIcon && "pr-11",
className
)}
ref={ref}
{...props}
/>
{trailingIcon && (
<div className="absolute right-4 top-1/2 -translate-y-1/2 flex items-center justify-center pointer-events-none text-muted-foreground/60 group-focus-within:text-primary transition-colors">
<div className="w-4 h-4 flex items-center justify-center">
{trailingIcon}
</div>
</div>
)}
</div>
)
}
)
Input.displayName = "Input"
export { Input }
export { Input }

View File

@@ -0,0 +1,86 @@
import * as React from "react"
import { cn } from "../../../lib/utils"
import { ChevronDown } from "lucide-react"
const SelectContext = React.createContext<any>(null);
export const Select = ({ value, onValueChange, children }: any) => {
const [open, setOpen] = React.useState(false);
const containerRef = React.useRef<HTMLDivElement>(null);
React.useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
setOpen(false);
}
};
document.addEventListener("mousedown", handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
};
}, []);
return (
<SelectContext.Provider value={{ value, onValueChange, open, setOpen }}>
<div className="relative" ref={containerRef}>{children}</div>
</SelectContext.Provider>
)
}
export const SelectTrigger = ({ className, children, leadingIcon, trailingIcon }: any) => {
const { open, setOpen } = React.useContext(SelectContext);
return (
<button
type="button"
onClick={() => setOpen(!open)}
className={cn(
"flex h-12 w-full capitalize items-center gap-3 rounded-xl border border-input bg-background/50 px-4 py-3 text-sm transition-all duration-300 focus:outline-none focus:border-primary focus:bg-background disabled:cursor-not-allowed disabled:opacity-50 group",
className
)}
>
{leadingIcon && (
<div className="w-4 h-4 flex items-center justify-center text-muted-foreground/60 group-focus:text-primary transition-colors shrink-0">
{leadingIcon}
</div>
)}
<div className="flex-1 text-left overflow-hidden whitespace-nowrap">
{children}
</div>
<div className="flex items-center gap-2 shrink-0">
{trailingIcon && (
<div className="w-4 h-4 flex items-center justify-center text-muted-foreground/60 group-focus:text-primary transition-colors">
{trailingIcon}
</div>
)}
<ChevronDown className={cn("h-4 w-4 opacity-50 transition-transform duration-200", open && "rotate-180")} />
</div>
</button>
)
}
export const SelectValue = ({ placeholder }: any) => {
const { value } = React.useContext(SelectContext);
return <span className="block truncate">{value || placeholder}</span>
}
export const SelectContent = ({ children, className }: any) => {
const { open } = React.useContext(SelectContext);
if (!open) return null;
return (
<div className={cn("absolute z-50 min-w-[8rem] overflow-hidden rounded-md border bg-white text-popover-foreground animate-in fade-in-80 mt-1 w-full max-h-60 overflow-y-auto", className)}>
<div className="p-1">{children}</div>
</div>
)
}
export const SelectItem = ({ value, children, className }: any) => {
const { onValueChange, setOpen } = React.useContext(SelectContext);
return (
<div
onClick={() => { onValueChange(value); setOpen(false); }}
className={cn("relative capitalize flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-2 text-sm outline-none hover:bg-slate-100 cursor-pointer", className)}
>
{children}
</div>
)
}

View File

@@ -0,0 +1,20 @@
import * as React from "react"
import { cn } from "@/lib/utils"
const Textarea = React.forwardRef<HTMLTextAreaElement, React.TextareaHTMLAttributes<HTMLTextAreaElement>>(
({ className, ...props }, ref) => {
return (
<textarea
className={cn(
"flex min-h-[120px] w-full rounded-xl border border-input bg-background/50 px-4 py-3 text-sm placeholder:text-muted-foreground/50 focus-visible:outline-none focus-visible:border-primary focus-visible:bg-background transition-all duration-300 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
{...props}
/>
)
}
)
Textarea.displayName = "Textarea"
export { Textarea }