mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 21:03:29 +00:00
e30b4fa8d5
refactor: implement groups in editor
43 lines
871 B
TypeScript
43 lines
871 B
TypeScript
import { useSortable } from '@dnd-kit/sortable';
|
|
import { CSS } from '@dnd-kit/utilities';
|
|
|
|
import style from './BlockEnd.module.scss';
|
|
|
|
interface BlockEndProps {
|
|
id: string;
|
|
colour?: string;
|
|
}
|
|
|
|
export default function BlockEnd(props: BlockEndProps) {
|
|
const { id, colour } = props;
|
|
const {
|
|
attributes: dragAttributes,
|
|
listeners: dragListeners,
|
|
setNodeRef,
|
|
transform,
|
|
transition,
|
|
} = useSortable({
|
|
id,
|
|
animateLayoutChanges: () => false,
|
|
disabled: true, // we do not want to drag end blocks
|
|
});
|
|
|
|
const dragStyle = {
|
|
transform: CSS.Transform.toString(transform),
|
|
transition,
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className={style.blockEnd}
|
|
ref={setNodeRef}
|
|
{...dragAttributes}
|
|
{...dragListeners}
|
|
style={{
|
|
...dragStyle,
|
|
...(colour ? { '--user-bg': colour } : {}),
|
|
}}
|
|
/>
|
|
);
|
|
}
|