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

chore: upgrade onchainkit version #6

Merged
merged 10 commits into from
Oct 16, 2024
Merged
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
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@coinbase/onchainkit": "^0.33.4",
"@coinbase/onchainkit": "^0.34.0",
"next": "^14.2.5",
"permissionless": "^0.1.26",
"react": "^18",
Expand Down
17 changes: 0 additions & 17 deletions src/app/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ a {
svg {
display: block;
overflow: visible;
vertical-align: middle;
}

ul {
Expand All @@ -64,22 +63,6 @@ ul {
z-index: 0;
}

.ockConnectWallet_Container span {
color: #030712;
}

/* i believe this is necessary because
of a div added by rainbowkit provider */
body > div {
height: 100%;
max-width: 100vw;
box-sizing: border-box;
}

a {
text-decoration: none;
}

.templateSection > div {
max-width: 100%;;
}
9 changes: 9 additions & 0 deletions src/components/Banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function Banner() {
return (
<div className="fixed top-0 left-0 flex h-14 xs:h-12 w-full flex-wrap items-center justify-center bg-black text-white">
<div className="flex h-full flex-wrap items-center justify-center text-center text-sm xs:text-lg">
This is a demo site. These products are not for sale.
</div>
</div>
);
}
4 changes: 2 additions & 2 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function Navbar() {
}, []);

return (
<header className="-mx-[50vw] fixed top-0 right-1/2 left-1/2 w-screen border-gray-200 border-b bg-white">
<header className="-mx-[50vw] fixed top-14 xs:top-12 right-1/2 left-1/2 h-11 w-screen border-gray-200 border-b bg-white">
<div className="mx-auto max-w-7xl px-4 py-3 sm:px-6 lg:px-8">
<div className="flex items-center justify-between">
<div className="flex items-center space-x-3">
Expand All @@ -55,7 +55,7 @@ export default function Navbar() {
</div>
</div>
{isMenuOpen && (
<div className="md:hidden">
<div className="bg-white md:hidden">
<ul className="space-y-2 px-4 py-2">
<NavbarLink link={TEMPLATE_LINK} label="FORK THIS TEMPLATE" />
<NavbarLink link={ONCHAINKIT_LINK} label="ONCHAINKIT" />
Expand Down
37 changes: 0 additions & 37 deletions src/components/OnchainProviders.test.tsx

This file was deleted.

6 changes: 4 additions & 2 deletions src/components/OnchainStore.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Banner } from './Banner';
import Navbar from './Navbar';
import OnchainStoreCart from './OnchainStoreCart';
import OnchainStoreItems from './OnchainStoreItems';
Expand All @@ -7,9 +8,10 @@ import OnchainStoreSummary from './OnchainStoreSummary';
export default function OnchainStore() {
return (
<OnchainStoreProvider>
<div className="flex h-full max-h-screen max-w-full flex-col px-1">
<div className="flex h-full max-h-screen max-w-full flex-col px-1 font-sansMono">
<Banner />
<Navbar />
<main className="mx-auto flex max-w-7xl grow flex-col py-10">
<main className="mx-auto flex max-w-7xl grow flex-col pt-24 pb-10">
<div className="flex grow flex-col pb-10 md:flex-row">
<OnchainStoreSummary />
<OnchainStoreItems />
Expand Down
6 changes: 3 additions & 3 deletions src/components/OnchainStoreCart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default function OnchainStoreCart() {
description,
pricing_type: 'fixed_price',
local_price: {
// NOTE: set to 0 for simulation purposes,
// replace with totalSum.toString() in real app
// NOTE: The values are set to zero on the template as we're not actually looking to sell anything here.
// To test with real values, replace with totalSum.toString() in real app
amount: '0',
currency: 'USD',
},
Expand All @@ -58,7 +58,7 @@ export default function OnchainStoreCart() {
<PayButton
coinbaseBranded={true}
text="Pay with Crypto"
// NOTE: comment back in to disable 0 amount in real app
// NOTE: comment back in to disable $0 amount in real app
// disabled={!totalSum}
/>
</Pay>
Expand Down
49 changes: 49 additions & 0 deletions src/components/OnchainStoreItem.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import OnchainStoreItem from './OnchainStoreItem';

const mockProduct = {
id: '1',
name: 'Sample Product',
price: 19.99,
image: 'https://example.com/image.jpg',
};

vi.mock('./QuantityInput', () => {
return {
default: ({ productId }: { productId: string }) => (
<input data-testid={`quantity-input-${productId}`} />
),
};
});

vi.mock('next/image', () => {
return {
default: ({
src,
alt,
width,
height,
}: {
src: string;
alt: string;
width: number;
height: number;
}) => <img src={src} alt={alt} width={width} height={height} />,
};
});

describe('OnchainStoreItem', () => {
it('should render product information correctly', () => {
render(<OnchainStoreItem {...mockProduct} />);

expect(screen.getByText('Sample Product')).toBeInTheDocument();
expect(screen.getByText('19.99 USDC')).toBeInTheDocument();
const imageElement = screen.getByAltText('123');
expect(imageElement).toBeInTheDocument();
expect(imageElement).toHaveAttribute('src', mockProduct.image);
expect(imageElement).toHaveAttribute('width', '400');
expect(imageElement).toHaveAttribute('height', '400');
expect(screen.getByTestId('quantity-input-1')).toBeInTheDocument();
});
});
4 changes: 2 additions & 2 deletions src/components/OnchainStoreItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import QuantityInput from './QuantityInput';

export default function OnchainStoreItem({ id, name, price, image }: Product) {
return (
<div className="flex flex-col">
<div className="mx-auto flex max-w-[300px] flex-col sm:mx-0">
<div className="mb-1 flex items-start justify-between">
<h2 className="font-regular text-xs">{name}</h2>
<p className="font-regular text-xs">{price.toFixed(2)} USDC</p>
</div>
<Image src={image} alt="123" width={400} height={400} />
<Image src={image} alt="123" width={280} height={280} />
<QuantityInput productId={id} />
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/OnchainStoreItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function OnchainStoreItems() {

return (
<div className="scroll mb-16 p-8 md:mb-0">
<div className="grid grid-cols-1 gap-8 sm:grid-cols-2">
<div className="grid grid-cols-1 gap-10 sm:grid-cols-2">
{products?.map((item) => (
<OnchainStoreItem {...item} key={item.id} />
))}
Expand Down
17 changes: 10 additions & 7 deletions src/components/OnchainStoreProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { createContext, useContext, useMemo, useState } from 'react';
import type { ReactNode } from 'react';
import type { OnchainStoreContextType } from '../types';
import jacketImage from '../images/jacket.png';
import airpodsImage from '../images/airpods.png';
import mugImage from '../images/mug.png';
import bottleImage from '../images/bottle.png';
import type { Product } from 'src/types';

const emptyContext = {} as OnchainStoreContextType;
Expand All @@ -14,24 +17,24 @@ type OnchainStoreProviderReact = {
};

const products: Product[] = [
{ id: 'product1', name: 'BUILDER JACKET', price: 0.04, image: jacketImage },
{ id: 'product1', name: `'BUILDER' JACKET`, price: 0.04, image: jacketImage },
{
id: 'product2',
name: 'DO NOT DISTURB AIRPODS',
name: `'DND, I'M BUILDING' AIRPODS`,
price: 0.01,
image: jacketImage,
image: airpodsImage,
},
{
id: 'product3',
name: 'CAFFEINATED TO BUILD MUG',
name: `'CAFFEINATED TO BUILD' MUG`,
price: 0.02,
image: jacketImage,
image: mugImage,
},
{
id: 'product4',
name: 'OCK BUILDER JACKET',
name: `'HYDRATED TO BUILD' BOTTLE`,
price: 0.01,
image: jacketImage,
image: bottleImage,
},
];

Expand Down
Binary file added src/images/airpods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/bottle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/mug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const config: Config = {
container: {
center: true,
screens: {
xs: '510px',
sm: '640px',
md: '768px',
lg: '1024px',
Expand Down Expand Up @@ -62,6 +63,7 @@ const config: Config = {
},
fontFamily: {
mono: ['IBM Plex Mono', 'monospace'],
sansMono: ['Noto Sans Mono', 'monospace'],
},
},
},
Expand Down