Skip to content

Commit

Permalink
built ProjectDetail component
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelLosier committed Jan 18, 2019
1 parent 681cc01 commit 6017d6c
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 5 deletions.
50 changes: 50 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
padding-bottom: 2rem;
background-color: #f5f4f1; }

.main .main-footer {
padding: 2rem;
border-top: 1px solid #63614B; }

.nav-bar ul {
padding: 0;
margin: 0;
Expand Down Expand Up @@ -202,3 +206,49 @@
.project-card .project-detail a:hover {
border: 1px solid #D4C134;
color: #D4C134; }

@keyframes slide-in {
from {
margin-left: 100%; }
to {
margin-left: 0; } }

@keyframes fade-in {
from {
opacity: 0%; }
to {
opacity: 100%; } }

.project-detail {
padding-top: 2rem; }
.project-detail h2 {
margin: 0rem auto 2rem auto;
padding: 1rem 2rem;
width: fit-content; }
.project-detail .artwork-navigation-container {
display: flex;
justify-content: space-around; }
.project-detail .artwork-navigation-container .image-container {
margin: 2rem auto;
max-width: 60%;
border: 1px solid #292820;
min-width: 300px; }
.project-detail .artwork-navigation-container .image-container:hover {
cursor: pointer; }
.project-detail .artwork-navigation-container .navigation-paddle {
display: flex;
align-items: center;
color: #AB9E39;
font-size: 4rem;
width: 10%;
min-width: 10%;
justify-content: center; }
.project-detail .artwork-navigation-container .navigation-paddle.visible:hover {
color: #D4C134;
background-color: rgba(41, 40, 32, 0.05);
cursor: pointer; }
.project-detail .caption {
margin: 2rem auto 2rem auto;
padding: 1rem;
font-style: italic;
width: fit-content; }
3 changes: 2 additions & 1 deletion src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
@import './components/image/image';
@import './components/featured-artwork/featured-artwork';
@import './components/project-selection/project-selection';
@import './components/project-card/project-card';
@import './components/project-card/project-card';
@import './components/project-detail/project-detail';
4 changes: 4 additions & 0 deletions src/components/main/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
padding-bottom:2rem;
background-color: $color-light-grey;
}
.main-footer{
padding: 2rem;
border-top: 1px solid $color-warm-grey;
}
}
26 changes: 23 additions & 3 deletions src/components/main/main.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Route, Link } from 'react-router-dom'
import NavBar from '../nav-bar/nav-bar.component'
import FeaturedArtwork from '../featured-artwork/featured-artwork.component';
import ProjectSelection from '../project-selection/project-selection.component';
import ProjectDetail from '../project-detail/project-detail.component';

import StaticResourceService from '../../services/staticResourceService';

Expand Down Expand Up @@ -47,9 +48,16 @@ class Main extends React.Component {
})
}

getProjectFromId = (projects, id) => {
const index = projects.findIndex((project) => {
return project._id == id
})
return projects[index];
}


render(){
const {artworks, projects, selectedProject} = this.state;
const {artworks, projects} = this.state;
return(
<div className="main">
<div className="main-header">
Expand Down Expand Up @@ -81,6 +89,7 @@ class Main extends React.Component {
render={null}
/>
<Route
exact={true}
path="/projects/:category"
render={({match}) => {
return(<ProjectSelection
Expand All @@ -90,11 +99,22 @@ class Main extends React.Component {
}}
/>
<Route
path="/projects/:id"
render={null}
path="/projects/:category/:_id"
render={({match}) => {
const project = this.getProjectFromId(projects, match.params._id);
return(
<div>
{projects.length > 0 && <ProjectDetail
project={project}
/>}
</div>
)

}}
/>
</div>
<div className="main-footer layout-container">
Art and Site Design &copy; {new Date().getFullYear()} Michel Losier
</div>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/project-card/project-card.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ProjectCard extends React.Component {
<h3>{project.name}</h3>
<p>{project.description}</p>
<Link
to={`/projects/${project._id}`}
to={`/projects/${project.category}/${project._id}`}
>
view
</Link>
Expand Down
48 changes: 48 additions & 0 deletions src/components/project-detail/_project-detail.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@import '../../stylesheets/variables';

.project-detail{
padding-top:2rem;
h2 {
margin: 0rem auto 2rem auto;
padding: 1rem 2rem;
width: fit-content;
//border-bottom: 1px solid $color-dark-grey;
}
.artwork-navigation-container {
display:flex;
justify-content: space-around;
.image-container{
margin: 2rem auto;
max-width: 60%;
border: 1px solid $color-dark-grey;
min-width: 300px;

&:hover{
cursor:pointer;
}
}
.navigation-paddle{
display:flex;
align-items: center;
color: $color-primary-olive;
font-size: 4rem;
width: 10%;
min-width:10%;
justify-content:center;

&.visible:hover{
color: $color-highlight-olive;
background-color: $color-light-grey-transparent;
cursor:pointer;
}
}
}

.caption{
margin: 2rem auto 2rem auto;
padding: 1rem;
font-style: italic;
width: fit-content;
//border-top: 1px solid $color-dark-grey;
}
}
72 changes: 72 additions & 0 deletions src/components/project-detail/project-detail.component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import PropTypes from 'prop-types'

import Image from '../image/image.component';


class ProjectDetail extends React.Component{
constructor(props){
super(props)
this.state = {
currentIndex: 0,
}
}
static propTypes = {
project: PropTypes.object,
}

handleNavigationPaddleClick = (intChange) => {

this.setState((prevState) => {
const {currentIndex} = prevState;
const nextIndex = currentIndex + intChange;

const newIndex = (nextIndex >= 0 && nextIndex < this.props.project.gallery.length) ?
nextIndex : currentIndex

return {currentIndex: newIndex}
})
}

render(){
const {project} = this.props;
const {currentIndex} = this.state;
const currentArtwork = project.gallery[currentIndex];
const currentArtworkImage = currentArtwork.images.largeImage;

const showLeft = currentIndex > 0;
const showRight = (currentIndex < (project.gallery.length-1)) && (project.gallery.length > 0);

return(
<div className="project-detail">
<h2>{project.name}</h2>
<div className="artwork-navigation-container">
<div
className={(showLeft) ? `visible navigation-paddle left` : `navigation-paddle left`}
onClick={()=>{this.handleNavigationPaddleClick(-1)}}
>
{showLeft && <p>&lt;</p>}
</div>
<div className="image-container">
<Image
url={currentArtworkImage.url}
altText={currentArtworkImage.altText}
/>
</div>
<div
className={(showRight) ? `visible navigation-paddle right` : `navigation-paddle right`}
onClick={()=>{this.handleNavigationPaddleClick(1)}}
>
{showRight && <p>&gt;</p>}
</div>
</div>
<div className="caption">
{currentArtwork.caption}
</div>
</div>
)
}

}

export default ProjectDetail;
1 change: 1 addition & 0 deletions src/stylesheets/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

$color-dark-grey: #292820;
$color-dark-grey-transparent: rgba(41,40,32,0.95);
$color-light-grey-transparent: rgba(41, 40, 32, 0.05);
$color-primary-olive: #AB9E39;
$color-highlight-olive: #D4C134;
$color-warm-grey: #63614B;
Expand Down

0 comments on commit 6017d6c

Please sign in to comment.