-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,261 additions
and
258 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
app/(pages)/edit/_components/edit-top-stats/components/ui/edit-top-item.tsx
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,91 @@ | ||
import * as React from 'react'; | ||
import MaterialSymbolsKidStar from '~icons/material-symbols/kid-star'; | ||
|
||
import Link from 'next/link'; | ||
|
||
import Small from '@/components/typography/small'; | ||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; | ||
import { Label } from '@/components/ui/label'; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipTrigger, | ||
} from '@/components/ui/tooltip'; | ||
import { cn } from '@/utils'; | ||
|
||
interface Props { | ||
user: API.User; | ||
rank: number; | ||
accepted: number; | ||
closed: number; | ||
denied: number; | ||
} | ||
|
||
const Component = ({ user, rank, accepted, denied, closed }: Props) => { | ||
return ( | ||
<div | ||
className={cn( | ||
'relative flex min-w-0 flex-1 w-full items-center gap-4 rounded-md p-4', | ||
'border border-secondary/60 bg-secondary/30', | ||
)} | ||
> | ||
<MaterialSymbolsKidStar | ||
className={cn( | ||
'absolute text-lg', | ||
rank === 1 | ||
? 'text-yellow-300' | ||
: rank === 2 | ||
? 'text-slate-300' | ||
: 'text-amber-700', | ||
'right-2 top-2 lg:-right-2 lg:-top-2', | ||
)} | ||
/> | ||
<Link href={`/u/${user.username}`}> | ||
<Avatar className="w-10 rounded-md"> | ||
<AvatarImage src={user.avatar} /> | ||
<AvatarFallback className="w-10 rounded-md" /> | ||
</Avatar> | ||
</Link> | ||
<div className="flex min-w-0 flex-col gap-1"> | ||
<Label className="truncate"> | ||
<Link className="truncate" href={`/u/${user.username}`}> | ||
{user.username} | ||
</Link> | ||
</Label> | ||
|
||
<div className="flex gap-3"> | ||
<Tooltip delayDuration={0}> | ||
<TooltipTrigger> | ||
<div className="flex items-center gap-2 text-muted-foreground"> | ||
<div className="flex size-2 items-center justify-center rounded-full bg-success" /> | ||
<Small>{accepted}</Small> | ||
</div> | ||
</TooltipTrigger> | ||
<TooltipContent>Прийнято</TooltipContent> | ||
</Tooltip> | ||
<Tooltip delayDuration={0}> | ||
<TooltipTrigger> | ||
<div className="flex items-center gap-2 text-muted-foreground"> | ||
<div className="flex size-2 items-center justify-center rounded-full bg-destructive" /> | ||
<Small>{denied}</Small> | ||
</div> | ||
</TooltipTrigger> | ||
<TooltipContent>Відхилено</TooltipContent> | ||
</Tooltip> | ||
|
||
<Tooltip delayDuration={0}> | ||
<TooltipTrigger> | ||
<div className="flex items-center gap-2 text-muted-foreground"> | ||
<div className="flex size-2 items-center justify-center rounded-full bg-warning" /> | ||
<Small>{closed}</Small> | ||
</div> | ||
</TooltipTrigger> | ||
<TooltipContent>Закрито</TooltipContent> | ||
</Tooltip> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Component; |
72 changes: 72 additions & 0 deletions
72
app/(pages)/edit/_components/edit-top-stats/edit-top-stats.tsx
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,72 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import MaterialSymbolsMoreHoriz from '~icons/material-symbols/more-horiz'; | ||
|
||
import EditTopStatsModal from '@/components/modals/edit-top-stats-modal/edit-top-stats-modal'; | ||
import { | ||
Carousel, | ||
CarouselContent, | ||
CarouselItem, | ||
} from '@/components/ui/carousel'; | ||
import useEditTop from '@/services/hooks/stats/edit/useEditTop'; | ||
import { useModalContext } from '@/services/providers/modal-provider'; | ||
|
||
import EditTopItem from './components/ui/edit-top-item'; | ||
|
||
function Component() { | ||
const { openModal } = useModalContext(); | ||
const { list } = useEditTop(); | ||
|
||
if (!list || list.length === 0) { | ||
return null; | ||
} | ||
|
||
const handleOpenModal = () => { | ||
openModal({ | ||
content: <EditTopStatsModal />, | ||
title: 'Топ контрибуторів', | ||
type: 'sheet', | ||
}); | ||
}; | ||
|
||
return ( | ||
<Carousel | ||
opts={{ | ||
breakpoints: { | ||
'(min-width: 1024px)': { | ||
active: false, | ||
}, | ||
}, | ||
}} | ||
className="-mx-4 lg:mx-0" | ||
> | ||
<CarouselContent containerClassName="lg:overflow-visible px-4 lg:px-0"> | ||
{list.slice(0, 3).map((stat, index) => ( | ||
<CarouselItem | ||
className="basis-3/4 md:basis-1/3 lg:basis-[30%]" | ||
key={stat.user.reference} | ||
> | ||
<EditTopItem | ||
rank={index + 1} | ||
user={stat.user} | ||
accepted={stat.accepted} | ||
closed={stat.closed} | ||
denied={stat.denied} | ||
/> | ||
</CarouselItem> | ||
))} | ||
<CarouselItem className="md:basis-1/3 lg:basis-[10%]"> | ||
<div | ||
onClick={handleOpenModal} | ||
className="flex items-center justify-center rounded-md border border-secondary/60 bg-secondary/30 p-4 opacity-60 hover:opacity-100" | ||
> | ||
<MaterialSymbolsMoreHoriz className="text-4xl text-muted-foreground" /> | ||
</div> | ||
</CarouselItem> | ||
</CarouselContent> | ||
</Carousel> | ||
); | ||
} | ||
|
||
export default Component; |
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
69 changes: 69 additions & 0 deletions
69
components/modals/edit-top-stats-modal/components/ui/edit-top-item.tsx
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,69 @@ | ||
import * as React from 'react'; | ||
import MaterialSymbolsKidStar from '~icons/material-symbols/kid-star'; | ||
|
||
import Link from 'next/link'; | ||
|
||
import Small from '@/components/typography/small'; | ||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; | ||
import { Label } from '@/components/ui/label'; | ||
import { cn } from '@/utils'; | ||
|
||
interface Props { | ||
user: API.User; | ||
rank: number; | ||
accepted: number; | ||
closed: number; | ||
denied: number; | ||
} | ||
|
||
const Component = ({ user, rank, accepted, denied, closed }: Props) => { | ||
return ( | ||
<div | ||
className={cn( | ||
'relative flex min-w-0 flex-1 items-center gap-4 rounded-md p-4', | ||
)} | ||
> | ||
<Label className="text-muted-foreground">{rank}</Label> | ||
<Link href={`/u/${user.username}`}> | ||
<Avatar className="size-12 rounded-md"> | ||
<AvatarImage src={user.avatar} /> | ||
<AvatarFallback className="size-12 rounded-md" /> | ||
</Avatar> | ||
</Link> | ||
<div className="flex min-w-0 flex-1 flex-col gap-1"> | ||
<Link className="truncate font-bold" href={`/u/${user.username}`}> | ||
{user.username} | ||
</Link> | ||
|
||
<div className="flex gap-3"> | ||
<div className="flex items-center gap-2 text-muted-foreground"> | ||
<div className="flex size-2 items-center justify-center rounded-full bg-success" /> | ||
<Small>{accepted}</Small> | ||
</div> | ||
<div className="flex items-center gap-2 text-muted-foreground"> | ||
<div className="flex size-2 items-center justify-center rounded-full bg-destructive" /> | ||
<Small>{denied}</Small> | ||
</div> | ||
<div className="flex items-center gap-2 text-muted-foreground"> | ||
<div className="flex size-2 items-center justify-center rounded-full bg-warning" /> | ||
<Small>{closed}</Small> | ||
</div> | ||
</div> | ||
</div> | ||
{rank <= 3 && ( | ||
<MaterialSymbolsKidStar | ||
className={cn( | ||
'text-lg', | ||
rank === 1 | ||
? 'text-yellow-300' | ||
: rank === 2 | ||
? 'text-slate-300' | ||
: 'text-amber-700', | ||
)} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Component; |
56 changes: 56 additions & 0 deletions
56
components/modals/edit-top-stats-modal/edit-top-stats-modal.tsx
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,56 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
import useEditTop from '@/services/hooks/stats/edit/useEditTop'; | ||
|
||
import EditTopItem from './components/ui/edit-top-item'; | ||
|
||
|
||
const Component = () => { | ||
const { list, fetchNextPage, isFetchingNextPage, hasNextPage, ref } = | ||
useEditTop(); | ||
|
||
if (!list) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<hr className="-mx-6 mt-4 h-px w-auto bg-border" /> | ||
<div className="-mx-6 h-full w-auto flex-1 overflow-y-scroll"> | ||
{list.map((stat, index) => { | ||
return ( | ||
<EditTopItem | ||
key={stat.user.reference} | ||
user={stat.user} | ||
rank={index + 1} | ||
accepted={stat.accepted} | ||
closed={stat.closed} | ||
denied={stat.denied} | ||
/> | ||
); | ||
})} | ||
{hasNextPage && ( | ||
<div className="px-4"> | ||
<Button | ||
variant="secondary" | ||
ref={ref} | ||
disabled={isFetchingNextPage} | ||
onClick={() => hasNextPage && fetchNextPage()} | ||
className="w-full" | ||
> | ||
{isFetchingNextPage && ( | ||
<span className="loading loading-spinner"></span> | ||
)} | ||
Завантажити ще | ||
</Button> | ||
</div> | ||
)} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Component; |
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
Oops, something went wrong.