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

NW6 | Rabia Avci | Full-Stack-Project | Week-2 | New video form #26

Merged
merged 5 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion client/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import NewVideoForm from "./NewVideoForm.jsx";
import VideoList from "./VideoRecommendations";

const App = () => {
return (
<>
<h1>Video Recommendations</h1>
<VideoList />
<VideoList />
<NewVideoForm />
</>
);
};
Expand Down
55 changes: 55 additions & 0 deletions client/src/NewVideoForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* CSS for NewVideoForm component */
div {
max-width: 500px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
background-color: #f9f9f9;
}

h2 {
text-align: center;
color: #333;
margin-bottom: 20px;
}

form {
display: flex;
flex-direction: column;
gap: 15px;
}

div > div {
display: flex;
flex-direction: column;
}

label {
font-weight: bold;
margin-bottom: 5px;
color: #555;
}

input {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}

button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #fff;
font-size: 16px;
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.

Is there any particular reason you're setting the cursor to pointer here? It should be pointer by default here https://developer.mozilla.org/en-US/docs/Web/CSS/cursor

Copy link
Owner Author

Choose a reason for hiding this comment

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

When its default it keeps an arrow, i wanted to make it a hand icon when hovering over the element :)

transition: background-color 0.3s;
}

button:hover {
background-color: #0056b3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Always nice to have a hover style for buttons.

Overall, I really like what you're doing here, good use of flex and nice touches like border-radius and padding in inputs throughtout

}
58 changes: 58 additions & 0 deletions client/src/NewVideoForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React, { useState } from "react";

import "./NewVideoForm.css";
const NewVideoForm = () => {
const [title, setTitle] = useState("");
const [src, setSrc] = useState("");

const handleSubmit = (e) => {
e.preventDefault();

fetch("/api/videos", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ title, src }),
})
.then((response) => response.json())
.then((data) => {
console.log(JSON.stringify(data));
})
.catch((error) => {
console.error(error);
});
};

return (
<div>
<h2>Add New Video</h2>
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="title">Video Title: </label>
<input
type="text"
id="title"
value={title}
onChange={(e) => setTitle(e.target.value)}
required
/>
</div>
<div>
<label htmlFor="src">Video URL: </label>
<input
type="url"
id="src"
value={src}
onChange={(e) => setSrc(e.target.value)}
required
/>
</div>
<button type="submit">Submit</button>
</form>
</div>
);
};

export default NewVideoForm;
Loading