nyuchimzizi
Mzizi — an open-architecture project of the Bundu Foundation, operated and developed by Nyuchi. Built on the Five African Minerals palette.
Built by Nyuchi Africav4.0.39
Date/time availability grid for bookings. Shows available, partially available, and unavailable slots with mineral color coding. Used for vehicle booking (Transport), venue booking (Nhimbe), and appointment scheduling (Health).
View the full component source code below.
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
type SlotStatus = "available" | "partial" | "unavailable" | "selected"
interface TimeSlot {
time: string
status: SlotStatus
}
interface BookingDay {
date: string
label: string
slots: TimeSlot[]
}
interface BookingCalendarProps extends React.ComponentProps<"div"> {
days: BookingDay[]
selectedSlot?: { date: string; time: string }
onSlotSelect?: (date: string, time: string) => void
}
const slotStyles: Record<SlotStatus, string> = {
available: "bg-[var(--color-malachite,#64FFDA)]/10 text-foreground hover:bg-[var(--color-malachite,#64FFDA)]/20 cursor-pointer",
partial: "bg-[var(--color-gold,#FFD740)]/10 text-foreground hover:bg-[var(--color-gold,#FFD740)]/20 cursor-pointer",
unavailable: "bg-muted/30 text-muted-foreground/40 cursor-not-allowed",
selected: "bg-primary text-primary-foreground ring-2 ring-primary/30",
}
function BookingCalendar({ days, selectedSlot, onSlotSelect, loading = false, className, ...props }: BookingCalendarProps) {
return (
<div data-slot="booking-calendar" data-portal="https://design.nyuchi.com/components/booking-calendar" className={cn("overflow-x-auto", className)} role="grid" aria-label="Booking availability" {...props}>
<div className="inline-flex gap-3 pb-2">
{days.map(day => (
<div key={day.date} className="w-28 shrink-0">
<div className="mb-2 text-center text-xs font-medium">{day.label}</div>
<div className="space-y-1">
{day.slots.map(slot => {
const isSelected = selectedSlot?.date === day.date && selectedSlot?.time === slot.time
const effectiveStatus = isSelected ? "selected" : slot.status
return (
<button
key={slot.time}
disabled={slot.status === "unavailable"}
onClick={() => slot.status !== "unavailable" && onSlotSelect?.(day.date, slot.time)}
aria-label={`${slot.time} on ${day.label}: ${slot.status}`}
aria-pressed={isSelected}
className={cn(
"w-full rounded-[var(--radius-sm,7px)] py-1.5 text-center text-xs font-medium transition-colors",
slotStyles[effectiveStatus]
)}
>
{slot.time}
</button>
)
})}
</div>
</div>
))}
</div>
<div className="mt-2 flex items-center gap-4 text-[9px] text-muted-foreground">
<span className="flex items-center gap-1"><span className="size-2 rounded-full bg-[var(--color-malachite,#64FFDA)]/40" /> Available</span>
<span className="flex items-center gap-1"><span className="size-2 rounded-full bg-[var(--color-gold,#FFD740)]/40" /> Limited</span>
<span className="flex items-center gap-1"><span className="size-2 rounded-full bg-muted" /> Unavailable</span>
</div>
</div>
)
}
export { BookingCalendar }
export type { BookingCalendarProps }
npx shadcn@latest add https://mzizi.dev/api/v1/ui/booking-calendarFetch this component's metadata and source code from the registry API.
/api/v1/ui/booking-calendar