Skip to content

Commit ed5223c

Browse files
Merge pull request #19 from New1Direction/feat/magnetic-and-cleanup
feat(website): magnetic primary CTAs + de-emoji the docs nav
2 parents c42991b + 7a69243 commit ed5223c

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

website/app/layout.config.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
2+
import { Icon } from '@/components/site/Icon';
23

3-
/** Shared nav config consumed by both the home and docs layouts. */
4+
/** Shared nav config consumed by the docs layout. */
45
export const baseOptions: BaseLayoutProps = {
56
nav: {
67
title: (
7-
<span style={{ fontWeight: 700, letterSpacing: '-0.02em' }}>
8-
🔭 RepoLens
8+
<span
9+
style={{
10+
display: 'inline-flex',
11+
alignItems: 'center',
12+
gap: 7,
13+
fontWeight: 700,
14+
letterSpacing: '-0.02em',
15+
}}
16+
>
17+
<Icon name="lens" size={18} />
18+
RepoLens
919
</span>
1020
),
1121
},

website/components/home/SiteMotion.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,33 @@ export function SiteMotion() {
113113

114114
// Recompute trigger positions once the display font has settled.
115115
ScrollTrigger.refresh();
116+
117+
// 5) Magnetic primary CTAs — they pull toward the cursor. Pointer
118+
// devices only; quickTo runs off the React render cycle.
119+
const magnetCleanups: Array<() => void> = [];
120+
if (window.matchMedia('(pointer: fine)').matches) {
121+
gsap.utils.toArray<HTMLElement>('.btn-primary').forEach((btn) => {
122+
const xTo = gsap.quickTo(btn, 'x', { duration: 0.5, ease: 'power3' });
123+
const yTo = gsap.quickTo(btn, 'y', { duration: 0.5, ease: 'power3' });
124+
const onMove = (e: PointerEvent) => {
125+
const r = btn.getBoundingClientRect();
126+
xTo((e.clientX - (r.left + r.width / 2)) * 0.35);
127+
yTo((e.clientY - (r.top + r.height / 2)) * 0.5);
128+
};
129+
const onLeave = () => {
130+
xTo(0);
131+
yTo(0);
132+
};
133+
btn.addEventListener('pointermove', onMove);
134+
btn.addEventListener('pointerleave', onLeave);
135+
magnetCleanups.push(() => {
136+
btn.removeEventListener('pointermove', onMove);
137+
btn.removeEventListener('pointerleave', onLeave);
138+
});
139+
});
140+
}
141+
142+
return () => magnetCleanups.forEach((fn) => fn());
116143
});
117144

118145
cleanup = () => mm.revert();

0 commit comments

Comments
 (0)