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

Commit

Permalink
feat: add connect wallet button
Browse files Browse the repository at this point in the history
  • Loading branch information
izaakwalz committed May 4, 2024
1 parent 6f19d25 commit f18c869
Show file tree
Hide file tree
Showing 9 changed files with 860 additions and 33 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@phosphor-icons/react": "^2.1.5",
"@radix-ui/react-alert-dialog": "^1.0.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.376.0",
Expand Down
420 changes: 416 additions & 4 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

66 changes: 40 additions & 26 deletions src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {

export type IconType = keyof typeof Icons;

type IconProps = React.HTMLAttributes<SVGElement>;
export type IconProps = React.HTMLAttributes<SVGElement>;

export const Icons = {
wallet: Wallet,
Expand All @@ -28,6 +28,33 @@ export const Icons = {
Storefront: Storefront,
GearSix: GearSix,
Power: Power,
close: (props: IconProps) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none" {...props}>
<path
d="M12.3955 7.59497L7.60352 12.387"
stroke="white"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M12.397 12.3899L7.60095 7.5929"
stroke="white"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M14.3345 0.750244H5.66549C2.64449 0.750244 0.750488 2.88924 0.750488 5.91624V14.0842C0.750488 17.1112 2.63549 19.2502 5.66549 19.2502H14.3335C17.3645 19.2502 19.2505 17.1112 19.2505 14.0842V5.91624C19.2505 2.88924 17.3645 0.750244 14.3345 0.750244Z"
stroke="white"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
),
goldMedal: (props: IconProps) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 23" fill="none" {...props}>
<path
Expand Down Expand Up @@ -83,8 +110,8 @@ export const Icons = {
y2="16.6387"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#FFC600" />
<stop offset="1" stop-color="#FFDE69" />
<stop stopColor="#FFC600" />
<stop offset="1" stopColor="#FFDE69" />
</linearGradient>
<linearGradient
id="paint1_linear_311_3749"
Expand All @@ -94,8 +121,8 @@ export const Icons = {
y2="12.9533"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#FFFCDD" />
<stop offset="1" stop-color="#FFE896" />
<stop stopColor="#FFFCDD" />
<stop offset="1" stopColor="#FFE896" />
</linearGradient>
</defs>
</svg>
Expand Down Expand Up @@ -163,8 +190,8 @@ export const Icons = {
y2="16.2559"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#9CA1A3" />
<stop offset="1" stop-color="#9CA1A3" stop-opacity="0" />
<stop stopColor="#9CA1A3" />
<stop offset="1" stopColor="#9CA1A3" stop-opacity="0" />
</linearGradient>
<linearGradient
id="paint1_linear_311_3767"
Expand All @@ -174,9 +201,9 @@ export const Icons = {
y2="13.6503"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#F1F5F5" />
<stop offset="0.0001" stop-color="white" />
<stop offset="1" stop-color="#F1F5F5" />
<stop stopColor="#F1F5F5" />
<stop offset="0.0001" stopColor="white" />
<stop offset="1" stopColor="#F1F5F5" />
</linearGradient>
</defs>
</svg>
Expand Down Expand Up @@ -238,24 +265,11 @@ export const Icons = {
y2="13.6502"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#FCFF80" />
<stop offset="0.401042" stop-color="#FDE870" />
<stop offset="1" stop-color="#FFC759" />
<stop stopColor="#FCFF80" />
<stop offset="0.401042" stopColor="#FDE870" />
<stop offset="1" stopColor="#FFC759" />
</linearGradient>
</defs>
</svg>
),
rectangle: (props: IconProps) => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 100 85"
fill="currentColor"
{...props}
>
<path
d="M0.5 4.00001C0.5 2.06701 2.067 0.5 4 0.5H96C97.933 0.5 99.5 2.067 99.5 4V79.7748C99.5 82.1977 97.0812 83.951 94.7342 83.2496C86.4259 80.7666 69.7217 76.5 53 76.5C34.5591 76.5 14.3248 81.145 5.04829 83.5598C2.76331 84.1546 0.5 82.4334 0.5 80.0878V4.00001Z"
fillOpacity="0.24"
/>
</svg>
)
};
58 changes: 58 additions & 0 deletions src/components/layouts/connect-wallet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use client';

import { useState } from 'react';
import { AlertDialog, AlertDialogContent, AlertDialogTrigger } from '../ui/alert-dialog';
import { ConnectWalletIcon, WalletIcon, WalletIconType } from '../wallet-icon';
import { Icons } from '../icons';

export default function ConnectWallet() {
const [isDialogOpen, setIsDialogOpen] = useState(false);

return (
<AlertDialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
<AlertDialogTrigger asChild>
<button className="flex items-center gap-2 rounded-lg border border-primary-300 px-[45px] py-4 font-heading text-[1rem] font-medium text-primary-300 hover:border-white hover:text-white">
Connect <ConnectWalletIcon className="h-4 w-[21px]" />
</button>
</AlertDialogTrigger>
<AlertDialogContent className="gap-6">
<div className="flex items-center justify-between">
<h1 className="text-[1.0625rem]/[1.5rem] font-medium ">Connect wallet</h1>
<button onClick={() => setIsDialogOpen(false)}>
<Icons.close className="size-6 stroke-white hover:stroke-primary-foreground" />
</button>
</div>
<div className="flex w-full flex-col gap-6">
<WalletButton icon="tailsManWallet" name="Tailsman" isRecommended />
<WalletButton icon="subWallet" name="Subwallet" />
</div>
</AlertDialogContent>
</AlertDialog>
);
}

interface WalletButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
name: string;
icon: WalletIconType;
isRecommended?: boolean;
}

export function WalletButton({ name, icon, isRecommended, ...props }: WalletButtonProps) {
const Icon = WalletIcon[icon];
return (
<button
className="flex w-full items-center justify-between rounded-lg border border-white px-4 py-2 transition-colors duration-300 hover:border-primary-foreground"
{...props}
>
<div className="flex items-center gap-2">
<Icon className="size-[42px]" />
<span className="text-[1rem]/[1.5rem]">{name}</span>
</div>
{isRecommended ? (
<span className="rounded-lg bg-primary px-2 text-center text-[0.75rem]/[1.5rem] font-light text-primary-300">
Recommended
</span>
) : null}
</button>
);
}
6 changes: 4 additions & 2 deletions src/components/layouts/site-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { siteConfig } from '@/config/site';
import Image from 'next/image';
import Link from 'next/link';
import { Icons } from '../icons';
import ConnectWallet from './connect-wallet';

export function SiteHeader() {
return (
Expand All @@ -22,9 +23,10 @@ export function SiteHeader() {
</Link>
))}
</nav>
<button className="flex items-center gap-2 rounded-lg border border-primary-300 px-[45px] py-4 font-heading text-[1rem] font-medium text-primary-300 hover:border-white hover:text-white">
<ConnectWallet />
{/* <button className="flex items-center gap-2 rounded-lg border border-primary-300 px-[45px] py-4 font-heading text-[1rem] font-medium text-primary-300 hover:border-white hover:text-white">
Connect <Icons.wallet className="h-4 w-5" />
</button>
</button> */}
</div>
</header>
);
Expand Down
124 changes: 124 additions & 0 deletions src/components/ui/alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
'use client';

import * as React from 'react';
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';

import { cn } from '@/lib/utils';
import { buttonVariants } from '@/components/ui/button';

const AlertDialog = AlertDialogPrimitive.Root;

const AlertDialogTrigger = AlertDialogPrimitive.Trigger;

const AlertDialogPortal = AlertDialogPrimitive.Portal;

const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Overlay
className={cn(
'fixed inset-0 z-50 bg-primary/50 backdrop-blur-[4px] backdrop-filter data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className
)}
{...props}
ref={ref}
/>
));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;

const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
>(({ className, ...props }, ref) => (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
className={cn(
'bg-primary-500 fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] rounded-lg p-6 shadow-header duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
className
)}
{...props}
/>
</AlertDialogPortal>
));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;

const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn('flex flex-col space-y-2 text-center sm:text-left', className)}
{...props}
/>
);
AlertDialogHeader.displayName = 'AlertDialogHeader';

const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
{...props}
/>
);
AlertDialogFooter.displayName = 'AlertDialogFooter';

const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold', className)}
{...props}
/>
));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;

const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description
ref={ref}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
));
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;

const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Action
ref={ref}
className={cn(buttonVariants(), className)}
{...props}
/>
));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;

const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Cancel
ref={ref}
className={cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', className)}
{...props}
/>
));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;

export {
AlertDialog,
AlertDialogPortal,
AlertDialogOverlay,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel
};
3 changes: 2 additions & 1 deletion src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const buttonVariants = cva(
secondary:
'bg-primary-200 hover:bg-primary-200/85 text-foreground disabled:opacity-50 disabled:pointer-events-none transition-colors',
warning:
'bg-primary-400 hover:bg-primary-400/85 text-foreground disabled:opacity-50 disabled:pointer-events-none transition-colors'
'bg-primary-400 hover:bg-primary-400/85 text-foreground disabled:opacity-50 disabled:pointer-events-none transition-colors',
outline: ''
},
size: {
default: 'py-[18px] px-6 text-[1rem]/[1.2rem]',
Expand Down
Loading

0 comments on commit f18c869

Please sign in to comment.