diff --git a/package.json b/package.json index 7d6b5d3..8a02eed 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ } ], "dependencies": { - "antd": "5.20.1", + "antd": "^5.20.3", "date-fns": "^3.6.0", "less": "^4.2.0", "less-loader": "^12.2.0", diff --git a/src/components/CalendarBody.tsx b/src/components/CalendarBody.tsx index 9cd69d1..6c8cc8a 100644 --- a/src/components/CalendarBody.tsx +++ b/src/components/CalendarBody.tsx @@ -1,17 +1,16 @@ import React, { useEffect, useRef } from 'react'; -import { Table } from 'antd'; +import { Table, Grid } from 'antd'; import { GenericEvent, CalendarBodyProps, - ColumnNode, } from './types'; import { getDayHoursEvents } from './utils'; import { createDayColumns, SCROLL_TO_ROW } from './columns'; const ALL_DAY_ROW = 0; - +const { useBreakpoint } = Grid; function Calendar({ weekDatesRange, @@ -20,39 +19,55 @@ function Calendar({ weekends, }: CalendarBodyProps) { const rowRef = useRef(null); + const screens = useBreakpoint(); + useEffect(() => { if (rowRef.current) { - rowRef.current?.scrollIntoView(); + rowRef.current.scrollIntoView(); } }, [rowRef]); - const dayColumns = createDayColumns(weekDatesRange, weekends, onEventClick) + const fontSize = screens.xs ? '12px' : '14px' const hourColumn = { - title: 'Hours', + title:
Hours
, dataIndex: 'hour', key: 'hour', - width: 1, - render: (hour: ColumnNode, { }, id: number) => { + width: screens.xs ? 50 : 1, + render: (hour: ColumnNode, {}, id: number) => { return { props: { - style: { width: '10%' }, + style: { + width: screens.xs ? '30%' : '10%', + fontSize: fontSize + }, }, - children: - SCROLL_TO_ROW === id ? ( - - // @ts-ignore -
{hour}
- ) : ( - // @ts-ignore -
{hour}
- ), + children: SCROLL_TO_ROW === id ? ( +
{hour}
+ ) : ( +
{hour}
+ ), }; }, }; + + const dayColumns = createDayColumns(weekDatesRange, weekends, onEventClick).map((col) => ({ + ...col, + title: ( +
+ {col.title} +
+ ), + })); + const tableColumns = [hourColumn, ...dayColumns]; return ( -
+
record.id} dataSource={getDayHoursEvents(weekDatesRange, getDayEvents)} @@ -69,13 +84,19 @@ function Calendar({ boxShadow: 'rgba(0, 0, 0, 0.05) -1px 4px 4px ', zIndex: 1, top: 0, + padding: '8px 0', }, }; } - return {}; + return { + style: { + padding: '8px 0', // Add padding for each row + }, + }; }} scroll={{ - y: 1000, + y: screens.xs ? 300 : 1000, + x: 'max-content', }} /> diff --git a/src/components/CalendarHeader.tsx b/src/components/CalendarHeader.tsx index 10b7b7d..bdd200d 100644 --- a/src/components/CalendarHeader.tsx +++ b/src/components/CalendarHeader.tsx @@ -29,14 +29,21 @@ const MonthName: React.FunctionComponent = ({ startWeek }) => { return format(startWeek, 'MMM') + '-' + format(endOfWeekDate, 'MMM'); }; + const belowButtonPadding = "4px 15px" + return ( -
- +
{getMonthName()} - +
Week {getWeek(new Date(addWeeks(startWeek, -1)))}
); @@ -48,6 +55,11 @@ export const CalendarHeader: React.FunctionComponent = ({ }) => { return ( <> + +
+ +
+
= ({ -
- -
+