diff --git a/tldraw/apps/tldraw-logseq/src/components/GeometryTools/GeometryTools.tsx b/tldraw/apps/tldraw-logseq/src/components/GeometryTools/GeometryTools.tsx new file mode 100644 index 0000000000..0fdb0e863c --- /dev/null +++ b/tldraw/apps/tldraw-logseq/src/components/GeometryTools/GeometryTools.tsx @@ -0,0 +1,58 @@ +import { useApp } from '@tldraw/react' +import { observer } from 'mobx-react-lite' +import * as React from 'react' +import { ToolButton } from '../ToolButton' +import * as Popover from '@radix-ui/react-popover' + +export const GeometryTools = observer(function GeometryTools() { + const geometries = [ + { + id: 'box', + icon: 'square', + title: 'Rectangle', + }, + { + id: 'ellipse', + icon: 'circle', + title: 'Circle', + }, + { + id: 'polygon', + icon: 'triangle', + title: 'Triangle', + }, + ] + + const app = useApp() + const [activeGeomId, setActiveGeomId] = React.useState( + () => (geometries.find(geo => geo.id === app.selectedTool.id) ?? geometries[0]).id + ) + + React.useEffect(() => { + setActiveGeomId(prevId => { + return geometries.find(geo => geo.id === app.selectedTool.id)?.id ?? prevId + }) + }, [app.selectedTool.id]) + + return ( + + + geo.id === activeGeomId)!} /> + + + +
+ {geometries.map(props => ( + + ))} +
+ + +
+
+ ) +}) diff --git a/tldraw/apps/tldraw-logseq/src/components/GeometryTools/index.ts b/tldraw/apps/tldraw-logseq/src/components/GeometryTools/index.ts new file mode 100644 index 0000000000..5a77574faf --- /dev/null +++ b/tldraw/apps/tldraw-logseq/src/components/GeometryTools/index.ts @@ -0,0 +1 @@ +export * from './GeometryTools' diff --git a/tldraw/apps/tldraw-logseq/src/components/PrimaryTools/PrimaryTools.tsx b/tldraw/apps/tldraw-logseq/src/components/PrimaryTools/PrimaryTools.tsx index fb13a0fac5..8d9aaac682 100644 --- a/tldraw/apps/tldraw-logseq/src/components/PrimaryTools/PrimaryTools.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/PrimaryTools/PrimaryTools.tsx @@ -2,61 +2,10 @@ import { useApp } from '@tldraw/react' import { observer } from 'mobx-react-lite' import * as React from 'react' import { ToolButton } from '../ToolButton' +import { GeometryTools } from '../GeometryTools' import { ColorInput } from '../inputs/ColorInput' import * as Separator from '@radix-ui/react-separator' -const GeometryToolButtons = observer(() => { - const geometries = [ - { - id: 'box', - icon: 'square', - title: 'Rectangle', - }, - { - id: 'ellipse', - icon: 'circle', - title: 'Circle', - }, - { - id: 'polygon', - icon: 'triangle', - title: 'Triangle', - }, - ] - - const app = useApp() - const [activeGeomId, setActiveGeomId] = React.useState( - () => (geometries.find(geo => geo.id === app.selectedTool.id) ?? geometries[0]).id - ) - - const [paneActive, setPaneActive] = React.useState(false) - - React.useEffect(() => { - setActiveGeomId(prevId => { - return geometries.find(geo => geo.id === app.selectedTool.id)?.id ?? prevId - }) - }, [app.selectedTool.id]) - - return ( -
setPaneActive(true)} - onMouseLeave={() => setPaneActive(false)} - > - { geo.id === activeGeomId)!} />} - {paneActive && ( -
- {geometries.map(props => ( - - ))} -
- )} -
- ) -}) - - - export const PrimaryTools = observer(function PrimaryTools() { const app = useApp() @@ -78,7 +27,7 @@ export const PrimaryTools = observer(function PrimaryTools() { - + {renderColor(color)} .tl-button[data-selected='true']::after { @apply block absolute; @@ -904,11 +886,15 @@ html[data-theme='dark'] { .tl-popover-content { @apply rounded-sm drop-shadow-md; - padding: 4px; background-color: var(--ls-secondary-background-color); z-index: 100000; } +.tl-geometry-toolbar { + box-shadow: none; + flex-flow: column; +} + .tl-popover-arrow { fill: var(--ls-secondary-background-color); }