Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: css alignment of calendar component on the home page #3276

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions components/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isAfter, parseISO } from 'date-fns';
import moment from 'moment';
import React from 'react';
import React, { useMemo } from 'react';
import { twMerge } from 'tailwind-merge';

import type { IEvent } from '@/types/event';
Expand Down Expand Up @@ -28,10 +29,19 @@ export default function Calendar({ className = '', size }: ICalendarProps) {

const CALENDAR_URL =
'https://calendar.google.com/calendar/embed?src=c_q9tseiglomdsj6njuhvbpts11c%40group.calendar.google.com&ctz=UTC';
const eventsExist = eventsData.length > 0;
const currentDate = new Date();
const eventsExist = useMemo(
() => eventsData?.some((event: IEvent) => isAfter(parseISO(event.date), currentDate)),
[currentDate]
);

return (
<div className={twMerge('overflow-hidden rounded-md border border-gray-200 bg-white p-4', className)}>
<div
className={twMerge(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mobile/tab view, the calendar div is not in the center, rather it is slightly shifted towards the right.
Screenshot from 2024-10-07 12-15-03

It should be in the center like other cards:
Screenshot from 2024-10-07 12-15-16

'overflow-hidden rounded-md border border-gray-200 bg-white p-4 h-full flex flex-col gap-2',
className
)}
>
Comment on lines +35 to +40
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address mobile view alignment issue

While the flex container improvements help with layout, the mobile view alignment issue mentioned in the past review still needs attention. The calendar div appears shifted to the right on mobile/tab views instead of being centered like other cards.

Apply this diff to center the component on mobile views:

 <div
   className={twMerge(
-    'overflow-hidden rounded-md border border-gray-200 bg-white p-4 h-full flex flex-col gap-2',
+    'overflow-hidden rounded-md border border-gray-200 bg-white p-4 h-full flex flex-col gap-2 mx-auto w-full',
     className
   )}
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
className={twMerge(
'overflow-hidden rounded-md border border-gray-200 bg-white p-4 h-full flex flex-col gap-2',
className
)}
>
<div
className={twMerge(
'overflow-hidden rounded-md border border-gray-200 bg-white p-4 h-full flex flex-col gap-2 mx-auto w-full',
className
)}
>

<Heading level={HeadingLevel.h2} typeStyle={HeadingTypeStyle.mdSemibold}>
{t('calendar.title')}
</Heading>
Expand All @@ -43,7 +53,7 @@ export default function Calendar({ className = '', size }: ICalendarProps) {
<span className='flex-1 self-center text-center'>{moment(event.date).format('D')}</span>
</div>
<div className='grow text-left sm:mt-0 sm:pl-6'>
<h2 className='title-font text-xl font-medium text-gray-900 hover:text-gray-500'>{event.title}</h2>
<h2 className='title-font font-medium text-gray-900 hover:text-gray-500'>{event.title}</h2>
<p className='text-gray-600'>
{moment(event.date).local().format('LLLL')} UTC
{moment(event.date).local().format('Z')}
Expand All @@ -53,13 +63,12 @@ export default function Calendar({ className = '', size }: ICalendarProps) {
</li>
))}
</ul>
{eventsExist ? (
<div className='pt-4' data-testid='Calendar-button'>
<div className='h-full content-center lg:pb-8'>
{!eventsExist && <div className='font-bold text-gray-700'>{t('calendar.noMeetingsMessage')}</div>}
<div className='sm:pt-0 md:pt-2 lg:pt-0' data-testid='Calendar-button'>
<GoogleCalendarButton href={CALENDAR_URL} text={t('calendar.viewCalendarBtn')} />
</div>
) : (
<div className='mt-2 text-gray-700'>{t('calendar.noMeetingsMessage')}</div>
)}
</div>
</div>
);
}
Loading
Loading