mirror of
https://github.com/kremalicious/portfolio.git
synced 2025-01-05 19:25:33 +01:00
more Pure Components
This commit is contained in:
parent
2cb9ca9181
commit
7a386c9ade
@ -34,7 +34,6 @@ const Typekit = () => (
|
|||||||
return (
|
return (
|
||||||
typekitID && (
|
typekitID && (
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<link rel="dns-prefetch" href="https://use.typekit.net/" />
|
|
||||||
<link rel="dns-prefetch" href="https://p.typekit.net/" />
|
<link rel="dns-prefetch" href="https://p.typekit.net/" />
|
||||||
|
|
||||||
{TypekitScript(typekitID)}
|
{TypekitScript(typekitID)}
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
transform-origin: top center;
|
transform-origin: top center;
|
||||||
transform-box: border-box;
|
transform-box: border-box;
|
||||||
|
|
||||||
// stylelint-disable no-descending-specificity
|
|
||||||
.logounit__title,
|
.logounit__title,
|
||||||
.logounit__description {
|
.logounit__description {
|
||||||
color: $text-color-light;
|
color: $text-color-light;
|
||||||
@ -60,7 +59,6 @@
|
|||||||
color: $text-color-light--dark;
|
color: $text-color-light--dark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// stylelint-enable no-descending-specificity
|
|
||||||
|
|
||||||
.logounit__logo {
|
.logounit__logo {
|
||||||
margin-bottom: $spacer / 3;
|
margin-bottom: $spacer / 3;
|
||||||
|
@ -27,21 +27,23 @@ const query = graphql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const NetworkIcon = props => {
|
class NetworkIcon extends PureComponent {
|
||||||
switch (props.title) {
|
render() {
|
||||||
|
switch (this.props.title) {
|
||||||
case 'Email':
|
case 'Email':
|
||||||
return <Email {...props} />
|
return <Email {...this.props} />
|
||||||
case 'Blog':
|
case 'Blog':
|
||||||
return <Blog {...props} />
|
return <Blog {...this.props} />
|
||||||
case 'Twitter':
|
case 'Twitter':
|
||||||
return <Twitter {...props} />
|
return <Twitter {...this.props} />
|
||||||
case 'GitHub':
|
case 'GitHub':
|
||||||
return <GitHub {...props} />
|
return <GitHub {...this.props} />
|
||||||
case 'Dribbble':
|
case 'Dribbble':
|
||||||
return <Dribbble {...props} />
|
return <Dribbble {...this.props} />
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Animation = posed.aside(moveInTop)
|
const Animation = posed.aside(moveInTop)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import Button from '../atoms/Button'
|
import Button from '../atoms/Button'
|
||||||
@ -50,14 +50,20 @@ const LinkIcon = ({ title, type, ...props }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProjectLinks = ({ links }) => (
|
export default class ProjectLinks extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
links: PropTypes.array
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
<div className={styles.projectLinks}>
|
<div className={styles.projectLinks}>
|
||||||
<h3 className={styles.title}>
|
<h3 className={styles.title}>
|
||||||
Links <span>Learn more on the interwebz.</span>
|
Links <span>Learn more on the interwebz.</span>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{links.map(link => {
|
{this.props.links.map(link => {
|
||||||
const { title, url, type } = link
|
const { title, url, type } = link
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -71,10 +77,6 @@ const ProjectLinks = ({ links }) => (
|
|||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
ProjectLinks.propTypes = {
|
|
||||||
links: PropTypes.array
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ProjectLinks
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Link, graphql, StaticQuery } from 'gatsby'
|
import { Link, graphql, StaticQuery } from 'gatsby'
|
||||||
import Img from 'gatsby-image'
|
import Img from 'gatsby-image'
|
||||||
@ -24,7 +24,11 @@ const query = graphql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const ProjectLink = ({ node }) => (
|
class ProjectLink extends PureComponent {
|
||||||
|
render() {
|
||||||
|
const { node } = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
<Link className={styles.link} to={node.slug}>
|
<Link className={styles.link} to={node.slug}>
|
||||||
<Img
|
<Img
|
||||||
className={styles.image}
|
className={styles.image}
|
||||||
@ -33,9 +37,11 @@ const ProjectLink = ({ node }) => (
|
|||||||
/>
|
/>
|
||||||
<h1 className={styles.title}>{node.title}</h1>
|
<h1 className={styles.title}>{node.title}</h1>
|
||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default class ProjectNav extends Component {
|
export default class ProjectNav extends PureComponent {
|
||||||
state = {
|
state = {
|
||||||
scrolledToCurrent: false
|
scrolledToCurrent: false
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { PureComponent } from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import { Link, StaticQuery, graphql } from 'gatsby'
|
||||||
import { StaticQuery, graphql } from 'gatsby'
|
|
||||||
import Vcard from '../atoms/Vcard'
|
import Vcard from '../atoms/Vcard'
|
||||||
import LogoUnit from '../molecules/LogoUnit'
|
import LogoUnit from '../molecules/LogoUnit'
|
||||||
import Networks from '../molecules/Networks'
|
import Networks from '../molecules/Networks'
|
||||||
@ -23,9 +22,15 @@ const query = graphql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const FooterMarkup = ({ meta, pkg, year }) => (
|
export default class Footer extends PureComponent {
|
||||||
|
state = { year: new Date().getFullYear() }
|
||||||
|
|
||||||
|
FooterMarkup = ({ meta, pkg, year }) => (
|
||||||
<footer className={styles.footer}>
|
<footer className={styles.footer}>
|
||||||
|
<Link to={'/'}>
|
||||||
<LogoUnit minimal />
|
<LogoUnit minimal />
|
||||||
|
</Link>
|
||||||
|
|
||||||
<Networks minimal />
|
<Networks minimal />
|
||||||
|
|
||||||
<p className={styles.footer__actions}>
|
<p className={styles.footer__actions}>
|
||||||
@ -39,16 +44,7 @@ const FooterMarkup = ({ meta, pkg, year }) => (
|
|||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
)
|
)
|
||||||
|
|
||||||
FooterMarkup.propTypes = {
|
|
||||||
meta: PropTypes.object,
|
|
||||||
pkg: PropTypes.object,
|
|
||||||
year: PropTypes.number
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Footer extends PureComponent {
|
|
||||||
state = { year: new Date().getFullYear() }
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
@ -58,7 +54,9 @@ export default class Footer extends PureComponent {
|
|||||||
const pkg = data.portfolioJson
|
const pkg = data.portfolioJson
|
||||||
const meta = data.dataYaml
|
const meta = data.dataYaml
|
||||||
|
|
||||||
return <FooterMarkup year={this.state.year} pkg={pkg} meta={meta} />
|
return (
|
||||||
|
<this.FooterMarkup year={this.state.year} pkg={pkg} meta={meta} />
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -18,6 +18,10 @@ const query = graphql`
|
|||||||
`
|
`
|
||||||
|
|
||||||
export default class Header extends PureComponent {
|
export default class Header extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
minimal: PropTypes.bool
|
||||||
|
}
|
||||||
|
|
||||||
state = { isMinimal: this.props.minimal }
|
state = { isMinimal: this.props.minimal }
|
||||||
|
|
||||||
checkMinimal = () => {
|
checkMinimal = () => {
|
||||||
@ -61,7 +65,3 @@ export default class Header extends PureComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Header.propTypes = {
|
|
||||||
minimal: PropTypes.bool
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Link, graphql } from 'gatsby'
|
import { Link, graphql } from 'gatsby'
|
||||||
import SEO from '../components/atoms/SEO'
|
import SEO from '../components/atoms/SEO'
|
||||||
@ -6,7 +6,7 @@ import ProjectImage from '../components/molecules/ProjectImage'
|
|||||||
import { ReactComponent as Images } from '../images/images.svg'
|
import { ReactComponent as Images } from '../images/images.svg'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
const getImageCount = (images, slug) => {
|
function getImageCount(images, slug) {
|
||||||
let array = []
|
let array = []
|
||||||
let slugWithoutSlashes = slug.replace(/\//g, '')
|
let slugWithoutSlashes = slug.replace(/\//g, '')
|
||||||
|
|
||||||
@ -17,7 +17,14 @@ const getImageCount = (images, slug) => {
|
|||||||
return array.length
|
return array.length
|
||||||
}
|
}
|
||||||
|
|
||||||
const Home = ({ data }) => {
|
export default class Home extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
data: PropTypes.object,
|
||||||
|
location: PropTypes.object
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { data } = this.props
|
||||||
const projects = data.allProjectsYaml.edges
|
const projects = data.allProjectsYaml.edges
|
||||||
const images = data.projectImageFiles.edges
|
const images = data.projectImageFiles.edges
|
||||||
|
|
||||||
@ -51,15 +58,9 @@ const Home = ({ data }) => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Home.propTypes = {
|
|
||||||
data: PropTypes.object,
|
|
||||||
location: PropTypes.object
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Home
|
|
||||||
|
|
||||||
export const IndexQuery = graphql`
|
export const IndexQuery = graphql`
|
||||||
query {
|
query {
|
||||||
allProjectsYaml {
|
allProjectsYaml {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { PureComponent } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { graphql } from 'gatsby'
|
import { graphql } from 'gatsby'
|
||||||
import FullWidth from '../components/atoms/FullWidth'
|
import FullWidth from '../components/atoms/FullWidth'
|
||||||
@ -9,12 +9,23 @@ import ProjectNav from '../components/molecules/ProjectNav'
|
|||||||
import SEO from '../components/atoms/SEO'
|
import SEO from '../components/atoms/SEO'
|
||||||
import styles from './Project.module.scss'
|
import styles from './Project.module.scss'
|
||||||
|
|
||||||
const ProjectMeta = ({ links, techstack }) => (
|
class ProjectMeta extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
links: PropTypes.array,
|
||||||
|
techstack: PropTypes.array
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { links, techstack } = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
<footer className={styles.meta}>
|
<footer className={styles.meta}>
|
||||||
{!!links && <ProjectLinks links={links} />}
|
{!!links && <ProjectLinks links={links} />}
|
||||||
{!!techstack && <ProjectTechstack techstack={techstack} />}
|
{!!techstack && <ProjectTechstack techstack={techstack} />}
|
||||||
</footer>
|
</footer>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ProjectImages = ({ projectImages, title }) => (
|
const ProjectImages = ({ projectImages, title }) => (
|
||||||
<FullWidth>
|
<FullWidth>
|
||||||
@ -26,12 +37,22 @@ const ProjectImages = ({ projectImages, title }) => (
|
|||||||
</FullWidth>
|
</FullWidth>
|
||||||
)
|
)
|
||||||
|
|
||||||
const Project = ({ data }) => {
|
ProjectImages.propTypes = {
|
||||||
const project = data.projectsYaml
|
projectImages: PropTypes.array,
|
||||||
const projectImages = data.projectImages.edges
|
title: PropTypes.string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Project extends PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
data: PropTypes.object.isRequired,
|
||||||
|
location: PropTypes.object.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const project = this.props.data.projectsYaml
|
||||||
|
const projectImages = this.props.data.projectImages.edges
|
||||||
|
const descriptionHtml = this.props.data.projectsYaml.fields.descriptionHtml
|
||||||
const { title, links, techstack } = project
|
const { title, links, techstack } = project
|
||||||
const description = data.projectsYaml.description
|
|
||||||
const descriptionWithLineBreaks = description.split('\n').join('\n\n')
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -52,31 +73,18 @@ const Project = ({ data }) => {
|
|||||||
<ProjectNav slug={project.slug} />
|
<ProjectNav slug={project.slug} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectMeta.propTypes = {
|
|
||||||
links: PropTypes.array,
|
|
||||||
techstack: PropTypes.array
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectImages.propTypes = {
|
|
||||||
projectImages: PropTypes.array,
|
|
||||||
title: PropTypes.string
|
|
||||||
}
|
|
||||||
|
|
||||||
Project.propTypes = {
|
|
||||||
data: PropTypes.object.isRequired,
|
|
||||||
location: PropTypes.object.isRequired
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Project
|
|
||||||
|
|
||||||
export const projectAndProjectsQuery = graphql`
|
export const projectAndProjectsQuery = graphql`
|
||||||
query($slug: String!) {
|
query($slug: String!) {
|
||||||
projectsYaml(slug: { eq: $slug }) {
|
projectsYaml(slug: { eq: $slug }) {
|
||||||
title
|
title
|
||||||
slug
|
slug
|
||||||
description
|
description
|
||||||
|
fields {
|
||||||
|
descriptionHtml
|
||||||
|
}
|
||||||
links {
|
links {
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
|
Loading…
Reference in New Issue
Block a user