[big chore] restore core to monorepo (#287)

* move core into repo, apps into apps folder, update tests

* Update scripts for build:core

* improve scripts

* remove noise from www

* Update .gitignore

* Fix focus bug

* add ci test script

* Update main.yml
This commit is contained in:
Steve Ruiz 2021-11-18 13:09:18 +00:00 committed by GitHub
parent 878ca710b7
commit e6a3e5c3ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
389 changed files with 12980 additions and 95 deletions

View file

@ -0,0 +1,64 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import * as React from 'react'
import { ColorStyle, Tldraw, TDShapeType, TldrawApp } from '@tldraw/tldraw'
export default function Imperative(): JSX.Element {
const rTldrawApp = React.useRef<TldrawApp>()
const handleMount = React.useCallback((app: TldrawApp) => {
rTldrawApp.current = app
app.createShapes(
{
id: 'rect1',
type: TDShapeType.Rectangle,
name: 'Rectangle',
childIndex: 1,
point: [0, 0],
size: [100, 100],
},
{
id: 'rect2',
name: 'Rectangle',
type: TDShapeType.Rectangle,
point: [200, 200],
size: [100, 100],
}
)
}, [])
React.useEffect(() => {
let i = 0
const interval = setInterval(() => {
const app = rTldrawApp.current!
const rect1 = app.getShape('rect1')
if (!rect1) {
app.createShapes({
id: 'rect1',
type: TDShapeType.Rectangle,
name: 'Rectangle',
childIndex: 1,
point: [0, 0],
size: [100, 100],
})
return
}
const color = i % 2 ? ColorStyle.Red : ColorStyle.Blue
app.patchShapes({
id: 'rect1',
style: {
...rect1.style,
color,
},
})
i++
}, 1000)
return () => clearInterval(interval)
}, [])
return <Tldraw onMount={handleMount} />
}