Implement slot time, move table cell components to a directory
This commit is contained in:
parent
277e3a215b
commit
e52f045775
|
@ -1,12 +1,12 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
export default function Day({
|
export default function DateHeader({
|
||||||
date,
|
date,
|
||||||
}) {
|
}) {
|
||||||
// TODO: format with date-fns
|
// TODO: format with date-fns
|
||||||
return date.getDate().toString().concat('.').concat((date.getMonth() + 1).toString()).concat(' - ').concat(date.getDay());
|
return date.getDate().toString().concat('.').concat((date.getMonth() + 1).toString()).concat(' - ').concat(date.getDay());
|
||||||
}
|
}
|
||||||
|
|
||||||
Day.propTypes = {
|
DateHeader.propTypes = {
|
||||||
date: PropTypes.object.isRequired,
|
date: PropTypes.object.isRequired,
|
||||||
};
|
};
|
|
@ -1,6 +1,6 @@
|
||||||
import { isTrackHidden } from './utils.js';
|
import { isTrackHidden } from '../utils.js';
|
||||||
import Speaker from './Speaker.jsx';
|
import Speaker from '../Speaker.jsx';
|
||||||
import FeedbackLink from './FeedbackLink.jsx';
|
import FeedbackLink from '../FeedbackLink.jsx';
|
||||||
|
|
||||||
export default function Event(event) {
|
export default function Event(event) {
|
||||||
return (<>
|
return (<>
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function SlotTime({
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
}) {
|
||||||
|
// TODO: format with date-fns
|
||||||
|
return start.getHours().toString().concat(':').concat(start.getMinutes()).concat(' - ').concat(end.getHours())
|
||||||
|
.concat(':').concat(end.getMinutes());
|
||||||
|
}
|
|
@ -3,12 +3,13 @@ import useSchedule from '../hooks/useSchedule.js';
|
||||||
import { isTrackHidden } from './utils.js';
|
import { isTrackHidden } from './utils.js';
|
||||||
import { Fragment, useState } from 'react';
|
import { Fragment, useState } from 'react';
|
||||||
import useScheduleTable from '../hooks/useScheduleTable.js';
|
import useScheduleTable from '../hooks/useScheduleTable.js';
|
||||||
import Event from './Event.jsx';
|
import Event from './Cell/Event.jsx';
|
||||||
import './Schedule.scss';
|
import './Schedule.scss';
|
||||||
import { langs } from './constants.js';
|
import { langs } from './constants.js';
|
||||||
import Speaker from './Speaker.jsx';
|
import Speaker from './Speaker.jsx';
|
||||||
import FeedbackLink from './FeedbackLink.jsx';
|
import FeedbackLink from './FeedbackLink.jsx';
|
||||||
import Day from './Day.jsx';
|
import DateHeader from './Cell/DateHeader.jsx';
|
||||||
|
import SlotTime from './Cell/SlotTime.jsx';
|
||||||
|
|
||||||
export default function Schedule({
|
export default function Schedule({
|
||||||
conferenceId,
|
conferenceId,
|
||||||
|
@ -56,7 +57,8 @@ export default function Schedule({
|
||||||
<tbody>
|
<tbody>
|
||||||
{rows.map(row => <tr key={row.id}>
|
{rows.map(row => <tr key={row.id}>
|
||||||
{row.cells.map(cell => <td key={cell.id} {...cell.attributes}>
|
{row.cells.map(cell => <td key={cell.id} {...cell.attributes}>
|
||||||
{cell.day && <Day date={cell.day} />}
|
{cell.dateHeader && <DateHeader date={cell.dateHeader} />}
|
||||||
|
{cell.slotTime && <SlotTime {...cell.slotTime} />}
|
||||||
{cell.event && <Event {...cell.event} />}
|
{cell.event && <Event {...cell.event} />}
|
||||||
</td>)}
|
</td>)}
|
||||||
</tr>)}
|
</tr>)}
|
||||||
|
|
|
@ -39,6 +39,7 @@ export default function useScheduleTable({
|
||||||
const rows = microslots.flatMap((date, index, array) => {
|
const rows = microslots.flatMap((date, index, array) => {
|
||||||
const isFirst = index === 0;
|
const isFirst = index === 0;
|
||||||
const isLast = index === array.length - 1;
|
const isLast = index === array.length - 1;
|
||||||
|
const nextDate = !isLast ? array[index + 1] : null;
|
||||||
const isFirstForTheDay = index > 0 && !isSameDay(date, array[index - 1]);
|
const isFirstForTheDay = index > 0 && !isSameDay(date, array[index - 1]);
|
||||||
const isLastForTheDay = array?.[index + 1] && !isSameDay(date, array[index + 1]);
|
const isLastForTheDay = array?.[index + 1] && !isSameDay(date, array[index + 1]);
|
||||||
|
|
||||||
|
@ -53,22 +54,25 @@ export default function useScheduleTable({
|
||||||
attributes: {
|
attributes: {
|
||||||
colSpan: header.length,
|
colSpan: header.length,
|
||||||
},
|
},
|
||||||
day: date,
|
dateHeader: date,
|
||||||
}]
|
}],
|
||||||
}] : [],
|
}] : [],
|
||||||
...showSlot ? [{
|
...showSlot ? [{
|
||||||
id: 'slot-'.concat(date.getTime().toString()),
|
id: 'slot-'.concat(date.getTime().toString()),
|
||||||
cells: [{
|
cells: [{
|
||||||
id: 1,
|
id: 1,
|
||||||
day: date, // TODO replace with slot time
|
slotTime: {
|
||||||
|
start: date,
|
||||||
|
end: nextDate,
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
id: 2,
|
id: 2,
|
||||||
}],
|
|
||||||
// attributes: {
|
// attributes: {
|
||||||
// className: 'schedule-'.concat(slot.event.language).concat(' ').concat(slot.event.track?.css_class),
|
// className: 'schedule-'.concat(slot.event.language).concat(' ').concat(slot.event.track?.css_class),
|
||||||
// colSpan: 2,
|
// colSpan: 2,
|
||||||
// },
|
// },
|
||||||
// event: slot.event,
|
// event: slot.event,
|
||||||
|
}],
|
||||||
}] : [],
|
}] : [],
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue