Skip to content

Commit

Permalink
Cleanups in the web UI & licensure fixes
Browse files Browse the repository at this point in the history
Properly scrolls on input, nicer font and spacing
  • Loading branch information
rdaum committed Jan 11, 2025
1 parent cf4c9df commit a8e24da
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 20 deletions.
21 changes: 20 additions & 1 deletion .licensure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ comments:
type: line
comment_char: "//"
trailing_lines: 1
- columns: 80
extension: ts
commenter:
type: line
comment_char: "//"
trailing_lines: 1
- columns: 80
extension: tsx
commenter:
type: line
comment_char: "//"
trailing_lines: 1
- columns: 80
extension: jsx
commenter:
type: line
comment_char: "//"
trailing_lines: 1
- columns: 80
extension: fbs
commenter:
Expand All @@ -53,4 +71,5 @@ excludes:
- LICENSE.*
- Dockerfile
- core
- .*\.(md|rst|txt|yml|png|jpg|gif|db|pem|lock|json|toml|in|out|html|moot|edn|node)
- node_modules
- .*\.(md|rst|txt|yml|png|jpg|gif|db|pem|lock|json|toml|in|out|html|moot|edn|node|css)
13 changes: 13 additions & 0 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

import { defineConfig } from 'cypress';

export default defineConfig({
Expand Down
13 changes: 13 additions & 0 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
Expand Down
13 changes: 13 additions & 0 deletions frontend/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
Expand Down
6 changes: 6 additions & 0 deletions frontend/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400&display=swap');

/*"messages" class name should use a mono font, take up the full width of the screen, and have a height of 50vh.*/
.messages {
font-family: 'Roboto Mono', monospace;
width: 100%;
}

.inputArea {
width: 100%;
}

.inputField {
font-family: 'Roboto Mono', monospace;
/* stretch to fill the width of the div, except for the submit button beside us */
width: calc(100% - 100px);
}
.inputSubmitButton {
font-family: 'Roboto Mono', monospace;
width: 80px;
}
78 changes: 59 additions & 19 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@
import { useEffect, useState } from "react";
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

import { useEffect, useState, useRef } from "react";
import "./App.css";

const Messages = ({ messages }) => {
const messagesEndRef = useRef(null);
const scrollToBottom = () => {
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
};
useEffect(scrollToBottom, [messages]);

return (
<div className="messages">
{messages.map(message => (
<div key={message}>{message}</div>
))}
<div ref={messagesEndRef} />
</div>
);
};

const InputField = ({ setMessage, sendMessage }) => {
const inputRef = useRef(null);
const onEntry = () => {
inputRef.current.focus();
sendMessage();
inputRef.current.value = "";
};
return (
<div className="inputArea">
<input
onChange={(e) => setMessage(e.target.value)}
type="text"
ref={inputRef}
placeholder="message"
className="inputField"
onKeyDown={(e) => e.key === "Enter" && onEntry()}
/>
<button onClick={onEntry} className="inputSubmitButton" type="button">
Send
</button>
</div>
);
}
function App() {
const [messages, setMessages] = useState([]);
const [socket, setSocket] = useState(null);
const [message, setMessage] = useState("");



function sendMessage() {
socket.send(
JSON.stringify({
Expand Down Expand Up @@ -33,26 +88,11 @@ function App() {

return (
<div>
<div>
{messages.map((m, index) => (
<div key={index}>
{m}
</div>
))}
</div>
<div>
<input
onChange={(e) => setMessage(e.target.value)}
type="text"
placeholder="message"
onKeyDown={(e) => e.key === "Enter" && sendMessage()}
/>
<button onClick={sendMessage}>
Send
</button>
</div>
<Messages messages={messages} />
<InputField setMessage={setMessage} sendMessage={sendMessage} />
</div>
);
}


export default App;
12 changes: 12 additions & 0 deletions frontend/src/host.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

import {Host, Connection} from 'moor-node-host';
import {readFileSync, writeFileSync} from 'node:fs';
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

/// <reference types="vite/client" />
13 changes: 13 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright (C) 2025 Ryan Daum <[email protected]> This program is free
// software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, version
// 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import { startupHost, startWebSocketServer } from './src/host';
Expand Down

0 comments on commit a8e24da

Please sign in to comment.