From 996058032e1298a6cbcfc3c1a8ce775de38d4d58 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 23 May 2018 00:03:46 +0200 Subject: [PATCH] refactor --- .codeclimate.yml | 2 + src/components/molecules/ProjectNav.jsx | 48 +++++++++++++----------- src/components/molecules/ThemeSwitch.jsx | 29 +++++++++----- src/templates/Project.jsx | 25 +++++++----- 4 files changed, 63 insertions(+), 41 deletions(-) create mode 100644 .codeclimate.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..012e0aa --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,2 @@ +exclude_patterns: + - src/lib/vcf/ diff --git a/src/components/molecules/ProjectNav.jsx b/src/components/molecules/ProjectNav.jsx index 07cb3e4..d5c5dca 100644 --- a/src/components/molecules/ProjectNav.jsx +++ b/src/components/molecules/ProjectNav.jsx @@ -7,34 +7,33 @@ import { ReactComponent as Index } from '../../images/index.svg' import '../atoms/Icons.scss' import './ProjectNav.scss' +const ProjectNavLink = ({ previous, next }) => { + const slug = previous ? previous.slug : next.slug + const title = previous ? previous.title : next.title + const img = previous ? previous.img : next.img + + return ( +
+ + {title} +

{title}

+ +
+ ) +} + const ProjectNav = ({ previous, next }) => ( ) +ProjectNavLink.propTypes = { + previous: PropTypes.object, + next: PropTypes.object +} + ProjectNav.propTypes = { previous: PropTypes.object, next: PropTypes.object diff --git a/src/components/molecules/ThemeSwitch.jsx b/src/components/molecules/ThemeSwitch.jsx index 63c5712..efb0f5c 100644 --- a/src/components/molecules/ThemeSwitch.jsx +++ b/src/components/molecules/ThemeSwitch.jsx @@ -1,10 +1,25 @@ import React, { PureComponent, Fragment } from 'react' +import PropTypes from 'prop-types' import Helmet from 'react-helmet' import { FadeIn } from '../atoms/Animations' import { ReactComponent as Day } from '../../images/day.svg' import { ReactComponent as Night } from '../../images/night.svg' import './ThemeSwitch.scss' +const ThemeToggle = props => { + return ( + + + + + + ) +} + class ThemeSwitch extends PureComponent { constructor(props) { super(props) @@ -44,15 +59,7 @@ class ThemeSwitch extends PureComponent { aria-describedby="toggle" checked={this.state.dark} /> - - - - - + @@ -61,4 +68,8 @@ class ThemeSwitch extends PureComponent { } } +ThemeToggle.propTypes = { + dark: PropTypes.bool +} + export default ThemeSwitch diff --git a/src/templates/Project.jsx b/src/templates/Project.jsx index 0aa410a..257bf93 100644 --- a/src/templates/Project.jsx +++ b/src/templates/Project.jsx @@ -22,6 +22,14 @@ const ProjectMeta = props => { ) } +const ProjectImages = props => ( + + {props.projectImages.map(({ node }) => ( + + ))} + +) + class Project extends Component { constructor(props) { super(props) @@ -43,9 +51,7 @@ class Project extends Component { return ( - - {title} - + @@ -56,13 +62,7 @@ class Project extends Component { source={this.state.descriptionWithLineBreaks} className="project__description" /> - - - {projectImages.map(({ node }) => ( - - ))} - - + @@ -78,6 +78,11 @@ ProjectMeta.propTypes = { techstack: PropTypes.array } +ProjectImages.propTypes = { + projectImages: PropTypes.array, + title: PropTypes.string +} + Project.propTypes = { data: PropTypes.object.isRequired, pathContext: PropTypes.object.isRequired