1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-12-05 13:38:57 -05:00

separate out windows me wallpaper container

This commit is contained in:
2022-01-29 11:15:25 -05:00
parent 19809479dd
commit b4cfbafaf0
5 changed files with 51 additions and 30 deletions

View File

@@ -0,0 +1,14 @@
.wallpaper {
display: flex;
justify-content: center;
align-items: center;
padding: 1.5em 0;
width: 100%;
min-height: 400px;
box-sizing: content-box;
}
.tile {
background-repeat: repeat;
background-position: center;
}

View File

@@ -0,0 +1,25 @@
import { useEffect, useRef } from "react";
import classNames from "classnames/bind";
import type { ReactNode } from "react";
import styles from "./Wallpaper.module.css";
const cx = classNames.bind(styles);
type Props = {
image: string;
tile?: boolean;
className?: string;
children: ReactNode;
};
const Wallpaper = ({ image, tile, className, ...rest }: Props) => {
const bgRef = useRef<HTMLDivElement>(null);
useEffect(() => {
bgRef.current.style.backgroundImage = `url(${image})`;
}, []); // eslint-disable-line react-hooks/exhaustive-deps
return <div ref={bgRef} className={cx(styles.wallpaper, { tile: !!tile }, className)} {...rest} />;
};
export default Wallpaper;