mirror of
https://github.com/kremalicious/portfolio.git
synced 2025-02-14 21:10:41 +01:00
more PureComponent
This commit is contained in:
parent
61ac372567
commit
0a17e42451
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import Helmet from 'react-helmet'
|
import Helmet from 'react-helmet'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { StaticQuery, graphql } from 'gatsby'
|
import { StaticQuery, graphql } from 'gatsby'
|
||||||
@ -43,7 +43,19 @@ const query = graphql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const SEO = ({ project }) => (
|
export default class SEO extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
project: PropTypes.object
|
||||||
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
project: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { project } = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
<StaticQuery
|
<StaticQuery
|
||||||
query={query}
|
query={query}
|
||||||
render={data => {
|
render={data => {
|
||||||
@ -89,13 +101,5 @@ const SEO = ({ project }) => (
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
SEO.propTypes = {
|
|
||||||
project: PropTypes.object
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SEO.defaultProps = {
|
|
||||||
project: {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SEO
|
|
||||||
|
@ -3,7 +3,6 @@ import PropTypes from 'prop-types'
|
|||||||
import { StaticQuery, graphql } from 'gatsby'
|
import { StaticQuery, graphql } from 'gatsby'
|
||||||
import posed from 'react-pose'
|
import posed from 'react-pose'
|
||||||
import { moveInBottom } from '../atoms/Transitions'
|
import { moveInBottom } from '../atoms/Transitions'
|
||||||
|
|
||||||
import { ReactComponent as Logo } from '../../images/logo.svg'
|
import { ReactComponent as Logo } from '../../images/logo.svg'
|
||||||
import styles from './LogoUnit.module.scss'
|
import styles from './LogoUnit.module.scss'
|
||||||
|
|
||||||
@ -19,37 +18,21 @@ const query = graphql`
|
|||||||
const Animation = posed.div(moveInBottom)
|
const Animation = posed.div(moveInBottom)
|
||||||
|
|
||||||
export default class LogoUnit extends PureComponent {
|
export default class LogoUnit extends PureComponent {
|
||||||
state = { isMinimal: false }
|
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
minimal: PropTypes.bool
|
minimal: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMinimal = () => {
|
|
||||||
const { minimal } = this.props
|
|
||||||
|
|
||||||
this.setState({ isMinimal: minimal })
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.checkMinimal()
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate() {
|
|
||||||
this.checkMinimal()
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<StaticQuery
|
<StaticQuery
|
||||||
query={query}
|
query={query}
|
||||||
render={data => {
|
render={data => {
|
||||||
const { title, tagline } = data.dataYaml
|
const { title, tagline } = data.dataYaml
|
||||||
const { isMinimal } = this.state
|
const { minimal } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animation>
|
<Animation>
|
||||||
<div className={isMinimal ? styles.minimal : styles.logounit}>
|
<div className={minimal ? styles.minimal : styles.logounit}>
|
||||||
<Logo className={styles.logounit__logo} />
|
<Logo className={styles.logounit__logo} />
|
||||||
<h1 className={styles.logounit__title}>
|
<h1 className={styles.logounit__title}>
|
||||||
{title.toLowerCase()}
|
{title.toLowerCase()}
|
||||||
|
@ -27,19 +27,23 @@ class ProjectMeta extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProjectImages = ({ projectImages, title }) => (
|
class ProjectImages extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
projectImages: PropTypes.array,
|
||||||
|
title: PropTypes.string
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
<FullWidth>
|
<FullWidth>
|
||||||
{projectImages.map(({ node }) => (
|
{this.props.projectImages.map(({ node }) => (
|
||||||
<div className={styles.imageWrap} key={node.id}>
|
<div className={styles.imageWrap} key={node.id}>
|
||||||
<ProjectImage fluid={node.fluid} alt={title} />
|
<ProjectImage fluid={node.fluid} alt={this.props.title} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</FullWidth>
|
</FullWidth>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
ProjectImages.propTypes = {
|
|
||||||
projectImages: PropTypes.array,
|
|
||||||
title: PropTypes.string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Project extends PureComponent {
|
export default class Project extends PureComponent {
|
||||||
@ -49,9 +53,10 @@ export default class Project extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const project = this.props.data.projectsYaml
|
const { data } = this.props
|
||||||
const projectImages = this.props.data.projectImages.edges
|
const project = data.projectsYaml
|
||||||
const descriptionHtml = this.props.data.projectsYaml.fields.descriptionHtml
|
const projectImages = data.projectImages.edges
|
||||||
|
const descriptionHtml = data.projectsYaml.fields.descriptionHtml
|
||||||
const { title, links, techstack } = project
|
const { title, links, techstack } = project
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -76,7 +81,7 @@ export default class Project extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const projectAndProjectsQuery = graphql`
|
export const projectQuery = graphql`
|
||||||
query($slug: String!) {
|
query($slug: String!) {
|
||||||
projectsYaml(slug: { eq: $slug }) {
|
projectsYaml(slug: { eq: $slug }) {
|
||||||
title
|
title
|
||||||
|
Loading…
x
Reference in New Issue
Block a user