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

Go to explore from share project #47

Merged
merged 4 commits into from
Jan 21, 2025
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
240 changes: 121 additions & 119 deletions src/styles/ExploreProjects.css
Original file line number Diff line number Diff line change
@@ -1,134 +1,136 @@
.explore-projects-container{
margin-top: 192px;
.explore-projects-container {
margin-top: 192px;
}
.ep-header{
font-size: 48px;
font-weight: 600;
.ep-header {
font-size: 48px;
font-weight: 600;
}
.projects-grid {
margin-top: 48px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
row-gap: 70px;
width: 100%;
margin-left: 20px;
}
.project-tile{
background-color: rgba(255, 255, 255, 0.08);
border-radius: 8px;
height: 280px;
width: 338px;
border-color: rgba(255, 255, 255, 0.24);
border-width: 0.1em;
position: relative;
}
.project-details{
padding: 59px 16px 80px 16px;
display: flex;
flex-direction: column;
gap: 10px;
}
.project-name{
font-size: 24px;
font-weight: 600;
}
.framework-badges{
display: flex;
gap: 8px;
height: 28px;
}
.tile-buttons{
display: flex;
margin-top: 12px;
gap: 12px;
}
.live-demo-button{
width: 145px;
height: 40px;
background-color: rgba(255, 255, 255, 0.24);
}
.git-link-button{
width: 145px;
height: 40px;
background-color: rgba(99, 233, 238, 0.24);
}
.like-comment-details{
position: absolute;
top: 5%;
right: 12px;
}
.like-img{
width: 30px;
height: auto;
}
.dislike-img{
width: 30px;
height: auto;
}
.details-img{
width: 30px;
height: auto;
}
.comments-img{
width: 30px;
height: auto;
margin-top: 48px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
row-gap: 70px;
width: 100%;
margin-left: 20px;
}
.project-tile {
background-color: rgba(255, 255, 255, 0.08);
border-radius: 8px;
height: 280px;
width: 338px;
border-color: rgba(255, 255, 255, 0.24);
border-width: 0.1em;
position: relative;
}
.project-details {
padding: 59px 16px 80px 16px;
display: flex;
flex-direction: column;
gap: 10px;
}
.project-name {
font-size: 24px;
font-weight: 600;
}
.framework-badges {
display: flex;
gap: 8px;
height: 28px;
}
.tile-buttons {
display: flex;
margin-top: 12px;
gap: 12px;
}
.live-demo-button {
width: 145px;
height: 40px;
background-color: rgba(255, 255, 255, 0.24);
}
.git-link-button {
width: 145px;
height: 40px;
background-color: rgba(99, 233, 238, 0.24);
}
.like-comment-details {
position: absolute;
top: 5%;
right: 12px;
}
.like-img {
width: 30px;
height: auto;
}
.dislike-img {
width: 30px;
height: auto;
}
.details-img {
width: 30px;
height: auto;
}
.comments-img {
width: 30px;
height: auto;
}
footer {
margin-top: auto; /* Push the footer to the bottom */
text-align: center; /* Center the logo */
margin-top: auto; /* Push the footer to the bottom */
text-align: center; /* Center the logo */
}
.page-wrapper{
display: flex;
flex-direction: column;
min-height: 100vh; /* Full viewport height */
.page-wrapper {
display: flex;
flex-direction: column;
min-height: 100vh; /* Full viewport height */
}
.ctd-logo {
width: 199px;
height: 72px;
margin: 0 auto; /* Center the logo horizontally */
margin-top: 50px;
margin-bottom: 40px;
width: 199px;
height: 72px;
margin: 0 auto; /* Center the logo horizontally */
margin-top: 50px;
margin-bottom: 40px;
}
.like-container {
position: relative;
}
position: relative;
}
.like-count {
position: absolute;
left: -20px; /* Default offset */
top: 8px;
transform: translateX(calc(-1 * (0.5em * (var(--digit-count, 1) - 1)))); /* Adjust dynamically */
font-size: 14px;
}
.signin-alert{
position: absolute;
top: -80px; /* Keeps the alert at a fixed vertical position */
width: auto;
}
.alertbox{
padding-right: 4px;
padding-left: 4px;
position: absolute;
left: -20px; /* Default offset */
top: 8px;
transform: translateX(
calc(-1 * (0.5em * (var(--digit-count, 1) - 1)))
); /* Adjust dynamically */
font-size: 14px;
}
.signin-alert {
position: absolute;
top: -80px; /* Keeps the alert at a fixed vertical position */
width: auto;
}
.alertbox {
padding-right: 4px;
padding-left: 4px;
display: flex;
justify-content: center;
align-items: center;
}
@media (max-width: 768px) {
.explore-projects-container {
margin-top: 120px;
min-width: 370px;
}
.ep-header {
text-align: center;
font-size: 32px;
}
.projects-grid {
margin-top: 48px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 30px;
width: 100%;
margin-left: 0px;
}
}
@media (max-width: 768px) {
.explore-projects-container{
margin-top: 120px;
min-width: 370px;
}
.ep-header{
text-align: center;
font-size: 32px;
}
.projects-grid {
margin-top: 48px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 30px;
width: 100%;
margin-left: 0px;
}
}
108 changes: 83 additions & 25 deletions src/views/ShareAProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
Fieldset,
Textarea,
Button,
Link,
Stack,
} from "@chakra-ui/react";
import { LuExternalLink } from "react-icons/lu";
import { Field } from "../components/ui/field";
import { Checkbox } from "../components/ui/checkbox";
import { Toaster, toaster } from "../components/ui/toaster";
Expand All @@ -20,10 +23,71 @@ const ShareAProject = () => {
youtube_video_link: "",
tags: [],
});
const [errors, setErrors] = useState({
github_link: "",
youtube_video_link: "",
});

const validateUrl = (url) => {
const urlPattern = /^(https?:\/\/)?([\w-]+(\.[\w-]+)+)(\/[\w-.]*)*(\?.+)?$/;
return urlPattern.test(url);
};
const handleSubmit = async (e) => {
e.preventDefault();
if (newProject.tags.length === 0) {
toaster.create({
title: "Please select at least one framework/language.",
type: "warning",
duration: 4000,
action: {
label: "x",
},
});
//console.log("Please select at least one framework/language.");
return;
}
const newErrors = {};

// Validate GitHub URL (Required)
if (!newProject.github_link || !validateUrl(newProject.github_link)) {
newErrors.github_link = "Please provide a valid GitHub repository URL.";
}

// Validate Live Demo URL (Optional, only if provided)
if (
newProject.youtube_video_link &&
!validateUrl(newProject.youtube_video_link)
) {
newErrors.youtube_video_link = "Please provide a valid Live Demo URL.";
}
console.log(Object.keys(newErrors).length);
if (Object.keys(newErrors).length > 0) {
setErrors(newErrors); // Display errors

if (errors.github_link) {
console.log(errors.github_link);
toaster.create({
title: errors.github_link,
type: "warning",
duration: 4000,
action: {
label: "x",
},
});
}
if (errors.youtube_video_link) {
console.log(errors.youtube_video_link);
toaster.create({
title: errors.youtube_video_link,
type: "warning",
duration: 4000,
action: {
label: "x",
},
});
}
return;
}
try {
const response = await fetch("http://localhost:8001/api/v1/addProject", {
method: "POST",
Expand Down Expand Up @@ -73,7 +137,7 @@ const ShareAProject = () => {
: [...prev.tags, value],
}));
};

//const isSubmitEnabled = newProject.tags.length > 0;
return (
<form onSubmit={handleSubmit}>
<div className="share-project-container">
Expand Down Expand Up @@ -253,31 +317,25 @@ const ShareAProject = () => {
}
/>
</Field>
<Field
marginTop="36px"
label={
<span style={{ fontSize: "20px" }}>Comments (Optional)</span>
}
>
<Textarea
variant="subtle"
marginTop="20px"
width="100%"
height="212px"
backgroundColor="rgba(255, 255, 255, 0.16)"
placeholder="Do you have any comments? (Optional)"
borderRadius="8px"
border="2px solid white"
/*value={newProject.comments}
onChange={(e) =>
setNewProject({ ...newProject, comments: e.target.value })
}*/
/>
<Button className="sp-button" variant="solid" type="submit">
SUBMIT PROJECT
</Button>
<Toaster />
<Field marginBottom={"20%"} marginTop={10}>
<Stack direction="row" h="20">
<Button
className="sp-button"
variant="solid"
type="submit"
//disabled={!isSubmitEnabled}
>
SUBMIT PROJECT
</Button>
<Link
style={{ fontSize: "20px", color: "#63E9EE", padding: "40px" }}
href="/explore-project"
>
Go to explore projects <LuExternalLink />
</Link>
</Stack>
</Field>
<Toaster />
</div>
</div>
<img className="ctd-logo" src="./images/ctd-logo.png"></img>
Expand Down
Loading