Skip to content

Instantly share code, notes, and snippets.

View hieptl's full-sized avatar
🎯
Focusing

Hiep Le hieptl

🎯
Focusing
View GitHub Profile
@hieptl
hieptl / storycard.js
Created August 4, 2021 13:36
StoryCard Component - Facebook Clone
function StoryCard({ name, src, profile }) {
return (
<div className="story__card">
<img
className="story__profile"
src={profile}
/>
<img
className="story__background"
src={src}
@hieptl
hieptl / inputbox.js
Last active August 11, 2021 11:57
Input Box Component - Facebook Clone
// import useRef, useState and useContext.
import { useRef, useState, useContext } from "react";
// import Context to get shared data from react context.
import Context from '../Context';
// import real time data and storage to interact with real time database and upload files to Firebase.
import { realTimeDb, storage } from "../firebase";
// import uuid to generate id for posts.
import { v4 as uuidv4 } from "uuid";
function InputBox() {
@hieptl
hieptl / posts.js
Created August 4, 2021 13:43
Posts Component - Facebook Clone
// import useContext to get shared data.
import { useContext } from 'react';
// import Context.
import Context from '../Context';
// import custom components.
import Post from "./Post";
function Posts() {
const { wallPosts } = useContext(Context);
return (
@hieptl
hieptl / post.js
Created August 4, 2021 13:45
Post Component - Facebook Clone
function Post({ createdBy, message, imageUrl, timestamp, userAvatar }) {
return (
<div className="post__container">
<div className="post__title-container">
<div className="post__title">
<img className="header__avatar" src={userAvatar} />
<div>
<p className="post__name">{createdBy}</p>
{timestamp ? (
<p className="post__timestamp">
@hieptl
hieptl / feed.js
Created August 4, 2021 13:48
Feed Component - Facebook Clone
// import custom components
import InputBox from "./InputBox";
import Stories from "./Stories";
import Posts from "./Posts";
function Feed({ posts }) {
return (
<div className="feed">
<div className="feed__container">
<Stories />
@hieptl
hieptl / contact.js
Last active August 11, 2021 11:52
Contact Component - Facebook Clone
// import useEffect, useState, useContext.
import { useEffect, useState, useContext } from 'react';
// import Context.
import Context from "../Context";
function Contact() {
const [contacts, setContacts] = useState([]);
const { user, cometChat, setSelectedContact, isChatLayoutShown } = useContext(Context);
@hieptl
hieptl / group.js
Last active August 11, 2021 12:09
Group Component - Facebook Clone
// import useEffect, useRef, useContext, useState.
import { useEffect, useRef, useContext, useState } from "react";
// import Context.
import Context from "../Context";
// import uuid to generate id for groups.
import { v4 as uuidv4 } from "uuid";
function Groups(props) {
const [groups, setGroups] = useState([]);
@hieptl
hieptl / chatbox.js
Last active August 11, 2021 11:45
ChatBox Component - Facebook Clone
// import useContext, useRef.
import { useContext, useRef, useEffect, useState } from "react";
// import Context.
import Context from "../Context";
// import custom components.
import Message from "./Message";
// import uuid to generate id for messages.
import { v4 as uuidv4 } from "uuid";
function ChatBox() {
@hieptl
hieptl / message.js
Created August 4, 2021 14:03
Message Component - Facebook Clone
function Message(props) {
const {message, avatar, isRight} = props;
if (!message || !avatar) {
return <></>
}
if (isRight) {
return (
<div className="message__right">
// import useContext, useRef.
import { useContext, useRef, useEffect, useState } from "react";
// import Context.
import Context from "../Context";
// import custom components.
import Message from "./Message";
// import uuid to generate id for messages.
import { v4 as uuidv4 } from "uuid";
function ChatBox() {