Started implementing ProjectDetails

This commit is contained in:
Aria Minaei 2021-08-09 15:23:14 +02:00
parent d38070025c
commit 49c97ebfcf
4 changed files with 85 additions and 41 deletions

View file

@ -1,5 +1,5 @@
import OutlinePanel from '@theatre/studio/panels/OutlinePanel/OutlinePanel'
import ObjectEditorPanel from '@theatre/studio/panels/DetailPanel/ObjectEditorPanel'
import DetailPanel from '@theatre/studio/panels/DetailPanel/DetailPanel'
import React from 'react'
import getStudio from '@theatre/studio/getStudio'
import {useVal} from '@theatre/dataverse-react'
@ -18,7 +18,7 @@ const PanelsRoot: React.FC = () => {
<>
{paneEls}
<OutlinePanel />
<ObjectEditorPanel />
<DetailPanel />
<SequenceEditorPanel />
</>
)

View file

@ -1,17 +1,16 @@
import {getOutlineSelection} from '@theatre/studio/selectors'
import {usePrism} from '@theatre/dataverse-react'
import {prism} from '@theatre/dataverse'
import React from 'react'
import styled from 'styled-components'
import DeterminePropEditor from './propEditors/DeterminePropEditor'
import {isSheetObject} from '@theatre/shared/instanceTypes'
import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
import {isProject, isSheetObject} from '@theatre/shared/instanceTypes'
import {
panelZIndexes,
TitleBar_Piece,
TitleBar_Punctuation,
} from '@theatre/studio/panels/BasePanel/common'
import {pointerEventsAutoInNormalMode} from '@theatre/studio/css'
import ObjectDetails from './ObjectDetails'
import ProjectDetails from './ProjectDetails'
const Container = styled.div`
background-color: transparent;
@ -97,16 +96,12 @@ const Body = styled.div`
user-select: none;
`
const ObjectEditorPanel: React.FC<{}> = (props) => {
const DetailPanel: React.FC<{}> = (props) => {
return usePrism(() => {
const selection = getOutlineSelection()
const obj = selection.find((s): s is SheetObject => isSheetObject(s))
if (!obj) return <></>
const key = prism.memo('key', () => JSON.stringify(obj.address), [obj])
const obj = selection.find(isSheetObject)
if (obj) {
return (
<Container>
<Content>
@ -126,18 +121,32 @@ const ObjectEditorPanel: React.FC<{}> = (props) => {
</Title>
</Header>
<Body>
<DeterminePropEditor
key={key}
obj={obj}
pointerToProp={obj.propsP}
propConfig={obj.template.config}
depth={1}
/>
<ObjectDetails objects={[obj]} />
</Body>
</Content>
</Container>
)
}
const project = selection.find(isProject)
if (project) {
return (
<Container>
<Content>
<Header>
<Title title={`${project.address.projectId}`}>
<TitleBar_Piece>{project.address.projectId} </TitleBar_Piece>
</Title>
</Header>
<Body>
<ProjectDetails projects={[project]} />
</Body>
</Content>
</Container>
)
}
return <></>
}, [])
}
export default ObjectEditorPanel
export default DetailPanel

View file

@ -0,0 +1,23 @@
import React, {useMemo} from 'react'
import DeterminePropEditor from './propEditors/DeterminePropEditor'
import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
const ObjectDetails: React.FC<{
objects: SheetObject[]
}> = ({objects}) => {
// @todo add support for multiple objects (it would show their common props)
const obj = objects[0]
const key = useMemo(() => JSON.stringify(obj.address), [obj])
return (
<DeterminePropEditor
key={key}
obj={obj}
pointerToProp={obj.propsP}
propConfig={obj.template.config}
depth={1}
/>
)
}
export default ObjectDetails

View file

@ -0,0 +1,12 @@
import type Project from '@theatre/core/projects/Project'
import React from 'react'
const ProjectDetails: React.FC<{
projects: Project[]
}> = ({projects}) => {
const project = projects[0]
return <div>editing project {project.address.projectId}</div>
}
export default ProjectDetails