IDE redesign, initial implementation #362

Merged
Irev-Dev merged 17 commits from kurt/update-ide-panel-toolbar-360 into main 2021-06-15 10:05:03 +02:00
2 changed files with 82 additions and 51 deletions
Showing only changes of commit 155923b2e7 - Show all commits

View File

@@ -31,9 +31,7 @@ const EditorMenu = () => {
<button className="cursor-not-allowed" disabled> <button className="cursor-not-allowed" disabled>
Edit Edit
</button> </button>
<button className="cursor-not-allowed" disabled> <ViewDropdown handleLayoutReset={() => thunkDispatch({type: 'resetLayout'})} />
View
</button>
</div> </div>
<button <button
className="text-gray-300 h-full cursor-not-allowed" className="text-gray-300 h-full cursor-not-allowed"
@@ -59,9 +57,7 @@ export default EditorMenu
function FileDropdown({ handleRender, handleStlDownload }) { function FileDropdown({ handleRender, handleStlDownload }) {
Irev-Dev commented 2021-06-14 02:21:45 +02:00 (Migrated from github.com)
Review

image

![image](https://user-images.githubusercontent.com/29681384/121826279-4ff0bf00-ccfa-11eb-8315-bd8a4cfc0ef7.png)
return ( return (
<Menu> <Dropdown name="File">
<Menu.Button className="text-gray-100">File</Menu.Button>
<Menu.Items className="absolute flex flex-col mt-10 bg-gray-500 rounded shadow-md text-gray-100">
<Menu.Item> <Menu.Item>
{({ active }) => ( {({ active }) => (
<button <button
@@ -95,7 +91,36 @@ function FileDropdown({ handleRender, handleStlDownload }) {
</button> </button>
)} )}
</Menu.Item> </Menu.Item>
</Menu.Items> </Dropdown>
</Menu> )
}
function ViewDropdown({ handleLayoutReset }) {
Irev-Dev commented 2021-06-14 02:21:59 +02:00 (Migrated from github.com)
Review

image

![image](https://user-images.githubusercontent.com/29681384/121826302-66971600-ccfa-11eb-8aa7-f48b627bc6a9.png)
return (
<Dropdown name="View">
<Menu.Item>
{({ active }) => (
<button
className={`${active && 'bg-gray-600'} px-2 py-1`}
onClick={handleLayoutReset}
>
Reset layout
</button>
)}
</Menu.Item>
</Dropdown>
)
}
function Dropdown({ name, children }: {name: string, children: React.ReactNode}) {
return (
<div className="relative">
<Menu>
<Menu.Button className="text-gray-100">{name}</Menu.Button>
<Menu.Items className="absolute flex flex-col mt-4 bg-gray-500 rounded shadow-md text-gray-100 overflow-hidden whitespace-nowrap">
{children}
</Menu.Items>
</Menu>
</div>
) )
} }

View File

@@ -47,6 +47,16 @@ let mutableState = null
export const useIdeState = () => { export const useIdeState = () => {
const code = '' const code = ''
const initialLayout = {
direction: 'row',
first: 'Editor',
second: {
direction: 'column',
first: 'Viewer',
second: 'Console',
splitPercentage: 70,
},
}
const initialState = { const initialState = {
ideType: 'INIT', ideType: 'INIT',
consoleMessages: [ consoleMessages: [
@@ -57,16 +67,7 @@ export const useIdeState = () => {
type: 'INIT', type: 'INIT',
data: null, data: null,
}, },
layout: { layout: initialLayout,
direction: 'row',
first: 'Editor',
second: {
direction: 'column',
first: 'Viewer',
second: 'Console',
splitPercentage: 70,
},
},
camera: {}, camera: {},
viewerSize: { width: 0, height: 0 }, viewerSize: { width: 0, height: 0 },
isLoading: false, isLoading: false,
@@ -129,6 +130,11 @@ export const useIdeState = () => {
...state, ...state,
isLoading: false, isLoading: false,
} }
case 'resetLayout':
return {
...state,
layout: initialLayout,
}
default: default:
return state return state
} }