diff --git a/public/locales/en/modules/calendar.json b/public/locales/en/modules/calendar.json index 9460bcfa6..8fcfdf442 100644 --- a/public/locales/en/modules/calendar.json +++ b/public/locales/en/modules/calendar.json @@ -15,6 +15,9 @@ }, "hideWeekDays": { "label": "Hide week days" + }, + "fontSize": { + "label": "Font Size" } } } diff --git a/src/widgets/calendar/CalendarDay.tsx b/src/widgets/calendar/CalendarDay.tsx index a7e307ebd..9cd4734b5 100644 --- a/src/widgets/calendar/CalendarDay.tsx +++ b/src/widgets/calendar/CalendarDay.tsx @@ -1,18 +1,46 @@ -import { Container, Indicator, IndicatorProps, Popover } from '@mantine/core'; +import { Container, Indicator, IndicatorProps, Popover, useMantineTheme, Button } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; import { MediaList } from './MediaList'; import { MediasType } from './type'; + interface CalendarDayProps { date: Date; medias: MediasType; + size: string; } -export const CalendarDay = ({ date, medias }: CalendarDayProps) => { +export const CalendarDay = ({ date, medias, size }: CalendarDayProps) => { const [opened, { close, open }] = useDisclosure(false); - - if (medias.totalCount === 0) { - return
{date.getDate()}
; + const { radius, fn } = useMantineTheme(); + var indicatorSize = 10; + var indicatorOffset = -4; + switch(size){ + case "xs": { + indicatorSize += 0; + indicatorOffset -= 0; + break; + } + case "sm": { + indicatorSize += 1; + indicatorOffset -= 1; + break; + } + case "md": { + indicatorSize += 2; + indicatorOffset -= 1; + break; + } + case "lg": { + indicatorSize += 3; + indicatorOffset -= 2; + break; + } + case "xl": { + indicatorSize += 4; + indicatorOffset -= 3; + break; + } } return ( @@ -29,11 +57,23 @@ export const CalendarDay = ({ date, medias }: CalendarDayProps) => { opened={opened} > - - - - - + 0 ? open : undefined} + sx={{ root: { + padding:'18% !important', + height: '100%', + width: '100%', + alignContent: 'center', + borderRadius: ['xs','sm'].includes(size) ? radius.md : radius.lg, + borderStyle: "solid", + borderWidth: "0.2rem", + borderColor: opened ? fn.primaryColor() : 'transparent', + }}} + > + + + +
{date.getDate()}
@@ -49,17 +89,19 @@ export const CalendarDay = ({ date, medias }: CalendarDayProps) => { }; interface DayIndicatorProps { + size: any; + offset: any; color: string; medias: any[]; children: JSX.Element; position: IndicatorProps['position']; } -const DayIndicator = ({ color, medias, children, position }: DayIndicatorProps) => { +const DayIndicator = ({ size, offset, color, medias, children, position }: DayIndicatorProps) => { if (medias.length === 0) return children; return ( - + {children} ); diff --git a/src/widgets/calendar/CalendarTile.tsx b/src/widgets/calendar/CalendarTile.tsx index 705167bca..67e93fada 100644 --- a/src/widgets/calendar/CalendarTile.tsx +++ b/src/widgets/calendar/CalendarTile.tsx @@ -37,6 +37,17 @@ const definition = defineWidget({ { label: 'Digital', value: 'digitalRelease' }, ], }, + fontSize:{ + type: 'select', + defaultValue: 'xs', + data: [ + { label: 'Extra Small', value: 'xs' }, + { label: 'Small', value: 'sm' }, + { label: 'Medium', value: 'md' }, + { label: 'Large', value: 'lg' }, + { label: 'Extra Large', value: 'xl' }, + ] + }, }, gridstack: { minWidth: 2, @@ -54,7 +65,7 @@ interface CalendarTileProps { } function CalendarTile({ widget }: CalendarTileProps) { - const { colorScheme } = useMantineTheme(); + const { colorScheme, radius } = useMantineTheme(); const { name: configName } = useConfigContext(); const [month, setMonth] = useState(new Date()); const isEditMode = useEditModeStore((x) => x.enabled); @@ -77,17 +88,24 @@ function CalendarTile({ widget }: CalendarTileProps) { defaultDate={new Date()} onPreviousMonth={setMonth} onNextMonth={setMonth} - size="xs" + size={widget.properties.fontSize} locale={i18n?.resolvedLanguage ?? 'en'} firstDayOfWeek={widget.properties.sundayStart ? 0 : 1} - hideWeekdays={widget.properties.hideWeekDays ? true : false} - style={{ position: 'relative', top: -10 }} + hideWeekdays={widget.properties.hideWeekDays} + style={{ position: 'relative' }} date={month} maxLevel="month" hasNextLevel={false} styles={{ calendarHeader: { maxWidth: 'inherit', + marginBottom: '0.35rem !important', + }, + calendarHeaderLevel: { + height:"100%", + }, + calendarHeaderControl:{ + height:"100%", }, calendar: { height: '100%', @@ -104,15 +122,21 @@ function CalendarTile({ widget }: CalendarTileProps) { flexDirection: 'column', width: '100%', }, + monthCell:{ + textAlign:'center', + }, month: { flex: 1, }, + day:{ + borderRadius: ['xs','sm'].includes(widget.properties.fontSize) ? radius.md : radius.lg, + }, }} getDayProps={(date) => ({ bg: getBgColorByDateAndTheme(colorScheme, date), })} renderDay={(date) => ( - + )} /> );