mirror of
https://github.com/inventree/InvenTree.git
synced 2026-07-05 06:32:55 +00:00
[UI] Calendar month colors (#12157)
Discriminate months which slightly different colors
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import type {
|
import type {
|
||||||
CalendarOptions,
|
CalendarOptions,
|
||||||
DatesSetArg,
|
DatesSetArg,
|
||||||
|
DayCellContentArg,
|
||||||
EventContentArg
|
EventContentArg
|
||||||
} from '@fullcalendar/core';
|
} from '@fullcalendar/core';
|
||||||
import allLocales from '@fullcalendar/core/locales-all';
|
import allLocales from '@fullcalendar/core/locales-all';
|
||||||
@@ -182,6 +183,25 @@ export default function Calendar({
|
|||||||
[calendarProps.eventContent, eventTooltipContent]
|
[calendarProps.eventContent, eventTooltipContent]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const monthDayCellClassNames = useCallback(
|
||||||
|
(arg: DayCellContentArg): string[] => {
|
||||||
|
const monthClass =
|
||||||
|
arg.date.getMonth() % 2 === 0
|
||||||
|
? 'fc-day-month-even'
|
||||||
|
: 'fc-day-month-odd';
|
||||||
|
const existing = calendarProps.dayCellClassNames;
|
||||||
|
if (!existing) return [monthClass];
|
||||||
|
if (typeof existing === 'function') {
|
||||||
|
const result = existing(arg);
|
||||||
|
const arr = Array.isArray(result) ? result : result ? [result] : [];
|
||||||
|
return [monthClass, ...arr];
|
||||||
|
}
|
||||||
|
if (Array.isArray(existing)) return [monthClass, ...existing];
|
||||||
|
return [monthClass, existing as string];
|
||||||
|
},
|
||||||
|
[calendarProps.dayCellClassNames]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{state.exportModal.modal}
|
{state.exportModal.modal}
|
||||||
@@ -309,6 +329,11 @@ export default function Calendar({
|
|||||||
{...calendarProps}
|
{...calendarProps}
|
||||||
datesSet={datesSet}
|
datesSet={datesSet}
|
||||||
eventContent={wrappedEventContent}
|
eventContent={wrappedEventContent}
|
||||||
|
dayCellClassNames={
|
||||||
|
isScrollView
|
||||||
|
? monthDayCellClassNames
|
||||||
|
: calendarProps.dayCellClassNames
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
padding: 0.35em 0;
|
padding: 0.35em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Alternating month backgrounds in the multi-month scroll calendar view */
|
||||||
|
[data-mantine-color-scheme='light'] .fc-day-month-odd:not(.fc-day-today) {
|
||||||
|
background-color: var(--mantine-color-gray-1);
|
||||||
|
}
|
||||||
|
[data-mantine-color-scheme='dark'] .fc-day-month-odd:not(.fc-day-today) {
|
||||||
|
background-color: var(--mantine-color-dark-4);
|
||||||
|
}
|
||||||
|
|
||||||
/* mantine-datatable overrides */
|
/* mantine-datatable overrides */
|
||||||
.mantine-datatable-pointer-cursor,
|
.mantine-datatable-pointer-cursor,
|
||||||
.mantine-datatable-context-menu-cursor {
|
.mantine-datatable-context-menu-cursor {
|
||||||
|
|||||||
Reference in New Issue
Block a user