Showing state being passed into useIdeState dispatch middleware to change ideType.

This commit is contained in:
Frank Noirot
2021-03-04 23:06:07 -05:00
parent 3f03cb375d
commit 661797b9a3
6 changed files with 70 additions and 9 deletions

View File

@@ -6,10 +6,16 @@ export const IdeContext = createContext()
const IdeToolbarNew = () => {
const [state, dispatch] = useIdeState()
function setIdeType(ide) { dispatch({ type: 'setIdeType', payload: { message: ide } }) }
return (
<IdeContext.Provider value={{ state, dispatch }}>
<div className="p-8 border-2">
<div>hi I'm the toolbar</div>
<nav class="flex">
<button onClick={() => setIdeType('openCascade')} class="p-2 br-2 border-2 m-2 bg-blue-200">Switch to OpenCascade</button>
<button onClick={() => setIdeType('openScad')} class="p-2 br-2 border-2 m-2 bg-indigo-200">Switch to OpenSCAD</button>
</nav>
<IdeContainer />
</div>
</IdeContext.Provider>

View File

@@ -9,7 +9,8 @@ const IdeViewer = () => {
<div>
I should be showing an{' '}
<span className="font-mono uppercase">{state.objectData?.type}</span>{' '}
right now
right now with the data{' '}
<span className="font-mono uppercase">{state.objectData?.data}</span>{' '}
</div>
</div>
)