tldraw/apps/www/components/ReadOnlyMultiplayerEditor.tsx
Steve Ruiz f0f545806a
[improvement] Quality and UI cleanup (#846)
* remove sponsors, ui cleanup

* fix radius

* improve panel

* remove cursor spline animations

* migrate options

* Switch hrs to divider

* fix text color on menu dark mode

* Remove option for clone handles

* fix wheel

* remove unused translations
2022-07-23 15:05:48 +01:00

53 lines
1.2 KiB
TypeScript

import * as React from 'react'
import { RoomProvider } from '../utils/liveblocks'
import { Tldraw, useFileSystem } from '@tldraw/tldraw'
import { styled } from 'styles'
import { useReadOnlyMultiplayerState } from 'hooks/useReadOnlyMultiplayerState'
interface Props {
roomId: string
}
const ReadOnlyMultiplayerEditor = ({ roomId }: Props) => {
return (
<RoomProvider id={roomId}>
<ReadOnlyEditor roomId={roomId} />
</RoomProvider>
)
}
// Inner Editor
function ReadOnlyEditor({ roomId }: Props) {
const { onSaveProjectAs, onSaveProject } = useFileSystem()
const { error, ...events } = useReadOnlyMultiplayerState(roomId)
if (error) return <LoadingScreen>Error: {error.message}</LoadingScreen>
return (
<div className="tldraw">
<Tldraw
autofocus
disableAssets={false}
showPages={false}
onSaveProjectAs={onSaveProjectAs}
onSaveProject={onSaveProject}
readOnly
{...events}
/>
</div>
)
}
export default ReadOnlyMultiplayerEditor
const LoadingScreen = styled('div', {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
})