Skip to content

Commit

Permalink
feat: create header and creating hero banner
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Mar 26, 2022
1 parent b990362 commit b45c659
Show file tree
Hide file tree
Showing 19 changed files with 1,353 additions and 239 deletions.
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ['media.graphcms.com'],
}
}

module.exports = nextConfig
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@
"lint": "next lint"
},
"dependencies": {
"@chakra-ui/react": "^1.8.6",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"framer-motion": "^6",
"graphql": "^16.3.0",
"graphql-request": "^4.2.0",
"next": "12.1.1",
"react": "17.0.2",
"react-dom": "17.0.2"
"react-dom": "17.0.2",
"react-icons": "^4.3.1"
},
"devDependencies": {
"@types/node": "17.0.23",
Expand Down
8 changes: 0 additions & 8 deletions pages/_app.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions pages/api/hello.ts

This file was deleted.

72 changes: 0 additions & 72 deletions pages/index.tsx

This file was deleted.

Binary file removed public/favicon.ico
Binary file not shown.
4 changes: 0 additions & 4 deletions public/vercel.svg

This file was deleted.

17 changes: 17 additions & 0 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Flex } from "@chakra-ui/react"
import { Logo } from "./Logo"
import { Navbar } from "./Navbar"

export const Header = () => {
return (
<Flex as="header"
bg="brand.primary"
align="center"
justify="space-around"
py="4"
>
<Logo />
<Navbar />
</Flex>
)
}
21 changes: 21 additions & 0 deletions src/components/HeroBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Flex } from "@chakra-ui/react";

export type HeroBannerProps = {
title: string,
background: {
url: string
},
description: string,
}

export const HeroBanner = ({ title, background, description}: HeroBannerProps) => {
return (
<Flex
bgImage={`url(${background.url})`}
height="20vh"
>
{ title }
{ description }
</Flex>
)
}
7 changes: 7 additions & 0 deletions src/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Image from "next/image"

export const Logo = () => {
return (
<Image src="https://media.graphcms.com/OdWKElwPSEia9nfabuxw?_ga=2.34469153.1858804931.1648141850-710560506.1647625745" width={120} height={40} />
)
}
15 changes: 15 additions & 0 deletions src/components/Navbar/NavItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Link as ChakraLink } from '@chakra-ui/react'
import Link from "next/link"

type NavItemProps = {
href: string
label: string
}

export const NavItem = ({ href, label }: NavItemProps) => {
return (
<Link href={href} passHref>
<ChakraLink>{label}</ChakraLink>
</Link>
)
}
12 changes: 12 additions & 0 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Flex } from "@chakra-ui/react"
import { NavItem } from "./NavItem"

export const Navbar = () => {
return (
<Flex as="nav" gap="1.5rem">
<NavItem href="/" label="Home" />
<NavItem href="/about" label="About" />
<NavItem href="/blog" label="Blog" />
</Flex>
)
}
15 changes: 15 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ChakraProvider } from '@chakra-ui/react'
import type { AppProps } from 'next/app'
import { Header } from '../components/Header'
import { theme } from '../styles/theme'

function MyApp({ Component, pageProps }: AppProps) {
return (
<ChakraProvider resetCSS theme={theme}>
<Header />
<Component {...pageProps} />
</ChakraProvider>
)
}

export default MyApp
34 changes: 34 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { gql } from 'graphql-request';
import type { GetStaticProps } from 'next';
import { HeroBanner, HeroBannerProps } from '../components/HeroBanner';
import { graphcms } from '../services/graphcms';

const Home = ({title, background, description}: HeroBannerProps) => {
return (
<HeroBanner
title={title}
background={background}
description={description}
/>
)
}

export const getStaticProps: GetStaticProps = async () => {
const query = gql`
{
heroBanner(where: {slug: "hero-principal"}) {
title,
background {
url
},
description
}
}
`
const { heroBanner } = await graphcms.request(query)
return {
props: {...heroBanner},
}
}

export default Home
4 changes: 4 additions & 0 deletions src/services/graphcms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { GraphQLClient } from 'graphql-request';
export const graphcms = new GraphQLClient(
'https://api-sa-east-1.graphcms.com/v2/cl176t5goieg801ywh05mbs03/master'
);
11 changes: 11 additions & 0 deletions src/styles/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { extendTheme } from '@chakra-ui/react'

const colors = {
brand: {
primary: '#FDC906',
secondary: '#414141',
tertiary: '#242121',
},
}

export const theme = extendTheme({ colors })
116 changes: 0 additions & 116 deletions styles/Home.module.css

This file was deleted.

Loading

0 comments on commit b45c659

Please sign in to comment.