Add images and wow styles

This commit is contained in:
obergodmar
2020-06-23 01:53:34 +03:00
parent 00e142bf09
commit 98a307f2cc
24 changed files with 259 additions and 21 deletions
@@ -1,8 +1,37 @@
import * as React from 'react'
import { useEffect, useMemo, useState } from 'react'
import { Background } from '../../assets'
import './view-component.scss'
interface Props {
src: string
}
export const ViewComponent = ({src}: Props) => {
const [imageSrc, setImageSrc] = useState(Background)
const isImage = useMemo(() => imageSrc !== Background, [imageSrc])
useEffect(() => {
setTimeout(() => {
const image = new Image()
image.src = src
image.onload = () => {
setImageSrc(src)
}
}, 500)
}, [src])
export const ViewComponent = () => {
return (
<div/>
<div
className='view'
style={{
backgroundImage: `url(${imageSrc})`,
backgroundRepeat: `${isImage ? 'no-repeat' : 'repeat'}`,
backgroundSize: `${isImage ? 'cover' : '256px'}`
}}
/>
)
}