-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changement Launch files rove/markhor
- Loading branch information
1 parent
110911b
commit 0c95d7a
Showing
8 changed files
with
133 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,47 @@ | ||
import React from 'react'; | ||
import { toast } from 'react-toastify'; | ||
import { Robot, robotSlice,selectRobot } from '@/renderer/store/modules/robot'; | ||
import { launchFilesSlice,selectAllLaunchFiles } from '@/renderer/store/modules/launchFiles'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import styled from 'styled-components'; | ||
import { GlobalState } from '@/renderer/store/store'; | ||
|
||
|
||
interface robot { | ||
name: string | ||
} | ||
|
||
function BasicExample() { | ||
const StyledSelect = styled.select` | ||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
font-size: 16px; | ||
color: white; | ||
border: none; | ||
background-color: #404040; | ||
`; | ||
|
||
|
||
const robot: robot[] = [ | ||
function DropdownRobot(){ | ||
const dispatch = useDispatch(); | ||
|
||
const robot: Robot[] = [ | ||
{ | ||
name:"rove", | ||
}, | ||
{ | ||
name:"markhor", | ||
}, | ||
] | ||
]; | ||
const handleRobotChange =(event: React.ChangeEvent<HTMLSelectElement>)=>{ | ||
const selectedRobot = event.target.value; | ||
dispatch(robotSlice.actions.toggleRobot(selectedRobot)); | ||
dispatch(launchFilesSlice.actions.changeRobot(selectedRobot)); | ||
toast.info("robot changed to "+ selectedRobot) | ||
}; | ||
return ( | ||
<div> | ||
<select> | ||
|
||
<StyledSelect onChange={handleRobotChange}> | ||
{robot.map((robot) => ( | ||
<option value={robot.name}>{robot.name}</option> | ||
))} | ||
</select> | ||
</div> | ||
</StyledSelect> | ||
|
||
); | ||
} | ||
|
||
export default BasicExample; | ||
export default DropdownRobot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { GlobalState } from '@/renderer/store/store'; | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
|
||
export interface Robot{ | ||
name: string; | ||
} | ||
|
||
export const initialState: Robot ={ | ||
name:'rove', | ||
}; | ||
|
||
export const robotSlice = createSlice({ | ||
name:'robotChoice', | ||
initialState, | ||
reducers:{ | ||
toggleRobot: (state, { payload }: PayloadAction<string>)=>{ | ||
state.name = payload; | ||
} | ||
} | ||
}); | ||
export const selectRobot =(state: GlobalState) => state.robot.name; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters