Skip to content

Commit

Permalink
Add UI
Browse files Browse the repository at this point in the history
Signed-off-by: Andreia Ocănoaia <[email protected]>
  • Loading branch information
andreia-oca committed Jun 9, 2024
1 parent d44558e commit a59a4df
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 40 deletions.
103 changes: 98 additions & 5 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,103 @@
color: #888;
}

.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}

h1 {
margin: 20px 0;
}

.subtitle {
margin: 10px 0 30px 0;
font-size: 18px;
color: #cccccc;
}

.card {
background: #2a2a2a;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
width: 100%;
max-width: 700px;
}

.input-box {
width: 25%;
border-radius: 5px;
box-shadow: none !important;
border: 2px solid #888;
font-size: 16px;
width: 90%;
padding: 10px;
}
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #444;
background: #333;
color: #f1f1f1;
}

.input-box::placeholder {
color: #888;
}

.submit-button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #fff;
cursor: pointer;
font-size: 16px;
}

.submit-button:hover {
background-color: #0056b3;
}

.spinner {
border: 3px solid rgba(255, 255, 255, 0.3);
border-top: 3px solid #fff;
border-radius: 50%;
width: 24px;
height: 24px;
animation: spin 0.8s linear infinite;
margin: 20px auto;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

.footer {
width: 100%;
text-align: center;
position: absolute;
bottom: 0;
left: 0;
padding: 10px 0;
background-color: #111;
}

.footer p {
font-size: 14px;
color: #ccc;
margin: 0;
}

.footer-link {
text-decoration: none;
color: inherit;
}

.footer-link:hover p {
color: #0073e6; /* Change to your desired hover color */
text-decoration: underline;
}
102 changes: 67 additions & 35 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,81 @@
import { useState } from "react";
import reactLogo from "./assets/react.svg";
import { BackendService } from "@genezio-sdk/rag-workshop";
import { BackendService, UserDescription, Recommendation } from "@genezio-sdk/rag-workshop";
import "./App.css";

export default function App() {
const [name, setName] = useState("");
const [response, setResponse] = useState("");
const [description, setDescription] = useState("");
const [response, setResponse] = useState<Recommendation[]>();
const [loading, setLoading] = useState(false);

async function sayHello() {
setResponse(await BackendService.hello(name));
async function askLlm(e: { preventDefault: () => void; }) {
e.preventDefault();
setLoading(true);
const defaultName = "John Doe";
const defaultDescription = "I am a full-stack developer passionate about open-source projects and generative AI.";
const user: UserDescription = {
name: name || defaultName,
description: description || defaultDescription,
};
console.log(user);
setResponse(await BackendService.ask(user));
console.log(response);
setLoading(false);
}

return (
<>
<div>
<a href="https://genezio.com" target="_blank">
<img
src="https://raw.githubusercontent.com/Genez-io/graphics/main/svg/Logo_Genezio_White.svg"
className="logo genezio light"
alt="Genezio Logo"
/>
<img
src="https://raw.githubusercontent.com/Genez-io/graphics/main/svg/Logo_Genezio_Black.svg"
className="logo genezio dark"
alt="Genezio Logo"
/>
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Genezio + React = ❤️</h1>
<div className="card">
<input
type="text"
className="input-box"
onChange={(e) => setName(e.target.value)}
placeholder="Enter your name"
/>
<br />
<br />

<button onClick={() => sayHello()}>Say Hello</button>
<p className="read-the-docs">{response}</p>
<div className="container">
<h1>Personalized Speaker Recommendations</h1>
<p className="subtitle">
Complete the form below to get a list of speakers and talks from the <a href="https://c3fest.com" target="_blank" rel="noopener noreferrer">C3 Festival</a> tailored just for you:
</p>
<div className="card">
<form onSubmit={askLlm}>
<label htmlFor="name">Enter your name below:</label>
<input
type="text"
id="name"
className="input-box"
onChange={(e) => setName(e.target.value)}
placeholder="John Doe"
/>
<br />
<br />
<label htmlFor="description">Enter your tech interest below:</label>
<input
type="text"
id="description"
className="input-box"
onChange={(e) => setDescription(e.target.value)}
placeholder="I am a full-stack developer passionate about open-source projects and generative AI."
/>
<br />
<br />
<button type="submit" className="submit-button">Send</button>
</form>
{/* load a spinner */}
{loading ? (
<div className="spinner"></div>
) : (
response && response.length > 0 && (
<div className="response-list">
{response.map((item, index) => (
<div key={index} className="response-item">
<h3>{item.speaker}</h3>
<p>{item.reason}</p>
</div>
))}
</div>
)
)}
</div>
</div>
<footer className="footer">
<a href="https://genezio.com" target="_blank" rel="noopener noreferrer" className="footer-link">
<p>Built with Genezio with ❤️</p>
</a>
</footer>
</>
);
}

0 comments on commit a59a4df

Please sign in to comment.