-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Create Asset List View and refactor overlay code #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2f2637a
start to create asset list
catarak 1d74aa8
begin refactoring overlay component to remove duplicate code
catarak 9ac1bec
refactoring of overlays, asset list styles
catarak 546724d
changes to add size to asset list
catarak eab2e25
fixes to asset list
catarak cea5faa
handle case in which a user hasn't uploaded any assets
catarak a8aecba
fix bug in which asset list only grabbed first asset
catarak 802a423
remove console.log
catarak 115ce9b
update overlay exit styling to use icon mixin
catarak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,70 @@ | ||
import React, { PropTypes } from 'react'; | ||
import InlineSVG from 'react-inlinesvg'; | ||
import { browserHistory } from 'react-router'; | ||
|
||
function Overlay(props) { | ||
return ( | ||
<div className="overlay"> | ||
<div className="overlay-content"> | ||
{props.children} | ||
const exitUrl = require('../../../images/exit.svg'); | ||
|
||
class Overlay extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.close = this.close.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
this.overlay.focus(); | ||
} | ||
|
||
close() { | ||
if (!this.props.closeOverlay) { | ||
browserHistory.push(this.props.previousPath); | ||
} else { | ||
this.props.closeOverlay(); | ||
} | ||
} | ||
|
||
render() { | ||
const { | ||
ariaLabel, | ||
title, | ||
children | ||
} = this.props; | ||
return ( | ||
<div className="overlay"> | ||
<div className="overlay__content"> | ||
<section | ||
tabIndex="0" | ||
role="main" | ||
aria-label={ariaLabel} | ||
ref={(element) => { this.overlay = element; }} | ||
className="overlay__body" | ||
> | ||
<header className="overlay__header"> | ||
<h2 className="overlay__title">{title}</h2> | ||
<button className="overlay__close-button" onClick={this.close}> | ||
<InlineSVG src={exitUrl} alt="close overlay" /> | ||
</button> | ||
</header> | ||
{children} | ||
</section> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
); | ||
} | ||
} | ||
|
||
Overlay.propTypes = { | ||
children: PropTypes.element | ||
children: PropTypes.element, | ||
closeOverlay: PropTypes.func, | ||
title: PropTypes.string, | ||
ariaLabel: PropTypes.string, | ||
previousPath: PropTypes.string.isRequired | ||
}; | ||
|
||
Overlay.defaultProps = { | ||
children: null | ||
children: null, | ||
title: 'Modal', | ||
closeOverlay: null, | ||
ariaLabel: 'modal' | ||
}; | ||
|
||
export default Overlay; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import axios from 'axios'; | ||
|
||
import * as ActionTypes from '../../../constants'; | ||
|
||
const ROOT_URL = process.env.API_URL; | ||
|
||
function setAssets(assets) { | ||
return { | ||
type: ActionTypes.SET_ASSETS, | ||
assets | ||
}; | ||
} | ||
|
||
export function getAssets(username) { | ||
return (dispatch, getState) => { | ||
axios.get(`${ROOT_URL}/S3/${username}/objects`, { withCredentials: true }) | ||
.then((response) => { | ||
dispatch(setAssets(response.data.assets)); | ||
}) | ||
.catch(response => dispatch({ | ||
type: ActionTypes.ERROR | ||
})); | ||
}; | ||
} | ||
|
||
export function deleteAsset(assetKey, userId) { | ||
return { | ||
type: 'PLACEHOLDER' | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,101 @@ | ||
import React, { PropTypes } from 'react'; | ||
import React from 'react'; | ||
import InlineSVG from 'react-inlinesvg'; | ||
import { browserHistory } from 'react-router'; | ||
|
||
const exitUrl = require('../../../images/exit.svg'); | ||
const squareLogoUrl = require('../../../images/p5js-square-logo.svg'); | ||
const playUrl = require('../../../images/play.svg'); | ||
const asteriskUrl = require('../../../images/p5-asterisk.svg'); | ||
|
||
class About extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.closeAboutModal = this.closeAboutModal.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
this.aboutSection.focus(); | ||
} | ||
|
||
closeAboutModal() { | ||
browserHistory.push(this.props.previousPath); | ||
} | ||
|
||
render() { | ||
return ( | ||
<section className="about" ref={(element) => { this.aboutSection = element; }} tabIndex="0"> | ||
<header className="about__header"> | ||
<h2 className="about__header-title">Welcome</h2> | ||
<button className="about__exit-button" onClick={this.closeAboutModal}> | ||
<InlineSVG src={exitUrl} alt="Close About Overlay" /> | ||
</button> | ||
</header> | ||
<div className="about__content"> | ||
<div className="about__content-column"> | ||
<InlineSVG className="about__logo" src={squareLogoUrl} alt="p5js Square Logo" /> | ||
<p className="about__play-video"> | ||
<a | ||
href="http://hello.p5js.org/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__play-video-button" src={playUrl} alt="Play Hello Video" /> | ||
Play hello! video</a> | ||
</p> | ||
</div> | ||
<div className="about__content-column"> | ||
<h3 className="about__content-column-title">New to p5.js?</h3> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/examples/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Examples</a> | ||
</p> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/tutorials/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Tutorials</a> | ||
</p> | ||
</div> | ||
<div className="about__content-column"> | ||
<h3 className="about__content-column-title">Resources</h3> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/libraries/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Libraries</a> | ||
</p> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/reference/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Reference</a> | ||
</p> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://forum.processing.org/two/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Forum</a> | ||
</p> | ||
</div> | ||
</div> | ||
<div className="about__footer"> | ||
<p className="about__footer-list"> | ||
<a | ||
href="https://github.com/processing/p5.js-web-editor" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>Contribute</a> | ||
</p> | ||
<p className="about__footer-list"> | ||
<a | ||
href="https://github.com/processing/p5.js-web-editor/issues/new" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>Report a bug</a> | ||
</p> | ||
<p className="about__footer-list"> | ||
<a | ||
href="https://twitter.com/p5xjs?lang=en" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>Twitter</a> | ||
</p> | ||
<button className="about__ok-button" onClick={this.closeAboutModal}>OK!</button> | ||
</div> | ||
</section> | ||
); | ||
} | ||
function About(props) { | ||
return ( | ||
<div className="about__content"> | ||
<div className="about__content-column"> | ||
<InlineSVG className="about__logo" src={squareLogoUrl} alt="p5js Square Logo" /> | ||
<p className="about__play-video"> | ||
<a | ||
href="http://hello.p5js.org/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__play-video-button" src={playUrl} alt="Play Hello Video" /> | ||
Play hello! video</a> | ||
</p> | ||
</div> | ||
<div className="about__content-column"> | ||
<h3 className="about__content-column-title">New to p5.js?</h3> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/examples/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Examples</a> | ||
</p> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/tutorials/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Tutorials</a> | ||
</p> | ||
</div> | ||
<div className="about__content-column"> | ||
<h3 className="about__content-column-title">Resources</h3> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/libraries/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Libraries</a> | ||
</p> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://p5js.org/reference/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Reference</a> | ||
</p> | ||
<p className="about__content-column-list"> | ||
<a | ||
href="https://forum.processing.org/two/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<InlineSVG className="about__content-column-asterisk" src={asteriskUrl} alt="p5 asterisk" /> | ||
Forum</a> | ||
</p> | ||
</div> | ||
<div className="about__footer"> | ||
<p className="about__footer-list"> | ||
<a | ||
href="https://github.com/processing/p5.js-web-editor" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>Contribute</a> | ||
</p> | ||
<p className="about__footer-list"> | ||
<a | ||
href="https://github.com/processing/p5.js-web-editor/issues/new" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>Report a bug</a> | ||
</p> | ||
<p className="about__footer-list"> | ||
<a | ||
href="https://twitter.com/p5xjs?lang=en" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
>Twitter</a> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
About.propTypes = { | ||
previousPath: PropTypes.string.isRequired | ||
}; | ||
|
||
export default About; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I think having different files would be good as I struggled a bit figuring out where new action constants should go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this file has gotten crazy, and can definitely be broken apart. Not sure if it would be better to put this in a folder called "constants" or maybe follow the "ducks" redux design pattern.