mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 05:38:26 -04:00
22 lines
638 B
TypeScript
22 lines
638 B
TypeScript
import { useEffect, useRef } from "react";
|
|
import classNames from "classnames";
|
|
|
|
import styles from "./Wallpaper.module.css";
|
|
|
|
export type WallpaperProps = JSX.IntrinsicElements["main"] & {
|
|
image: string;
|
|
tile?: boolean;
|
|
};
|
|
|
|
const Wallpaper = ({ image, tile, className, ...rest }: WallpaperProps) => {
|
|
const bgRef = useRef<HTMLDivElement>(null);
|
|
|
|
useEffect(() => {
|
|
bgRef.current.style.backgroundImage = `url(${image})`;
|
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
return <main ref={bgRef} className={classNames(styles.wallpaper, tile && styles.tile, className)} {...rest} />;
|
|
};
|
|
|
|
export default Wallpaper;
|