Showing state being passed into useIdeState dispatch middleware to change ideType.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user