-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
118 additions
and
10 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
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,8 +1,17 @@ | ||
import { useDispatch } from 'react-redux'; | ||
import { modalActions, Modals } from './store/modalSlice'; | ||
|
||
/** | ||
* Button component that opens the ConnectionConfigModal. | ||
*/ | ||
export default function ConnectionConfig() { | ||
const dispatch = useDispatch(); | ||
return ( | ||
<div className="ConnectionConfig"></div> | ||
<div className="ConnectionConfig"> | ||
<button className="ConnectionConfig-button" | ||
Check failure on line 11 in src/renderer/ConnectionConfig.tsx
|
||
onClick={() => dispatch(modalActions.setActive(Modals.ConnectionConfig))}> | ||
Check failure on line 12 in src/renderer/ConnectionConfig.tsx
|
||
Connection settings... | ||
</button> | ||
</div> | ||
); | ||
} |
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,5 +1,5 @@ | ||
.ResizeBar { | ||
background-color: black; | ||
background-color: gray; | ||
width: 5px; | ||
cursor: col-resize; | ||
} | ||
|
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import Modal from './Modal'; | ||
import { Modals } from '../store/modalSlice'; | ||
|
||
/** | ||
* Modal component exposing info about the connection to the robot (IP address, port, etc.) | ||
*/ | ||
export default function ConnectionInfoModal() { | ||
return ( | ||
<div className="ConnectionInfoModal">Connection info modal</div> | ||
<Modal modalType={Modals.ConnectionConfig} modalTitle="Connection info"> | ||
Test | ||
</Modal> | ||
); | ||
} |
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,8 +1,13 @@ | ||
import { Modals } from '../store/modalSlice'; | ||
import Modal from './Modal'; | ||
|
||
/** | ||
* Modal component displaying info about a connected gamepad. | ||
*/ | ||
export default function GamepadInfoModal() { | ||
return ( | ||
<div className="GamepadInfoModal">Gamepad info modal</div> | ||
<Modal modalType={Modals.GamepadInfo} modalTitle="Gamepad info"> | ||
Test | ||
</Modal> | ||
); | ||
} |
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,28 @@ | ||
.Modal { | ||
display: none; | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: white; | ||
border-radius: 5px; | ||
} | ||
.modal-active { | ||
display: block; | ||
} | ||
.Modal-title-bar { | ||
white-space: nowrap; | ||
padding: 20px; | ||
background-color: blue; | ||
border-radius: inherit; | ||
} | ||
.Modal-title { | ||
padding-right: 20vw; | ||
} | ||
.Modal-close-button { | ||
background-color: transparent; | ||
border: none; | ||
} | ||
.Modal-content { | ||
padding: 20px; | ||
} |
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,28 @@ | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { modalActions, Modals } from '../store/modalSlice'; | ||
import type { State } from '../store/store'; | ||
import './Modal.css'; | ||
|
||
/** | ||
* Generic modal component. | ||
*/ | ||
export default function Modal({ modalType, modalTitle, children }) { | ||
const isActive = useSelector((state: State) => state.modal.activeModal === modalType); | ||
const dispatch = useDispatch(); | ||
return ( | ||
<div className={'Modal' + (isActive ? ' modal-active' : '')}> | ||
<div className="Modal-title-bar"> | ||
<span className="Modal-title"> | ||
{modalTitle} | ||
</span> | ||
<button className="Modal-close-button" | ||
onClick={() => dispatch(modalActions.setActive(Modals.None))}> | ||
X | ||
</button> | ||
</div> | ||
<div className="Modal-content"> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
} |
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,27 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
export enum Modals { | ||
None, | ||
ConnectionConfig, | ||
GamepadInfo | ||
} | ||
const initialState = { | ||
activeModal: Modals.None | ||
}; | ||
export const modalSlice = createSlice({ | ||
name: 'modal', | ||
initialState: initialState, | ||
reducers: { | ||
/** | ||
* Sets the currently active modal. | ||
*/ | ||
setActive: (state, { payload }) => { | ||
console.log('set active to ' + payload.toString()); | ||
state.activeModal = payload; | ||
} | ||
} | ||
}); | ||
|
||
export const modalActions = modalSlice.actions; | ||
export type ModalState = typeof initialState; | ||
export default modalSlice.reducer; |
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,14 +1,17 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import robotInfoReducer, { RobotInfoState } from './robotInfoSlice'; | ||
import editorReducer, { EditorState } from './editorSlice'; | ||
import modalReducer, { ModalState } from './modalSlice'; | ||
|
||
export interface State { | ||
robotInfo: RobotInfoState, | ||
editor: EditorState | ||
editor: EditorState, | ||
modal: ModalState | ||
} | ||
export default configureStore({ | ||
reducer: { | ||
robotInfo: robotInfoReducer, | ||
editor: editorReducer | ||
editor: editorReducer, | ||
modal: modalReducer | ||
} | ||
}); |