Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn upgrade && yarn format-all #2779

Merged
merged 7 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Blog/Feed/Item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Item: React.FC<IBlogFeedItemProps> = ({
>
<Link href={slug} className={styles.pictureLink}>
{picture ? (
<Image fluid={image} className={styles.picture} />
image && <Image fluid={image} className={styles.picture} />
) : (
<Placeholder className={styles.picture} />
)}
julieg18 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
40 changes: 24 additions & 16 deletions src/components/Blog/Post/HeroPic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@ import Image from 'gatsby-image'
import React from 'react'

import { BLOG } from '../../../../consts'
import {
IBlogPostHeroPic,
IGatsbyImageProps
} from '../../../../templates/blog-post'
import { IFluidObject } from '../../../../templates/blog-post'

import styles from './styles.module.css'

const NonStretchedImage: React.FC<IGatsbyImageProps> = props => {
let normalizedProps = props
interface INonStretchedImageProps {
fluid: IFluidObject
style?: object
}

interface IHeroPicProps {
picture: {
fluid: IFluidObject
}
pictureComment?: string
}

const NonStretchedImage: React.FC<INonStretchedImageProps> = props => {
let style = {}
if (props.fluid && props.fluid.presentationWidth) {
const presetantionWidth = props.fluid?.presentationWidth
const presetantionWidth = props.fluid.presentationWidth
const width =
presetantionWidth < BLOG.imageMaxWidthHero
? presetantionWidth / 2
: presetantionWidth
normalizedProps = {
...props,
style: {
...(props.style || {}),
maxWidth: width,
margin: '0 auto'
}
style = {
...(props.style || {}),

maxWidth: width,
margin: '0 auto'
}
}
return <Image {...normalizedProps} />

return <Image style={style} {...props} />
}

const HeroPic: React.FC<IBlogPostHeroPic> = ({ pictureComment, picture }) => {
const HeroPic: React.FC<IHeroPicProps> = ({ pictureComment, picture }) => {
return (
<div className={styles.pictureWrapper}>
<div className={styles.picture}>
Expand Down
15 changes: 2 additions & 13 deletions src/templates/blog-post.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FixedObject, FluidObject, GatsbyImageProps } from 'gatsby-image'
import { FixedObject, FluidObject } from 'gatsby-image'

import { graphql } from 'gatsby'
import React from 'react'
Expand All @@ -8,22 +8,11 @@ import Post from '../components/Blog/Post'

import { ISocialIcon } from '../components/SocialIcon'

interface IFluidObject extends FluidObject {
export interface IFluidObject extends FluidObject {
presentationWidth: number
presentationHeight: number
}

export interface IGatsbyImageProps extends GatsbyImageProps {
fluid?: IFluidObject
}

export interface IBlogPostHeroPic {
picture?: {
fluid: IFluidObject
}
pictureComment?: string
}

export interface IBlogPostData {
id: string
html: string
Expand Down