Skip to content

Commit 873a8bd

Browse files
committed
feat: improvements
1 parent e623653 commit 873a8bd

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@mdx-js/react": "^2.1.5",
2323
"@next/mdx": "^13.0.4",
2424
"@plaiceholder/next": "^2.5.0",
25+
"@radix-ui/react-slot": "^1.2.3",
2526
"@radix-ui/react-tooltip": "^1.2.7",
2627
"@tailwindcss/postcss": "^4.1.8",
2728
"@types/lodash": "^4.17.17",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Footer/Footer.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { nanoid } from 'nanoid'
22
import Link from 'next/link'
33
import { useMemo } from 'react'
44
import { ThemeSwitcher } from '../theme-switcher/theme-switcher'
5+
import { Text } from '../ui/text'
56

67
type Link = {
78
href: string
@@ -69,7 +70,12 @@ export const Footer = ({
6970
: undefined
7071
}
7172
>
72-
{link.name}
73+
<Text
74+
variant="hover-decoration"
75+
className="text-gray-900 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors duration-200"
76+
>
77+
{link.name}
78+
</Text>
7379
</Link>
7480
{index < allLinks.length - 1 && (
7581
<span className="ml-4 text-gray-400 dark:text-gray-600">

src/components/ui/text.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use client'
2+
3+
import { motion, type MotionProps } from 'motion/react'
4+
import * as Slot from '@radix-ui/react-slot'
5+
import { cn } from '@/lib/utils'
6+
7+
type Variant = {
8+
variant: string
9+
component: React.FC<React.ComponentProps<'span'> & Partial<MotionProps>>
10+
}
11+
12+
const variants = [
13+
{
14+
variant: 'hover-decoration',
15+
component: ({ children, className, ...props }) => (
16+
<div
17+
className={cn(
18+
'relative after:absolute after:bottom-0 after:left-0 after:h-px after:w-full after:origin-bottom-right',
19+
'after:scale-x-0 after:bg-current after:transition-transform after:duration-300 after:ease-in-out hover:after:origin-bottom-left hover:after:scale-x-100',
20+
)}
21+
>
22+
<span {...props} className={cn(className)}>
23+
{children}
24+
</span>
25+
</div>
26+
),
27+
},
28+
] as const satisfies readonly Variant[]
29+
30+
export type TextProps = {
31+
variant?: typeof variants[number]['variant']
32+
} & React.ComponentProps<'span'> &
33+
Partial<MotionProps>
34+
35+
export function Text({
36+
variant = 'hover-decoration',
37+
className,
38+
...props
39+
}: TextProps) {
40+
const FALLBACK_INDEX = 0
41+
42+
const variantComponent = variants.find(
43+
(v) => v.variant === variant,
44+
)?.component
45+
46+
const Component = variantComponent || variants[FALLBACK_INDEX].component
47+
48+
return (
49+
<Slot.Root className={cn('font-medium text-sm')}>
50+
<Component {...props} className={className} />
51+
</Slot.Root>
52+
)
53+
}

src/pages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ pensamentos (tanto em inglês quanto em português).`
143143
onMouseLeave={handleMouseLeave}
144144
>
145145
<div
146-
className={`absolute -inset-1 bg-gradient-to-r from-blue-600 via-purple-600 to-pink-600 rounded-full blur-sm transition-all duration-500 ${
146+
className={`absolute -inset-1 bg-gradient-to-r from-blue-600 via-blue-500 to-blue-400 rounded-full blur-sm transition-all duration-500 ${
147147
showAnimation ? 'opacity-75 animate-spin' : 'opacity-0'
148148
}`}
149149
></div>
150150
<div
151-
className={`absolute -inset-0.5 bg-gradient-to-r from-blue-500 via-purple-500 to-pink-500 rounded-full transition-all duration-500 ${
151+
className={`absolute -inset-0.5 bg-gradient-to-r from-blue-500 via-blue-400 to-blue-300 rounded-full transition-all duration-500 ${
152152
showAnimation ? 'opacity-100 animate-spin' : 'opacity-0'
153153
}`}
154154
></div>

0 commit comments

Comments
 (0)