Skip to content

Commit

Permalink
Add location to blurb
Browse files Browse the repository at this point in the history
  • Loading branch information
lukem512 committed Mar 7, 2017
1 parent db02721 commit 8eda2ab
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
Binary file added public/location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class App extends Component {
src: "https://i.imgur.com/qOzvV95.jpg",
title: "Eucalyptus",
description: "An *Oceanic* tree in _Kew Gardens_.",
location: '51.4823816, -0.2891944',
},
{
src: "https://i.imgur.com/57fNtrZ.jpg",
Expand All @@ -30,7 +31,7 @@ class App extends Component {
title: "Red hot",
description: "Due to it's oils this species is extremely flammable.",
},
]} timeout={1000} />
]} timeout={3000} />

{/* This is displayed beneath your photos. This can be moved if
desired. */}
Expand Down
14 changes: 14 additions & 0 deletions src/Photo.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
letter-spacing: 0.22px;
}

.photo .blurb .location {
opacity: 0.6;
transition: opacity 0.2s ease-out;
}

.photo .blurb .location:hover {
opacity: 1.0;
}

.photo .blurb .location img {
border-style: none;
border: 0;
}

.photo .blurb .underline {
text-decoration: underline;
}
Expand Down
12 changes: 11 additions & 1 deletion src/Photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Photo = React.createClass({
margin: React.PropTypes.number,
title: React.PropTypes.string,
description: React.PropTypes.string,
location: React.PropTypes.string,
timeout: React.PropTypes.number,
},

Expand All @@ -21,8 +22,16 @@ const Photo = React.createClass({
};
},

renderLocation() {
const latlong = this.props.location.replace(/\s/g, '');
const link = 'https://www.google.com/maps/@' + latlong + ',15z';
return (<a target="_blank" className="location" href={link}>
<img src="./location.png" width={12} role="presentation" />
</a>);
},

renderOverlay() {
const {title, description, margin = 0} = this.props;
const {title, description, location, margin = 0} = this.props;

// Display empty div for initial transition
if (!this.img) {
Expand All @@ -48,6 +57,7 @@ const Photo = React.createClass({
dangerouslySetInnerHTML={{__html: parse(title)}}/>}
{description && <p className="photo-description"
dangerouslySetInnerHTML={{__html: parse(description)}} />}
{location && this.renderLocation()}
</div>
);
},
Expand Down
3 changes: 1 addition & 2 deletions src/Triplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class Triplicate extends Component {
const obj = typeof photo === 'object' ? photo : {src: photo};
const key = `photo-${i}`;
return (<Photo width={this.getLandscapeWidth(photos, margin)}
margin={margin} key={key} timeout={this.props.timeout}
src={obj.src} title={obj.title} description={obj.description} />);
margin={margin} key={key} timeout={this.props.timeout} {...obj} />);
})}
</div>
);
Expand Down

0 comments on commit 8eda2ab

Please sign in to comment.