From 8dd922d66991fa93aded95f5a6a3e2711dd2e62d Mon Sep 17 00:00:00 2001 From: fermarinsanchez Date: Thu, 15 Feb 2024 18:45:46 +0100 Subject: [PATCH] fix(HoverCard): add withinPortal to HoverCard and fix eslint errors --- .../components/ScheduleItem/ScheduleItem.js | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/leemons/src/common/ClassroomHeaderBar/components/ScheduleItem/ScheduleItem.js b/packages/leemons/src/common/ClassroomHeaderBar/components/ScheduleItem/ScheduleItem.js index 9b61e62c9..e1b72cc50 100644 --- a/packages/leemons/src/common/ClassroomHeaderBar/components/ScheduleItem/ScheduleItem.js +++ b/packages/leemons/src/common/ClassroomHeaderBar/components/ScheduleItem/ScheduleItem.js @@ -1,9 +1,9 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import { Box, HoverCard, Text, TextClamp } from '@bubbles-ui/components'; -import { SCHEDULE_PROPS } from '../../ClassroomHeaderBar.constants'; import { TimeClockCircleIcon } from '@bubbles-ui/icons/outline'; import { find, forEach } from 'lodash'; +import { SCHEDULE_PROPS } from '../../ClassroomHeaderBar.constants'; function formatTime(time) { if (time.length > 5) { @@ -15,8 +15,8 @@ function formatTime(time) { const ScheduleItem = ({ schedule, scheduleLabel, locale, firstDayOfWeek = 1, classes, cx }) => { const [weekDays, setWeekDays] = useState([]); - const renderSchedule = (schedule) => { - const { day, start, end, dayWeek } = schedule; + const renderSchedule = (scheduleParam) => { + const { day, start, end, dayWeek } = scheduleParam; const week = find(weekDays, { index: dayWeek }); return ( {`${ @@ -30,23 +30,23 @@ const ScheduleItem = ({ schedule, scheduleLabel, locale, firstDayOfWeek = 1, cla import(`dayjs/locale/${locale}.js`).then((e) => { orderedWeekdays = [...e.weekdays]; if (firstDayOfWeek > 0) { - const e = [...Array(firstDayOfWeek).keys()]; - forEach(e, () => { + const el = [...Array(firstDayOfWeek).keys()]; + forEach(el, () => { orderedWeekdays.push(orderedWeekdays.shift()); }); } setWeekDays( - orderedWeekdays.map((day, index) => { + orderedWeekdays.map((day) => { let dayLabel = day.substring(0, 2); dayLabel = dayLabel.charAt(0).toUpperCase() + dayLabel.slice(1); - return { label: dayLabel, index: e.weekdays.indexOf(day), day: day }; + return { label: dayLabel, index: e.weekdays.indexOf(day), day }; }), ); }); }, [locale]); return ( - + @@ -59,7 +59,7 @@ const ScheduleItem = ({ schedule, scheduleLabel, locale, firstDayOfWeek = 1, cla - {schedule.map((schedule) => renderSchedule(schedule))} + {schedule.map((scheduleElem) => renderSchedule(scheduleElem))} @@ -69,6 +69,11 @@ const ScheduleItem = ({ schedule, scheduleLabel, locale, firstDayOfWeek = 1, cla ScheduleItem.defaultProps = {}; ScheduleItem.propTypes = { schedule: PropTypes.arrayOf(SCHEDULE_PROPS), + scheduleLabel: PropTypes.string, + locale: PropTypes.string, + firstDayOfWeek: PropTypes.number, + classes: PropTypes.object, + cx: PropTypes.func, }; export { ScheduleItem };