refactor: empty state for cuesheet

This commit is contained in:
Carlos Valente
2025-07-16 20:56:35 +02:00
committed by Carlos Valente
parent 9618bec847
commit 90105a199a
4 changed files with 45 additions and 2 deletions
@@ -11,8 +11,7 @@ interface EmptyProps {
className?: string;
}
export default function Empty(props: EmptyProps) {
const { text, className, ...rest } = props;
export default function Empty({ text, className, ...rest }: EmptyProps) {
return (
<div className={cx([style.emptyContainer, className])} {...rest}>
<EmptyImage className={style.empty} />
@@ -0,0 +1,19 @@
.emptyContainer {
width: 100%;
color: $white-10;
.emptyCell {
margin-inline: auto;
text-align: center;
}
.empty {
width: 100%;
opacity: 0.8;
}
.text {
font-weight: 600;
font-size: 2em;
}
}
@@ -0,0 +1,20 @@
import EmptyImage from '../../../assets/images/empty.svg?react';
import style from './EmptyTableBody.module.scss';
interface EmptyTableBodyProps {
text: string;
}
export default function EmptyTableBody({ text }: EmptyTableBodyProps) {
return (
<tbody className={style.emptyContainer}>
<tr>
<td colSpan={99} className={style.emptyCell}>
<EmptyImage className={style.empty} />
{text && <span className={style.text}>{text}</span>}
</td>
</tr>
</tbody>
);
}
@@ -13,6 +13,7 @@ import {
import { colourToHex, cssOrHexToColour } from 'ontime-utils';
import { RUNDOWN } from '../../../../common/api/constants';
import EmptyTableBody from '../../../../common/components/state/EmptyTableBody';
import { useSelectedEventId } from '../../../../common/hooks/useSocket';
import { getAccessibleColour } from '../../../../common/utils/styleUtils';
import { usePersistedCuesheetOptions } from '../../cuesheet.options';
@@ -47,6 +48,10 @@ export default function CuesheetBody({ rowModel, selectedRef, table }: CuesheetB
};
}, []);
if (rowModel.rows.length === 0) {
return <EmptyTableBody text='No data in rundown' />;
}
return (
<tbody>
{rowModel.rows.map((row, index) => {