Skip to content

Commit

Permalink
move create context for page bur
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Cohen committed Feb 29, 2024
1 parent 414aff5 commit af00948
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
17 changes: 10 additions & 7 deletions courseup/src/app/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
import { useState } from 'react';
import { Header } from 'components/common/header';
import classNames from 'classnames';
import BlurContext from 'components/common/BlurContext';

export default function Content({ children }: Readonly<{ children: React.ReactNode }>): React.ReactNode {
const [blurBackground, setBlurBackground] = useState(false);

return (
<>
<Header blurBackground={blurBackground} setBlurBackground={setBlurBackground} />
{blurBackground ? (
<div className={classNames('pointer-events-none transition-all', { 'blur-md': blurBackground })}>
{children}
</div>
) : (
<div>{children}</div>
)}
<BlurContext.Provider value={{ blurBackground: blurBackground, setBlurBackground: setBlurBackground }}>
{blurBackground ? (
<div className={classNames('pointer-events-none transition-all', { 'blur-md': blurBackground })}>
{children}
</div>
) : (
<div>{children}</div>
)}
</BlurContext.Provider>
</>
);
}
9 changes: 9 additions & 0 deletions courseup/src/components/common/BlurContext/BlurContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Context, createContext } from 'react';
import { Dispatch, SetStateAction } from 'react';

export const BlurContext: Context<Blur> = createContext<Blur>({ blurBackground: false, setBlurBackground: () => {} });

interface Blur {
blurBackground: Readonly<boolean>;
setBlurBackground: Dispatch<SetStateAction<boolean>>;
}
2 changes: 2 additions & 0 deletions courseup/src/components/common/BlurContext/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { BlurContext } from './BlurContext';
export default BlurContext;

0 comments on commit af00948

Please sign in to comment.