Skip to content

Commit

Permalink
chore: final touches to homepage (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurtu-gal authored Apr 28, 2024
1 parent dd0b457 commit abe394d
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 111 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.21.3",
"smooth-scroll": "^16.1.3",
"tailwind-merge": "^2.2.2"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/app/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function App() {
<Suspense fallback={<PageLoader />}>
<Routes>
<Route exact path='/' element={<Pages.Home />} />
<Route path='/register' element={<Pages.Register />} />
<Route path='/play' element={<Pages.Playground />} />
</Routes>
</Suspense>
Expand Down
8 changes: 4 additions & 4 deletions src/components/AboutUs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import aboutUsData from '../data/aboutUsData.js';

export default function AboutUs() {
return (
<section>
<div className='container py-6 flex flex-col items-center md:pb-[30px] sm:pb-[51px]'>
<>
<section className='container py-6 flex flex-col items-center md:pb-[30px] sm:pb-[51px]' id='about'>
<Paragraph variant='body2' className='text-center font-semibold'>
{aboutUsData.tag1}
<br />
Expand All @@ -17,7 +17,7 @@ export default function AboutUs() {
{aboutUsData.tag3}
</Paragraph>
</Paragraph>
</div>
</section>

<div className='justify-between px-[0px] sm:px-[77px] md:px-[115px] lg:px-[175px] grid grid-cols-1 sm:grid-cols-3 gap-3 pb-[40px] sm:pb-[130px] md:pb-[135px]'>
{aboutUsData.lists.map((list, index) => (
Expand All @@ -43,6 +43,6 @@ export default function AboutUs() {
<span className='font-syne text-left text-base sm:text-3.5xl font-bold mr-[15px]'> {aboutUsData.content2}</span>
<img src={aboutUsData.star_img_url} alt='star' className='sm:h-[76px] sm:w-[76px] h-[45px] inline-block align-top' />
</Paragraph>
</section>
</>
);
}
4 changes: 2 additions & 2 deletions src/components/FaqSection/faq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function FAQ() {
};

return (
<div className='md:w-[76%] w-[92%] justify-items-center mt-[10px] mb-[44px] mx-auto'>
<section className='md:w-[76%] w-[92%] justify-items-center mt-[10px] mb-[44px] mx-auto' id='faq'>
<div className='flex flex-col items-center justify-center mb-[40px]'>
<Heading
variant='h1'
Expand Down Expand Up @@ -56,7 +56,7 @@ function FAQ() {
</div>
))}
</div>
</div>
</section>
);
}

Expand Down
18 changes: 9 additions & 9 deletions src/components/Hero.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { PersonalizedText, Text } from './shared/typography';
import { HeroText1 } from './shared/typography';
import { HeroText2 } from './shared/typography';
import { imgURLs } from '../data/eventsData';
import Button from './shared/Button';
import { Link } from 'react-router-dom';

const Hero = () => {
return (
<div className='mx-5 lg:mx-14 xl:max-w-[1483px] -z-1 relative'>
<section className='lg:mx-14 xl:max-w-[1483px] -z-1 relative p-5 xl:mx-auto' id='hero'>
<div className='flex flex-col md:flex-row justify-center items-center min-h-screen gap-20 lg:gap-10'>
<div className='w-[100%] md:w-1/2 h-fit'>
<div className='flex flex-col justify-end ml-2 text-primary-foreground'>
Expand All @@ -16,13 +18,11 @@ const Hero = () => {
Lorem Ipsum Dolar <HeroText2 style={{ display: 'inline-block' }}> sit Amet</HeroText2> luyto
</HeroText1>

<button
className='px-4 py-2 rounded-md border border-solid border-black bg-orange-500 shadow-button mt-5'
style={{
boxShadow: '2px 2px 0px 0px #000, 3px 4px 9.2px 0px rgba(222, 222, 222, 0.48) inset',
}}>
<Text variant='button'>Register Now</Text>
</button>
<Link to='/register'>
<Button variant='primary' size='medium' className='mt-5'>
<Text variant='button'>Register Now</Text>
</Button>
</Link>
</div>
<div
className={`w-[100%] xl:w-1/2 md:w-2/3 flex items-center justify-center relative h-[100%]
Expand Down Expand Up @@ -85,7 +85,7 @@ const Hero = () => {
</div>
</div>
</div>
</div>
</section>
);
};
export default Hero;
1 change: 1 addition & 0 deletions src/components/shared/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const buttonVariants = cva(['flex', 'items-center', 'justify-center', 'rounded']
'gap-[10px]',
'text-black',
'font-semibold',
'shadow-button',
],
},
size: {
Expand Down
75 changes: 0 additions & 75 deletions src/components/shared/NavBar.jsx

This file was deleted.

110 changes: 110 additions & 0 deletions src/components/shared/marginals/NavBar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { useState, useContext } from 'react';
import { AuthContext } from '../../../context/AuthContext';
import { Link } from 'react-router-dom';
import Text from '../typography/Text';
import Navigation from '../../../data/Navigation';
import image from '../../../assets/images/image.png';
import Button from '../Button';
import Logo from '../Logo';
import Hamburger from '../Hamburger';
import { signInWithGoogle, signOutUser } from '../../../firebase/login';
import SmoothScroll from 'smooth-scroll';

// Function Returning new scroll object
const newScrollObject = () => {
return new SmoothScroll('', {
offset: () => 100,
});
};

const handleScroll = id => {
if (typeof window !== 'undefined' && id) {
const isHome = window.location.pathname === '/';
if (isHome) {
const scroll = newScrollObject();
const anchor = document.getElementById(id);
scroll.animateScroll(anchor);
}
}
};

function NavBar() {
const { userInfo, setUserData } = useContext(AuthContext);

const { navItems, logo } = Navigation;
const [isNavOpen, setIsNavOpen] = useState(false);

const toggleNav = () => {
setIsNavOpen(!isNavOpen);
};

return (
<nav className='sticky top-0 z-20'>
<div
className='navbar flex justify-between items-center opacity-53 bg-hard-light bg-center bg-cover bg-[#F9F5F2] h-[73.8px] overflow-hidden pl-5 md:pl-10'
style={{ backgroundImage: `url(${image})` }}>
<Logo src={logo.src} alt={logo.alt} />
<ul className={`navitem md:flex ${isNavOpen ? 'hidden' : 'flex'} hidden list-none`}>
<NavList navItems={navItems} toggleNav={() => {}} />
</ul>
<div>
<Hamburger onClick={toggleNav} isOpen={isNavOpen}></Hamburger>
<Button
variant='primary'
size='medium'
className='mr-[56.6px] hidden md:flex'
style={{
boxShadow: '2px 2px 0px 0px #000, 3px 4px 9.2px 0px rgba(222, 222, 222, 0.48) inset',
}}
onClick={async () => {
if (userInfo[0].uid) {
setUserData(await signOutUser());
} else {
setUserData(await signInWithGoogle());
}
}}>
<Text variant='navButton'>{userInfo[0].uid ? 'logout' : 'login'}</Text>
</Button>
</div>
</div>
<div className='w-full' style={{ height: '1px', backgroundColor: 'black' }}></div>
{isNavOpen && (
<ul
className='navMobile flex flex-col justify-center bg-[#252525] items-center gap-[41px] fixed min-h-full min-w-full top-[74px] bottom-0 text-white md:hidden list-none'
// style={{ position: 'absolute', top: '74px', left: '0', right: '0', bottom: '0' }}>
>
<NavList navItems={navItems} toggleNav={toggleNav} />
</ul>
)}
</nav>
);
}

const onClick = (id, toggleNav) => {
handleScroll(id);
toggleNav();
};

const NavList = ({ navItems, toggleNav }) => {
return (
<>
{navItems.map(({ id, name, link }) => (
<li
key={id}
className='nav-item'
onClick={link ? null : () => onClick(id, toggleNav)}
onKeyPress={link ? null : () => onClick(id, toggleNav)}
role='menuitem'
tabIndex={0}>
<Link to={link} key={id}>
<Text variant='nav' className='mx-[55px] max-[1100px]:mx-[25px]'>
{name}
</Text>
</Link>
</li>
))}
</>
);
};

export default NavBar;
4 changes: 2 additions & 2 deletions src/components/shared/marginals/footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Heading, Paragraph } from '../typography/index.jsx';

export default function Footer() {
return (
<div className='w-full bg-[#1E1E1E] pb-[24px]'>
<section className='w-full bg-[#1E1E1E] pb-[24px]' id='footer'>
<div className='w-[95%] mx-auto pt-[16px] pb-[24px] md:pb-[52px]' style={{ borderBottom: '1px solid white' }}>
<div className='w-full flex justify-end'>
<div className='h-[50px] md:h-[76px] w-[50px] md:w-[76px]'>
Expand Down Expand Up @@ -78,6 +78,6 @@ export default function Footer() {
</div>
</div>
</div>
</div>
</section>
);
}
34 changes: 17 additions & 17 deletions src/data/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ export default {

navItems: [
{
id: 'About us',
name: 'About',
link: '/about',
id: 'about',
name: 'About us',
},
// {
// id: 'events',
// name: 'Events',
// },
// {
// name: 'Sponsors',
// link: '/sponsors',
// },
{
id: 'Events',
name: 'Events',
link: '/events',
id: 'footer',
name: 'Contact Us',
},
{
id: 'Sponsors',
name: 'Sponsors',
link: '/sponsors',
},
{
id: 'Contact us',
name: 'Contact',
link: '/contact',
id: 'faq',
name: 'FAQs',
},
{
id: 'FAQS',
name: 'FAQs',
link: '/faqs',
id: 'register',
name: 'Register',
link: '/register',
},
],
};
2 changes: 1 addition & 1 deletion src/pages/home.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AboutUs from '../components/AboutUs';
import FAQ from '../components/FaqSection/faq';
import Hero from '../components/Hero';
import Navbar from '../components/shared/NavBar';
import Navbar from '../components/shared/marginals/NavBar';
import Footer from '../components/shared/marginals/footer';

export default function Home() {
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { lazy } from 'react';
export default {
Home: lazy(() => import('./home')),
Playground: lazy(() => import('./playground')),
Register: lazy(() => import('./register')),
};
Loading

0 comments on commit abe394d

Please sign in to comment.