forked from CodeYourFuture/Full-Stack-Project-Assessment
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This includes everything under Level 100, 150 and 199, except for adding MUI support - frontend is still running without external dependencies This does not yet include the generated Fly.io deployment files though, they will be added in a later commit
- Loading branch information
Showing
17 changed files
with
2,291 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"jest/globals": true | ||
}, | ||
"extends": ["@codeyourfuture/standard"], | ||
"parser": "@babel/eslint-parser", | ||
"root": true, | ||
"rules": { | ||
"indent": "off", | ||
"operator-linebreak": "off" | ||
}, | ||
"plugins": ["jest"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"arrowParens": "always", | ||
"bracketSpacing": true, | ||
"endOfLine": "lf", | ||
"semi": true, | ||
"singleQuote": false, | ||
"trailingComma": "es5", | ||
"useTabs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export default function OrderingSelector({ order, setOrder }) { | ||
return ( | ||
<div className="order-selector"> | ||
<h3>Select order of videos</h3> | ||
<ul> | ||
<li> | ||
<button | ||
disabled={order == "rating_asc"} | ||
onClick={() => setOrder("rating_asc")} | ||
title="Ascending by vote" | ||
> | ||
⬆️ | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
disabled={order == "rating_desc"} | ||
onClick={() => setOrder("rating_desc")} | ||
title="Descending by vote" | ||
> | ||
⬇️ | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
disabled={order == "id"} | ||
onClick={() => setOrder("id")} | ||
title="Creation order" | ||
> | ||
➡️ | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
disabled={order == "random"} | ||
onClick={() => setOrder("random")} | ||
title="Random order" | ||
> | ||
🔀 | ||
</button> | ||
</li> | ||
</ul> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// source: https://stackoverflow.com/questions/3452546/how-do-i-get-the-youtube-video-id-from-a-url | ||
function youtubeLinkParser(url) { | ||
let regExp = | ||
/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/; | ||
let match = url.match(regExp); | ||
return match && match[7].length == 11 ? match[7] : false; | ||
} | ||
|
||
export default function Video({ video, updateVideo }) { | ||
const youtubeId = youtubeLinkParser(video.url); | ||
|
||
return ( | ||
<li className="video"> | ||
<h2> | ||
<a href={video.url} tabIndex={0}> | ||
{video.title} | ||
</a> | ||
</h2> | ||
{youtubeId && ( | ||
<iframe | ||
src={`https://www.youtube.com/embed/${youtubeId}`} | ||
title={video.title} | ||
frameBorder="0" | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" | ||
allowFullScreen | ||
></iframe> | ||
)} | ||
<h3>Rating</h3> | ||
<div title="Rating" className="rating"> | ||
{video.rating} | ||
</div> | ||
<h3>Controls</h3> | ||
<div className="controls"> | ||
<button onClick={() => updateVideo(video, "delete")}> | ||
Remove video | ||
</button> | ||
<button onClick={() => updateVideo(video, "up")}>Up Vote</button> | ||
<button onClick={() => updateVideo(video, "down")}>Down Vote</button> | ||
</div> | ||
</li> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Video from "./Video"; | ||
|
||
export default function VideoList({ videos, updateVideo }) { | ||
return ( | ||
<ul id="videos"> | ||
{videos.map((video) => ( | ||
<Video key={video.id} video={video} updateVideo={updateVideo} /> | ||
))} | ||
</ul> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { useState } from "react"; | ||
|
||
export default function VideoSubmisson({ addVideo }) { | ||
const [title, setTitle] = useState(""); | ||
const [url, setUrl] = useState(""); | ||
const [changed, setChanged] = useState(false); | ||
|
||
const titleValid = !changed || title !== ""; | ||
const urlValid = | ||
!changed || url.match(/youtube.com\/watch\?v=[a-zA-Z0-9-]{11}/); | ||
|
||
const updateField = function (e) { | ||
setChanged(true); | ||
|
||
switch (e.target.name) { | ||
case "title": | ||
setTitle(e.target.value); | ||
break; | ||
case "url": | ||
setUrl(e.target.value); | ||
break; | ||
} | ||
}; | ||
|
||
const submitVideo = function (e) { | ||
e.preventDefault(); | ||
|
||
if (changed && titleValid && urlValid) { | ||
addVideo(title, url); | ||
|
||
setChanged(false); | ||
setTitle(""); | ||
setUrl(""); | ||
} | ||
}; | ||
|
||
return ( | ||
<div id="submit-video"> | ||
<h2>Submit a new video</h2> | ||
<form aria-label="Submit a new video" onSubmit={submitVideo}> | ||
<label htmlFor="title">Title: </label> | ||
<input | ||
type="text" | ||
name="title" | ||
id="title" | ||
value={title} | ||
onChange={updateField} | ||
className={titleValid ? "valid" : "invalid"} | ||
/> | ||
<label htmlFor="url">Url: </label> | ||
<input | ||
type="text" | ||
name="url" | ||
id="url" | ||
value={url} | ||
onChange={updateField} | ||
className={urlValid ? "valid" : "invalid"} | ||
/> | ||
<button type="submit">Submit</button> | ||
</form> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.