mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-23 01:29:41 +01:00
concept for showing project images count
This commit is contained in:
parent
252ae46c4c
commit
5789563242
3
src/images/images.svg
Normal file
3
src/images/images.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
||||
<path fill="#000000" d="M17.1250778,6.17151499 L15.0790778,0.536514988 C14.9280778,0.120514988 14.4840778,-0.100485012 14.0900778,0.0445149878 L0.492077822,5.00751499 C0.0980778217,5.15151499 -0.100922178,5.60451499 0.0510778217,6.02051499 L2.20707782,11.961515 L2.20707782,8.77851499 C2.20707782,7.34051499 3.35507782,6.17151499 4.76707782,6.17151499 L8.36007782,6.17151499 L12.6450778,3.16351499 L15.1240778,6.17151499 L17.1250778,6.17151499 Z M19.2380778,8.00151499 L4.76707782,8.00151499 C4.34707782,8.00151499 4.00507782,8.33551499 4.00507782,8.77851499 L4.00507782,18.198515 C4.00607782,18.642515 4.34807782,19.001515 4.76707782,19.001515 L19.2380778,19.001515 C19.6580778,19.001515 20.0000778,18.642515 20.0000778,18.198515 L20.0000778,8.77851499 C20.0000778,8.33551499 19.6580778,8.00151499 19.2380778,8.00151499 Z M18.0000778,17.001515 L6.00007782,17.001515 L6.00007782,15.001515 L7.98407782,10.983515 L10.7520778,14.419515 L13.3500778,11.757515 L16.6880778,10.552515 L18.0000778,14.001515 L18.0000778,17.001515 Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
@ -2,21 +2,45 @@ import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Link, graphql } from 'gatsby'
|
||||
import ProjectImage from '../components/molecules/ProjectImage'
|
||||
import { ReactComponent as Images } from '../images/images.svg'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
const getImageCount = (imageEdges, slug) => {
|
||||
let array = []
|
||||
|
||||
imageEdges.map(({ node }) => {
|
||||
if (node.name.includes(slug.replace(/\//g, ''))) {
|
||||
array.push(node)
|
||||
}
|
||||
})
|
||||
|
||||
return array
|
||||
}
|
||||
|
||||
const Home = ({ data }) => {
|
||||
const projects = data.allProjectsYaml.edges
|
||||
const imageEdges = data.projectImageFiles.edges
|
||||
|
||||
return (
|
||||
<div className={styles.projects}>
|
||||
{projects.map(({ node }) => {
|
||||
const { slug, title, img } = node
|
||||
const imageCount = getImageCount(imageEdges, slug).length
|
||||
|
||||
return (
|
||||
<article className={styles.project} key={slug}>
|
||||
<Link to={slug}>
|
||||
<h1 className={styles.title}>{title}</h1>
|
||||
<ProjectImage fluid={img.childImageSharp.fluid} alt={title} />
|
||||
|
||||
{imageCount > 0 && (
|
||||
<small
|
||||
className={styles.imageCount}
|
||||
title={`${imageCount} project images`}
|
||||
>
|
||||
<Images /> {imageCount}
|
||||
</small>
|
||||
)}
|
||||
</Link>
|
||||
</article>
|
||||
)
|
||||
@ -49,5 +73,13 @@ export const IndexQuery = graphql`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
projectImageFiles: allFile(filter: { name: { regex: "/portfolio/" } }) {
|
||||
edges {
|
||||
node {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
@ -60,3 +60,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.imageCount {
|
||||
position: absolute;
|
||||
bottom: $spacer / 4;
|
||||
right: $spacer / 2;
|
||||
color: $brand-light;
|
||||
font-size: $font-size-mini;
|
||||
opacity: .85;
|
||||
|
||||
svg {
|
||||
fill: $brand-light;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user