1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-15 09:35:21 +01:00

merge Image & PostImage

This commit is contained in:
Matthias Kretschmann 2019-11-08 18:06:56 +01:00
parent ae93accd08
commit 8a7556325a
Signed by: m
GPG Key ID: 606EEEF3C479A91F
18 changed files with 91 additions and 118 deletions

View File

@ -2,7 +2,7 @@
@import 'mixins'; @import 'mixins';
.exif { .exif {
margin-top: -($spacer); margin-top: -($spacer * $line-height);
margin-bottom: $spacer * 2; margin-bottom: $spacer * 2;
} }

View File

@ -1,20 +1,54 @@
@import 'variables';
@import 'mixins'; @import 'mixins';
.imageWrap { .imageTitle {
@include transition();
font-size: $font-size-h3;
font-family: $font-family-headings;
line-height: $line-height-headings;
font-weight: $font-weight-headings;
font-style: normal;
text-align: left;
margin: 0;
position: absolute;
top: 10%;
padding: $spacer / 3 $spacer;
background: rgba($link-color, 0.85);
color: #fff !important;
text-shadow: 0 1px 0 #000;
left: 0;
opacity: 0;
transform: translate3d(0, -20px, 0);
}
.image {
@include media-frame; @include media-frame;
@include breakoutviewport;
margin-left: auto; max-width: none;
margin-right: auto; margin: $spacer * $line-height auto;
margin-bottom: $spacer;
display: block; display: block;
@media (min-width: 940px) {
max-width: 940px;
border-radius: $border-radius; border-radius: $border-radius;
overflow: hidden;
a & {
position: relative;
display: block;
} }
a:hover & { // single photo post teasers
&:only-child {
margin-top: 0;
margin-bottom: 0;
}
a:hover &,
a:focus & {
border-color: $link-color !important; border-color: $link-color !important;
.imageTitle {
opacity: 1;
transform: translate3d(0, 0, 0);
}
} }
} }

View File

@ -1,17 +1,14 @@
import React from 'react' import React from 'react'
import { graphql } from 'gatsby' import { graphql } from 'gatsby'
import Img from 'gatsby-image' import Img from 'gatsby-image'
import styles from './Image.module.scss'
import { ImageProps } from '../../@types/Image' import { ImageProps } from '../../@types/Image'
import styles from './Image.module.scss'
export const Image = ({ fluid, fixed, alt }: ImageProps) => ( export const Image = ({ title, fluid, fixed, alt, original }: ImageProps) => (
<Img <figure className={styles.image} data-original={original && original.src}>
className={styles.imageWrap} <Img backgroundColor="transparent" fluid={fluid} fixed={fixed} alt={alt} />
backgroundColor="transparent" {title && <figcaption className={styles.imageTitle}>{title}</figcaption>}
fluid={fluid} </figure>
fixed={fixed}
alt={alt}
/>
) )
export const imageSizeDefault = graphql` export const imageSizeDefault = graphql`

View File

@ -47,6 +47,10 @@
} }
} }
figure {
margin: 0;
}
:global(.gatsby-image-wrapper) { :global(.gatsby-image-wrapper) {
margin-bottom: 0; margin-bottom: 0;
} }

View File

@ -35,6 +35,10 @@
} }
} }
figure {
margin: 0;
}
img { img {
margin-bottom: 0; margin-bottom: 0;
} }

View File

@ -21,6 +21,8 @@
} }
figure { figure {
margin: 0;
> div { > div {
margin: 0; margin: 0;
} }

View File

@ -1,9 +1,9 @@
import React from 'react' import React from 'react'
import { graphql, Link } from 'gatsby' import { graphql, Link } from 'gatsby'
import Page from '../templates/Page' import Page from '../templates/Page'
import PostImage from '../templates/Post/PostImage'
import styles from './photos.module.scss'
import { Post } from '../@types/Post' import { Post } from '../@types/Post'
import { Image } from '../components/atoms/Image'
import styles from './photos.module.scss'
const page = { const page = {
frontmatter: { frontmatter: {
@ -21,7 +21,7 @@ const PhotoThumb = ({ photo }: { photo: Post }) => {
<article className={styles.photo}> <article className={styles.photo}>
{image && ( {image && (
<Link to={slug}> <Link to={slug}>
<PostImage title={title} fluid={fluid} alt={title} /> <Image title={title} fluid={fluid} alt={title} />
</Link> </Link>
)} )}
</article> </article>

View File

@ -31,6 +31,8 @@ kbd {
} }
pre { pre {
@include breakoutviewport;
position: relative; position: relative;
display: block; display: block;
padding: 0; padding: 0;
@ -45,11 +47,6 @@ pre {
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
max-height: 800px; max-height: 800px;
@media (min-width: $screen-sm) {
margin-left: -($spacer);
margin-right: -($spacer);
}
code { code {
padding: $spacer / 2; padding: $spacer / 2;
white-space: pre; white-space: pre;

View File

@ -77,7 +77,7 @@ $color-headings--dark: $brand-main-light;
// Spacing // Spacing
///////////////////////////////////// /////////////////////////////////////
$spacer: ($font-size-base * $line-height); $spacer: 1.7rem;
$padding-base-vertical: 0.75rem; $padding-base-vertical: 0.75rem;
$padding-base-horizontal: 1.25rem; $padding-base-horizontal: 1.25rem;

View File

@ -1,9 +1,9 @@
import React from 'react' import React from 'react'
import { Helmet } from 'react-helmet' import { Helmet } from 'react-helmet'
import { Post } from '../@types/Post'
import SEO from '../components/atoms/SEO' import SEO from '../components/atoms/SEO'
import Layout from '../components/Layout' import Layout from '../components/Layout'
import styles from './Page.module.scss' import styles from './Page.module.scss'
import { Post } from '../@types/Post'
export default function Page({ export default function Page({
title, title,

View File

@ -1,38 +0,0 @@
@import 'variables';
@import 'mixins';
.imageTitle {
transition: 0.1s ease-out;
font-size: $font-size-h3;
font-family: $font-family-headings;
line-height: $line-height-headings;
font-weight: $font-weight-headings;
font-style: normal;
text-align: left;
margin: 0;
position: absolute;
top: 10%;
padding: $spacer / 3 $spacer;
background: rgba($link-color, 0.85);
color: #fff !important;
text-shadow: 0 1px 0 #000;
left: 0;
opacity: 0;
transform: translate3d(0, -20px, 0);
}
.image {
display: block;
a & {
position: relative;
display: block;
}
a:hover & {
.imageTitle {
opacity: 1;
transform: translate3d(0, 0, 0);
}
}
}

View File

@ -1,13 +0,0 @@
import React from 'react'
import { Image } from '../../components/atoms/Image'
import styles from './PostImage.module.scss'
import { ImageProps } from '../../@types/Image'
const PostImage = ({ title, fluid, fixed, alt, original }: ImageProps) => (
<figure className={styles.image} data-original={original && original.src}>
<Image fluid={fluid} fixed={fixed} alt={alt} />
{title && <figcaption className={styles.imageTitle}>{title}</figcaption>}
</figure>
)
export default PostImage

View File

@ -2,9 +2,10 @@
.lead { .lead {
font-size: $font-size-large; font-size: $font-size-large;
margin-bottom: $spacer; margin-bottom: $spacer * $line-height;
} }
.index { .index {
font-size: $font-size-base; font-size: $font-size-base;
margin-top: $spacer * $line-height;
} }

View File

@ -2,8 +2,8 @@ import React from 'react'
import { Link } from 'gatsby' import { Link } from 'gatsby'
import { ReactComponent as Forward } from '../../images/forward.svg' import { ReactComponent as Forward } from '../../images/forward.svg'
import { ReactComponent as Infinity } from '../../images/infinity.svg' import { ReactComponent as Infinity } from '../../images/infinity.svg'
import styles from './PostLinkActions.module.scss'
import stylesPostMore from './PostMore.module.scss' import stylesPostMore from './PostMore.module.scss'
import styles from './PostLinkActions.module.scss'
const PostLinkActions = ({ const PostLinkActions = ({
linkurl, linkurl,

View File

@ -8,7 +8,7 @@
font-size: $font-size-h1; font-size: $font-size-h1;
color: $color-headings; color: $color-headings;
margin-top: 0; margin-top: 0;
margin-bottom: $spacer; margin-bottom: $spacer * $line-height;
:global(.dark) & { :global(.dark) & {
color: $color-headings--dark; color: $color-headings--dark;

View File

@ -54,13 +54,3 @@
} }
} }
} }
.imageWrap {
@include breakoutviewport();
figure {
max-width: none;
margin-top: $spacer * 1.5;
margin-bottom: 0;
}
}

View File

@ -1,19 +1,19 @@
import React from 'react' import React from 'react'
import { Helmet } from 'react-helmet' import { Helmet } from 'react-helmet'
import { graphql } from 'gatsby' import { graphql } from 'gatsby'
import { Post as PostMetadata } from '../../@types/Post'
import Layout from '../../components/Layout' import Layout from '../../components/Layout'
import PostImage from './PostImage' import Exif from '../../components/atoms/Exif'
import SEO from '../../components/atoms/SEO'
import RelatedPosts from '../../components/molecules/RelatedPosts'
import PostTitle from './PostTitle' import PostTitle from './PostTitle'
import PostLead from './PostLead' import PostLead from './PostLead'
import PostContent from './PostContent' import PostContent from './PostContent'
import PostActions from './PostActions' import PostActions from './PostActions'
import PostLinkActions from './PostLinkActions' import PostLinkActions from './PostLinkActions'
import SEO from '../../components/atoms/SEO'
import PostMeta from './PostMeta' import PostMeta from './PostMeta'
import Exif from '../../components/atoms/Exif'
import RelatedPosts from '../../components/molecules/RelatedPosts'
import styles from './index.module.scss' import styles from './index.module.scss'
import { Post as PostMetadata } from '../../@types/Post' import { Image } from '../../components/atoms/Image'
export default function Post({ export default function Post({
data, data,
@ -40,13 +40,11 @@ export default function Post({
{type === 'post' && <PostLead post={post} />} {type === 'post' && <PostLead post={post} />}
{type === 'photo' && <PostContent post={post} />} {type === 'photo' && <PostContent post={post} />}
{image && ( {image && (
<div className={styles.imageWrap}> <Image
<PostImage
fluid={image.childImageSharp.fluid} fluid={image.childImageSharp.fluid}
alt={title} alt={title}
original={image.childImageSharp.original} original={image.childImageSharp.original}
/> />
</div>
)} )}
{image && image.fields && <Exif exif={image.fields.exif} />} {image && image.fields && <Exif exif={image.fields.exif} />}

View File

@ -1,18 +1,17 @@
import React from 'react' import React from 'react'
import { Link, graphql } from 'gatsby' import { Link, graphql } from 'gatsby'
import { Post } from '../@types/Post'
import Layout from '../components/Layout' import Layout from '../components/Layout'
import PostImage from './Post/PostImage' import Pagination from '../components/molecules/Pagination'
import Featured from '../components/molecules/Featured'
import PostTitle from './Post/PostTitle' import PostTitle from './Post/PostTitle'
import PostLead from './Post/PostLead' import PostLead from './Post/PostLead'
import PostContent from './Post/PostContent' import PostContent from './Post/PostContent'
import PostMore from './Post/PostMore' import PostMore from './Post/PostMore'
import PostLinkActions from './Post/PostLinkActions' import PostLinkActions from './Post/PostLinkActions'
import SEO from '../components/atoms/SEO' import SEO from '../components/atoms/SEO'
import Pagination from '../components/molecules/Pagination'
import Featured from '../components/molecules/Featured'
import styles from './Posts.module.scss' import styles from './Posts.module.scss'
import stylesPost from './Post/index.module.scss' import { Image } from '../components/atoms/Image'
import { Post } from '../@types/Post'
export default function Posts({ export default function Posts({
data, data,
@ -43,14 +42,12 @@ export default function Posts({
{image && ( {image && (
<Link to={slug} title={title}> <Link to={slug} title={title}>
<div className={stylesPost.imageWrap}> <Image
<PostImage
title={type === 'photo' ? title : null} title={type === 'photo' ? title : null}
fluid={image.childImageSharp.fluid} fluid={image.childImageSharp.fluid}
alt={title} alt={title}
original={image.childImageSharp.original} original={image.childImageSharp.original}
/> />
</div>
</Link> </Link>
)} )}