Skip to content

Commit

Permalink
Tweak topbar button styling
Browse files Browse the repository at this point in the history
Prevent images from being dragged.
Add HelpModal with placeholder content.
Make icons for ConnectionConfigButton.
Extract ConnectionConfigButton to TopbarButton, then add another one
that opens the HelpModal.
  • Loading branch information
Hal-9k1 committed Oct 19, 2024
1 parent 48f812c commit 9b9acbd
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 40 deletions.
28 changes: 28 additions & 0 deletions assets/network.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions assets/no-network.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions assets/question.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/renderer/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ body {
}

.App {
--window-head-color: blue;
--window-head-color: navy;
--window-head-text-color: white;
--window-accent-color: grey;
--body-color: white;
Expand Down Expand Up @@ -32,7 +32,7 @@ body {
z-index: 20;
backdrop-filter: blur(2px);
}
.App-modal-container:has(.modal-active) {
.App-modal-container:has(.Modal-active) {
display: block;
}
.App-confirm-dialog-text {
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ConfirmModal from './modals/ConfirmModal';
import ConnectionConfigModal, {
ConnectionConfigChangeEvent,
} from './modals/ConnectionConfigModal';
import HelpModal from './modals/HelpModal';
import GamepadInfoModal from './modals/GamepadInfoModal';
import ResizeBar from './ResizeBar';
import {
Expand Down Expand Up @@ -412,6 +413,7 @@ export default function App() {
onConnectionConfigModalOpen={() =>
changeActiveModal('ConnectionConfig')
}
onHelpModalOpen={() => changeActiveModal('Help')}
dawnVersion={dawnVersion}
robotLatencyMs={robotLatencyMs}
robotBatteryVoltage={robotBatteryVoltage}
Expand Down Expand Up @@ -480,6 +482,7 @@ export default function App() {
FieldIPAddress={FieldIPAddress}
FieldStationNum={FieldStationNum}
/>
<HelpModal isActive={activeModal === 'Help'} onClose={closeModal} />
<GamepadInfoModal
isActive={activeModal === 'GamepadInfo'}
onClose={closeModal}
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/ConnectionConfigButton.css

This file was deleted.

24 changes: 0 additions & 24 deletions src/renderer/ConnectionConfigButton.tsx

This file was deleted.

1 change: 1 addition & 0 deletions src/renderer/Editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
transition: filter 0.25s;
/* Fix other filter variables so transition is directly from black to blue: */
filter: invert(0%) sepia(100%) hue-rotate(180deg) saturate(0);
pointer-events: none;
}
.Editor-tbbtn-toggled img {
/* CSS filter witchcraft producing #0088ff */
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/Topbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
.Topbar-right-group {
float: right;
}
.Topbar-tail {
clear: both;
}
.Topbar-dawn-version {
font-size: 25px;
margin-right: 40px;
Expand All @@ -32,6 +29,7 @@
font-weight: bold;
font-size: 15px;
}

.Topbar-robot-disconnected {
background-color: indianred;
}
Expand Down
20 changes: 17 additions & 3 deletions src/renderer/Topbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import ConnectionConfigButton from './ConnectionConfigButton';
import TopbarButton from './TopbarButton';
import questionSvg from '../../assets/question.svg';
import connectionSvg from '../../assets/network.svg';
import noConnectionSvg from '../../assets/no-network.svg';
import './Topbar.css';

const GOOD_BATTERY_VOLTAGE = 11;
Expand All @@ -11,6 +14,7 @@ const FAIR_LATENCY_MS = 200;
* @param props - props
* @param props.onConnectionConfigModalOpen - handler called when the ConnectionConfigModal should
* be opened
* @param props.onHelpModalOpen - handler called when the HelpModal should be opened
* @param props.robotLatencyMs - latency in milliseconds of the connection to the currently
* connected robot, or -1 if there is no robot connected
* @param props.robotBatteryVoltage - battery voltage in volts of the currently connected robot. The
Expand All @@ -19,11 +23,13 @@ const FAIR_LATENCY_MS = 200;
*/
export default function Topbar({
onConnectionConfigModalOpen,
onHelpModalOpen,
robotBatteryVoltage,
robotLatencyMs,
dawnVersion,
}: {
onConnectionConfigModalOpen: () => void;
onHelpModalOpen: () => void;
robotBatteryVoltage: number;
robotLatencyMs: number;
dawnVersion: string;
Expand Down Expand Up @@ -66,9 +72,17 @@ export default function Topbar({
{robotInfo}
</div>
<div className="Topbar-right-group">
<ConnectionConfigButton onModalOpen={onConnectionConfigModalOpen} />
<TopbarButton
onModalOpen={onHelpModalOpen}
alt="Dawn and robot API help"
src={questionSvg}
/>
<TopbarButton
onModalOpen={onConnectionConfigModalOpen}
alt="Connection configuration"
src={robotLatencyMs === -1 ? noConnectionSvg : connectionSvg}
/>
</div>
<div className="Topbar-tail" />
</div>
);
}
18 changes: 18 additions & 0 deletions src/renderer/TopbarButton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.TopbarButton {
height: 100%;
}
.TopbarButton button {
background-color: transparent;
border: none;
outline: none;
cursor: pointer;
}
.TopbarButton img {
height: 25px;
border: 3px solid lightgray;
border-radius: 6px;
pointer-events: none;
}
.TopbarButton button:active img {
border-color: gray;
}
26 changes: 26 additions & 0 deletions src/renderer/TopbarButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import './TopbarButton.css';

/**
* Image button component in the Topbar that opens a modal.
* @param props - props
* @param props.onModalOpen - click handler for the button that opens the ConnectionConfigModal
* @param props.src - source of the image
* @param props.alt - string to use as the image alt text and button hover text
*/
export default function TopbarButton({
onModalOpen,
src,
alt,
}: {
onModalOpen: () => void;
src: string;
alt: string;
}) {
return (
<div className="TopbarButton">
<button type="button" onClick={onModalOpen} title={alt}>
<img src={src} alt={alt} />
</button>
</div>
);
}
23 changes: 23 additions & 0 deletions src/renderer/modals/HelpModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Modal from './Modal';

/**
* Modal component displaying help for Dawn and the robot API.
* @param props - props
* @param props.onClose - handler called when the modal is closed by any means
* @param props.isActive - whether to display the modal
*/
export default function GamepadInfoModal({
onClose,
isActive,
}: {
onClose: () => void;
isActive: boolean;
}) {
return (
<Modal modalTitle="Help" onClose={onClose} isActive={isActive}>
This is a very helpful message. So helpful, in fact, that it&apos;s too
helpful to even write here. Its helpfulness would blind your eyes with its
brilliance.
</Modal>
);
}
3 changes: 2 additions & 1 deletion src/renderer/modals/Modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
transform: translate(-50%, -50%);
background-color: var(--body-color);
border-radius: 10px;
font-family: Arial, sans-serif;
}
.modal-active {
.Modal-active {
display: block;
}
.Modal-title-bar {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/modals/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Modal({
className?: string;
}) {
return (
<div className={`Modal${isActive ? ' modal-active' : ''}`}>
<div className={`Modal${isActive ? ' Modal-active' : ''}`}>
<div className="Modal-title-bar">
<span className="Modal-title">{modalTitle}</span>
<button className="Modal-close-button" onClick={onClose} type="button">
Expand Down

0 comments on commit 9b9acbd

Please sign in to comment.