-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from janndriessen/feat/payment-ui
feat: payment ui
- Loading branch information
Showing
15 changed files
with
4,973 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
# GHOPAY | ||
|
||
Submission for [LFGHO](https://ethglobal.com/events/lfgho) - ETHGlobal 2024 | ||
|
||
## Setup | ||
|
||
### /shop | ||
|
||
The shop application included the payment online shop and merchant dashboard flow. | ||
|
||
``` | ||
nvm current | ||
v20.11.0 // make sure to use the latest node.js version | ||
cp .env.default .env.local | ||
npm install | ||
npm run dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALCHEMY_ID= | ||
WALLETCONNECT_PROJECT_ID= |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,78 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer base { | ||
:root { | ||
--background: 0 0% 100%; | ||
--foreground: 222.2 84% 4.9%; | ||
--foreground: 245.29 16.5% 40.39%; | ||
|
||
--card: 0 0% 100%; | ||
--card-foreground: 222.2 84% 4.9%; | ||
|
||
--popover: 0 0% 100%; | ||
--popover-foreground: 222.2 84% 4.9%; | ||
|
||
--primary: 222.2 47.4% 11.2%; | ||
--primary-foreground: 210 40% 98%; | ||
|
||
|
||
/* GHO colors */ | ||
--primary: 258.62 47.54% 88.04%; | ||
--primary-foreground: 245.29 16.5% 40.39%; | ||
|
||
--secondary: 210 40% 96.1%; | ||
--secondary-foreground: 222.2 47.4% 11.2%; | ||
|
||
--muted: 210 40% 96.1%; | ||
--muted-foreground: 215.4 16.3% 46.9%; | ||
|
||
--accent: 210 40% 96.1%; | ||
--accent-foreground: 222.2 47.4% 11.2%; | ||
|
||
|
||
/* GHO colors */ | ||
--accent: 258.62 47.54% 88.04%; | ||
--accent-foreground: 245.29 16.5% 40.39%; | ||
|
||
--destructive: 0 84.2% 60.2%; | ||
--destructive-foreground: 210 40% 98%; | ||
|
||
--border: 214.3 31.8% 91.4%; | ||
--input: 214.3 31.8% 91.4%; | ||
--ring: 222.2 84% 4.9%; | ||
|
||
--radius: 0.5rem; | ||
} | ||
|
||
.dark { | ||
--background: 222.2 84% 4.9%; | ||
--foreground: 210 40% 98%; | ||
|
||
--card: 222.2 84% 4.9%; | ||
--card-foreground: 210 40% 98%; | ||
|
||
--popover: 222.2 84% 4.9%; | ||
--popover-foreground: 210 40% 98%; | ||
|
||
--primary: 210 40% 98%; | ||
--primary-foreground: 222.2 47.4% 11.2%; | ||
|
||
--secondary: 217.2 32.6% 17.5%; | ||
--secondary-foreground: 210 40% 98%; | ||
|
||
--muted: 217.2 32.6% 17.5%; | ||
--muted-foreground: 215 20.2% 65.1%; | ||
|
||
--accent: 217.2 32.6% 17.5%; | ||
--accent-foreground: 210 40% 98%; | ||
|
||
--destructive: 0 62.8% 30.6%; | ||
--destructive-foreground: 210 40% 98%; | ||
|
||
--border: 217.2 32.6% 17.5%; | ||
--input: 217.2 32.6% 17.5%; | ||
--ring: 212.7 26.8% 83.9%; | ||
} | ||
} | ||
|
||
@layer base { | ||
* { | ||
@apply border-border; | ||
} | ||
body { | ||
@apply bg-background text-foreground; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { motion } from 'framer-motion' | ||
import Image from 'next/image' | ||
|
||
import { PrimaryButton } from '@/components/ui/button' | ||
|
||
type GhoButtonProps = { | ||
onClick: () => void | ||
} | ||
|
||
export function GhoButton({ onClick }: GhoButtonProps) { | ||
return ( | ||
<motion.button whileHover={{ scale: 1.06 }} whileTap={{ scale: 0.96 }}> | ||
<PrimaryButton size={'lg'} onClick={onClick}> | ||
<div className="flex items-center gap-2"> | ||
<Image | ||
src="/assets/icon-light.svg" | ||
width={36} | ||
height={36} | ||
alt="GHO icon" | ||
/> | ||
<p>Pay with GHO</p> | ||
</div> | ||
</PrimaryButton> | ||
</motion.button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { ConnectKitButton } from 'connectkit' | ||
import { motion } from 'framer-motion' | ||
|
||
import './styles.css' | ||
|
||
const sidebar = { | ||
open: () => ({ | ||
right: 0, | ||
transition: { | ||
type: 'spring', | ||
damping: 20, | ||
stiffness: 100, | ||
restDelta: 2, | ||
}, | ||
}), | ||
closed: { | ||
right: '-400px', | ||
transition: { | ||
delay: 0.5, | ||
type: 'spring', | ||
stiffness: 400, | ||
damping: 40, | ||
}, | ||
}, | ||
} | ||
|
||
const variants = { | ||
open: { | ||
transition: { staggerChildren: 0.07, delayChildren: 0.2 }, | ||
}, | ||
closed: { | ||
transition: { staggerChildren: 0.05, staggerDirection: -1 }, | ||
}, | ||
} | ||
|
||
const variantsItems = { | ||
open: { | ||
y: 0, | ||
opacity: 1, | ||
transition: { | ||
y: { stiffness: 1000, velocity: -100 }, | ||
}, | ||
}, | ||
closed: { | ||
y: 50, | ||
opacity: 0, | ||
transition: { | ||
y: { stiffness: 1000 }, | ||
}, | ||
}, | ||
} | ||
|
||
export const PaymentPopup = () => ( | ||
<motion.div className="background shadow-xl p-8" variants={sidebar}> | ||
<motion.ul variants={variants}> | ||
<PayHeadline label="Pay 129.159 GHO" key={0} /> | ||
<QRCode code={'0x0'} key={1} /> | ||
<div className="mt-6"> | ||
<Text label="To pay, scan the code inside the app" key={2} /> | ||
</div> | ||
<div className="mt-16"> | ||
<Text label="or..." key={3} /> | ||
</div> | ||
<div className="flex flex-col items-center mt-8 w-full"> | ||
<motion.li variants={variantsItems}> | ||
<ConnectKitButton /> | ||
</motion.li> | ||
</div> | ||
</motion.ul> | ||
</motion.div> | ||
) | ||
|
||
export const PayHeadline = ({ label }: { label: string }) => { | ||
return ( | ||
<motion.li variants={variantsItems}> | ||
<h2 className="font-bold text-4xl text-center mt-8">{label}</h2> | ||
</motion.li> | ||
) | ||
} | ||
|
||
/* eslint-disable @next/next/no-img-element */ | ||
export const QRCode = ({ code }: { code: string }) => { | ||
return ( | ||
<motion.li variants={variantsItems}> | ||
<div className="bg-white rounded-xl p-8 mt-8"> | ||
<img | ||
src="/assets/qr-code-temp.png" | ||
width={300} | ||
height={300} | ||
alt="GHO QR code" | ||
/> | ||
</div> | ||
</motion.li> | ||
) | ||
} | ||
|
||
export const Text = ({ label }: { label: string }) => { | ||
return ( | ||
<motion.li variants={variantsItems}> | ||
<p className="font-semibold text-3xl text-center">{label}</p> | ||
</motion.li> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.background { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
width: 400px; | ||
background: linear-gradient(to bottom, #dbd2ef, #f0ebf9 60%); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
'use client' | ||
|
||
import { useEffect, useState, useRef, MutableRefObject } from 'react' | ||
import { motion, useCycle } from 'framer-motion' | ||
|
||
import { GhoButton } from './components/gho-button' | ||
import { PaymentPopup } from './components/payment-popup' | ||
|
||
export default function Payment() { | ||
return <h1>Payment</h1> | ||
const [isOpen, toggleOpen] = useCycle(false, true) | ||
|
||
const onClickPay = () => { | ||
console.log('open payment') | ||
toggleOpen() | ||
} | ||
|
||
return ( | ||
<div className="flex items-center justify-center h-screen"> | ||
<motion.nav initial={false} animate={isOpen ? 'open' : 'closed'}> | ||
<PaymentPopup /> | ||
<GhoButton onClick={onClickPay} /> | ||
</motion.nav> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use client' | ||
|
||
import { WagmiConfig, createConfig } from 'wagmi' | ||
import { sepolia } from 'wagmi/chains' | ||
import { | ||
ConnectKitProvider, | ||
ConnectKitButton, | ||
getDefaultConfig, | ||
} from 'connectkit' | ||
|
||
const config = createConfig( | ||
getDefaultConfig({ | ||
alchemyId: process.env.ALCHEMY_ID!, | ||
walletConnectProjectId: process.env.WALLETCONNECT_PROJECT_ID!, | ||
|
||
// Required | ||
appName: 'GHOPAY', | ||
|
||
// Optional | ||
appDescription: 'G(H)O PAY!', | ||
appUrl: 'https://gho.xyz', | ||
appIcon: 'https://family.co/logo.png', // your app's icon, no bigger than 1024x1024px (max. 1MB) | ||
chains: [sepolia], | ||
}), | ||
) | ||
|
||
export function Providers({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<WagmiConfig config={config}> | ||
<ConnectKitProvider theme={'soft'} mode={'light'}> | ||
{children} | ||
<ConnectKitButton /> | ||
</ConnectKitProvider> | ||
</WagmiConfig> | ||
) | ||
} |
Oops, something went wrong.