Add src/components/cardStack/CardStackContext.tsx

This commit is contained in:
2026-03-11 20:16:29 +00:00
parent 080e9b0ae5
commit 6bc9bd2fd7

View File

@@ -0,0 +1,31 @@
import { createContext, useContext, ReactNode } from 'react';
export interface CardStackContextType {
isVisible: boolean;
getAnimationProps: () => { isVisible: boolean };
itemRefs?: Record<string, HTMLElement | null>;
}
const CardStackContext = createContext<CardStackContextType | undefined>(undefined);
export function useCardStack() {
const context = useContext(CardStackContext);
if (!context) {
return {
isVisible: false,
getAnimationProps: () => ({ isVisible: false }),
itemRefs: {}
};
}
return context;
}
export function CardStackProvider({ children, value }: { children: ReactNode; value: CardStackContextType }) {
return (
<CardStackContext.Provider value={value}>
{children}
</CardStackContext.Provider>
);
}
export default CardStackContext;