Skip to content

Commit e59ea96

Browse files
authored
Add animated star border to search dialog (#10)
1 parent b19e8e7 commit e59ea96

File tree

5 files changed

+250
-136
lines changed

5 files changed

+250
-136
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ on:
44
pull_request:
55
branches:
66
- main
7+
paths-ignore:
8+
- '*.md'
79

810
jobs:
911
build:
1012
name: Build
1113
runs-on: ubuntu-latest
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
1217
steps:
1318
- uses: actions/checkout@v4
1419

@@ -29,3 +34,11 @@ jobs:
2934

3035
- name: Build
3136
run: pnpm build
37+
38+
- name: Setup flyctl
39+
uses: superfly/flyctl-actions/setup-flyctl@master
40+
41+
- name: Build Fly app
42+
run: flyctl deploy --build-only
43+
env:
44+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

components.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@
1818
"lib": "@/lib",
1919
"hooks": "@/hooks"
2020
},
21-
"registries": {}
21+
"registries": {
22+
"@react-bits": "https://reactbits.dev/r/{name}.json"
23+
}
2224
}

src/components/StarBorder.tsx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import type React from 'react';
2+
import { cn } from '@/lib/utils';
3+
4+
type StarBorderProps<T extends React.ElementType> =
5+
React.ComponentPropsWithoutRef<T> & {
6+
as?: T;
7+
className?: string;
8+
children?: React.ReactNode;
9+
color?: string;
10+
speed?: React.CSSProperties['animationDuration'];
11+
thickness?: number;
12+
isAnimating?: boolean;
13+
};
14+
15+
const StarBorder = <T extends React.ElementType = 'div'>({
16+
as,
17+
className = '',
18+
color = 'white',
19+
speed = '6s',
20+
thickness = 1,
21+
isAnimating = true,
22+
children,
23+
...rest
24+
}: StarBorderProps<T>) => {
25+
const Component = as || 'div';
26+
27+
return (
28+
<Component
29+
className={cn('relative inline-block overflow-hidden', className)}
30+
{...(rest as React.ComponentPropsWithoutRef<T>)}
31+
style={{
32+
padding: `${thickness}px`,
33+
...(rest as React.CSSProperties & { style?: React.CSSProperties })
34+
.style,
35+
}}
36+
>
37+
<div
38+
className={cn(
39+
'absolute w-[300%] h-[50%] bottom-[-11px] right-[-250%] rounded-full animate-star-movement-bottom z-0 transition-opacity duration-500',
40+
!isAnimating && 'opacity-0',
41+
)}
42+
style={{
43+
background: `radial-gradient(circle, ${color}, transparent 10%)`,
44+
animationDuration: speed,
45+
animationPlayState: isAnimating ? 'running' : 'paused',
46+
opacity: isAnimating ? 0.7 : 0,
47+
}}
48+
/>
49+
<div
50+
className={cn(
51+
'absolute w-[300%] h-[50%] top-[-10px] left-[-250%] rounded-full animate-star-movement-top z-0 transition-opacity duration-500',
52+
!isAnimating && 'opacity-0',
53+
)}
54+
style={{
55+
background: `radial-gradient(circle, ${color}, transparent 10%)`,
56+
animationDuration: speed,
57+
animationPlayState: isAnimating ? 'running' : 'paused',
58+
opacity: isAnimating ? 0.7 : 0,
59+
}}
60+
/>
61+
<div className="relative z-[1]">{children}</div>
62+
</Component>
63+
);
64+
};
65+
66+
export default StarBorder;

0 commit comments

Comments
 (0)