Example work
This commit is contained in:
@@ -57,11 +57,37 @@ export const Todo = Component.make(function* Todo(props: TodoProps) {
|
|||||||
{props._tag === "edit" &&
|
{props._tag === "edit" &&
|
||||||
<Flex direction="column" justify="center" align="center" gap="1">
|
<Flex direction="column" justify="center" align="center" gap="1">
|
||||||
<IconButton
|
<IconButton
|
||||||
|
onClick={() => Runtime.runSync(runtime)(
|
||||||
|
Ref.updateSome(state.ref, todos => Option.gen(function*() {
|
||||||
|
if (props.index <= 0)
|
||||||
|
return yield* Option.none()
|
||||||
|
|
||||||
|
const toSwapIndex = props.index - 1
|
||||||
|
const toSwap = yield* Chunk.get(todos, toSwapIndex)
|
||||||
|
return todos.pipe(
|
||||||
|
Chunk.replace(props.index, toSwap),
|
||||||
|
Chunk.replace(toSwapIndex, todo),
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<FaArrowUp />
|
<FaArrowUp />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
|
onClick={() => Runtime.runSync(runtime)(
|
||||||
|
Ref.updateSome(state.ref, todos => Option.gen(function*() {
|
||||||
|
if (props.index >= Chunk.size(todos))
|
||||||
|
return yield* Option.none()
|
||||||
|
|
||||||
|
const toSwapIndex = props.index + 1
|
||||||
|
const toSwap = yield* Chunk.get(todos, toSwapIndex)
|
||||||
|
return todos.pipe(
|
||||||
|
Chunk.replace(props.index, toSwap),
|
||||||
|
Chunk.replace(toSwapIndex, todo),
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<FaArrowDown />
|
<FaArrowDown />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
Reference in New Issue
Block a user