11import { createContext , useContext , useState } from 'react' ;
2- import FollowCursor from './Cursor' ;
2+ import FollowCursor from './FollowCursor' ;
3+ import SplashCursor from './SplashCursor' ;
4+
5+ export type CursorType = 'follow' | 'splash' ;
36
47export const CursorContext = createContext < {
5- cursorState : boolean ;
68 insets :
79 | {
810 height : number ;
@@ -12,7 +14,7 @@ export const CursorContext = createContext<{
1214 borderRadius ?: string ;
1315 }
1416 | undefined ;
15- toggle : ( ) => void ;
17+ setCursorType : ( type : CursorType ) => void ;
1618 setCursorInsets : (
1719 args :
1820 | {
@@ -25,10 +27,9 @@ export const CursorContext = createContext<{
2527 | undefined ,
2628 ) => void ;
2729} > ( {
28- cursorState : true ,
2930 insets : undefined ,
3031 // eslint-disable-next-line @typescript-eslint/no-empty-function
31- toggle : ( ) => { } ,
32+ setCursorType : ( type : CursorType ) => { } ,
3233 setCursorInsets : (
3334 args :
3435 | {
@@ -44,7 +45,7 @@ export const CursorContext = createContext<{
4445} ) ;
4546
4647const CursorProvider = ( { children } : { children : React . ReactNode } ) => {
47- const [ cursorState , setCursorState ] = useState ( true ) ;
48+ const [ cursorType , setCursorTypeState ] = useState < CursorType > ( 'follow' ) ;
4849 const [ insets , setCursorSize ] = useState <
4950 | {
5051 height : number ;
@@ -56,8 +57,8 @@ const CursorProvider = ({ children }: { children: React.ReactNode }) => {
5657 | undefined
5758 > ( undefined ) ;
5859
59- const toggle = ( ) => {
60- setCursorState ( ( prev ) => ! prev ) ;
60+ const setCursorType = ( type : CursorType ) => {
61+ setCursorTypeState ( type ) ;
6162 } ;
6263
6364 const setCursorInsets = (
@@ -75,9 +76,13 @@ const CursorProvider = ({ children }: { children: React.ReactNode }) => {
7576
7677 return (
7778 < CursorContext . Provider
78- value = { { cursorState, insets, toggle, setCursorInsets } }
79+ value = { {
80+ insets,
81+ setCursorType,
82+ setCursorInsets,
83+ } }
7984 >
80- < FollowCursor />
85+ { cursorType === 'splash' ? < SplashCursor /> : < FollowCursor /> }
8186 { children }
8287 </ CursorContext . Provider >
8388 ) ;
0 commit comments