feat: Add @radix-ui/react-progress package for progress bar on Invest page

This commit is contained in:
Pattadon 2024-08-30 10:41:07 +07:00
parent b321f04354
commit 5f2db259a5
4 changed files with 109 additions and 3 deletions

View File

@ -11,6 +11,7 @@
"dependencies": {
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-navigation-menu": "^1.2.0",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0",
"@supabase/ssr": "^0.4.0",
@ -22,6 +23,7 @@
"next": "14.2.5",
"next-themes": "^0.3.0",
"react": "^18",
"react-countup": "^6.5.3",
"react-dom": "^18",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7"

View File

@ -7,6 +7,9 @@ dependencies:
'@radix-ui/react-navigation-menu':
specifier: ^1.2.0
version: 1.2.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1)
'@radix-ui/react-progress':
specifier: ^1.1.0
version: 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1)
'@radix-ui/react-separator':
specifier: ^1.1.0
version: 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1)
@ -40,6 +43,9 @@ dependencies:
react:
specifier: ^18
version: 18.3.1
react-countup:
specifier: ^6.5.3
version: 6.5.3(react@18.3.1)
react-dom:
specifier: ^18
version: 18.3.1(react@18.3.1)
@ -671,6 +677,27 @@ packages:
react-dom: 18.3.1(react@18.3.1)
dev: false
/@radix-ui/react-progress@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1):
resolution: {integrity: sha512-aSzvnYpP725CROcxAOEBVZZSIQVQdHgBr2QQFKySsaD14u8dNT0batuXI+AAGDdAHfXH8rbnHmjYFqVJ21KkRg==}
peerDependencies:
'@types/react': '*'
'@types/react-dom': '*'
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
peerDependenciesMeta:
'@types/react':
optional: true
'@types/react-dom':
optional: true
dependencies:
'@radix-ui/react-context': 1.1.0(@types/react@18.3.4)(react@18.3.1)
'@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1)
'@types/react': 18.3.4
'@types/react-dom': 18.3.0
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
dev: false
/@radix-ui/react-roving-focus@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.4)(react-dom@18.3.1)(react@18.3.1):
resolution: {integrity: sha512-EA6AMGeq9AEeQDeSH0aZgG198qkfHSbvWTf1HvoDmOB5bBG/qTxjYMWUKMnYiV6J/iP/J8MEFSuB2zRU2n7ODA==}
peerDependencies:
@ -1351,6 +1378,10 @@ packages:
engines: {node: '>= 0.6'}
dev: false
/countup.js@2.8.0:
resolution: {integrity: sha512-f7xEhX0awl4NOElHulrl4XRfKoNH3rB+qfNSZZyjSZhaAoUk6elvhH+MNxMmlmuUJ2/QNTWPSA7U4mNtIAKljQ==}
dev: false
/cross-spawn@7.0.3:
resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}
engines: {node: '>= 8'}
@ -2961,6 +2992,15 @@ packages:
/queue-microtask@1.2.3:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
/react-countup@6.5.3(react@18.3.1):
resolution: {integrity: sha512-udnqVQitxC7QWADSPDOxVWULkLvKUWrDapn5i53HE4DPRVgs+Y5rr4bo25qEl8jSh+0l2cToJgGMx+clxPM3+w==}
peerDependencies:
react: '>= 16.3.0'
dependencies:
countup.js: 2.8.0
react: 18.3.1
dev: false
/react-dom@18.3.1(react@18.3.1):
resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==}
peerDependencies:

View File

@ -1,6 +1,6 @@
"use client";
import React from "react";
import React, { useState, useEffect } from "react";
import Image from "next/image";
import {
Carousel,
@ -10,10 +10,20 @@ import {
CarouselPrevious,
} from "@/components/ui/carousel";
import { Card, CardContent } from "@/components/ui/card";
import CountUp from "react-countup";
import { Progress } from "@/components/ui/progress";
import { Separator } from "@/components/ui/separator";
import { Button } from "@/components/ui/button";
export default function Invest() {
const [progress, setProgress] = useState(0);
useEffect(() => {
// percent success
const timer = setTimeout(() => setProgress(66), 500);
return () => clearTimeout(timer);
}, []);
return (
<div className=" w-[90%] h-[500px]-500 ml-20 mt-12">
<div className=" w-[90%] h-[500px]-500 ml-32 mt-12">
<div>
<div className="flex">
<Image src="./logo.svg" alt="logo" width={50} height={50} />
@ -43,7 +53,33 @@ export default function Invest() {
<CarouselPrevious />
<CarouselNext />
</Carousel>
<div className="bg-emerald-800 w-1/3 h-[400px] ml-[5%]"></div>
<div className=" w-1/3 mt-4 h-[400px] ml-[8%] ">
<div className="pl-5">
<h1 className="font-semibold text-4xl mt-8">
<CountUp
start={0}
end={100000}
duration={2}
prefix="$"
className=""
/>
</h1>
<p className=""> 5% raised of $5M max goal</p>
<Progress value={progress} className="w-[60%] h-3 mt-3" />
<h1 className="font-semibold text-4xl mt-8">
{" "}
<CountUp start={0} end={1000} duration={2} className="" />
</h1>
<p className=""> Investors</p>
</div>
<Separator decorative className="mt-3 w-3/4 ml-5" />
<h1 className="font-semibold text-4xl mt-8 ml-5">
{" "}
<CountUp start={0} end={5800} duration={2} className="" /> hours
</h1>
<p className="ml-5"> Left to invest</p>
<Button className="mt-10 ml-[25%]">Invest</Button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,28 @@
"use client"
import * as React from "react"
import * as ProgressPrimitive from "@radix-ui/react-progress"
import { cn } from "@/lib/utils"
const Progress = React.forwardRef<
React.ElementRef<typeof ProgressPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
>(({ className, value, ...props }, ref) => (
<ProgressPrimitive.Root
ref={ref}
className={cn(
"relative h-4 w-full overflow-hidden rounded-full bg-secondary",
className
)}
{...props}
>
<ProgressPrimitive.Indicator
className="h-full w-full flex-1 bg-primary transition-all"
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
/>
</ProgressPrimitive.Root>
))
Progress.displayName = ProgressPrimitive.Root.displayName
export { Progress }