-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40c262b
commit a724893
Showing
14 changed files
with
167 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const backgroundFadeIn = { | ||
to: { | ||
opacity: 1, | ||
}, | ||
config: { | ||
duration: 1500, | ||
}, | ||
}; | ||
|
||
export const backgroundFadeOut = { | ||
to: { | ||
opacity: 0, | ||
}, | ||
config: { | ||
duration: 1500, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@import "src/styles"; | ||
|
||
.background { | ||
z-index: -1; | ||
position: absolute; | ||
opacity: 0; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
|
||
main, div { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
main { | ||
z-index: 0; | ||
background: linear-gradient(0deg, rgba(0, 2, 15, 0.40) 0%, rgba(0, 2, 15, 0.40) 100%), radial-gradient(169.2% 55.43% at 63.35% 53.43%, rgba(50, 57, 96, 0.25) 9.89%, rgba(52, 60, 103, 0.75) 100%); | ||
backdrop-filter: blur(125px); | ||
} | ||
|
||
div { | ||
z-index: -1; | ||
background-position: center; | ||
background-size: cover; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { type BackgroundProps, ZaboState } from "@/types"; | ||
import { animated, useSpring } from "@react-spring/web"; | ||
import { useEffect } from "react"; | ||
import { backgroundFadeIn, backgroundFadeOut } from "./Background.animation"; | ||
import style from "./Background.module.scss"; | ||
|
||
export const Background = (backgroundProps: BackgroundProps) => { | ||
const { imageUrl, state } = backgroundProps; | ||
|
||
const [springs, api] = useSpring(() => ({ | ||
from: { | ||
opacity: 0, | ||
}, | ||
})); | ||
|
||
useEffect(() => { | ||
if (state === ZaboState.CURRENT_STATE) { | ||
api.start(backgroundFadeIn); | ||
} else if (state === ZaboState.SHOWN_STATE) { | ||
api.start(backgroundFadeOut); | ||
} | ||
}); | ||
|
||
return ( | ||
<animated.div className={style.background} style={{ ...springs }}> | ||
<main /> | ||
<div style={{ backgroundImage: `url(${imageUrl})` }} /> | ||
</animated.div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Background"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./useInterval"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useEffect, useRef } from "react"; | ||
|
||
export const useInterval = (callback: () => void, delay?: number | null) => { | ||
const savedCallback = useRef<() => void>(() => {}); | ||
|
||
useEffect(() => { | ||
savedCallback.current = callback; | ||
}); | ||
|
||
useEffect(() => { | ||
if (delay !== null) { | ||
const interval = setInterval(() => savedCallback.current(), delay || 0); | ||
return () => clearInterval(interval); | ||
} | ||
|
||
return undefined; | ||
}, [delay]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { ZaboState } from "./ZaboState"; | ||
|
||
export type BackgroundProps = { | ||
imageUrl: string; | ||
state: ZaboState; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters