17 lines
391 B
TypeScript
17 lines
391 B
TypeScript
import { createContext, useContext } from "react";
|
|
|
|
const CardDepthContext = createContext(0);
|
|
|
|
export function useCardDepth() {
|
|
return useContext(CardDepthContext);
|
|
}
|
|
|
|
export function CardDepthProvider({ children }: { children: React.ReactNode }) {
|
|
const depth = useCardDepth();
|
|
return (
|
|
<CardDepthContext.Provider value={depth + 1}>
|
|
{children}
|
|
</CardDepthContext.Provider>
|
|
);
|
|
}
|