Skip to content

Instantly share code, notes, and snippets.

@trickydisco78
Created December 7, 2018 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trickydisco78/4283d721ec4f3b18607c74d75376a79d to your computer and use it in GitHub Desktop.
Save trickydisco78/4283d721ec4f3b18607c74d75376a79d to your computer and use it in GitHub Desktop.
import * as React from 'react'
import Img from 'gatsby-image'
import { renameProp, renameKeys } from '../../utils/renameprop'
import HeroText from './heroText'
import './hero.css'
interface IHeroProps {
heroImg?: object
}
const Hero: React.SFC<IHeroProps> = ({
heroImg,
heroText,
addText,
heroTextPos,
heroLink
}) => {
const webPsrc = renameKeys(heroImg.webp, {
srcSet: 'srcSetWebp',
src: 'srcWebP'
})
const heroFluid = { ...heroImg.png, ...webPsrc }
return (
<section>
{addText ? <a href="#" className="hero-link"> : null}
<div className={`hero ${addText ? '${heroTextPos}' : null}`}>
<Img
fluid={heroFluid}
style={{
position: 'absolute',
width: '100%',
height: '100%',
left: 0
}}
/>
{addText ? (
<HeroText heroText={heroText} />
) : null}
{addText ? </a> : null}
</div>
</section>
)
}
export default Hero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment