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

fixed:#1887 Event and Holiday Calendar View #2534

Closed
Changes from 4 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
146 changes: 82 additions & 64 deletions src/components/EventCalendar/EventCalendar.module.css
Original file line number Diff line number Diff line change
@@ -345,7 +345,21 @@
gap: 10px;
margin-top: 35px;
}
.holidays_card {
flex: 1;
padding: 20px;
background-color: var(--holiday-card-bg);
border-radius: 10px;
box-shadow: var(--card-shadow);
}

.events_card {
flex: 1;
padding: 20px;
background-color: #ffffff;
border-radius: 10px;
box-shadow: var(--card-shadow);
}
.card__holidays {
background-color: rgba(246, 242, 229, 1);
display: flex;
@@ -429,39 +443,67 @@
height: 12px;
display: inline-block;
}
.holidayIndicator {
composes: baseIndicator;
background-color: var(--holiday-indicator-color);
}

.commonText {
.holidayText {
font-size: 14px;
color: var(--text-color-secondary);
color: #555555;
}
.eventsLegend {
display: flex;
align-items: center;
gap: 8px;
}

.holidayText {
composes: commonText;
.listContainer {
width: fit-content;
display: flex;
align-items: center;
gap: 8px;
}

.holidayIndicator {
background-color: rgba(0, 0, 0, 0.15);
border-radius: 5px;
width: 20px;
height: 12px;
display: inline-block;
}

.holidayText {
font-size: 14px;
color: #555555;
}
.eventsLegend {
display: flex;
align-items: center;
gap: 8px;
}
:root {
--holiday-indicator-color: rgba(0, 0, 0, 0.15);

--holiday-date-color: rgba(255, 152, 0, 1);

--text-color-primary: rgba(51, 51, 51, 1);

--text-color-secondary: rgba(85, 85, 85, 1);
}
.organizationIndicator {
composes: baseIndicator;
background-color: var(--organization-indicator-color);
background-color: rgba(82, 172, 255, 0.5);
border-radius: 5px;
width: 20px;
height: 12px;
display: inline-block;
}

.legendText {
composes: commonText;
font-size: 14px;
color: #555555;
}
@media only screen and (max-width: 700px) {
.list_container_new,
.listContainer,
.eventsLegend {
gap: 4px;
}
}

.holidayIndicator,
.organizationIndicator {
@@ -474,55 +516,20 @@
font-size: 12px;
}
}

:root {
--container-padding: 20px;
--container-gap: 20px;
--container-bg: rgba(249, 249, 249, 1);
--holiday-indicator-color: rgba(0, 0, 0, 0.15);
--organization-indicator-color: rgba(82, 172, 255, 0.5);
--indicator-spacing: 8px;
--mobile-breakpoint: 700px;
--small-mobile-breakpoint: 500px;
--user-indicator-color: rgba(139, 195, 74, 1);
--holiday-card-bg: #fff8e1;
--holiday-date-color: #ff9800;
--text-color-primary: #333333;
--text-color-secondary: #555555;
--card-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
}
.container {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
padding: var(--container-padding);
gap: var(--container-gap);
background-color: var(--container-bg);
}

.holidays_card {
flex: 1;
padding: 20px;
background-color: var(--holiday-card-bg);
border-radius: 10px;
box-shadow: var(--card-shadow);
}

.card_title {
font-size: 16px;
font-weight: 600;
color: var(--text-color-primary);
margin-bottom: 15px;
}

.holiday_list {
.card_list {
list-style: none;
padding: 0;
margin: 0;
}

.holiday_item {
.card_list_item {
display: flex;
justify-content: space-between;
align-items: center;
@@ -536,31 +543,42 @@
color: var(--holiday-date-color);
}

.calendar_infocards {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
gap: 20px;
padding: 20px;
background-color: var(--grey-bg-color);
}

.holidays_card,
.events_card {
flex: 1;
padding: 20px;
background-color: #ffffff;
border-radius: 10px;
box-shadow: var(--card-shadow);
}

.legend {
display: flex;
flex-direction: column;
gap: 12px;
.holidays_card {
background-color: var(--holiday-card-bg);
}

.user_events {
display: flex;
align-items: center;
gap: 8px;
.events_card {
background-color: white;
}

.user_indicator {
composes: baseIndicator;
background-color: var(--user-indicator-color);
.legend {
display: flex;
flex-direction: column;
gap: 12px;
}

.user_legend_text {
composes: commonText;
.userEvents__color {
background-color: rgba(139, 195, 74, 1);
border-radius: 5px;
width: 20px;
height: 12px;
display: inline-block;
}
87 changes: 35 additions & 52 deletions src/components/EventCalendar/EventCalendar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import EventListCard from 'components/EventListCard/EventListCard';
import dayjs from 'dayjs';
import React, { useMemo, useState, useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import Button from 'react-bootstrap/Button';
import styles from './EventCalendar.module.css';
import { ChevronLeft, ChevronRight } from '@mui/icons-material';
@@ -221,13 +221,6 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
setExpanded(index);
}
};
const filteredHolidays = useMemo(
() =>
holidays?.filter(
(holiday) => dayjs(holiday.date, 'MM-DD').month() === currentMonth,
),
[holidays, currentMonth],
);
/*istanbul ignore next*/
const allDayEventsList: JSX.Element[] =
events
@@ -275,7 +268,6 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
/>
);
}) || [];

return (
<>
<div className={styles.calendar_hour_block}>
@@ -296,7 +288,6 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
? styles.expand_list_container
: styles.list_container
}
style={{ width: 'fit-content' }}
>
<div
className={
@@ -313,9 +304,7 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
(windowWidth <= 700 && allDayEventsList?.length > 0)) && (
<button
className={styles.btn__more}
onClick={() => {
toggleExpand(-100);
}}
onClick={() => toggleExpand(-100)}
>
{expanded === -100 ? 'View less' : 'View all'}
</button>
@@ -324,44 +313,43 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
</div>
</div>

<div className={styles.container}>
{/* Holidays Card */}
<div className={styles.calendar_infocards}>
<div className={styles.holidays_card}>
<h3 className={styles.card_title}>Holidays</h3>
<ul className={styles.holiday_list}>
{filteredHolidays?.map((holiday, index) => (
<li key={index}>{holiday.name}</li>
))}
<ul className={styles.card_list}>
{holidays
?.filter(
(holiday) =>
dayjs(holiday.date, 'MM-DD').month() === currentMonth,
)
.map((holiday, index) => (
<li className={styles.card_list_item} key={index}>
<span className={styles.holiday_date}>
{months[parseInt(holiday.date.slice(0, 2), 10) - 1]}{' '}
{holiday.date.slice(3)}
</span>
<span>{holiday.name}</span>
</li>
))}
</ul>
</div>

<div className={styles.events_card}>
<h3 className={styles.card_title}>Events</h3>
<div className={styles.legend}>
<div className={styles.list_container_new}>
<span
className={styles.holidayIndicator}
role="img"
aria-label="Holiday indicator"
></span>
<div className={styles.listContainer}>
<span className={styles.holidayIndicator}></span>
<span className={styles.holidayText}>Holidays</span>
</div>
<div className={styles.eventsLegend}>
<span
className={styles.organizationIndicator}
role="img"
aria-label="Organization event indicator"
></span>
<span className={styles.organizationIndicator}></span>
<span className={styles.legendText}>
Events Created by Organization
</span>
</div>
<div className={styles.user_events}>
<span
className={styles.user_indicator}
role="img"
aria-label="User event indicator"
></span>
<span className={styles.user_legend_text}>
<div className={styles.eventsLegend}>
<span className={styles.userEvents__color}></span>
<span className={styles.legendText}>
Events Created by User
</span>
</div>
@@ -461,16 +449,7 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
.map((holiday) => {
return <HolidayCard key={holiday.name} holidayName={holiday.name} />;
});
const getVisibleEvents = (
expanded: boolean,
holidayList: JSX.Element[],
allEventsList: JSX.Element[],
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
) => {
if (expanded) return allEventsList;
const maxEvents = holidayList?.length > 0 ? 1 : 2;
return allEventsList?.slice(0, maxEvents);
};

return (
<div
key={index}
@@ -492,11 +471,15 @@ const Calendar: React.FC<InterfaceCalendarProps> = ({
}
>
<div>{holidayList}</div>
{getVisibleEvents(
expanded === index,
holidayList,
allEventsList,
)}
{
/*istanbul ignore next*/
expanded === index
? allEventsList
: holidayList?.length > 0
? /*istanbul ignore next*/
allEventsList?.slice(0, 1)
: allEventsList?.slice(0, 2)
}
</div>
{(allEventsList?.length > 2 ||
(windowWidth <= 700 && allEventsList?.length > 0)) && (

Unchanged files with check annotations Beta

Check warning on line 1 in .husky/pre-commit

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
npm run format:fix
# npm run lint:fix
npm run lint-staged