Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
58e3f20
added structure diles
Dani-dan99 Jun 30, 2023
b3dbd4b
added a file structure
melanierolo Jul 3, 2023
c237656
Merge pull request #2 from melanierolo/feature-structurev2
melanierolo Jul 3, 2023
2f08d7e
add onNavigate and routes
Dani-dan99 Jul 3, 2023
7d32c44
fixed cyclical dependency
Dani-dan99 Jul 4, 2023
dd20167
Merge pull request #5 from melanierolo/featureHistory
Dani-dan99 Jul 4, 2023
07e9ee9
added template string for the login
melanierolo Jul 4, 2023
8eea3c5
added css on the Login page
melanierolo Jul 4, 2023
4d93674
Merge pull request #7 from melanierolo/featureLogin-html-css
melanierolo Jul 4, 2023
fabc7a6
added template string on the component called register
melanierolo Jul 5, 2023
f06f7a3
add CSS-register-page
Dani-dan99 Jul 5, 2023
59c5db8
add EventListener and Event(click)
Dani-dan99 Jul 5, 2023
a1dd6e3
Merge pull request #9 from melanierolo/featureRegister-html-css
Dani-dan99 Jul 5, 2023
4b393da
implemented user registration using Firebase
melanierolo Jul 7, 2023
6457dea
added alert error on the register
melanierolo Jul 10, 2023
78c9f4b
added a navbar without CSS
melanierolo Jul 10, 2023
a73df7a
added a component called Header
melanierolo Jul 10, 2023
70d4815
added the function called signOut(owner firebase)
melanierolo Jul 10, 2023
7d49e1a
Merge pull request #11 from melanierolo/feature-firebase1
melanierolo Jul 10, 2023
b0c3e31
Added login
Claucegoma Jul 10, 2023
b10c7c6
Merge pull request #13 from melanierolo/featureEmail
Claucegoma Jul 11, 2023
9aae846
added Google buttton firebase
Dani-dan99 Jul 11, 2023
c05d02b
Merge pull request #15 from melanierolo/featureGoogle
Dani-dan99 Jul 11, 2023
ff7ac1e
added a mobile navbar
melanierolo Jul 12, 2023
897e820
added a navbar for desktop
melanierolo Jul 12, 2023
b3bca60
changed the color of an hr,margin of menuItemProfile and width of men…
melanierolo Jul 13, 2023
473f17d
Merge pull request #17 from melanierolo/featureNavbar
melanierolo Jul 13, 2023
caff24f
publishPost-css
Claucegoma Jul 13, 2023
17bc93b
resolving mergin
Claucegoma Jul 13, 2023
526b5af
Merge pull request #19 from melanierolo/featureToPublishPost
Claucegoma Jul 13, 2023
626f4d4
add my post
Dani-dan99 Jul 13, 2023
76b477e
fix conflict merging
Dani-dan99 Jul 13, 2023
cd92a25
Merge pull request #21 from melanierolo/featureMyPost
Dani-dan99 Jul 13, 2023
bc65f93
added a typography called Sora
melanierolo Jul 13, 2023
eef53b4
Merge pull request #23 from melanierolo/featureTypography
melanierolo Jul 13, 2023
aa68059
added documents on Firebase
melanierolo Jul 14, 2023
13b5eda
added real time collection data
melanierolo Jul 14, 2023
3d538ff
added onAuthStateChanged
melanierolo Jul 14, 2023
7a56854
show all post of firebase
melanierolo Jul 17, 2023
c4d69bd
added a userRegister on the localStorage
melanierolo Jul 17, 2023
3bd578a
Merge pull request #25 from melanierolo/featureFirestorePosts
melanierolo Jul 18, 2023
21007ba
add a myPostEdit.js and a userId
melanierolo Jul 18, 2023
ce1a183
fix css on the navbar
melanierolo Jul 19, 2023
e2cedd4
Merge pull request #26 from melanierolo/featureFilterPost
melanierolo Jul 19, 2023
d997c7f
Merge pull request #27 from melanierolo/improveNavbar
melanierolo Jul 19, 2023
71c715c
add photo at the post
Claucegoma Jul 19, 2023
ae48a2e
image added for authentication with email and password
Claucegoma Jul 20, 2023
cc1be47
Merge pull request #29 from melanierolo/featurePostGoogle
Claucegoma Jul 20, 2023
7222c24
SortPostByDate
Dani-dan99 Jul 20, 2023
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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@
"createdAt": "2023-06-06T21:37:46.504Z",
"version": "6.3.0",
"commit": "a942adeb868f1fe54b86e34cc4fc4ddb0601700d"
},
"dependencies": {
"firebase": "^9.23.0"
}
}
}
Binary file added src/assets/fonts/Sora-Bold.ttf
Binary file not shown.
Binary file added src/assets/fonts/Sora-ExtraBold.ttf
Binary file not shown.
Binary file added src/assets/fonts/Sora-ExtraLight.ttf
Binary file not shown.
Binary file added src/assets/fonts/Sora-Light.ttf
Binary file not shown.
Binary file added src/assets/fonts/Sora-Medium.ttf
Binary file not shown.
Binary file added src/assets/fonts/Sora-Regular.ttf
Binary file not shown.
Binary file added src/assets/fonts/Sora-SemiBold.ttf
Binary file not shown.
Binary file added src/assets/fonts/Sora-Thin.ttf
Binary file not shown.
10 changes: 10 additions & 0 deletions src/assets/icons/Account circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/AskQuestion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/CatHead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/Detective.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/DoctorsBag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/FoldedBooklet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/Google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/Happy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/Heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/Help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/LightOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/assets/icons/account-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/blueGear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/close-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/hamburger-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/postCat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/shares.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/userBlack.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icons/userIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/catsSociety--logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/gatito_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/gatito_registro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions src/components/feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Header } from "./header.js";
import { PublishPost } from "./publishPost.js";
import { addPost } from "../lib/firebase.js";
import { queryPosts } from "../lib/firebase.js";
import { MyPosts } from "./myPosts.js";
import { MyPostEdit } from "./myPostEdit.js";

export const Feed = (onNavigate) => {
// Parent
const feedDiv = document.createElement("div");

// Childs
const headerHtml = Header(onNavigate);
const publishPostHtml = PublishPost();

feedDiv.appendChild(headerHtml);
feedDiv.appendChild(publishPostHtml);

const buttonPublish = publishPostHtml.querySelector("#buttonPublish");
const inputTextPublish = publishPostHtml.querySelector("#inputTextPublish");

buttonPublish.addEventListener("click", () => {
const getUserRegister = JSON.parse(localStorage.getItem("userRegister"));
console.log("sin json.parse", localStorage.getItem("userRegister"));
console.log(
"con json.parse",
JSON.parse(localStorage.getItem("userRegister"))
);
const userName = getUserRegister.email;
const likes = 8;
const img = "/dadasda/userPruebita.png";
const textPublish = inputTextPublish.value;
const userId = JSON.parse(localStorage.getItem("userRegister")).id;

console.log("hice click", textPublish);
addPost(img, likes, userName, textPublish, userId)
.then((result) => {
console.log("result *****************", result);
inputTextPublish.value = "";
onNavigate("/feed");
})
.catch((error) => console.log(error));
});

let posts = [];
queryPosts()
.then((snapshot) => {
snapshot.docs.forEach((doc) => {
posts.push({ ...doc.data(), id: doc.id });
});
const userId = JSON.parse(localStorage.getItem("userRegister")).id;
posts.forEach((post) => {
// Show all Data in HTML
let myPostsHtml;
if (post.user_id === userId) {
myPostsHtml = MyPostEdit(post.user_name, post.user_post);
} else {
myPostsHtml = MyPosts(post.user_name, post.user_post);
}
feedDiv.appendChild(myPostsHtml);
});
})
.catch((error) => {
console.log(error);
});

return feedDiv;
};
123 changes: 123 additions & 0 deletions src/components/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { signOut } from "firebase/auth";
import { auth } from "../lib/firebase.js";

export function Header(onNavigate) {
// Template String
const logoHeader = `<img class="logoHeader__img" src="./assets/images/catsSociety--logo.png" alt="" />`;
const menuProfile = `<ul class="menuProfile">
<li class="menuItemProfile"><img class="menuProfile__img"src="./assets/icons/userIcon.png" alt="userIcon" /></li>
<li class="menuItemProfile"><a id="userName">Nombre de usuario</a></li>
<li class="menuItemProfile"><a id="userNickName">@username</a></li>
<hr class="menu__line" />
<li class="menuItemProfile">
<a id="myPosts"><img class="menuIconProfile"src="./assets/icons/userIcon.png" alt="userIcon" />Mis publicaciones</a>
</li>
<li class="menuItemProfile">
<a id="feeds"><img class="menuIconProfile"src="./assets/icons/postCat.png" alt="postCat" />Feeds</a>
</li>
<li class="menuItemProfile">
<a id="configuration"> <img class="menuIconProfile"src="./assets/icons/blueGear.png" alt="gearIcon" />Configuración</a>
</li>
<hr class="menu__line" />
<li class="menuItemProfile"><a id="logOut">Cerrar Sesión</a></li>
</ul>
<button class="hamburger">
<img class="profileIcon" src="./assets/icons/account-icon.svg"/>
<img class="closeIcon" src="./assets/icons/close-icon.png"/>
</button>`;
const menuTopics = `<ul class="menuTopics">
<li class="menuItemTopics">
<a id="understandCat"><img class="menuIcon" src="./assets/icons/Heart.png" alt="heart-icon" />¿Cómo entender a un gato?</a></li>
<li class="menuItemTopics">
<a id="memes"><img class="menuIcon" src="./assets/icons/Happy.png" alt="happy-icon"/>Memes</a></li>
<li class="menuItemTopics">
<a id="tips"><img class="menuIcon" src="./assets/icons/AskQuestion.png" alt="tip-icon" />Tips</a></li>
<li class="menuItemTopics">
<a id="curiosities"><img class="menuIcon" src="./assets/icons/LightOn.png" alt="curiosities icon" />Curiosidades</a></li>
<hr class="menu__line" />
<li class="menuItemTopics">
<a id="tipDay"><img class="menuIcon" src="./assets/icons/Detective.png" alt="tipDay-icon" />Tip/dato del día</a></li>
<li class="menuItemTopics"><a id="vet">
<img class="menuIcon" src="./assets/icons/DoctorsBag.png" alt="vet-icon" />Veterinarios</a></li>
<li class="menuItemTopics"><a id="help">
<img class="menuIcon" src="./assets/icons/Help.png" alt="help-icon" />Ayuda</a></li>
</ul>
<button class="hamburgerTopic">
<img class="profileIconTopic" src="./assets/icons/hamburger-icon.svg"/>
<img class="closeIconTopic" src="./assets/icons/close-icon.png"/>
</button>`;

const headerTemplate = `<nav class="header__menuTopics">${menuTopics}</nav>
<div class="header__logoHeader">${logoHeader}</div>
<nav class="header__menuProfile">${menuProfile}</nav>`;

// DOM
const headerHtml = document.createElement("div");
headerHtml.classList.add("header");
headerHtml.innerHTML = headerTemplate;

const myPosts = headerHtml.querySelector("#myPosts");
const feeds = headerHtml.querySelector("#feeds");
const logOut = headerHtml.querySelector("#logOut");

myPosts.addEventListener("click", () => {
onNavigate("/myPosts");
});

feeds.addEventListener("click", () => {
onNavigate("/feed");
});
logOut.addEventListener("click", async () => {
await signOut(auth);
onNavigate("/ ");
console.log(signOut(auth));
console.log("user signed out");
});

// Menu CSS - Profile

const menuItemsProfile = headerHtml.querySelectorAll(".menuItemProfile");
const hamburgerButton = headerHtml.querySelector(".hamburger");
const menuProfileHtml = headerHtml.querySelector(".menuProfile");
const closeIcon = headerHtml.querySelector(".closeIcon");

hamburgerButton.addEventListener("click", () => {
if (menuProfileHtml.classList.contains("showMenu")) {
menuProfileHtml.classList.remove("showMenu");
closeIcon.style.display = "none";
} else {
menuProfileHtml.classList.add("showMenu");
closeIcon.style.display = "block";
}
});

menuItemsProfile.forEach((menuItem) => {
menuItem.addEventListener("click", () => {
console.log("hiciste click");
});
});

// Menu CSS - Topics
const menuItemsTopics = headerHtml.querySelectorAll(".menuItemTopics");
const hamburgerButtonTopic = headerHtml.querySelector(".hamburgerTopic");
const menuTopicsHtml = headerHtml.querySelector(".menuTopics");
const closeIconTopic = headerHtml.querySelector(".closeIconTopic");

hamburgerButtonTopic.addEventListener("click", () => {
if (menuTopicsHtml.classList.contains("showMenuTopic")) {
menuTopicsHtml.classList.remove("showMenuTopic");
closeIconTopic.style.display = "none";
} else {
menuTopicsHtml.classList.add("showMenuTopic");
closeIconTopic.style.display = "block";
}
});

menuItemsTopics.forEach((menuItem) => {
menuItem.addEventListener("click", () => {
console.log("hiciste click");
});
});

return headerHtml;
}
112 changes: 112 additions & 0 deletions src/components/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Funciones para la interacción con el DOM del login y la vista(create element o template string)

import {
GoogleAuthProvider,
signInWithEmailAndPassword,
signInWithPopup,
} from "firebase/auth";
import { auth } from "../lib/firebase";
import { async } from "regenerator-runtime";

export const Login = (onNavigate) => {
//Template Strings
const loginLogo = `<div class="loginLogo">
<img class="loginLogo__img" src="./assets/images/catsSociety--logo.png" alt="logo CatsSociety" />
<h2 class="loginLogo__title">CatsSociety</h2>
</div>`;

const loginForm = `<form class="loginForm" id="loginForm">
<label class="loginForm__label marginBottom_4" for="userEmail">Email:</label>
<input class="loginForm__input marginBottom_4" type="email" id="userEmail" name="userEmail" placeholder="John@email.com">
<label class="loginForm__label marginBottom_4" for="userPassword">Contraseña:</label>
<input class="loginForm__input marginBottom_4" type="password" id="userPassword" name="userPassword" placeholder="Contraseña">
<a class="loginForm__link loginForm__link--black marginBottom_16">¿Olvidaste la contraseña?</a>
<input id="btnLogin" class="btn btn--primary marginBottom_8" type="submit" value="Iniciar Sesión">
</form>`;

const loginButtons = `<div class="loginButtons">
<h4 class="loginButtons__o marginBottom_8">o</h4>
<button id="loginGoogle" class="btn btn--google marginBottom_16">Continua con Google</button>
<p>¿No tienes una cuenta? <a class="loginForm__link loginForm__link--blue" id="linkRegister">Regístrate</a></p>
</div>`;

const login = `<section class="sectionLeft">
</section>
<section class="sectionRight">
<div class="login">
${loginLogo}
${loginForm}
${loginButtons}
</div>
</section>`;

const loginDiv = document.createElement("div");
loginDiv.classList.add("container");
loginDiv.innerHTML = login;

const linkRegister = loginDiv.querySelector("#linkRegister");
linkRegister.addEventListener("click", () => onNavigate("/register"));

const loginFormId = loginDiv.querySelector("#loginForm");
console.log(loginFormId);
loginFormId.addEventListener("submit", async (e) => {
console.log("miau");
e.preventDefault();
const userEmail = loginFormId["userEmail"].value;
const password = loginFormId["userPassword"].value;
console.log(userEmail, password);
let userRegister = {};
localStorage.removeItem("userRegister");
try {
const userCredentials = await signInWithEmailAndPassword(
auth,
userEmail,
password
);
if (userCredentials.operationType === "signIn") {
console.log("user-data", userCredentials);
userRegister["email"] = userCredentials.user.email;
userRegister["id"] = userCredentials.user.uid;
userRegister["photoUrl"] = "./assets/icons/Account circle.svg";
localStorage.setItem("userRegister", JSON.stringify(userRegister));
console.log(userRegister);
onNavigate("/feed");
}
console.log(userCredentials);
} catch (error) {
if (error.code === "auth/wrong-password") {
alert("Contreseña incorrecta");
} else if (error.code === "auth/user-not-found") {
alert("Usuario no encontrado");
} else {
alert(error.message, "error");
}
}
});
// -------Login Google-------
const googleButton = loginDiv.querySelector("#loginGoogle");
googleButton.addEventListener("click", async () => {
const provider = new GoogleAuthProvider();
let userRegister = {};
localStorage.removeItem("userRegister");
try {
const googleCredentials = await signInWithPopup(auth, provider);
console.log(googleCredentials);

if (googleCredentials.operationType === "signIn") {
console.log("user-data", googleCredentials);
userRegister["email"] = googleCredentials.user.email;
userRegister["id"] = googleCredentials.user.uid;
userRegister["photoUrl"] = googleCredentials.user.photoURL;
userRegister["name"] = googleCredentials.user.displayName;
localStorage.setItem("userRegister", JSON.stringify(userRegister));
console.log(userRegister);
onNavigate("/feed");
}
} catch (error) {
console.log(error);
}
});

return loginDiv;
};
29 changes: 29 additions & 0 deletions src/components/myPostEdit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export const MyPostEdit = (name, textPost, photoUrl) => {
const myPostsDiv = document.createElement("div");

const post = `<div class="containerPost">
<div class="containerUser">
<img class="userBlack"src="${photoUrl}" alt="user Black"/>
<a class="names" >${name}</a>
<p>Esta es mi publicación</p>
</div>

<p class="feedPost" >${textPost}</p>

<div class="horizontal-line"></div>

<div class="containerIcons">
<div class="containerLike">
<img class="likeCat" src="./assets/icons/CatHead.png"/>
<p class="like">Me gusta</p>
</div>

<div class="sharePost">
<img class="share" src="./assets/icons/shares.png"/>
<p class="shareText">Compartir</p>
</div>
</div>
</div>`;
myPostsDiv.innerHTML = post;
return myPostsDiv;
};
Loading