Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0104596
feat: iniciando o desafio
GuilhermeRX Oct 13, 2022
3014573
feat: iniciando um contexto
GuilhermeRX Oct 13, 2022
7128ae3
feat: definindo rota /home
GuilhermeRX Oct 13, 2022
fd4f2c6
feat: definindo funções que fazem requisições para a API
GuilhermeRX Oct 13, 2022
822ba73
refactor: preparando o ambiente
GuilhermeRX Oct 13, 2022
ae5974e
feat: componentes header e postsContainer
GuilhermeRX Oct 13, 2022
0fca278
feat: listagem dos posts na página principal
GuilhermeRX Oct 13, 2022
c1d58a5
feat: link para a página interna do post ao clicar no card
GuilhermeRX Oct 13, 2022
dc209d1
feat: pegando informações sobre o post retornadas pela api e renderiz…
GuilhermeRX Oct 13, 2022
08fa829
feat: estilização do header
GuilhermeRX Oct 13, 2022
a468e18
refactor: trocando font-family e retirando arquivos desnecessários.
GuilhermeRX Oct 13, 2022
3fb5557
fix: trocando propriedade que fornecia o link das imgs pois alguns po…
GuilhermeRX Oct 13, 2022
ad9798f
style: adicionando estilo ao container que renderiza os cards
GuilhermeRX Oct 13, 2022
e897b80
style: adicionando font-family
GuilhermeRX Oct 13, 2022
0dadadf
refactor: refatorando função para eliminar código desnecessário.
GuilhermeRX Oct 13, 2022
1af0996
style: alterando tamanho das imagens dos cards
GuilhermeRX Oct 13, 2022
df8a67e
style: aumentando espaçamento entre os cards
GuilhermeRX Oct 13, 2022
5a2d179
style:
GuilhermeRX Oct 14, 2022
0947c56
refactor: Alterando mensagem com o nome do author na página do post e…
GuilhermeRX Oct 14, 2022
d1678b5
fix: tratando nome do auhor quando ele é undefined
GuilhermeRX Oct 14, 2022
5267247
feat: Btn page home no header
GuilhermeRX Oct 14, 2022
78232f6
style: weigth author name
GuilhermeRX Oct 14, 2022
b92591c
style: postCard
GuilhermeRX Oct 14, 2022
579d33b
feat: component footer
GuilhermeRX Oct 14, 2022
eec8607
feat: página principal implementada salvando a primeira renderização …
GuilhermeRX Oct 14, 2022
db8b05b
feat:
GuilhermeRX Oct 15, 2022
1482731
feat: metatags na page home e page interna
GuilhermeRX Oct 15, 2022
96cef7b
merge
GuilhermeRX Oct 15, 2022
62fd9ec
Merge pull request #1 from GuilhermeRX/implement-next
GuilhermeRX Oct 15, 2022
6c7d94d
refactor: removendo arquivos desnecessários.
GuilhermeRX Oct 15, 2022
fc84330
Update README.md
GuilhermeRX Oct 15, 2022
182c344
Update README.md
GuilhermeRX Oct 15, 2022
ba53ed5
Update README.md
GuilhermeRX Oct 15, 2022
e897f62
style: melhorando espaçamento de algumas tags na page interna
GuilhermeRX Oct 16, 2022
548b98d
Merge branch 'luiz-guilherme-avelino'
GuilhermeRX Oct 16, 2022
2e1752f
style: tag code
GuilhermeRX Oct 16, 2022
6fe762a
Merge branch 'luiz-guilherme-avelino'
GuilhermeRX Oct 16, 2022
7874f59
style: tags pre e code
GuilhermeRX Oct 16, 2022
0659797
style: fontsize h1
GuilhermeRX Oct 16, 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
14 changes: 14 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
"next/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true
}
]
]
}
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"
}
39 changes: 35 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# 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
next-env.d.ts
13 changes: 13 additions & 0 deletions components/footer/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { FooterStyled } from './style'

export default function Footer() {
return (
<FooterStyled>
<span>Sobre a Apiki</span>
<p>Empresa especializada em WordPress com três unidades de negócios.</p>
<p>Design e Desenvolvimento;</p>
<p>Suporte e manutenção.</p>
<p>Em resumo, só fazemos uma coisa em WordPress: tudo.</p>
</FooterStyled>
)
}
25 changes: 25 additions & 0 deletions components/footer/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import styled from "styled-components";
import palet from "../../services/palet";

export const FooterStyled = styled.footer`
display: flex;
background-color: #eee;
width: 100%;
flex-direction: column;
position: relative;
bottom: 0;
left: 0;
align-items: center;
justify-content: flex-start;
padding: 24px;
span {
color: ${palet.secondary};
font-weight: 700;
margin-bottom: 18px;
}
p {
color: ${palet.primary};
line-height: 1.6;
text-align: center;
}
`;
13 changes: 13 additions & 0 deletions components/header/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Image from 'next/image';
import Link from 'next/link';
import logo from '../../images/logo.png';
import { HeaderContainer } from './style';

export default function Header() {
return (
<HeaderContainer>
<Image src={logo} alt='Apiki Logo' />
<Link href='/'>Home</Link>
</HeaderContainer>
)
}
24 changes: 24 additions & 0 deletions components/header/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import styled from "styled-components";
import palet from "../../services/palet";

export const HeaderContainer = styled.header`
background-color: ${palet.primary};
background: linear-gradient(90deg, #67666a 0%, #000000 100%);
width: 100%;
height: 60px;
display: flex;
margin-bottom: 16px;
align-items: center;
justify-content: space-between;
padding: 16px;

a {
text-decoration: none;
color: #eee;
font-weight: 500;
transition: 0.4s;
:hover {
color: ${palet.highligth};
}
}
`;
21 changes: 21 additions & 0 deletions components/postCard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable @next/next/no-img-element */
import { useRouter } from 'next/router';
import { Card, Description } from './style';

export default function PostCard(prop) {
const { image, title, slug, author, description } = prop.info;
const router = useRouter()

const handleClick = () => router.push(`/blog/${slug}`)

return (
<Card>
<img src={image} alt={title} onClick={handleClick} />
<div onClick={handleClick}>
<h2>{title}</h2>
<p>{`Por ${author}`}</p>
<Description>{description}</Description>
</div>
</Card>
)
}
60 changes: 60 additions & 0 deletions components/postCard/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import styled from "styled-components";
import palet from "../../services/palet";

export const Card = styled.article`
display: flex;
width: 100%;
height: 100%;
min-height: 90px;
margin-bottom: 24px;
align-items: flex-start;
justify-content: flex-start;

img {
max-width: 26%;
height: auto;
border-radius: 8px;
cursor: pointer;
}

@media screen and (min-width: 800px){
img {
max-width: 250px;
}
}

div {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
height: 100%;
padding: 8px;
cursor: pointer;
h2 {
font-size: 14px;
font-weight: 500;
line-height: 1;
max-width: 400px;
color: ${palet.secondary};
transition: 0.4s;

:hover {
color: ${palet.highligth};
}
}
p {
color: ${palet.primary};
font-size: 12px;
margin-top: 4px;
max-width: 400px;
}
}
`;

export const Description = styled.p`
font-weight: 500;
@media screen and (max-width: 480px) {
display: none;
}
`;
41 changes: 41 additions & 0 deletions components/postsContainer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useContext, useEffect, useState } from 'react';
import AppContext from '../../context/AppContext';
import { requestPosts } from '../../services/fetchAPI';
import PostCard from '../postCard';
import { Btn, BtnContainer, PageCount, PostContainer } from './style';

export default function PostsContainer() {
const [page, setPage] = useState(1);
const { posts, setPosts } = useContext(AppContext);

useEffect(() => {
const getPosts = async () => {
const request = await requestPosts(page);
setPosts(request);
};
getPosts();
}, [page, setPosts]);

return (
<PostContainer>
{posts?.data && posts.data.map((post, i) => (
<PostCard key={i} info={
{
image: post["yoast_head_json"]["og_image"][0].url.replace('.png', '-350x250.png'),
title: post.title.rendered,
slug: post.slug,
author: post["yoast_head_json"]["twitter_misc"]["Escrito por"],
description: post['yoast_head_json'].description,
}
} />
))}
<BtnContainer>
<Btn onClick={() => setPage(page === 1 ? 1 : page - 1)}>Voltar</Btn>
<PageCount>{`${page} de ${posts?.totalPages}`}</PageCount>
<Btn onClick={() => setPage(page < posts.totalPages ? page + 1 : page)}>Carregar mais...</Btn>
</BtnContainer>

</PostContainer>
)
}

42 changes: 42 additions & 0 deletions components/postsContainer/style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import styled from "styled-components";

export const PostContainer = styled.main`
display: flex;
flex-direction: column;
width: 100%;
min-height: 100vh;
align-items: center;
padding: 16px;
justify-content: center;

@media screen and (min-width: 800px){
padding: 46px;
}
`

export const BtnContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
`;

export const Btn = styled.button`
padding: 8px 16px;
border-radius: 8px;
background: none;
margin: 8px;
border: 1px solid #eee;
transition: 0.4s;
cursor: pointer;
:hover {
background-color: #eee;
}
:active {
padding: 6px 14px;
}
`;

export const PageCount = styled.p`
font-size: 12px;
align-self: center;
`;
5 changes: 5 additions & 0 deletions context/AppContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createContext } from 'react';

const AppContext = createContext({});

export default AppContext;
17 changes: 17 additions & 0 deletions context/AppProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useState } from "react";
import AppContext from "./AppContext";

export default function AppProvider({ data = {}, children }) {
const [posts, setPosts] = useState(data);

const contextValue = {
posts,
setPosts,
}

return (
<AppContext.Provider value={contextValue}>
{children}
</AppContext.Provider>
)
}
Binary file added 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.
12 changes: 12 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('next').NextConfig} */

const nextConfig = {
reactStrictMode: true,
swcMinify: true,
styledComponents: true,
images: {
domains: ['blog.apiki.com']
}
}

module.exports = nextConfig
Loading