Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from brolag/ab/components
Browse files Browse the repository at this point in the history
Add misc components
  • Loading branch information
brolag authored Feb 19, 2024
2 parents 122b574 + c95c30a commit 7d7e241
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 35 deletions.
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"start": "next start"
},
"dependencies": {
"@heroicons/react": "^2.1.1",
"@planetscale/database": "^1.11.0",
"@prisma/adapter-planetscale": "^5.6.0",
"@prisma/client": "^5.6.0",
Expand Down
Binary file added public/images/bg.webp
Binary file not shown.
Binary file added public/images/cafe1.webp
Binary file not shown.
Binary file added public/images/cafe2.webp
Binary file not shown.
Binary file added public/images/cafe3.webp
Binary file not shown.
Binary file added public/images/cafe4.webp
Binary file not shown.
Binary file added public/images/cafe5.webp
Binary file not shown.
37 changes: 16 additions & 21 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { type Connector, type ConnectVariables } from "@starknet-react/core";
import Button from "../ui/Button";
import { ShoppingCartIcon } from "@heroicons/react/24/solid";

interface HeaderProps {
address: string | undefined;
Expand All @@ -14,24 +16,24 @@ export default function Header({
disconnect,
}: HeaderProps) {
return (
<div className="flex flex-row items-center justify-between">
<header className="flex items-center justify-between bg-white p-4 shadow-md">
<div>
{address ? (
<div className="relative inline-flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-gray-100 dark:bg-gray-600">
<span className="font-medium text-gray-600 dark:text-gray-300">
JL
</span>
</div>
<div className="relative inline-flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-gray-100 dark:bg-gray-600">
<span className="font-medium text-gray-600 dark:text-gray-300">
JL
</span>
</div>
) : (
<div className="font-bold text-primary text-xl">
Welcome to CofiBlocks ☕️
</div>
<div className="text-primary text-xl font-bold">
Welcome to CofiBlocks ☕️
</div>
)}

</div>
<div>
<div className="flex items-center gap-4">
<ShoppingCartIcon className="h-6 w-6 cursor-pointer text-gray-600" />
{!address ? (
<ul>
<ul className="flex gap-2">
{connectors.map((connector) => (
<li key={connector.id}>
<button
Expand All @@ -44,16 +46,9 @@ export default function Header({
))}
</ul>
) : (
<div className="flex flex-col items-center gap-4">
<button
onClick={() => disconnect()}
className="bg-primary text-secondary w-[8.125rem] rounded-xl p-4 font-bold shadow-md"
>
LOGOUT
</button>
</div>
<Button onClick={disconnect}>Disconnect </Button>
)}
</div>
</div>
</header>
);
}
2 changes: 1 addition & 1 deletion src/components/layout/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Main({ children }: MainProps) {
return (
<>
<SiteHead />
<div className="font-roboto h-screen container mx-auto bg-white p-6 ">
<div className="font-roboto h-screen mx-auto w-full bg-white">
{children}
</div>
</>
Expand Down
19 changes: 19 additions & 0 deletions src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { type ReactNode } from "react";

interface ButtonProps {
onClick: () => void;
disabled?: boolean;
children: ReactNode;
}

export default function Button({ onClick, disabled = false, children }: ButtonProps) {
return (
<button
disabled={disabled}
onClick={onClick}
className="bg-primary text-secondary w-[8.125rem] rounded-xl p-4 font-bold shadow-md"
>
{children}
</button>
);
}
53 changes: 53 additions & 0 deletions src/components/ui/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import Image from "next/image";
import Button from "./Button";
import { Subtitle } from "./Typography";

interface CardProps {
title: string;
description: string;
imageUrl: string;
imageAlt?: string;
price: string;
className?: string;
}

export default function Card({
title,
description,
imageUrl,
imageAlt = "Imagen del producto",
price,
className = "",
}: CardProps) {
return (
<div
className={`card card-compact bg-base-100 shadow-xl ${className} group hover:cursor-pointer`}
>
<div className="relative overflow-hidden">
<div className="transition-transform duration-300 ease-in-out group-hover:scale-105">
<Image
src={imageUrl}
alt={imageAlt}
width={400}
height={250}
layout="responsive"
objectFit="cover"
/>
</div>
</div>
<div className="card-body">
<Subtitle className="card-title">{title}</Subtitle>
<p>{description}</p>
<div className="mt-4 flex items-center justify-between">
<div className="text-primary text-lg font-bold">{`$${price}`}</div>
<Button
onClick={() => console.log("Comprar")}
>
Add to Cart
</Button>
</div>
</div>
</div>
);
}
43 changes: 43 additions & 0 deletions src/components/ui/Hero.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { useState } from "react";
import Button from "./Button";

interface HeroProps {
title: string;
description: string;
buttonText: string;
buttonOnClick: (searchTerm: string) => void;
}

function Hero({ title, description, buttonText, buttonOnClick }: HeroProps) {
const [searchTerm, setSearchTerm] = useState("");

const handleSearchClick = () => {
buttonOnClick(searchTerm);
};

return (
<div
className="mb-10 h-2/4 bg-cover bg-center"
style={{
backgroundImage: "url('/images/bg.webp')",
}}
>
<div className="flex h-full flex-col items-center justify-center bg-black bg-opacity-50 p-4">
<h1 className="text-center text-5xl font-bold text-white">{title}</h1>
<p className="mt-4 text-center text-xl text-white">{description}</p>
<div className="mt-8 flex w-full max-w-md flex-row items-center justify-center gap-3">
<input
type="text"
placeholder="Buscar..."
className="input input-bordered w-full max-w-xs"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
/>
<Button onClick={handleSearchClick}>{buttonText}</Button>
</div>
</div>
</div>
);
}

export default Hero;
56 changes: 56 additions & 0 deletions src/components/ui/Typography.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { type ReactNode } from "react";

interface TypographyProps {
children: ReactNode;
className?: string;
}

export function H1({ children, className = "" }: TypographyProps) {
return (
<h1
className={`text-primary font-roboto text-4xl font-bold md:text-5xl lg:text-6xl ${className}`}
>
{children}
</h1>
);
}

export function H2({ children, className = "" }: TypographyProps) {
return (
<h2
className={`text-primary font-roboto text-3xl font-semibold md:text-4xl lg:text-5xl ${className}`}
>
{children}
</h2>
);
}

export function H3({ children, className = "" }: TypographyProps) {
return (
<h3
className={`text-primary font-roboto text-2xl font-medium md:text-3xl lg:text-4xl ${className}`}
>
{children}
</h3>
);
}

export function Subtitle({ children, className = "" }: TypographyProps) {
return (
<p
className={`text-primary font-roboto text-xl font-light md:text-2xl ${className}`}
>
{children}
</p>
);
}

export function Label({ children, className = "" }: TypographyProps) {
return (
<span
className={`text-primary font-roboto text-sm font-normal md:text-base ${className}`}
>
{children}
</span>
);
}
79 changes: 79 additions & 0 deletions src/features/ProductCatalog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const coffeeCards = [
{
id: 1,
title: "Café de Especialidad 1",
description: "Descripción del Café de Especialidad 1.",
imageUrl: "/images/cafe1.webp",
imageAlt: "Paquete de Café de Especialidad 1",
},
{
id: 2,
title: "Café de Especialidad 2",
description: "Descripción del Café de Especialidad 2.",
imageUrl: "/images/cafe2.webp",
imageAlt: "Paquete de Café de Especialidad 2",
},
{
id: 3,
title: "Café de Especialidad 3",
description: "Descripción del Café de Especialidad 3.",
imageUrl: "/images/cafe3.webp",
imageAlt: "Paquete de Café de Especialidad 3",
},
{
id: 4,
title: "Café de Especialidad 4",
description: "Descripción del Café de Especialidad 4.",
imageUrl: "/images/cafe4.webp",
imageAlt: "Paquete de Café de Especialidad 4",
},
{
id: 5,
title: "Café de Especialidad 5",
description: "Descripción del Café de Especialidad 5.",
imageUrl: "/images/cafe5.webp",
imageAlt: "Paquete de Café de Especialidad 5",
},
{
id: 6,
title: "Café de Especialidad 3",
description: "Descripción del Café de Especialidad 3.",
imageUrl: "/images/cafe3.webp",
imageAlt: "Paquete de Café de Especialidad 3",
},
{
id: 7,
title: "Café de Especialidad 4",
description: "Descripción del Café de Especialidad 4.",
imageUrl: "/images/cafe4.webp",
imageAlt: "Paquete de Café de Especialidad 4",
},
{
id: 8,
title: "Café de Especialidad 5",
description: "Descripción del Café de Especialidad 5.",
imageUrl: "/images/cafe5.webp",
imageAlt: "Paquete de Café de Especialidad 5",
},
];

import React from "react";
import Card from "~/components/ui/Card";

export default function ProductCatalog() {
return (
<div className="grid grid-cols-1 gap-10 p-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{coffeeCards.map(({ id, title, description, imageUrl, imageAlt }) => (
<Card
key={id}
title={title}
description={description}
imageUrl={imageUrl}
imageAlt={imageAlt}
price="10.00"
/>
))}
</div>
);
}

23 changes: 10 additions & 13 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useConnect } from "@starknet-react/core";
import { useDisconnect } from "@starknet-react/core";
import Header from "~/components/layout/Header";
import Main from "~/components/layout/Main";
import Hero from "~/components/ui/Hero";
import ProductCatalog from "~/features/ProductCatalog";

export default function Home() {
// TODO: This is an example of a TRPC query, let's keep it there for now.
Expand All @@ -19,19 +21,14 @@ export default function Home() {
connectors={connectors}
disconnect={disconnect}
/>
<div className="bg-primary my-20 flex w-full flex-col items-center">
<div className="text-secondary flex h-60 flex-col items-center justify-center p-5">
<h1 className="text-center text-4xl font-bold mb-10">
Welcome Coffee Lover
</h1>
<div className="flex flex-row items-center w-full space-x-1">
<input className="rounded-xl border-none border-0 text-xl text-primary font-bold p-1" type="text" />
<button className="text-bold bg-secondary text-black rounded-full p-2 shadow-sm text-sm">
🔎
</button>
</div>
</div>
</div>
<Hero
title="Welcome Coffee Lover"
description="Find the best coffee in the world"
buttonText="Search"
buttonOnClick={() => console.log("Button clicked")}
/>
<ProductCatalog />

</Main>
);
}

0 comments on commit 7d7e241

Please sign in to comment.