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

feat/header #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 3 deletions apps/commerce/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb)))
rgb(var(--background-start-rgb));
}
3 changes: 2 additions & 1 deletion apps/commerce/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Layout from '@/components/common/Layout';
import { TRPCReactProvider } from '@/sdk/lib/trpc/react';
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
Expand Down Expand Up @@ -29,7 +30,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<body className={inter.className}>
<Suspense>
<TRPCReactProvider headers={headers()}>
<main>{children}</main>
<Layout>{children}</Layout>
</TRPCReactProvider>
</Suspense>
</body>
Expand Down
2 changes: 1 addition & 1 deletion apps/commerce/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Link from 'next/link';

export default async function HomePage() {
return (
<div className="flex min-h-screen flex-col items-center p-24">
<div className="flex min-h-screen flex-col items-center">
<span>Home</span>
<Link href="/product/camiseta-de-manga-longa" prefetch>
Produto Teste
Expand Down
5 changes: 5 additions & 0 deletions apps/commerce/src/components/common/Footer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const Footer = () => {
return <footer></footer>;
};

export default Footer;
79 changes: 79 additions & 0 deletions apps/commerce/src/components/common/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import Image from 'next/image';
import Link from 'next/link';
import { redirect } from 'next/navigation';

export const Header = () => {
async function handleSearch(e: FormData) {
'use server';
const query = e.get('search') as string;

if (query) {
const url = `/search?q=${encodeURIComponent(query)}`;

redirect(url);
}
}

return (
<header className="sticky top-0 z-50">
<div className="bg-slate-950">
<div className="container flex flex-row justify-between text-slate-300">
<nav className="hidden gap-4 lg:flex">
<Link className="p-1 pl-0 transition-colors hover:text-slate-400" href="/">
Size Guide
</Link>
<div className="h-full w-[1px] bg-slate-300" />
<Link className="p-1 transition-colors hover:text-slate-400" href="/">
Contact Us
</Link>
<div className="h-full w-[1px] bg-slate-300" />
</nav>
<Link
className="flex flex-grow items-center justify-center truncate p-1 text-sm transition-colors hover:text-slate-400 lg:text-base"
href="/"
>
Complimentary Shipping on All Orders Within Australia
</Link>
<nav className="hidden gap-4 lg:flex">
<div className="h-full w-[1px] bg-slate-300" />
<Link className="p-1 transition-colors hover:text-slate-400" href="/">
My Account
</Link>
<div className="h-full w-[1px] bg-slate-300" />
<Link className="p-1 pr-0 transition-colors hover:text-slate-400" href="/">
Help Center
</Link>
</nav>
</div>
</div>
<div className="flex flex-col gap-2 bg-white py-3 shadow-sm lg:py-0">
<div className="container flex h-full min-h-[35px] flex-row justify-between text-slate-950 lg:min-h-[60px]">
<div>Menus</div>
<Link className="flex flex-grow items-center justify-center" href="/">
<Image
className="h-full w-24 lg:h-full lg:w-28"
alt="Logo"
height={120}
width={120}
src="/vercel.svg"
/>
</Link>
<div>Inputs, Cart</div>
</div>
<div className="container flex lg:hidden">
<form action={handleSearch} className="w-full">
<input
type="text"
name="search"
id="mobile-menu"
placeholder="Search for your products"
className="w-full rounded-sm border border-slate-300 p-2 text-sm text-slate-950 focus:outline focus:outline-offset-2 focus:outline-slate-950"
/>
</form>
</div>
</div>
</header>
);
};

export default Header;
18 changes: 18 additions & 0 deletions apps/commerce/src/components/common/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Footer from '../Footer';
import Header from '../Header';

type Props = {
children: React.ReactNode;
};

export const Layout = ({ children }: Props) => {
return (
<>
<Header />
<main>{children}</main>
<Footer />
</>
);
};

export default Layout;
3 changes: 2 additions & 1 deletion apps/commerce/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const config: Config = {
],
theme: {
container: {
center: true
center: true,
padding: '1rem'
},
extend: {
backgroundImage: {
Expand Down