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

Implement base layout #12

Merged
merged 37 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d04939a
Install use-onclickoutside hook
LauraBeatris Nov 3, 2020
5f08d20
Add header assets
LauraBeatris Nov 3, 2020
0031d52
Remove app placeholder content
LauraBeatris Nov 3, 2020
eb7f612
Add base structure for Navbar
LauraBeatris Nov 3, 2020
750f113
Add base structure for Header
LauraBeatris Nov 3, 2020
ec79406
Add header to app
LauraBeatris Nov 3, 2020
12dfd91
Remove self-hosted fonts
LauraBeatris Nov 3, 2020
63ced8d
Install react-icons and react-with-breakpoints
LauraBeatris Nov 3, 2020
4ae255f
Add base header navbar links
LauraBeatris Nov 3, 2020
74f8116
Set font-body to body element
LauraBeatris Nov 3, 2020
4fe9c13
Add tailwind breakpoints provider and root provider
LauraBeatris Nov 3, 2020
18d4868
Add font-family link and context provider to root app
LauraBeatris Nov 3, 2020
fa6e04a
Show mobile navbar and desktop navbar
LauraBeatris Nov 3, 2020
4966d79
Increase desktop header link margin
LauraBeatris Nov 3, 2020
0ac6f8b
Add new header navbar link
LauraBeatris Nov 3, 2020
d70b02a
Disable tailwind utilities purge
LauraBeatris Nov 3, 2020
0a78044
Update postcss config and enable tailwind utilites purge again
LauraBeatris Nov 3, 2020
016ef5f
Update purge paths on tailwind config
LauraBeatris Nov 3, 2020
12fb403
Add new color to tailwind theme
LauraBeatris Nov 4, 2020
5ad272e
Add links to sections on header navbars
LauraBeatris Nov 4, 2020
dcad08f
Install clsx to concatenate classes
LauraBeatris Nov 4, 2020
f946b65
Add variants to margin and border-width utilities
LauraBeatris Nov 4, 2020
8c81773
Update yarn.lock
LauraBeatris Nov 4, 2020
538c9a6
Add default texts for footer
LauraBeatris Nov 4, 2020
b37c175
Add footer
LauraBeatris Nov 4, 2020
ae8672c
Fix margin of mobile header navbar links
LauraBeatris Nov 4, 2020
d0949ae
Rollback postcss changes
LauraBeatris Nov 4, 2020
2ba607e
Install framer-motion
LauraBeatris Nov 4, 2020
71664d7
Add presence animation to mobile navbar links
LauraBeatris Nov 4, 2020
cbae8a3
Bump next to 10.0.1
LauraBeatris Nov 4, 2020
9f43e5d
Extract taiwind breakpoints to separate file
LauraBeatris Nov 4, 2020
d3478c8
Remove deprecated unsized prop from Image
LauraBeatris Nov 4, 2020
2621248
Break words on Footer and improve responsiveness
LauraBeatris Nov 4, 2020
f640129
Fix mobile navbar animation
LauraBeatris Nov 4, 2020
3f8f5a7
Fix JSX identation to be consistent across files
LauraBeatris Nov 4, 2020
3f1e435
Add todo comment related to refactor
LauraBeatris Nov 4, 2020
26bcd71
Fix tailwind purge config
LauraBeatris Nov 4, 2020
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
56 changes: 56 additions & 0 deletions components/Footer/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from "react";
import clsx from "clsx";

import { FooterContentProps, FooterContentItemProps } from "./types";

const FooterContentItem: React.FC<FooterContentItemProps> = ({
title,
children,
}) => (
<div className="flex flex-col items-start last:mt-5 md:last:mt-0 max-w-full">
<h3 className="mb-5 text-orange-100 text-3xl font-semibold">{title}</h3>

{children}
</div>
);

const subtitleClassName = "break-words text-white max-w-full";

const FooterContent: React.FC<FooterContentProps> = ({
footerSocialMediasTitle,
footerContactTitle,
socialMedias,
email,
}) => {
const mailTo = `mailto:${email}`;

const socialMediaLinkClasses = clsx([subtitleClassName, "footer-social-media-link"]);

return (
<footer className="flex flex-col md:flex-row justify-between items-start md:items-center w-screen bg-black py-10 px-5 md:py-16 md:px-32">
<FooterContentItem title={footerSocialMediasTitle}>
<ul className="w-full flex">
{
socialMedias.map(socialMedia => (
<a
key={socialMedia.href}
href={socialMedia.href}
className={socialMediaLinkClasses}
>
<span className="hover:border-b-2">
{socialMedia.label}
</span>
</a>
))
}
</ul>
</FooterContentItem>

<FooterContentItem title={footerContactTitle}>
<a href={mailTo} className={subtitleClassName}>{email}</a>
</FooterContentItem>
</footer>
);
};

export default FooterContent;
14 changes: 14 additions & 0 deletions components/Footer/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SocialMedia } from "./types";

export const footerSocialMedias: SocialMedia[] = [
{
href: "https://www.instagram.com/floripa.mais/",
label: "Instagram",
},
{
href: "https://www.linkedin.com/company/floripa-mais/",
label: "Linkedin",
},
];

export const orgEmail = "[email protected]";
16 changes: 16 additions & 0 deletions components/Footer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";

import Content from "./Content";
import { footerSocialMedias, orgEmail } from "./constants";

const Footer: React.FC = () => (
// TODO -> Fetch data from CMS and set the default value as the constants
<Content
footerSocialMediasTitle="Conecte-se"
footerContactTitle="Contato"
socialMedias={footerSocialMedias}
email={orgEmail}
/>
);

export default Footer;
15 changes: 15 additions & 0 deletions components/Footer/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface SocialMedia {
href: string;
label: string;
}

export interface FooterContentProps {
footerSocialMediasTitle: string;
footerContactTitle: string;
socialMedias: SocialMedia[];
email: string;
}

export interface FooterContentItemProps {
title: string;
}
104 changes: 104 additions & 0 deletions components/Header/MobileNavbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React, { useRef, useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { Link } from "react-scroll";
import Image from "next/image";
import useOnClickOutside from "use-onclickoutside";
import { AiOutlineClose } from "react-icons/ai";

import { headerNavbarLinks } from "./constants";

const navbarInitialMotionStyle = {
top: 0,
right: 0,
opacity: 0,
left: "100%",
};

const navbarMotionStyles = {
exit: navbarInitialMotionStyle,
initial: navbarInitialMotionStyle,
animate: {
opacity: 1,
right: 0,
left: "unset",
},
};

const NavbarMobile: React.FC = () => {
const [isNavbarMobileOpen, setIsNavbarMobileOpen] = useState(false);

const navElementRef = useRef(null);

const openNavbarMobile = (): void => {
setIsNavbarMobileOpen(true);
};

const closeNavbarMobile = (): void => {
setIsNavbarMobileOpen(false);
};

useOnClickOutside(navElementRef, closeNavbarMobile);

return (
<>
<button
className="flex items-center cursor-pointer bg-none border-none outline-none focus:outline-none"
type="button"
onClick={openNavbarMobile}
>
<Image
src="/icons/navbarButton.png"
alt="Navbar Button"
width={30}
height={50}
loading="eager"
/>
</button>

<AnimatePresence>
{
isNavbarMobileOpen && (
<motion.nav
key="navbar"
ref={navElementRef}
exit={navbarMotionStyles.exit}
initial={navbarMotionStyles.initial}
animate={navbarMotionStyles.animate}
className="flex flex-col w-64 p-5 h-screen fixed bg-gray-900"
>
<header className="w-full flex justify-end">
<button
type="button"
onClick={closeNavbarMobile}
className="outline-none focus:outline-none"
>
<AiOutlineClose className="text-white text-2xl" color="#fff" />
</button>
</header>

<ul className="w-full flex flex-col">
{
headerNavbarLinks.map(link => (
<Link
to={link.sectionId}
spy
key={link.label}
smooth
duration={500}
activeClass="text-yellow-100"
className="text-white cursor-pointer hover:text-yellow-100 mt-8 font-semibold text-xl uppercase"
>
{link.label}
</Link>
))
}
</ul>
</motion.nav>
)
}
</AnimatePresence>
</>
);
};

export default NavbarMobile;
27 changes: 27 additions & 0 deletions components/Header/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Defines the links to be show on the header navbar
*
* TODO -> Get the section ids from constants stored on the sections structure
*/
export const headerNavbarLinks = [
{
label: "Ações",
sectionId: "actions-section",
LauraBeatris marked this conversation as resolved.
Show resolved Hide resolved
},
{
label: "Doações",
sectionId: "donations-section",
},
{
label: "Missão",
sectionId: "mission-section",
},
{
label: "Equipe",
sectionId: "team-section",
},
{
label: "Contato",
sectionId: "contact-section",
},
];
50 changes: 50 additions & 0 deletions components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from "react";
import Image from "next/image";
import { Link as ScrollLink } from "react-scroll";
import { HideAt, ShowAt } from "react-with-breakpoints";

import MobileNavbar from "./MobileNavbar";
import { headerNavbarLinks } from "./constants";

const Header: React.FC = () => (
<header className="bg-black w-screen fixed flex items-center justify-between py-4 px-8">
<div className="flex items-center w-full justify-between max-w-screen-lg mx-auto">
<div className="md:h-20 md:w-20 w-10 h-10 relative">
<Image
quality={100}
title="Floripa+"
src="/images/logo.png"
alt="Floripa Mais Logo"
loading="eager"
layout="fill"
/>
</div>

<HideAt breakpoint="small">
<ul className="flex items-center">
{
headerNavbarLinks.map(link => (
<ScrollLink
to={link.sectionId}
key={link.label}
spy
smooth
duration={500}
activeClass="text-yellow-100"
className="text-white cursor-pointer hover:text-yellow-100 ml-8 font-semibold text-xl uppercase"
>
{link.label}
</ScrollLink>
))
}
</ul>
</HideAt>

<ShowAt breakpoint="small">
<MobileNavbar />
</ShowAt>
</div>
</header>
);

export default Header;
11 changes: 11 additions & 0 deletions contexts/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

import TailwindBreakpointsProvider from "./tailwindBreakpointsProvider";

const ContextProviders: React.FC = ({ children }) => (
<TailwindBreakpointsProvider>
{children}
</TailwindBreakpointsProvider>
);

export default ContextProviders;
12 changes: 12 additions & 0 deletions contexts/tailwindBreakpointsProvider/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import { BreakpointsProvider } from "react-with-breakpoints";

import { tailwindBreakpoints } from "styles/tailwind";

const TailwindBreakpointsProvider: React.FC = ({ children }) => (
<BreakpointsProvider breakpoints={tailwindBreakpoints}>
{children}
</BreakpointsProvider>
);

export default TailwindBreakpointsProvider;
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@
},
"dependencies": {
"autoprefixer": "9.8.6",
"next": "^10.0.0",
"clsx": "^1.1.1",
"framer-motion": "^2.9.4",
"next": "^10.0.1",
"next-seo": "^4.13.0",
"postcss-import": "^12.0.1",
"react": "16.14.0",
"react-dom": "16.14.0",
"tailwindcss": "^1.9.4"
"react-icons": "^3.11.0",
"react-scroll": "^1.8.1",
"react-with-breakpoints": "^4.0.4",
"tailwindcss": "^1.9.4",
"use-onclickoutside": "^0.3.1"
},
"devDependencies": {
"@jungsoft/eslint-config": "4.0.1",
Expand Down
10 changes: 9 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ import { AppProps } from "next/app";

import "styles/main.css";

import ContextProviders from "contexts";
import seoConfig from "config/seo";
import Header from "components/Header";
import Footer from "components/Footer";

const App: React.FC<AppProps> = ({ Component, pageProps }) => (
<>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;500;600&display=swap" rel="stylesheet" />
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the self-hosted fonts since they aren't working - I still don't know why

But it's important to check if the fonts are taking too long to download and if it is - Let's try to solve the issue with the self-hosted fonts

</Head>
<DefaultSeo {...seoConfig} />
<Component {...pageProps} />
<ContextProviders>
<Header />
<Component {...pageProps} />
<Footer />
</ContextProviders>
</>
);

Expand Down
2 changes: 1 addition & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MyDocument extends Document {
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="/favicons/apple-touch-icon-152x152.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/favicons/apple-touch-icon-114x114.png" />
</Head>
<body>
<body className="font-body min-w-screen">
<Main />
<NextScript />
</body>
Expand Down
8 changes: 1 addition & 7 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ const App: React.FC = () => (
<Head>
<title>Floripa+ | Torne a ilha em um lugar melhor</title>
</Head>
<main className="h-screen w-screen flex justify-center items-center bg-background-light">
<h1 className="text-gray-900 text-3xl animate-pulse font-medium">
Work in progress
{" "}
<span aria-label="Work in progress emoji" role="img">👷‍♀️</span>
</h1>
</main>
<main id="page-wrapper" className="h-screen w-screen flex justify-center items-center bg-background-light" />
</>
);

Expand Down
Binary file added public/icons/navbarButton.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 public/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading