This repository has been archived by the owner on Apr 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4619a15
commit 691d82d
Showing
42 changed files
with
545 additions
and
401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { CSSProperties } from 'react' | ||
import { graphql, useStaticQuery } from 'gatsby' | ||
import Img from 'gatsby-image' | ||
|
||
import styled from '@emotion/styled' | ||
|
||
const StyledImageProvider = styled.div` | ||
height: 100%; | ||
width: 100%; | ||
` | ||
|
||
interface ImageProviderProps { | ||
fileName: string | ||
alt: string | ||
wrapperStyles?: CSSProperties | ||
imageStyles?: CSSProperties | ||
isNotRelativeToGatsbyImgWrapper?: boolean | ||
IsAPricingBoxIcon?: boolean | ||
} | ||
|
||
const ImageProvider = ({ fileName, alt, wrapperStyles, imageStyles, isNotRelativeToGatsbyImgWrapper, IsAPricingBoxIcon }: ImageProviderProps) => { | ||
const { allImageSharp } = useStaticQuery(graphql` | ||
query { | ||
allImageSharp { | ||
nodes { | ||
fluid(traceSVG: { color: "#0b2144" }) { | ||
originalName | ||
tracedSVG | ||
src | ||
} | ||
} | ||
} | ||
} | ||
`) | ||
|
||
const fluid = allImageSharp.nodes.find((n: any) => n.fluid.originalName === fileName) | ||
.fluid | ||
|
||
const imageStylesIfIsNotRelativeToGatsbyImgWrapper = { | ||
top: '50%', | ||
transform: 'translateY(-50%) scale(.93)', | ||
}; | ||
|
||
let position; | ||
|
||
if (isNotRelativeToGatsbyImgWrapper) { | ||
position = 'none' | ||
} else if (IsAPricingBoxIcon) { | ||
position = 'static' | ||
} else { | ||
position = 'relative' | ||
} | ||
|
||
return ( | ||
<StyledImageProvider> | ||
<Img className="gatsby-image" fluid={fluid} alt={alt} style={{position, ...wrapperStyles}} imgStyle={isNotRelativeToGatsbyImgWrapper ? imageStylesIfIsNotRelativeToGatsbyImgWrapper : imageStyles ? imageStyles : {}} /> | ||
</StyledImageProvider> | ||
) | ||
} | ||
|
||
export default ImageProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.