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

Component folder #3

Merged
merged 2 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Added folder for each component, moved and renamed component to index.js
  • Loading branch information
Aaron-Lin-74 committed Feb 23, 2022
commit 182dda8f104ad81534079f438b06a6310c94675f
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { FcSpeaker } from 'react-icons/fc'
import useAudio from '../hooks/useAudio'
import useAudio from '../../hooks/useAudio'
import styled from 'styled-components'
import { Fade } from 'react-awesome-reveal'

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Link } from 'react-router-dom'
import { FiFacebook, FiInstagram, FiTwitter, FiYoutube } from 'react-icons/fi'
import logo from '../logo.svg'
import logo from '../../logo.svg'
import './Footer.css'
const Footer = () => {
return (
Expand Down
9 changes: 4 additions & 5 deletions src/components/Gallery.js → src/components/Gallery/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useState, useEffect } from 'react'
import { useGlobalContext } from '../contexts/AppContext'
import { useGlobalContext } from '../../contexts/AppContext'
import styled from 'styled-components'
import load from '../resources/gifs/loading2.gif'
import AnimalCard from './AnimalCard'
import PlayCard from './PlayCard'
import AnimalCard from '../AnimalCard'
import PlayCard from '../PlayCard'
import {
FcAlphabeticalSortingAz,
FcAlphabeticalSortingZa,
Expand Down Expand Up @@ -106,7 +105,7 @@ const Gallery = ({ mode }) => {
{loading ? (
<LoadingContainer>
<ImgContainer>
<img src={load} alt='loading...' />
<img src='/images/loading.gif' alt='loading...' />
</ImgContainer>
</LoadingContainer>
) : mode === 'play' ? (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Login.js → src/components/Login/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import styled from 'styled-components'
import { signInWithGoogle } from '../firebase'
import { signInWithGoogle } from '../../firebase'
import { Redirect } from 'react-router-dom'
import useAuth from '../hooks/useAuth'
import useAuth from '../../hooks/useAuth'

function Login() {
// Once login, redirect to home page
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/components/Navbar.js → src/components/Navbar/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react'
import './Navbar.css'
import logo from '../logo.svg'
import logo from '../../logo.svg'
import { FcMenu, FcPrevious } from 'react-icons/fc'
import {
AiFillHome,
Expand All @@ -10,9 +10,9 @@ import {
} from 'react-icons/ai'
import { IoMdCloudUpload } from 'react-icons/io'
import { RiSearchFill } from 'react-icons/ri'
import { signOutUser } from '../firebase'
import { signOutUser } from '../../firebase'
import { Link } from 'react-router-dom'
import useAuth from '../hooks/useAuth'
import useAuth from '../../hooks/useAuth'

const Navbar = () => {
const [click, setClick] = useState(false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef, useContext } from 'react'
import { PlayContext } from '../pages/Play'
import { PlayContext } from '../../pages/Play'

const PlayCard = ({ name, imageURL, showMini }) => {
const { checkResult } = useContext(PlayContext)
Expand Down
4 changes: 2 additions & 2 deletions src/components/Playbar.js → src/components/Playbar/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useRef, useContext } from 'react'
import styled from 'styled-components'
import { PlayContext } from '../pages/Play'
import { useGlobalContext } from '../contexts/AppContext'
import { PlayContext } from '../../pages/Play'
import { useGlobalContext } from '../../contexts/AppContext'
import { FcSearch } from 'react-icons/fc'

const Playbar = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef, useEffect } from 'react'
import { useGlobalContext } from '../contexts/AppContext'
import { useGlobalContext } from '../../contexts/AppContext'

const SearchForm = () => {
const { setSearchTerm } = useGlobalContext()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import styled from 'styled-components'
import { useHistory } from 'react-router-dom'
import { addDoc, subscriptionRef } from '../firebase'
import { addDoc, subscriptionRef } from '../../firebase'

function Subscription() {
const [email, setEmail] = useState()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { addDoc, animalsRef } from '../firebase'
import { addDoc, animalsRef } from '../../firebase'
import styled from 'styled-components'
import {
getStorage,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import styled from 'styled-components'
import { useGlobalContext } from '../contexts/AppContext'
import { useGlobalContext } from '../../contexts/AppContext'

function Viewers() {
const { setAnimalType } = useGlobalContext()
Expand Down
43 changes: 43 additions & 0 deletions src/contexts/AuthContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { useReducer, useContext } from 'react'

const AuthContext = React.createContext()

const initialState = {
name: '',
email: '',
photo: '',
}

const ACTIONS = {
SET_USER_LOGIN: 'SET_USER_LOGIN',
SET_SIGN_OUT: 'SET_SIGN_OUT',
}

function reducer(state, action) {
switch (action.type) {
case ACTIONS.SET_USER_LOGIN:
return {
name: action.payload.name,
email: action.payload.email,
photo: action.payload.photo,
}
case ACTIONS.SET_SIGN_OUT:
return { name: '', email: '', photo: '' }
default:
return state
}
}
export const AuthProvider = ({ children }) => {
const [state, dispatch] = useReducer(reducer, initialState)
const selectUserName = () => state.name
const selectUserEmail = () => state.email
const selectUserPhoto = () => state.photo
const signIn = () => {
dispatch({type: ACTIONS.SET_USER_LOGIN, payload: {}})
}
return <AuthContext.Provider value={{}}>{children}</AuthContext.Provider>
}

export const useAuth = () => {
return useContext(AuthContext)
}