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

Fernando Gurgel #127

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d7dc1a4
init
gurgelff Aug 4, 2022
5ea0ea8
feat: add support for sass
gurgelff Aug 4, 2022
5436d5e
feat: Apiki API Types
gurgelff Aug 4, 2022
ae0b26d
struct: types folder
gurgelff Aug 5, 2022
c1ec765
feat: add apiki to img domains
gurgelff Aug 5, 2022
8493d11
feat: basic posts list
gurgelff Aug 5, 2022
985b52d
impr: named destructuring with types
gurgelff Aug 5, 2022
e1f786c
feat: headers type
gurgelff Aug 5, 2022
1092685
feat: total pages
gurgelff Aug 5, 2022
8705912
impr: semantic image width and height
gurgelff Aug 5, 2022
0886c1d
impr: postState type
gurgelff Aug 7, 2022
a1f5f26
feat: pagination
gurgelff Aug 7, 2022
2f16624
impr: axios params
gurgelff Aug 7, 2022
e31ea93
feat: create simple post pages
gurgelff Aug 7, 2022
c7dd2e2
feat: stylize the posts page
gurgelff Aug 7, 2022
a559780
fix: useEffect param out of place
gurgelff Aug 7, 2022
14da727
impr: all posts page style colors
gurgelff Aug 7, 2022
d0f22cf
feat: Author Section
gurgelff Aug 9, 2022
20be846
feat: Navbar Component
gurgelff Aug 9, 2022
4702bb1
feat: Navbar on all pages
gurgelff Aug 9, 2022
dfab947
impr: DRY index.js
gurgelff Aug 9, 2022
45d4430
feat: Page Component to proper track pagination
gurgelff Aug 9, 2022
8e75d12
feat/impr: single post with ISR optimization and DRY
gurgelff Aug 9, 2022
5d922c5
feat: add gravatar to image domains
gurgelff Aug 9, 2022
50d9cda
feat: type AuthorSection
gurgelff Aug 9, 2022
6c5ba11
feat/impr: fetchPosts to help in DRY
gurgelff Aug 9, 2022
9d0bf82
feat: Author type-related features and type for Post Static Props
gurgelff Aug 9, 2022
b11b06c
feat: AuthorSection styles
gurgelff Aug 9, 2022
a65bb98
feat: avoid horizontalextra space issues on mobile
gurgelff Aug 9, 2022
04e1890
feat: author and pagination styles on home
gurgelff Aug 9, 2022
284bbaf
feat: Navbar component styles
gurgelff Aug 9, 2022
bd8555c
feat: Single Post Styles
gurgelff Aug 9, 2022
98f1be0
feat: get all posts for ISR
gurgelff Aug 9, 2022
3b26884
impr: DRY Page Slug handler
gurgelff Aug 9, 2022
ff831b2
impr: [utils/post] complete props checking
gurgelff Aug 9, 2022
ecd20bb
impr/struc: ISR
gurgelff Aug 9, 2022
eabec2b
impr: post styles
gurgelff Aug 9, 2022
cb65c9f
feat: sharp image optimization
gurgelff Aug 10, 2022
d1c56f3
impr: index get static props type
gurgelff Aug 10, 2022
76825ca
impr: img sizes | proper load next page effect | more semantic aria l…
gurgelff Aug 10, 2022
4bdc5a9
impr: img sizes | feat: bottom back button
gurgelff Aug 10, 2022
fa4ce2d
feat: isolated apiki colors
gurgelff Aug 10, 2022
15f424a
impr: mixins | feat:bottom button back
gurgelff Aug 10, 2022
2deb105
feat: Styles Utils
gurgelff Aug 10, 2022
28e95e9
feat: Author OOCSS
gurgelff Aug 10, 2022
e5ad9cb
impr: globals @import apiki colors
gurgelff Aug 10, 2022
9bd5049
impr: Home styles OOCSS
gurgelff Aug 10, 2022
821116c
impr: Navbar styles OOCSS
gurgelff Aug 10, 2022
a393984
fix: remove layout=responsive to fix width
gurgelff Aug 10, 2022
9118ad7
doc: include main improvs
gurgelff Aug 10, 2022
e84bc51
impr: author avatar alt
gurgelff Aug 11, 2022
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
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
38 changes: 34 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Dependency directories
node_modules/
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Next.js build output
.next
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Desafio - Front-end Developer
# Desafio - Front-end Developer | Fernando Gurgel
Este desafio tem como objetivo te avaliar como desenvolvedor Front-end: JavaScript, HTML, CSS e lógica de programação.

## Principais Diferenciais deste projeto
Dentre as principais melhorias e diferenciais, estão:
- Super Otimização de velocidade para mobile e desktop (score 100% GTMetrix e Google Pagespeed)
- Páginas estáticas (ISR - incremental static regeneration)
- Suporte a tema escuro (selecionado automaticamente)
- Alta reutilização de código usando utils (DRY)
- Tipagem (TypeScript)
- NextJS
- OOCSS
- SASS

## DEMO
![GIF mostrando as funcionalidade do projeto](https://media4.giphy.com/media/ALCUlzW0k88Hl8g1A0/giphy.gif?cid=790b7611221ccc32a7c753f142ab2dd99fd0ce18b411f8ab&rid=giphy.gif&ct=g)

Versão Live: [acessar](https://front-end-challenge-beta.vercel.app).
## O Desafio
Queremos montar uma versão do blog da Apiki apenas para Devs, e queremos que essa seja uma solução headless, esta nova versão terá as seguintes páginas:

Expand Down
49 changes: 49 additions & 0 deletions components/AuthorSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { NextPage } from "next";
import Image from "next/image";
import { AuthorSectionProps } from "../types/AuthorSection";
import styles from "../styles/AuthorSection.module.scss";

const AuthorSection: NextPage<AuthorSectionProps> = ({
hideOnMobile = false,
avatar,
authorLink,
authorName,
date,
}) => {
const post_date = new Date(date);
const date_options: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "long",
day: "numeric",
};
return (
<>
{authorName && (
<span
id={hideOnMobile ? styles.hideOnMobile : ""}
className={styles.post_author_section}
>
<a className={styles.post_author_link} href={authorLink}>
{avatar && (
<Image
alt={authorName || "Autor do post"}
className={styles.post_author_avatar}
width={48}
height={48}
src={avatar}
/>
)}
<span className={styles.post_author_name}>
{authorName ?? null}
</span>
</a>
<span className={styles.post_date}>
{post_date.toLocaleDateString("pt-BR", date_options) ?? null}
</span>
</span>
)}
</>
);
};

export default AuthorSection;
41 changes: 41 additions & 0 deletions components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Image from "next/image";
import logo from "../public/logo-apiki-symbol.png";
import styles from "../styles/Navbar.module.scss";

const Navbar = () => {
return (
<nav
role="navbar"
aria-label="Barra de Navegação"
className={styles.navbar}
>
<a
role="home"
aria-label="Link da página inicial"
href="https://blog.apiki.com/"
className={styles.navbar_link}
>
<Image src={logo} alt="logo" width={50} height={50} />
Página inicial
</a>
<a
role="about"
aria-label="Link da página sobre nós"
href="https://blog.apiki.com/sobre/"
className={styles.navbar_link}
>
Sobre nós
</a>
<a
role="contact"
aria-label="Link da página de contatos"
href="https://apiki.com/atendimento/"
className={styles.navbar_link}
>
Contato
</a>
</nav>
);
};

export default Navbar;
5 changes: 5 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
images: {
domains: ["blog.apiki.com", "secure.gravatar.com"],
},
};

module.exports = nextConfig;
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "front-end-challenge",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"axios": "^0.27.2",
"html-entities": "^2.3.3",
"html-react-parser": "^3.0.1",
"isomorphic-dompurify": "^0.20.0",
"next": "12.2.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"sass": "^1.54.3",
"sharp": "^0.30.7"
},
"devDependencies": {
"@types/node": "18.6.3",
"@types/react": "18.0.15",
"@types/react-dom": "18.0.6",
"eslint": "8.21.0",
"eslint-config-next": "12.2.3",
"typescript": "4.7.4"
}
}
14 changes: 14 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "../styles/globals.scss";
import type { AppProps } from "next/app";
import Navbar from "../components/Navbar";

function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<Navbar />
<Component {...pageProps} />
</>
);
}

export default MyApp;
27 changes: 27 additions & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { GetStaticProps, NextPage } from "next";
import { PostsProps } from "../types/Posts";
import { fetchPosts } from "../utils/post";
import Page from "./page/[slug]";

const getTenPostsUrl =
"https://blog.apiki.com/wp-json/wp/v2/posts?_embed&categories=518";

const Home: NextPage<PostsProps> = (props) => {
return <Page {...props} />;
};

export const getStaticProps: GetStaticProps = async () => {
const postsOptions = { params: { page: 1 } };

const { posts, headers } = await fetchPosts(getTenPostsUrl, postsOptions);

return {
props: {
posts,
totalPages: parseInt(headers["x-wp-totalpages"] as string) ?? 1,
page: 1,
},
};
};

export default Home;
Loading