Skip to content

Commit

Permalink
code cleanup and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMacF committed Jul 4, 2017
1 parent 3149d7a commit 538ec55
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 78 deletions.
32 changes: 7 additions & 25 deletions public/src/components/AlbumPhotoDisplay.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import React from 'react';

/* ------------------------------
Render a slideshow carousel to the page for a single album:
-carousel shows single photo with controls for previous and next
-carousel indicators renders thumbnails of the entire album of photos and can control the main carousel
-triggers a lightbox on click of the photo in the main carousel
-------------------------------*/

const AlbumPhotoDisplay = ({photos, albums, selectAlbum, currentPhoto}) => {
const slides = photos.map((photo, i) => {
if (i === currentPhoto) {
Expand All @@ -24,9 +31,7 @@ const AlbumPhotoDisplay = ({photos, albums, selectAlbum, currentPhoto}) => {
}
})
const indicators = photos.map((photo, i) => {
// if (i !== 0) {
return (<li className="" data-slide-to={i} data-target="#myCarousel"><img alt="" src={photo.url}/></li>)
// }
})
return (
<div>
Expand Down Expand Up @@ -54,26 +59,3 @@ const AlbumPhotoDisplay = ({photos, albums, selectAlbum, currentPhoto}) => {
}

export default AlbumPhotoDisplay;

/*<div class="row hidden-phone" id="slider-thumbs">
<div class="span12">
<ol className="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" className="active"><a className="thumbnail" id="carousel-selector-0"><img alt="" src={photos[0].url}/></a></li>
{indicators}
</ol>
</div>
</div>
<div className="carousel-caption"><h3 >{photos[4].description}</h3></div>
<div className="item active" data-slide-number="0" onClick={()=>{console.log(0)}}>
<img src={photos[0].url} alt="First Slide" /><div className="carousel-caption"><h3 >{photos[0].description}</h3></div>
</div>
onClick={()=>{console.log(i)}}
<li className="" data-slide-to="0" data-target="#myCarousel">
<img alt="" src={photos[0].url} />
</li>
*/
12 changes: 7 additions & 5 deletions public/src/components/album.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import Photo from './photo.jsx';

const Album = ({album, selectAlbum}) => { // edited this (wip)
/*const photos = album.photos.map(photo, i) => {
return (<div className="col-md-3"><Photo photo={photo} key={album.name + i}/></div>)
}*/
/* ------------------------------
Render an individual album row with the first 4 photos to the App for each album:
-uses selectAlbum method from app.jsx
-------------------------------*/

const Album = ({album, selectAlbum}) => {
const photos = album.photos.map((photo, i) => {
if(i < 4) {
return (<div className="col-md-3" onClick={() => { selectAlbum(album, i); }}><Photo photo={photo}/></div>);
Expand All @@ -15,7 +17,7 @@ const Album = ({album, selectAlbum}) => { // edited this (wip)
<div>
<div className="row">
<div className="col-md-12">
<h3 className="album-title" onClick={() => { selectAlbum(album); }}>{album.name}</h3> {/* << make dynamic*/}
<h3 className="album-title" onClick={() => { selectAlbum(album); }}>{album.name}</h3>
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions public/src/components/albumPhotos.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React from 'react';
import Photo from './photo.jsx';

/* ------------------------------
defunct not currently in use
-------------------------------*/

const AlbumPhotos = ({}) => {
return (
<div>
Expand Down
7 changes: 5 additions & 2 deletions public/src/components/albumdisplay.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from 'react';
import AlbumPhotos from './albumPhotos.jsx';
import AlbumPhotoDisplay from './AlbumPhotoDisplay.jsx';

/* ------------------------------
Render a single album to the page
-calls albumPhotoDisplay
-------------------------------*/

const AlbumDisplay = ({currentAlbum, albums, selectAlbum, currentPhoto}) => {
return (
<div>
<AlbumPhotoDisplay photos={currentAlbum.photos} albums={albums} selectAlbum={selectAlbum} currentPhoto={currentPhoto}/>
{/*<AlbumPhotos album={currentAlbum}/>*/}
</div>
);
};
Expand Down
5 changes: 5 additions & 0 deletions public/src/components/albumlist.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React from 'react';
import Album from './album.jsx';

/* ------------------------------
Render the list of albums from the album state in App.jsx
-calls Album.jsx for each album
-------------------------------*/

const AlbumList = ({albums, selectAlbum}) => {
const albumNode = albums.map((album, i) => {
return (<Album album={album} selectAlbum={selectAlbum} key={i} />);
Expand Down
31 changes: 10 additions & 21 deletions public/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import AlbumDisplay from './albumdisplay.jsx';
import AlbumList from './albumlist.jsx';
import Album from './album.jsx';

/* ------------------------------
Main react App:
-holds the states
-holds the methods
-------------------------------*/

export default class App extends React.Component {
constructor(props) {
super(props);
Expand All @@ -16,12 +22,12 @@ export default class App extends React.Component {
currentAlbumIndex: 5,
currentUser: {
albums: []
}, // change
displayUser: {} // change
},
displayUser: {}
};
}

addPhoto(photo, albumName, description, newAlbumName) { // pass in album name/id pulled from drop-down selector?
addPhoto(photo, albumName, description, newAlbumName) {

var data = new FormData();
data.append('photo', photo, photo.name);
Expand All @@ -47,7 +53,6 @@ export default class App extends React.Component {
processData: false,
contentType: false,
success: function(response) {
console.log('success', response);
this.setState({albums: response.albums, photos: response.photos});
}.bind(this),
error: function(error) {
Expand All @@ -58,8 +63,6 @@ export default class App extends React.Component {

selectAlbum(album, photo) {
let photoNum = photo || 0;
console.log(album);
console.log(photoNum)
this.setState({currentAlbum: album, currentPhoto: photoNum});
}

Expand All @@ -68,30 +71,22 @@ export default class App extends React.Component {
type: 'GET',
url: '/user/' + this.state.currentUser,
success: function(data) {
console.log(data);
this.setState({albums: data.albums, currentUser: data, displayUser: data});
console.log(this.state.albums);
}.bind(this),
error: function(err) {
console.error('error', err);
}.bind(this)
});
}

changeAlbum(dir) {
//dir -1 or 1
// set.state of current album to next or previous album
}

renderPage({currentAlbum, albums, selectAlbum, currentPhoto}) {
renderPage({currentAlbum, albums, selectAlbum, currentPhoto}) { //logic for whether a single album should display or album list
if (currentAlbum === null) {
return (
<AlbumList
albums={albums}
selectAlbum={selectAlbum}
/>
);
//return (<Album />);
} else {
return (
<AlbumDisplay
Expand Down Expand Up @@ -121,9 +116,3 @@ export default class App extends React.Component {
}
}


/*
<AlbumDisplay currentAlbum={this.state.currentAlbum}/>
<AlbumList albums={this.state.albums} selectAlbum={this.selectAlbum.bind(this)}/>
<Album />
*/
7 changes: 6 additions & 1 deletion public/src/components/navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react';
// import Bootstrap from 'bootstrap';
import PhotoForm from './photoform.jsx';

/* ------------------------------
Render Navbar to top of page:
-uses bootstrap navbar
-calls on PhotoForm
-------------------------------*/

const Navbar = ({addPhoto, currentUser}) => {
return (

Expand Down
4 changes: 4 additions & 0 deletions public/src/components/photo.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from 'react';

/* ------------------------------
renders a single photo currently in use from album.jsx
-------------------------------*/

const Photo = ({photo}) => {
return (
<img className="img-responsive" src={photo.url} title={photo.description}/>
Expand Down
15 changes: 6 additions & 9 deletions public/src/components/photoform.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from 'react';

/* ------------------------------
Render Photo upload form to dropdown in navbar:
-call upon addPhoto method from App.jsx
-------------------------------*/

const PhotoForm = ({addPhoto, currentUser}) => {
let photo;
let name;
Expand Down Expand Up @@ -27,11 +32,10 @@ const PhotoForm = ({addPhoto, currentUser}) => {
});

return (
<form method="post" encType="multpart/form-data" onSubmit={(e) => { // add a drop-down selector for album?
<form method="post" encType="multpart/form-data" onSubmit={(e) => {
e.preventDefault();
addPhoto(photo.files[0], name, desc.value, newName.value);
photo.value = '';
// name.value = '';
desc.value = '';
newName.value = '';
}}>
Expand Down Expand Up @@ -67,10 +71,3 @@ const PhotoForm = ({addPhoto, currentUser}) => {

export default PhotoForm;

/*
<div className="form-group">
<input id="name" className="form-control" type="text" name="name" placeholder="Album name" autoComplete="off" ref={node2 => {
name = node2;
}}/>
</div>
*/
10 changes: 3 additions & 7 deletions public/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/app.jsx'; // eslint-disable-line
// import Bootstrap from 'bootstrap/dist/css/bootstrap.css';
// var React = require('react');
// var ReactDOM = require('react-dom');
// var App = require('./components/app.jsx');

// var test = () => console.log('test');

// test();
/* ------------------------------
Render react app to html dom
-------------------------------*/

ReactDOM.render(<App />, document.getElementById('app')); // eslint-disable-line
15 changes: 7 additions & 8 deletions public/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
padding-bottom: 10px;
width: 300px;
}
/*.dropdown-menu .form-group {
margin-bottom: 7px;
}*/

.navbar-brand {
padding: 1px 6px;
}

.navbar-brand>img {
max-width: 150px;
}

body {
padding-top: 50px;
padding-bottom: 50px;
}

.new-name-hidden {
display: none;
}
Expand All @@ -27,9 +28,11 @@ body {
height: 500px;
max-height: 500px;
}

.carousel .item{
min-height: 280px; /* Prevent carousel from being distorted if for some reason image doesn't load */
}

.carousel .item img{
margin: 0 auto; /* Align slide image horizontally center */
width: auto;
Expand Down Expand Up @@ -84,18 +87,14 @@ body {
color: #93c7ff;
}

.carousel-caption h3 {
/* color: black !important; */

}

.img-responsive {
height: 250px;
}

.album-title {
color: #29a7b4;
}

.album-row {
background: #5486a5;
padding-top: 10px;
Expand Down

0 comments on commit 538ec55

Please sign in to comment.