This commit is contained in:
@@ -304,14 +304,14 @@ const CalendarWeek = ({
|
||||
);
|
||||
};
|
||||
|
||||
function maybeYear(yearMonthString: string) {
|
||||
function srOnlyYear(yearMonthString: string) {
|
||||
// formatYearMonth only shows the year for non-current years; always expose it to screen readers
|
||||
const yearMonth = new Date(yearMonthString);
|
||||
const now = new Date();
|
||||
const isCurrentYear = yearMonth.getFullYear() == now.getFullYear();
|
||||
if (isCurrentYear) {
|
||||
return <span className="sr-only"> {yearMonth.getFullYear()}</span>;
|
||||
const isCurrentYear = yearMonth.getFullYear() === new Date().getFullYear();
|
||||
if (!isCurrentYear) {
|
||||
return null;
|
||||
}
|
||||
return ` ${yearMonth.getFullYear()}`;
|
||||
return <span className="sr-only"> {yearMonth.getFullYear()}</span>;
|
||||
}
|
||||
|
||||
const EventCalendar = ({ events }: { events: EventOverviewItemFragment[] }) => {
|
||||
@@ -354,7 +354,7 @@ const EventCalendar = ({ events }: { events: EventOverviewItemFragment[] }) => {
|
||||
>
|
||||
<h2 onClick={() => toggleYearMonth(yearMonth)}>
|
||||
{formatYearMonth(yearMonth)}
|
||||
{maybeYear(yearMonth)}{" "}
|
||||
{srOnlyYear(yearMonth)}{" "}
|
||||
<span className={styles.eventCounter}>({eventCount})</span>
|
||||
</h2>
|
||||
{eventCount === 0 && (
|
||||
|
||||
Reference in New Issue
Block a user