1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-13 16:45:14 +01:00

post actions

This commit is contained in:
Matthias Kretschmann 2018-08-29 19:44:31 +02:00
parent 23d2ea0ce8
commit 1ad607c43b
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,64 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import ModalThanks from '../molecules/ModalThanks'
import styles from './PostActions.module.scss'
import Twitter from '../svg/Twitter'
import Bitcoin from '../svg/Bitcoin'
class PostActions extends PureComponent {
constructor(props) {
super(props)
this.state = {
showModal: false
}
}
toggleModal = () => {
this.setState({ showModal: !this.state.showModal })
}
render() {
const { url, slug } = this.props
return (
<aside className={styles.actions}>
<article className={styles.action}>
<Twitter />
<h1 className={styles.actionTitle}>Have a comment?</h1>
<p className={styles.actionText}>
Hit me up{' '}
<a
href={`https://twitter.com/intent/tweet?text=@kremalicious&url=${url}${slug}`}
>
@kremalicious
</a>
</p>
</article>
<article className={styles.action}>
<Bitcoin />
<h1 className={styles.actionTitle}>Found something useful?</h1>
<p className={styles.actionText}>
Say thanks{' '}
<a href="#" onClick={this.toggleModal}>
with Bitcoins or Ether.
</a>
</p>
</article>
<ModalThanks
isOpen={this.state.showModal}
handleCloseModal={this.toggleModal}
/>
</aside>
)
}
}
PostActions.propTypes = {
slug: PropTypes.string.isRequired,
url: PropTypes.string.isRequired
}
export default PostActions

View File

@ -0,0 +1,52 @@
@import 'variables';
@import 'mixins';
.actions {
@include divider;
@include divider-top;
margin-top: $spacer * 3;
padding: $spacer * $line-height 0;
@media (min-width: $screen-xs) {
display: flex;
justify-content: space-between;
}
}
.action {
padding-left: 1.75rem;
position: relative;
&:first-child {
margin-bottom: $spacer * 2;
}
@media (min-width: $screen-xs) {
flex: 1 1 48%;
&:first-child {
margin-bottom: 0;
}
}
svg {
position: absolute;
left: 0;
top: .2rem;
fill: $brand-grey-light;
}
}
.actionTitle {
font-size: $font-size-base;
line-height: $line-height;
color: $text-color;
margin-top: 0;
margin-bottom: 0;
}
.actionText {
font-size: $font-size-small;
margin-bottom: 0;
}

View File

@ -99,6 +99,23 @@
}
}
@mixin divider-top() {
position: relative;
border-top: 1px dashed #afc3cb;
margin-top: $spacer * $line-height;
margin-bottom: $spacer * $line-height;
&::after {
content: '';
position: absolute;
left: 0;
height: 1px;
top: 0;
width: 100%;
border-bottom: 1px dashed #fff;
}
}
// Heading band
/////////////////////////////////////

View File

@ -8,6 +8,7 @@ import PostTitle from '../components/atoms/PostTitle'
import PostLead from '../components/atoms/PostLead'
import PostContent from '../components/atoms/PostContent'
import PostMeta from '../components/molecules/PostMeta'
import PostActions from '../components/atoms/PostActions'
import styles from './Post.module.scss'
const Post = ({ data, location }) => {
@ -32,6 +33,8 @@ const Post = ({ data, location }) => {
<PostContent post={post} />
<PostActions slug={post.fields.slug} url={meta.url} />
<PostMeta post={post} meta={meta} />
</article>
</Layout>
@ -80,6 +83,7 @@ export const pageQuery = graphql`
}
contentYaml {
url
author {
uri
}