Skip to content

Commit

Permalink
Merge pull request #761 from ionicprotocol/development
Browse files Browse the repository at this point in the history
  • Loading branch information
rhlsthrm authored Nov 6, 2024
2 parents 869a047 + a82ec22 commit 2065b53
Show file tree
Hide file tree
Showing 24 changed files with 1,955 additions and 14 deletions.
9 changes: 3 additions & 6 deletions packages/ui/app/_components/DynamicSubNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ function DynamicSubNav() {
);
}
return (
<a
<div
className={`${`${pools[+chainId]?.bg ?? pools[mode.id]?.bg} ${
pools[+chainId]?.text ?? pools[mode.id]?.text
}`} absolute w-full z-20 top-full left-0 text-center text-sm font-medium cursor-pointer `}
// onClick={() => router.push('/points')}
href="https://jumper.exchange/superfest/"
target="_blank"
}`} absolute w-full z-20 top-full left-0 text-center text-sm font-medium `}
>
<div className={`h-max w-full flex group z-20 givep overflow-x-hidden`}>
{clone()}
{clone()}
</div>
</a>
</div>
);
}

Expand Down
27 changes: 25 additions & 2 deletions packages/ui/app/_components/dashboards/CollateralSwapPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import type { MarketData } from '@ui/types/TokensDataMap';

import MaxDeposit from './MaxDeposit';
import SwapTo from './SwapTo';
import { SlippageDropdown } from '../SlippageDropdown';

import { collateralSwapAbi } from '@ionicprotocol/sdk/src';

Expand Down Expand Up @@ -78,6 +77,30 @@ ChartJS.register(
Legend
);

// Replace the SlippageDropdown import with a simpler dropdown implementation
const SlippageSelector = ({
onSlippageChange
}: {
onSlippageChange: (value: number) => void;
}) => {
return (
<div className="flex items-center justify-between w-full text-xs pb-2">
<span className="text-white/50">SLIPPAGE TOLERANCE</span>
<select
className="bg-graytwo text-white rounded px-2 py-1 text-xs"
onChange={(e) => onSlippageChange(Number(e.target.value))}
defaultValue="0.01"
>
<option value="0.001">0.1%</option>
<option value="0.005">0.5%</option>
<option value="0.01">1%</option>
<option value="0.02">2%</option>
<option value="0.05">5%</option>
</select>
</div>
);
};

export default function CollateralSwapPopup({
swapRef,
toggler,
Expand Down Expand Up @@ -564,7 +587,7 @@ export default function CollateralSwapPopup({
</div>
</div>
<div className="h-[2px] w-full mx-auto bg-white/10 my-2.5" />
<SlippageDropdown onSlippageChange={handleSlippageChange} />
<SlippageSelector onSlippageChange={handleSlippageChange} />
</div>

<div className="sticky bottom-0 bg-grayone w-full px-8 pb-4">
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"components": "@ui/components",
"utils": "@ui/lib/utils"
}
}
}
63 changes: 63 additions & 0 deletions packages/ui/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use client';

import * as React from 'react';

import { ChevronLeft, ChevronRight } from 'lucide-react';
import { DayPicker } from 'react-day-picker';

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

export type CalendarProps = React.ComponentProps<typeof DayPicker>;

function Calendar({
className,
classNames,
showOutsideDays = true,
...props
}: CalendarProps) {
return (
<DayPicker
showOutsideDays={showOutsideDays}
className={cn('p-3', className)}
classNames={{
months: 'flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0',
month: 'space-y-4',
caption: 'flex justify-center pt-1 relative items-center',
caption_label: 'text-sm font-medium',
nav: 'space-x-1 flex items-center',
nav_button: cn(
buttonVariants({ variant: 'outline' }),
'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100'
),
nav_button_previous: 'absolute left-1',
nav_button_next: 'absolute right-1',
table: 'w-full border-collapse space-y-1',
head_row: 'flex',
head_cell:
'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]',
row: 'flex w-full mt-2',
cell: 'h-9 w-9 text-center text-sm p-0 relative',
day: cn(
buttonVariants({ variant: 'ghost' }),
'h-9 w-9 p-0 font-normal aria-selected:opacity-100'
),
day_selected:
'bg-accent text-black hover:bg-accent hover:text-black focus:bg-accent focus:text-black',
day_today: 'bg-accent/20 text-accent',
day_outside: 'text-muted-foreground opacity-50',
day_disabled: 'text-muted-foreground opacity-50',
day_hidden: 'invisible',
...classNames
}}
components={{
IconLeft: () => <ChevronLeft className="h-4 w-4" />,
IconRight: () => <ChevronRight className="h-4 w-4" />
}}
{...props}
/>
);
}
Calendar.displayName = 'Calendar';

export { Calendar };
90 changes: 90 additions & 0 deletions packages/ui/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import * as React from 'react';

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

const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
'rounded-lg border bg-card text-card-foreground shadow-sm',
className
)}
{...props}
/>
));
Card.displayName = 'Card';

const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn('flex flex-col space-y-1.5 p-6', className)}
{...props}
/>
));
CardHeader.displayName = 'CardHeader';

const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn(
'text-2xl font-semibold leading-none tracking-tight',
className
)}
{...props}
/>
));
CardTitle.displayName = 'CardTitle';

const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
));
CardDescription.displayName = 'CardDescription';

const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn('p-6 pt-0', className)}
{...props}
/>
));
CardContent.displayName = 'CardContent';

const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn('flex items-center p-6 pt-0', className)}
{...props}
/>
));
CardFooter.displayName = 'CardFooter';

export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardDescription,
CardContent
};
31 changes: 31 additions & 0 deletions packages/ui/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';

import * as React from 'react';

import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
import { Check } from 'lucide-react';

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

const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn('flex items-center justify-center text-current')}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
));
Checkbox.displayName = CheckboxPrimitive.Root.displayName;

export { Checkbox };
126 changes: 126 additions & 0 deletions packages/ui/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import * as React from 'react';

import * as DialogPrimitive from '@radix-ui/react-dialog';
import { X } from 'lucide-react';

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

const Dialog = DialogPrimitive.Root;
const DialogTrigger = DialogPrimitive.Trigger;
const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;

const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className
)}
{...props}
/>
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;

interface DialogContentProps
extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
hideCloseButton?: boolean;
}

const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
DialogContentProps
>(({ className, children, hideCloseButton = false, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-2xl translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background px-6 py-4 shadow-lg 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%] rounded-3xl',
className
)}
{...props}
>
{children}
{!hideCloseButton && (
<DialogPrimitive.Close className="absolute right-6 top-6 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-6 w-6" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
)}
</DialogPrimitive.Content>
</DialogPortal>
));
DialogContent.displayName = DialogPrimitive.Content.displayName;

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

const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
'text-2xl font-medium leading-none tracking-tight',
className
)}
{...props}
/>
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;

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

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

export {
Dialog,
DialogPortal,
DialogOverlay,
DialogClose,
DialogTrigger,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription
};
Loading

0 comments on commit 2065b53

Please sign in to comment.