medkit/src/kit/date-leaf.tsx

33 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { cn } from "@/lib/utils"
const WEEKDAYS = ["вс", "пн", "вт", "ср", "чт", "пт", "сб"]
const MONTHS = ["янв", "фев", "мар", "апр", "мая", "июн", "июл", "авг", "сен", "окт", "ноя", "дек"]
/** Дата приёма «листком календаря». */
export function DateLeaf({ date, upcoming }: { date: string; upcoming?: boolean }) {
const [d, m, y] = date.split(".").map(Number)
const weekday = WEEKDAYS[new Date(y, m - 1, d).getDay()]
return (
<div
className={cn(
"flex w-12 shrink-0 flex-col items-center overflow-hidden rounded-lg border bg-card text-center leading-none",
upcoming ? "border-primary/30" : "",
)}
>
<div
className={cn(
"w-full py-1 text-[10px] font-semibold uppercase",
upcoming ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground",
)}
>
{weekday}
</div>
<div className="pt-1.5 text-lg font-semibold tabular">{d}</div>
<div className="pb-1.5 text-[10px] text-muted-foreground">
{MONTHS[m - 1]} {String(y).slice(2)}
</div>
</div>
)
}