add grip element to draggable post item
This commit is contained in:
parent
1617846d86
commit
42ca88f627
|
@ -7,6 +7,12 @@
|
||||||
span {
|
span {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
svg {
|
||||||
|
height: 100%;
|
||||||
|
width: 1rem;
|
||||||
|
padding-right: 1rem;
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.posts {
|
.posts {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { DataRow } from '../api/DataRow';
|
||||||
import { Post } from './display/Post';
|
import { Post } from './display/Post';
|
||||||
|
|
||||||
import style from './DraggablePostsList.module.scss';
|
import style from './DraggablePostsList.module.scss';
|
||||||
|
import { GripVertical } from './display/GripVertical';
|
||||||
|
|
||||||
type SetRowsFunction = (data: DataRow[]) => void;
|
type SetRowsFunction = (data: DataRow[]) => void;
|
||||||
|
|
||||||
|
@ -10,7 +11,7 @@ function PostDraggableListItem({ item, dragHandleProps, rows, setRows }: { item:
|
||||||
|
|
||||||
function onChange() {
|
function onChange() {
|
||||||
rows.splice(rows.indexOf(item), 1);
|
rows.splice(rows.indexOf(item), 1);
|
||||||
setRows(rows);
|
setRows([ ...rows ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -18,8 +19,9 @@ function PostDraggableListItem({ item, dragHandleProps, rows, setRows }: { item:
|
||||||
<span>
|
<span>
|
||||||
<label for={`row-list-${item.id}`} style={{ display: 'none' }}>Select</label>
|
<label for={`row-list-${item.id}`} style={{ display: 'none' }}>Select</label>
|
||||||
<input type='checkbox' id={`row-list-${item.id}`} onChange={onChange}/>
|
<input type='checkbox' id={`row-list-${item.id}`} onChange={onChange}/>
|
||||||
|
<GripVertical {...dragHandleProps} />
|
||||||
</span>
|
</span>
|
||||||
<Post className={style.posts} row={item} {...dragHandleProps} />
|
<Post className={style.posts} row={item} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +38,6 @@ export function DraggablePostsList(props: DraggablePostsList) {
|
||||||
template={p => PostDraggableListItem({ ...p, setRows: props.setRows, rows: props.rows })}
|
template={p => PostDraggableListItem({ ...p, setRows: props.setRows, rows: props.rows })}
|
||||||
list={props.rows}
|
list={props.rows}
|
||||||
onMoveEnd={rows => props.setRows([ ...rows ])}
|
onMoveEnd={rows => props.setRows([ ...rows ])}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import type React from "preact/compat";
|
||||||
|
|
||||||
|
export function GripVertical(props: React.JSX.SVGAttributes<SVGSVGElement>) {
|
||||||
|
return (
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-grip-vertical" viewBox="0 0 16 16" {...props}>
|
||||||
|
<path d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/>
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in New Issue