Skip to content

Commit

Permalink
Merge pull request #17 from A-Bahadory/week1/marcus
Browse files Browse the repository at this point in the history
Completed front end video listings and basic styling
  • Loading branch information
A-Bahadory authored Apr 25, 2024
2 parents d283983 + f11c716 commit e8a3af3
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 111 deletions.
3 changes: 3 additions & 0 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Videos from "./Videos/Videos";

const App = () => {
return (
<>
<h1>Video Recommendations</h1>
<Videos />
</>
);
};
Expand Down
36 changes: 36 additions & 0 deletions client/src/Videos/Videos.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useState, useEffect, useRef } from "react";
import "./videos.scss";

const Videos = () => {
const [videos, setVideos] = useState([]);
const fetchedVideos = useRef(true);

useEffect(() => {
if (fetchedVideos.current) {
fetchedVideos.current = false;
fetch("/api/videos")
.then((res) => res.json())
.then((data) => {
setVideos(data);
fetchedVideos.current = true;
});
}
}, []);

const mapVideos = videos.map((video, index) => {
return (
<div key={index} className="container">
<p>{video.title}</p>
<iframe
src={video.src}
title="Video recommendations"
className="container_video"
></iframe>
</div>
);
});

return <p>{mapVideos}</p>;
};

export default Videos;
11 changes: 11 additions & 0 deletions client/src/Videos/videos.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.container {
margin-top: 2rem;
padding-left: 1rem;

&_video {
border-radius: 1rem;
border: none;
box-shadow: 6px 4px 18px 0 #00000042;
margin-top: 0.6rem;
}
}
11 changes: 9 additions & 2 deletions client/src/index.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
html,
body {
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}

body {
background-color: #f1f7ed;
color: #b33951;
}

h1 {
text-align: center;
margin-top: 1.4rem;
}
89 changes: 10 additions & 79 deletions db/initdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,13 @@ DROP TABLE IF EXISTS videos CASCADE;

CREATE TABLE videos (title VARCHAR, src VARCHAR);

INSERT INTO
videos (title, src)
VALUES
(
'Never Gonna Give You Up',
'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
);

INSERT INTO
videos (title, src)
VALUES
(
'The Coding Train',
'https://www.youtube.com/watch?v=HerCR8bw_GE'
);

INSERT INTO
videos (title, src)
VALUES
(
'Mac & Cheese | Basics with Babish',
'https://www.youtube.com/watch?v=FUeyrEN14Rk'
);

INSERT INTO
videos (title, src)
VALUES
(
'Videos for Cats to Watch - 8 Hour Bird Bonanza',
'https://www.youtube.com/watch?v=xbs7FT7dXYc'
);

INSERT INTO
videos (title, src)
VALUES
(
'The Complete London 2012 Opening Ceremony | London 2012 Olympic Games',
'https://www.youtube.com/watch?v=4As0e4de-rI'
);

INSERT INTO
videos (title, src)
VALUES
(
'Learn Unity - Beginner''s Game Development Course',
'https://www.youtube.com/watch?v=gB1F9G0JXOo'
);

INSERT INTO
videos (title, src)
VALUES
(
'Cracking Enigma in 2021 - Computerphile',
'https://www.youtube.com/watch?v=RzWB5jL5RX0'
);

INSERT INTO
videos (title, src)
VALUES
(
'Coding Adventure: Chess AI',
'https://www.youtube.com/watch?v=U4ogK0MIzqk'
);

INSERT INTO
videos (title, src)
VALUES
(
'Why the Tour de France is so brutal',
'https://www.youtube.com/watch?v=ZacOS8NBK6U'
);

INSERT INTO
videos (title, src)
VALUES
(
'Coding Adventure: Ant and Slime Simulations',
'https://www.youtube.com/watch?v=X-iSQQgOd1A'
);
INSERT INTO videos (title,src) VALUES ('Never Gonna Give You Up','https://www.youtube.com/embed/dQw4w9WgXcQ?si=sdvqEritjOTwN2Af');
INSERT INTO videos (title,src) VALUES ('The Coding Train','https://www.youtube.com/embed/HerCR8bw_GE?si=5Xfqx9K1JMB_QCBh');
INSERT INTO videos (title,src) VALUES ('Mac & Cheese | Basics with Babish','https://www.youtube.com/embed/FUeyrEN14Rk?si=dUHtCerjTKIdgK5u');
INSERT INTO videos (title,src) VALUES ('Videos for Cats to Watch - 8 Hour Bird Bonanza','https://www.youtube.com/embed/xbs7FT7dXYc?si=W9bjQcH1cYbIlnY3');
INSERT INTO videos (title,src) VALUES ('The Complete London 2012 Opening Ceremony | London 2012 Olympic Games','https://www.youtube.com/embed/4As0e4de-rI?si=QvvaM7T6gj31cQ6z');
INSERT INTO videos (title,src) VALUES ('Learn Unity - Beginners Game Development Course','https://www.youtube.com/embed/gB1F9G0JXOo?si=zh21-opwR7otFnSZ');
INSERT INTO videos (title,src) VALUES ('Cracking Enigma in 2021 - Computerphile','https://www.youtube.com/embed/RzWB5jL5RX0?si=OuYo20zJalIFBT2w');
INSERT INTO videos (title,src) VALUES ('Coding Adventure: Chess AI','https://www.youtube.com/embed/U4ogK0MIzqk?si=xICbZlD8Hm9nCyWy');
INSERT INTO videos (title,src) VALUES ('Coding Adventure: Ant and Slime Simulations','https://www.youtube.com/embed/X-iSQQgOd1A?si=bZUPXmKxC43YzERA');
INSERT INTO videos (title,src) VALUES ('Why the Tour de France is so brutal','https://www.youtube.com/embed/ZacOS8NBK6U?si=nfaj6AHw0aaE-c7C');
52 changes: 22 additions & 30 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"npm": ">=10"
},
"dependencies": {
"sass": "^1.75.0",
"serverless-http": "^3.2.0"
}
}

0 comments on commit e8a3af3

Please sign in to comment.