Skip to content

Commit

Permalink
feat: add video backgrounds for the nova hero (#1453)
Browse files Browse the repository at this point in the history
* feat: add video backgrounds for the nova hero

* fix: add missing playsInline for iOS :)
  • Loading branch information
VmMad authored Apr 25, 2024
1 parent b4f0647 commit 90974c0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
13 changes: 11 additions & 2 deletions client/src/app/components/Hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@
pointer-events: none;
z-index: -1;

.bg-image {
video {
position: absolute;
top: 0;
left: 0;
width: auto;
max-width: 100%;
height: 100%;
max-width: 100%;
object-fit: cover;
opacity: 1;
transition: opacity 300ms;
}

video.bg--hidden {
opacity: 0;
}
}

Expand Down
17 changes: 13 additions & 4 deletions client/src/app/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ interface IHero {
}

export default function Hero({ network, subtitle, overline, networkStats, assetStats }: IHero): React.JSX.Element {
const theme = useGetThemeMode();

const backgroundImage = HERO_BACKGROUNDS[theme];
const activeTheme = useGetThemeMode();
return (
<div id="hero">
<div className="bg-container">
<img src={backgroundImage} className="bg-image" alt="background" />
{Object.entries(HERO_BACKGROUNDS).map(([theme, backgroundUrl]) => (
<video
key={backgroundUrl}
autoPlay
playsInline
loop
muted
className={activeTheme === theme ? "bg--active" : "bg--hidden"}
>
<source src={backgroundUrl} type="video/mp4" />
</video>
))}
</div>
<div className="wrapper">
<div className="inner">
Expand Down
9 changes: 5 additions & 4 deletions client/src/app/lib/constants/backgrounds.constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import HeroTestnetLight from "~/assets/background/hero-testnet-light.png";
import HeroTestnetDark from "~/assets/background/hero-testnet-dark.png";
import { ThemeMode } from "../enums";

const LIGHTMODE_BACKGROUND_URL = "https://files.iota.org/media/explorer_hero_nova_light.mp4";
const DARKMODE_BACKGROUND_URL = "https://files.iota.org/media/explorer_hero_nova_dark.mp4";

export const HERO_BACKGROUNDS: Record<ThemeMode, string> = {
[ThemeMode.Light]: HeroTestnetLight,
[ThemeMode.Dark]: HeroTestnetDark,
[ThemeMode.Light]: LIGHTMODE_BACKGROUND_URL,
[ThemeMode.Dark]: DARKMODE_BACKGROUND_URL,
};
Binary file removed client/src/assets/background/hero-testnet-dark.png
Binary file not shown.
Binary file removed client/src/assets/background/hero-testnet-light.png
Binary file not shown.

0 comments on commit 90974c0

Please sign in to comment.