import React, {useContext, useMemo, useState} from 'react'; import {useStreamWithUpdater} from "ui/effects"; import Window, {DIRECTIONS} from "ui/components/Window"; import Stack from "ui/components/Stack"; import Button from "ui/components/controls/Button"; import {RiDeleteBinLine} from "react-icons/ri"; import {SKETCHER_STORAGE_PREFIX} from "../project"; import {SketcherAppContext} from "./SketcherAppContext"; export function SketchManager() { const [request, setRequest] = useStreamWithUpdater(ctx => ctx.ui.$sketchManagerRequest); if (!request) { return null; } const x = request.x || 200; const y = request.y || 200; const DIRS = DIRECTIONS; return setRequest(null)}> } function SketchList() { const [modification, setModification] = useState( 0); const {project} = useContext(SketcherAppContext); const items = useMemo(() => { const theItems = []; for (let name of Object.keys(localStorage)) { if (name.indexOf(SKETCHER_STORAGE_PREFIX) === 0) { name = name.substring(SKETCHER_STORAGE_PREFIX.length); } theItems.push(name); } return theItems; }, [modification]); return {items.map(item =>
project.openSketch(item)}> {item}
)}
; } const listStyle = { display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: 12, cursor: 'pointer' };