Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 initialize gui #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions control-station/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions control-station/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format": "prettier --write .",
"test": "tsc --noEmit",
"preview": "vite preview"
},
"dependencies": {
Expand All @@ -15,8 +17,8 @@
},
"devDependencies": {
"@eslint/js": "^9.11.1",
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^9.11.1",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
Expand All @@ -25,5 +27,17 @@
"typescript": "^5.5.3",
"typescript-eslint": "^8.7.0",
"vite": "^5.4.8"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
43 changes: 14 additions & 29 deletions control-station/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
import { useState } from "react";
import reactLogo from "./assets/react.svg";
import viteLogo from "/vite.svg";
import "./App.css";
import React from 'react';
import Navbar from './components/Navbar/Navbar';
import StatusIndicator from './components/StatusIndicator/StatusIndicator';
import ControlPanel from './components/ControlPanel/ControlPanel';
import './App.css';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use absolute addresses wherever possible


function App() {
const [count, setCount] = useState(0);

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
<div className="App">
<Navbar />
<StatusIndicator status="green" />
<main className="content">
{"HX10 GUI"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is just a text and no explicit TS code is being added here, you can just use HX10 GUI instead of {"HX10 GUI"}

</main>
<ControlPanel />
</div>
);
}

export default App;
export default App;
24 changes: 24 additions & 0 deletions control-station/src/components/ControlPanel/ControlPanel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.status-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-around;
padding: 10px;
background-color: gray;
}

.status-button {
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 1rem;
font-weight: bold;
cursor: pointer;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding padding to status-bar, you can add margin to status-button. This will make the gui more responsive to different screen sizes


.run { background-color: #4CAF50; color: white; }
.stop { background-color: #F44336; color: white; }
.halt { background-color: #FFA500; color: white; }
.load { background-color: #FFD700; color: white; }
15 changes: 15 additions & 0 deletions control-station/src/components/ControlPanel/ControlPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import './ControlPanel.css';

function ControlPanel() {
return (
<footer className="status-bar">
<button className="status-button run">Run</button>
<button className="status-button stop">Stop</button>
<button className="status-button halt">Halt</button>
<button className="status-button load">Load</button>
</footer>
);
}

export default ControlPanel;
18 changes: 18 additions & 0 deletions control-station/src/components/Navbar/Navbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.navbar {
position: fixed;
top: 0;
left: 0;
right: 0;

font-size: 1.5rem;
background-color: grey;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: normal;

height: 40px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for adding a constant height to the navbar?

padding: 0 10px;

}
14 changes: 14 additions & 0 deletions control-station/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import HX from "../../images/HX_Logo.svg";

import "./Navbar.css";

function Navbar() {
return (
<header className="navbar">
<img alt="HX logo" src={HX} style={{ height: "30px" }} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use relative units for height of the image, something like rem. This way if I have a different font size, it won't look weird next to the logo

HyperXite
</header>
);
}

export default Navbar;
55 changes: 55 additions & 0 deletions control-station/src/components/StatusIndicator/StatusIndicator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.status-indicator-container {
position: fixed;
left: 10px;
top: 50%;
transform: translateY(-50%);
width: 70px;
height: 300px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding constant height and width to the status indicator, can we make it relative?

display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
background-color: gray;
padding: 15px 0;
border-radius: 10px;
}

.status-label {
font-size: 16px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the font size relative

font-weight: bold;
color: white;
margin-bottom: 10px;
}

.status-circles {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
height: 80%;
}

.status-circle {
width: 40px;
height: 40px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this relative to the parent div?

border-radius: 50%;
border: 2px solid #333;
opacity: 0.3;
transition: opacity 0.3s ease;
}

.status-circle.red {
background-color: #F44336;
}

.status-circle.yellow {
background-color: #FFA500;
}

.status-circle.green {
background-color: #4CAF50;
}

.status-circle.active {
opacity: 1;
}
23 changes: 23 additions & 0 deletions control-station/src/components/StatusIndicator/StatusIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import './StatusIndicator.css';

type StatusType = 'green' | 'yellow' | 'red';

interface StatusIndicatorProps {
status: StatusType;
}

function StatusIndicator({ status }: StatusIndicatorProps) {
return (
<div className="status-indicator-container">
<div className="status-label">Status</div>
<div className="status-circles">
<div className={`status-circle green ${status === 'green' ? 'active' : ''}`}></div>
<div className={`status-circle yellow ${status === 'yellow' ? 'active' : ''}`}></div>
<div className={`status-circle red ${status === 'red' ? 'active' : ''}`}></div>
</div>
</div>
);
}

export default StatusIndicator;
6 changes: 6 additions & 0 deletions control-station/src/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module "*.svg" {
import React = require("react");
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>;
const src: string;
export default src;
}
Binary file added control-station/src/images/HX Logo.png
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for having a PNG of the logo too?

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions control-station/src/images/HX_Logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions control-station/src/index.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason index.tsx was created. Since, it is the same as main.tsx. Try to use main.tsx.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';

// const root = ReactDOM.createRoot(
// document.getElementById('root') as HTMLElement
// );
// root.render(
// <React.StrictMode>
// <App />
// </React.StrictMode>
// );

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
24 changes: 0 additions & 24 deletions control-station/tsconfig.app.json

This file was deleted.

32 changes: 28 additions & 4 deletions control-station/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
"compilerOptions": {
"target": "ES2020",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [
{ "path": "./tsconfig.node.json" }
]
}
}
Loading