Skip to content

Commit 2c81e5c

Browse files
Nuevo componente evento calendario
* fix(PDYE-1216): nuevo diseño componente evento y revert evento clickable --------- Co-authored-by: Javiera Munita <javiera.munita@eclass.cl>
1 parent 4085149 commit 2c81e5c

File tree

6 files changed

+80
-111
lines changed

6 files changed

+80
-111
lines changed

src/organisms/Calendar/Dropdown/CalendarDropdown.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const CalendarDropdown = ({
1010
loading,
1111
onlyToCalendar = false,
1212
m,
13-
clickEvent,
1413
}: ICalendarDropdown): JSX.Element => {
1514
const date = new Date(now)
1615
const isoDate = date.toISOString()
@@ -25,7 +24,6 @@ export const CalendarDropdown = ({
2524
redirectToCalendar={redirectToCalendar}
2625
text={text}
2726
onlyToCalendar={onlyToCalendar}
28-
clickEvent={clickEvent}
2927
/>
3028
)
3129
}

src/organisms/Calendar/Dropdown/CalendarDropdown/CalendarDropdownContainer.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const CalendarDropdownContainer = ({
1818
courseColors,
1919
onlyToCalendar,
2020
m,
21-
clickEvent,
2221
}: ICalendarDropdown): JSX.Element => {
2322
const [isMobile] = useMediaQuery('(max-width: 577px)')
2423
const { closeAndMarkSeen, empty, hasNew, ...all } = useParseEvents(events, now)
@@ -170,7 +169,6 @@ export const CalendarDropdownContainer = ({
170169
text={text}
171170
redirecToCalendar={redirectToCalendar}
172171
isMobile={isMobile}
173-
clickEvent={clickEvent}
174172
/>
175173
)}
176174
</Box>

src/organisms/Calendar/Dropdown/CalendarDropdown/Components/Events.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BtnSecondary } from '@/molecules'
22
import { Box } from '@chakra-ui/react'
33
import { vars } from '@theme'
44

5-
import { Text, Event, ICalendarDropdown } from '../../types'
5+
import { Text, Event } from '../../types'
66
import { EventsGroup } from './EventsGroup'
77

88
interface IEventsProps {
@@ -15,7 +15,6 @@ interface IEventsProps {
1515
redirecToCalendar: () => void
1616
isMobile: boolean
1717
colors?: Record<string, string>
18-
clickEvent?: ICalendarDropdown['clickEvent']
1918
}
2019

2120
export const Events = ({
@@ -24,7 +23,6 @@ export const Events = ({
2423
redirecToCalendar,
2524
isMobile,
2625
colors,
27-
clickEvent,
2826
}: IEventsProps): JSX.Element => {
2927
const { today, tomorrow, next } = events
3028
return (
@@ -62,21 +60,18 @@ export const Events = ({
6260
text={text?.course ?? ''}
6361
title={text?.events?.today ?? 'Hoy'}
6462
events={today}
65-
clickEvent={clickEvent}
6663
/>
6764
<EventsGroup
6865
colors={colors}
6966
text={text?.course ?? ''}
7067
title={text?.events?.tomorrow ?? 'Mañana'}
7168
events={tomorrow}
72-
clickEvent={clickEvent}
7369
/>
7470
<EventsGroup
7571
colors={colors}
7672
text={text?.course ?? ''}
7773
title={text?.events?.next ?? 'Próximos'}
7874
events={next}
79-
clickEvent={clickEvent}
8075
/>
8176
</Box>
8277
)

src/organisms/Calendar/Dropdown/CalendarDropdown/Components/EventsGroup.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
1-
import { Box, MenuGroup } from '@chakra-ui/react'
2-
31
import { EventsList } from '@/organisms/Calendar'
2+
import { Box, MenuGroup } from '@chakra-ui/react'
43
import { vars } from '@theme'
5-
import { Event, ICalendarDropdown } from '../../types'
4+
import { Event } from '../../types'
65

76
interface IEventsGroupProps {
87
title: string
98
events: Event[]
109
text: string
1110
colors?: Record<string, string>
12-
clickEvent?: ICalendarDropdown['clickEvent']
1311
}
1412

15-
export const EventsGroup = ({
16-
title,
17-
events,
18-
text,
19-
colors,
20-
clickEvent,
21-
}: IEventsGroupProps): JSX.Element => {
13+
export const EventsGroup = ({ title, events, text, colors }: IEventsGroupProps): JSX.Element => {
2214
if (!events || (events && events.length === 0)) return <></>
23-
24-
const handleClick = (event: Event): void => {
25-
clickEvent?.(event)
26-
}
2715
return (
2816
<Box
2917
className="calendar-events-group"
@@ -61,15 +49,16 @@ export const EventsGroup = ({
6149
key={event.id}
6250
name={event.associated_resource.name || ''}
6351
courseName={event.course.name}
64-
date={event.formatedDate.start}
65-
hours={event.formatedDate.hours}
52+
day={event.formatedDate.day}
53+
date={event.formatedDate.date}
54+
time={event.formatedDate.time}
6655
color={
6756
event.course_id && colors?.[event.course_id] ? colors[event.course_id] : '#82504A'
6857
}
6958
text={text}
59+
type={event.type}
7060
hasNotification={event.isNew}
71-
isDropdown
72-
clickEvent={() => handleClick(event)}
61+
showsCourseName
7362
/>
7463
</Box>
7564
)

src/organisms/Calendar/Dropdown/types.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ interface Course {
99
}
1010

1111
interface FormattedDate {
12-
start: string
13-
hours: string
12+
day: string
13+
date: string
14+
time: string
1415
}
1516

1617
export interface Event {
@@ -22,6 +23,7 @@ export interface Event {
2223
course: Course
2324
formatedDate: FormattedDate
2425
isNew?: boolean
26+
type: string
2527
}
2628

2729
export type Events = Event[]
@@ -49,5 +51,4 @@ interface ICalendarDropdown {
4951
redirectToCalendar: () => void
5052
text?: Text
5153
onlyToCalendar?: boolean
52-
clickEvent?: (event: Event) => void
5354
}
Lines changed: 67 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,93 @@
11
import { Box } from '@chakra-ui/react'
2-
3-
import { Calendar } from '@/atoms/Icons/Calendar'
4-
import { Clock } from '@/atoms/Icons/Clock'
52
import { vars } from '@theme'
3+
64
import { NotificationIcon } from './NotificationIcon'
7-
import { Ripples } from '@atoms'
85

96
export interface IEventList {
10-
hasNotification?: boolean
11-
isDropdown?: boolean
12-
name: string
137
color?: string
148
courseName?: string
15-
text: string
9+
day: string
1610
date: string
17-
hours: string
18-
clickEvent?: () => void
11+
hasNotification?: boolean
12+
showsCourseName?: boolean
13+
time: string
14+
name: string
15+
text: string
16+
type: string
1917
}
2018

2119
export const EventsList = ({
22-
hasNotification,
23-
isDropdown,
24-
name,
2520
courseName,
2621
color,
27-
text,
22+
day,
2823
date,
29-
hours,
30-
clickEvent,
24+
hasNotification,
25+
showsCourseName,
26+
time,
27+
name,
28+
text,
29+
type,
3130
}: IEventList): JSX.Element => {
3231
const border = `1px solid ${vars('colors-neutral-platinum') ?? '#E8E8E8'}`
3332

34-
const handleClick = (): void => clickEvent?.()
33+
const initOrEnd = [
34+
'end-course',
35+
'init-course',
36+
'init-course-flexible',
37+
'end-course-flexible',
38+
].includes(type)
39+
40+
const dateTextStyle = {
41+
fontSize: '18px',
42+
fontWeight: '700',
43+
color: vars('colors-neutral-white'),
44+
lineHeight: '100%',
45+
}
3546

3647
return (
37-
<Ripples>
48+
<Box className="eventsList" borderTop={border} p="16px 24px" display="flex" gap="12px">
3849
<Box
39-
className="eventsList"
40-
borderTop={border}
41-
padding="16px 24px"
42-
onClick={handleClick}
43-
cursor="pointer"
44-
bg={vars('colors-neutral-white') ?? '#fff'}
45-
_hover={{
46-
bg: vars('colors-neutral-cultured2') ?? '#F8F8F8',
47-
}}
50+
bg={color}
51+
minW="80px"
52+
minH="80px"
53+
maxW="80px"
54+
maxH="80px"
55+
borderRadius="4px"
56+
p="8px"
57+
display="flex"
58+
flexDirection="column"
59+
justifyContent="space-around"
4860
>
49-
<Box display="flex" flexDirection="column" gap="8px">
50-
<Box
51-
lineHeight="21px"
52-
display="flex"
53-
justifyContent="space-between"
54-
alignItems="center"
55-
fontSize="16px"
56-
>
57-
{name} {hasNotification && <NotificationIcon />}
58-
</Box>
59-
<Box
60-
display="flex"
61-
lineHeight="19px"
62-
fontSize="14px"
63-
sx={{
64-
svg: {
65-
marginRight: '4px',
66-
},
67-
span: {
68-
verticalAlign: 'middle',
69-
},
70-
}}
71-
>
72-
<Box paddingRight="8px" borderRight={border}>
73-
<Calendar />
74-
<span>{date}</span>
75-
</Box>
76-
<Box paddingLeft="8px">
77-
<Clock />
78-
<span>{hours}</span>
61+
<Box as="span" sx={dateTextStyle}>
62+
{day}
63+
</Box>
64+
<Box as="span" sx={dateTextStyle}>
65+
{date}
66+
</Box>
67+
<Box as="span" fontSize="14px" fontWeight="700" color={vars('colors-neutral-white')}>
68+
{time}
69+
</Box>
70+
</Box>
71+
72+
<Box display="flex" flexDirection="column" gap="8px">
73+
<Box
74+
lineHeight="21px"
75+
display="flex"
76+
justifyContent="space-between"
77+
alignItems="center"
78+
fontSize="16px"
79+
fontWeight="700"
80+
>
81+
{name} {hasNotification && <NotificationIcon />}
82+
</Box>
83+
{showsCourseName && !initOrEnd && (
84+
<Box display="flex" alignItems="center" gap="4px" lineHeight="19px">
85+
<Box as="span" color={vars('colors-neutral-gray') ?? '#808080'} fontSize="14px">
86+
<strong>{text ? `${text}:` : 'Curso:'}</strong> {courseName}
7987
</Box>
8088
</Box>
81-
{isDropdown && (
82-
<Box display="flex" alignItems="center" gap="4px" lineHeight="19px">
83-
<Box
84-
alignSelf="flex-start"
85-
bg={color}
86-
borderRadius="50%"
87-
display="block"
88-
h="10px"
89-
mt="4px"
90-
maxH="10px"
91-
maxW="10px"
92-
minH="10px"
93-
minW="10px"
94-
w="10px"
95-
/>
96-
<Box as="span" color={vars('colors-neutral-gray') ?? '#808080'} fontSize="14px">
97-
<strong>{text ?? 'Curso'}:</strong> {courseName}
98-
</Box>
99-
</Box>
100-
)}
101-
</Box>
89+
)}
10290
</Box>
103-
</Ripples>
91+
</Box>
10492
)
10593
}

0 commit comments

Comments
 (0)