Moved r3f's toolbar out of the snapshot editor

This commit is contained in:
Aria Minaei 2021-07-10 12:15:27 +02:00
parent 7f30f08bd0
commit 86547aa4cb
8 changed files with 19 additions and 20 deletions

View file

@ -6,7 +6,7 @@ import {useEditorStore} from '../store'
import {OrbitControls} from '@react-three/drei' import {OrbitControls} from '@react-three/drei'
import shallow from 'zustand/shallow' import shallow from 'zustand/shallow'
import root from 'react-shadow/styled-components' import root from 'react-shadow/styled-components'
import UI from './UI' import Toolbar from './Toolbar/Toolbar'
import ProxyManager from './ProxyManager' import ProxyManager from './ProxyManager'
import studio from '@theatre/studio' import studio from '@theatre/studio'
import {useVal} from '@theatre/dataverse-react' import {useVal} from '@theatre/dataverse-react'
@ -62,7 +62,7 @@ const EditorScene = () => {
) )
} }
const Wrapper = styled.div<{editorOpen: boolean}>` const Wrapper = styled.div<{visible: boolean}>`
tab-size: 4; tab-size: 4;
line-height: 1.15; /* 1 */ line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */
@ -74,7 +74,7 @@ const Wrapper = styled.div<{editorOpen: boolean}>`
bottom: 0px; bottom: 0px;
left: 0px; left: 0px;
z-index: 50; z-index: 50;
display: ${(props) => (props.editorOpen ? 'block' : 'none')}; display: ${(props) => (props.visible ? 'block' : 'none')};
` `
const CanvasWrapper = styled.div` const CanvasWrapper = styled.div`
@ -107,7 +107,8 @@ const Editor: VFC = () => {
return ( return (
<root.div> <root.div>
<GlobalStyle /> <GlobalStyle />
<Wrapper id="theatre-plugin-r3f-root" editorOpen={editorOpen}> <Wrapper id="theatre-plugin-r3f-root" visible={true}>
<Toolbar />
{sceneSnapshot ? ( {sceneSnapshot ? (
<> <>
<CanvasWrapper> <CanvasWrapper>
@ -125,8 +126,6 @@ const Editor: VFC = () => {
<EditorScene /> <EditorScene />
</Canvas> </Canvas>
</CanvasWrapper> </CanvasWrapper>
<UI />
</> </>
) : null} ) : null}
</Wrapper> </Wrapper>

View file

@ -2,7 +2,7 @@ import type {VFC} from 'react'
import {useState} from 'react' import {useState} from 'react'
import React from 'react' import React from 'react'
import TransformControlsModeSelect from './TransformControlsModeSelect' import TransformControlsModeSelect from './TransformControlsModeSelect'
import {useEditorStore} from '../store' import {useEditorStore} from '../../store'
import shallow from 'zustand/shallow' import shallow from 'zustand/shallow'
import TransformControlsSpaceSelect from './TransformControlsSpaceSelect' import TransformControlsSpaceSelect from './TransformControlsSpaceSelect'
import ViewportShadingSelect from './ViewportShadingSelect' import ViewportShadingSelect from './ViewportShadingSelect'
@ -10,9 +10,9 @@ import {GiPocketBow, RiFocus3Line} from 'react-icons/all'
import {Vector3} from 'three' import {Vector3} from 'three'
import type {$FixMe} from '@theatre/shared/utils/types' import type {$FixMe} from '@theatre/shared/utils/types'
import studio from '@theatre/studio' import studio from '@theatre/studio'
import {getSelected} from './useSelected' import {getSelected} from '../useSelected'
import {useVal} from '@theatre/dataverse-react' import {useVal} from '@theatre/dataverse-react'
import IconButton from './elements/IconButton' import IconButton from './utils/IconButton'
import {PortalContext} from 'reakit' import {PortalContext} from 'reakit'
import styled from 'styled-components' import styled from 'styled-components'
@ -37,7 +37,7 @@ const TopRow = styled.div`
align-items: flex-start; align-items: flex-start;
` `
const Toolbar = styled.div` const Tools = styled.div`
display: flex; display: flex;
gap: 1rem; gap: 1rem;
` `
@ -46,7 +46,7 @@ const ToolGroup = styled.div`
pointer-events: auto; pointer-events: auto;
` `
const UI: VFC = () => { const Toolbar: VFC = () => {
const [editorObject] = useEditorStore( const [editorObject] = useEditorStore(
(state) => [state.editorObject], (state) => [state.editorObject],
shallow, shallow,
@ -67,7 +67,7 @@ const UI: VFC = () => {
<PortalContext.Provider value={wrapper}> <PortalContext.Provider value={wrapper}>
<Container ref={setWrapper}> <Container ref={setWrapper}>
<TopRow> <TopRow>
<Toolbar> <Tools>
<ToolGroup> <ToolGroup>
<TransformControlsModeSelect <TransformControlsModeSelect
value={transformControlsMode} value={transformControlsMode}
@ -160,11 +160,11 @@ const UI: VFC = () => {
}} }}
/> />
</ToolGroup> </ToolGroup>
</Toolbar> </Tools>
</TopRow> </TopRow>
</Container> </Container>
</PortalContext.Provider> </PortalContext.Provider>
) )
} }
export default UI export default Toolbar

View file

@ -1,8 +1,8 @@
import type {VFC} from 'react' import type {VFC} from 'react'
import React from 'react' import React from 'react'
import {GiClockwiseRotation, GiMove, GiResize} from 'react-icons/all' import {GiClockwiseRotation, GiMove, GiResize} from 'react-icons/all'
import type {TransformControlsMode} from '../store' import type {TransformControlsMode} from '../../store'
import CompactModeSelect from './elements/CompactModeSelect' import CompactModeSelect from './utils/CompactModeSelect'
export interface TransformControlsModeSelectProps { export interface TransformControlsModeSelectProps {
value: TransformControlsMode value: TransformControlsMode

View file

@ -1,8 +1,8 @@
import type {VFC} from 'react' import type {VFC} from 'react'
import React from 'react' import React from 'react'
import type {TransformControlsSpace} from '../store' import type {TransformControlsSpace} from '../../store'
import {BiCube, BiGlobe} from 'react-icons/all' import {BiCube, BiGlobe} from 'react-icons/all'
import CompactModeSelect from './elements/CompactModeSelect' import CompactModeSelect from './utils/CompactModeSelect'
export interface TransformControlsSpaceSelectProps { export interface TransformControlsSpaceSelectProps {
value: TransformControlsSpace value: TransformControlsSpace

View file

@ -1,8 +1,8 @@
import type {VFC} from 'react' import type {VFC} from 'react'
import React from 'react' import React from 'react'
import type {ViewportShading} from '../store' import type {ViewportShading} from '../../store'
import {FaCube, GiCube, GiIceCube, BiCube} from 'react-icons/all' import {FaCube, GiCube, GiIceCube, BiCube} from 'react-icons/all'
import CompactModeSelect from './elements/CompactModeSelect' import CompactModeSelect from './utils/CompactModeSelect'
export interface ViewportShadingSelectProps { export interface ViewportShadingSelectProps {
value: ViewportShading value: ViewportShading