/** * Copyright (C) Paul Sarando * Distributed under the Eclipse Public License (http://www.eclipse.org/legal/epl-v10.html). */ import React from "react"; import { CalendarDate, datesMatch } from "../Utils"; import "./tolkien-calendars.css"; interface DateCellProps { className: string; currentDate: Date; date: CalendarDate; description: string; emoji: string; month: string; weekday: string; } interface GregorianDateDisplayProps { date: Date; } const dateKey = (date: CalendarDate, suffix?: string | number) => `${date.month}/${date.day}${suffix}`; const getDateColor = ( monthColor: string, date1: Date | undefined, date2: Date ) => { if (date1 && datesMatch(date1, date2)) { return "highlight"; } return monthColor; }; const GregorianDateDisplay = (props: GregorianDateDisplayProps) => (
{props.date.toDateString()}
); const DateCell = (props: DateCellProps) => { const { className, currentDate, date: { gregorian, day }, description, emoji, month, weekday, } = props; const dayColor = getDateColor(className, gregorian, currentDate); const day1 = day === 1; const dateDisplay = day1 ? month : day; const dateDisplayClassName = day1 ? "month-name-display" : "date-display"; return (
{day1 && emoji}
{dateDisplay}
); }; export { dateKey, getDateColor, GregorianDateDisplay }; export default DateCell;