Skip to content

Commit

Permalink
refactor(tooltip): replace Tooltip component with AnimatedTooltip
Browse files Browse the repository at this point in the history
Updated the Navbar, ClientProjects, and RepositoryCard components to utilize the new AnimatedTooltip component instead of the previous Tooltip implementation. This change enhances the user experience with smoother animations and improved tooltip functionality across the application.
  • Loading branch information
kWAYTV committed Dec 11, 2024
1 parent 432a60e commit 3c24d28
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 79 deletions.
54 changes: 26 additions & 28 deletions src/components/core/layout/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import { Link } from 'next-view-transitions';

import { AnimatedTooltip } from '@/components/motion/tooltip';
import { Button } from '@/components/ui/button';
import { ModeToggle } from '@/components/ui/mode-toggle';
import {
Tooltip,
TooltipContent,
TooltipTrigger
} from '@/components/ui/tooltip';
import { navItems } from '@/enums/nav';
import type { NavPath } from '@/types/nav';

Expand All @@ -27,30 +23,32 @@ export function Navbar() {
(typeof navItems)[NavPath]
][]
).map(([path, { name, icon: Icon, tooltip }]) => (
<Tooltip key={path}>
<TooltipTrigger asChild>
<Button
variant='linkHover2'
className='flex items-center gap-2 p-2'
asChild
<AnimatedTooltip
key={path}
content={{
description: tooltip
}}
>
<Button
variant='linkHover2'
className='flex items-center gap-2 p-2'
asChild
>
<Link
href={path}
aria-label={`Navigate to ${name}`}
{...(name.toLowerCase() === 'github'
? {
target: '_blank',
rel: 'noopener noreferrer'
}
: {})}
>
<Link
href={path}
aria-label={`Navigate to ${name}`}
{...(name.toLowerCase() === 'github'
? {
target: '_blank',
rel: 'noopener noreferrer'
}
: {})}
>
<Icon className='h-4 w-4' aria-hidden='true' />
<span className='capitalize'>{name}</span>
</Link>
</Button>
</TooltipTrigger>
<TooltipContent>{tooltip}</TooltipContent>
</Tooltip>
<Icon className='h-4 w-4' aria-hidden='true' />
<span className='capitalize'>{name}</span>
</Link>
</Button>
</AnimatedTooltip>
))}
<ModeToggle />
</div>
Expand Down
50 changes: 19 additions & 31 deletions src/components/core/projects/client-projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import { ChevronLeft, ChevronRight } from 'lucide-react';
import { RepositoryCard } from '@/components/core/projects/repository-card';
import { RepositoryCardSkeleton } from '@/components/core/projects/repository-card-skeleton';
import { SearchInput } from '@/components/core/projects/search-input';
import { AnimatedTooltip } from '@/components/motion/tooltip';
import { Button } from '@/components/ui/button';
import { Separator } from '@/components/ui/separator';
import {
Tooltip,
TooltipContent,
TooltipTrigger
} from '@/components/ui/tooltip';
import { useGithubRepos } from '@/hooks/use-github-repos';

export function ClientProjects() {
Expand Down Expand Up @@ -65,37 +61,29 @@ export function ClientProjects() {
<>
<Separator className='my-2' />
<div className='flex items-center justify-between'>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant='ghost'
onClick={() => setCurrentPage(p => Math.max(1, p - 1))}
disabled={currentPage === 1}
>
<ChevronLeft className='h-4 w-4' />
</Button>
</TooltipTrigger>
<TooltipContent>Previous page</TooltipContent>
</Tooltip>
<AnimatedTooltip content={{ description: 'Previous page' }}>
<Button
variant='ghost'
onClick={() => setCurrentPage(p => Math.max(1, p - 1))}
disabled={currentPage === 1}
>
<ChevronLeft className='h-4 w-4' />
</Button>
</AnimatedTooltip>

<span className='text-sm text-muted-foreground'>
Page {currentPage} of {totalPages}
</span>

<Tooltip>
<TooltipTrigger asChild>
<Button
variant='ghost'
onClick={() =>
setCurrentPage(p => Math.min(totalPages, p + 1))
}
disabled={currentPage === totalPages}
>
<ChevronRight className='h-4 w-4' />
</Button>
</TooltipTrigger>
<TooltipContent>Next page</TooltipContent>
</Tooltip>
<AnimatedTooltip content={{ description: 'Next page' }}>
<Button
variant='ghost'
onClick={() => setCurrentPage(p => Math.min(totalPages, p + 1))}
disabled={currentPage === totalPages}
>
<ChevronRight className='h-4 w-4' />
</Button>
</AnimatedTooltip>
</div>
</>
)}
Expand Down
28 changes: 8 additions & 20 deletions src/components/core/projects/repository-card.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { GitFork, LockIcon, Star } from 'lucide-react';

import { AnimatedTooltip } from '@/components/motion/tooltip';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
Tooltip,
TooltipContent,
TooltipTrigger
} from '@/components/ui/tooltip';
import type { Repository } from '@/interfaces/github';

interface RepositoryCardProps {
Expand All @@ -33,12 +29,9 @@ export function RepositoryCard({ repository }: RepositoryCardProps) {
</a>
</Button>
{repository.private && (
<Tooltip>
<TooltipTrigger>
<LockIcon className='h-4 w-4 text-neutral-500' />
</TooltipTrigger>
<TooltipContent>Private repository</TooltipContent>
</Tooltip>
<AnimatedTooltip content={{ description: 'Private repository' }}>
<LockIcon className='h-4 w-4 text-neutral-500' />
</AnimatedTooltip>
)}
</div>
<div className='flex items-center gap-4 text-sm text-neutral-600 dark:text-neutral-400'>
Expand All @@ -61,16 +54,11 @@ export function RepositoryCard({ repository }: RepositoryCardProps) {
{repository.language || 'Unknown'}
</Badge>
{repository.description && (
<Tooltip>
<TooltipTrigger asChild>
<span className='line-clamp-1 cursor-default text-neutral-600 dark:text-neutral-400'>
{repository.description}
</span>
</TooltipTrigger>
<TooltipContent side='bottom' className='max-w-[300px]'>
<AnimatedTooltip content={{ description: repository.description }}>
<span className='line-clamp-1 cursor-default text-neutral-600 dark:text-neutral-400'>
{repository.description}
</TooltipContent>
</Tooltip>
</span>
</AnimatedTooltip>
)}
</div>
</div>
Expand Down

0 comments on commit 3c24d28

Please sign in to comment.