Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions multimodal/websites/docs/src/components/CursorContext.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions multimodal/websites/docs/src/components/CustomCursor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import clsx from 'clsx';
import { useCursor } from './CursorContext';


interface CustomCursorProps {
className?: string;
Expand All @@ -13,8 +13,8 @@ const CustomCursor: React.FC<CustomCursorProps> = ({ className }) => {
const [isFullscreen, setIsFullscreen] = useState(false);
const cursorRef = useRef<HTMLDivElement>(null);

// 使用上下文中的状态而不是本地状态
const { isHovered } = useCursor();
// Use local state to manage hover effect
const [isHovered, setIsHovered] = useState(false);

useEffect(() => {
const handleMouseMove = (e: MouseEvent) => {
Expand Down
26 changes: 5 additions & 21 deletions multimodal/websites/docs/src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { useNavigate } from '@rspress/core/runtime';
import { motion, HTMLMotionProps } from 'framer-motion';
import { useCursor } from './CursorContext';


export interface LinkProps extends Omit<HTMLMotionProps<'a'>, 'href'> {
/**
Expand All @@ -25,11 +25,7 @@ export interface LinkProps extends Omit<HTMLMotionProps<'a'>, 'href'> {
*/
children: React.ReactNode;

/**
* Whether to apply cursor hover effect
* @default true
*/
applyCursorEffect?: boolean;

}

/**
Expand Down Expand Up @@ -61,28 +57,17 @@ export const Link: React.FC<LinkProps> = ({
className = '',
onClick,
children,
applyCursorEffect = true,

...rest
}) => {
const navigate = useNavigate();
const { setIsHovered } = useCursor();


// Check if the link is external
const isExternalLink =
href?.startsWith('http') || href?.startsWith('//') || href?.startsWith('#');

// Handle cursor hover effect
const handleMouseEnter = () => {
if (applyCursorEffect) {
setIsHovered(true);
}
};

const handleMouseLeave = () => {
if (applyCursorEffect) {
setIsHovered(false);
}
};

// Handle click event
const handleClick = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
Expand All @@ -108,8 +93,7 @@ export const Link: React.FC<LinkProps> = ({
href={href}
className={className}
onClick={handleClick}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}

// If external link, add relevant attributes
{...(isExternalLink ? { target: rest.target || '_blank', rel: 'noopener noreferrer' } : {})}
{...rest}
Expand Down
2 changes: 1 addition & 1 deletion multimodal/websites/docs/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export * from './NotFoundLayout';
export * from './UnderConstructionLayout';
export * from './SocialCallout';
export * from './Link';
export * from './CursorContext';

export * from './Banner';
export * from './Replay';
export * from './hooks';
16 changes: 5 additions & 11 deletions multimodal/websites/docs/src/pages/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FaGithub, FaCopy, FaCheck } from 'react-icons/fa';
import CustomCursor from '@components/CustomCursor';
import { Link } from '@components/Link';
import { VideoPanel } from '@components/VideoPanel';
import { CursorProvider, useCursor } from '@components/CursorContext';

import { usePageMeta, generatePageTitle, optimizeDescription } from '@components/hooks';
import './index.css';

Expand Down Expand Up @@ -36,7 +36,7 @@ const HomePageContent = () => {
const [cursorVisible, setCursorVisible] = useState(true);
const [currentSlide, setCurrentSlide] = useState(0);
const [copied, setCopied] = useState(false);
const { setIsHovered } = useCursor();


const auroraRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -289,8 +289,7 @@ const HomePageContent = () => {
className="text-white hover:text-primary transition-colors duration-300"
target="_blank"
rel="noopener noreferrer"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}

>
<FaGithub className="w-8 h-8 hover:text-[var(--accent)] transition-all duration-300" />
</Link>
Expand Down Expand Up @@ -440,8 +439,7 @@ const HomePageContent = () => {
className="absolute right-0 top-1/2 transform -translate-y-1/2 text-accent hover:text-white p-2 rounded-full bg-black/30 transition-all duration-300"
onClick={copyCommand}
title="Copy Command"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}

>
{copied ? <FaCheck className="text-[var(--accent)]" /> : <FaCopy />}
</button>
Expand Down Expand Up @@ -492,9 +490,5 @@ const HomePageContent = () => {
};

export const HomePage = () => {
return (
<CursorProvider>
<HomePageContent />
</CursorProvider>
);
return <HomePageContent />;
};
16 changes: 6 additions & 10 deletions multimodal/websites/docs/theme/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CursorProvider } from '@components/CursorContext';

import { Layout as BasicLayout } from '@rspress/core/theme';
import { NotFoundLayout } from '../src/components';
import { Showcase } from '../src/components/Showcase';
Expand All @@ -12,27 +12,23 @@ const Layout = () => {

if (location.pathname.startsWith(DYNAMIC_ROUTE.Showcase)) {
return (
<CursorProvider>
<>
<Nav />
<Showcase />
</CursorProvider>
</>
);
}

if (location.pathname.startsWith(DYNAMIC_ROUTE.Replay)) {
return (
<CursorProvider>
<>
<Nav />
<Replay />
</CursorProvider>
</>
);
}

return (
<CursorProvider>
<BasicLayout NotFoundLayout={NotFoundLayout} />
</CursorProvider>
);
return <BasicLayout NotFoundLayout={NotFoundLayout} />;
};

export { Layout };
Expand Down