Merge branch 'ux' into 'master'

UX

See merge request !81
This commit is contained in:
Lucas 2017-06-05 19:17:50 +00:00
commit be8c84e0a9
6 changed files with 62 additions and 50 deletions

View File

@ -47,7 +47,7 @@ export default class DownloadButton extends React.PureComponent {
</MenuItem> </MenuItem>
</Dropdown.Menu> </Dropdown.Menu>
<Modal show={this.state.showModal} onHide={this.hideModal}> <Modal show={this.state.showModal} onHide={this.hideModal} dialogClassName="player-modal">
<Modal.Header closeButton> <Modal.Header closeButton>
<Modal.Title> <Modal.Title>
<i className="fa fa-globe"></i> <i className="fa fa-globe"></i>

View File

@ -1,41 +1,18 @@
import React from "react" import React from "react"
export default class Poster extends React.Component { export default function Poster(props) {
constructor(props) { const selected = props.selected ? " thumbnail-selected" : "";
super(props); const imgClass = "thumbnail" + selected;
} return (
shouldComponentUpdate(nextProps) { <div>
if (nextProps.index !== this.props.index) { return true } <div className="col-xs-12 col-sm-6 col-md-3 col-lg-2">
if (nextProps.selected !== this.props.selected) { return true } <a className={imgClass}>
if (nextProps.data.get("poster_url") !== this.props.data.get("poster_url")) { return true } <img
return false; src={props.data.get("poster_url")}
} onClick={props.onClick}
render() { />
const selected = this.props.selected ? " thumbnail-selected" : ""; </a>
const imgClass = "thumbnail" + selected;
const displayClearFixLg = (this.props.index % 6) === 0;
const displayClearFixMd = (this.props.index % 4) === 0;
const displayClearFixSm = (this.props.index % 2) === 0;
return (
<div>
{displayClearFixLg &&
<div className="clearfix visible-lg"></div>
}
{displayClearFixMd &&
<div className="clearfix visible-md"></div>
}
{displayClearFixSm &&
<div className="clearfix visible-sm"></div>
}
<div className="col-xs-12 col-sm-6 col-md-3 col-lg-2">
<a className={imgClass}>
<img
src={this.props.data.get("poster_url")}
onClick={this.props.onClick}
/>
</a>
</div>
</div> </div>
); </div>
} );
} }

View File

@ -131,14 +131,26 @@ class Posters extends React.PureComponent {
{this.props.elmts.toIndexedSeq().map(function(movie, index) { {this.props.elmts.toIndexedSeq().map(function(movie, index) {
const imdbId = movie.get("imdb_id"); const imdbId = movie.get("imdb_id");
const selected = (imdbId === this.props.selectedImdbId) ? true : false; const selected = (imdbId === this.props.selectedImdbId) ? true : false;
let clearFixes = [];
if ((index % 6) === 0) { clearFixes.push("clearfix visible-lg") };
if ((index % 4) === 0) { clearFixes.push("clearfix visible-md") };
if ((index % 2) === 0) { clearFixes.push("clearfix visible-sm") };
return ( return (
<Poster <div>
index={index} {clearFixes.length > 0 && clearFixes.map(function(el, i) {
data={movie} return (
key={imdbId} <div key={`${imdbId}-${i}`} className={el}></div>
selected={selected} );
onClick={() => this.props.onClick(imdbId)} })}
/> <Poster
data={movie}
key={imdbId}
selected={selected}
onClick={() => this.props.onClick(imdbId)}
/>
</div>
) )
} ,this)} } ,this)}
</InfiniteScroll> </InfiniteScroll>

View File

@ -2,14 +2,16 @@ import React from "react"
import { Nav, Navbar, NavItem, NavDropdown, MenuItem } from "react-bootstrap" import { Nav, Navbar, NavItem, NavDropdown, MenuItem } from "react-bootstrap"
import { LinkContainer } from "react-router-bootstrap" import { LinkContainer } from "react-router-bootstrap"
export default class NavBar extends React.PureComponent { export default class AppNavBar extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
userLoggedIn: (props.username !== ""), userLoggedIn: (props.username !== ""),
displayMoviesSearch: this.shouldDisplayMoviesSearch(props.router), displayMoviesSearch: this.shouldDisplayMoviesSearch(props.router),
displayShowsSearch: this.shouldDisplayShowsSearch(props.router), displayShowsSearch: this.shouldDisplayShowsSearch(props.router),
expanded: false,
}; };
this.setExpanded = this.setExpanded.bind(this);
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// Update the state based on the next props // Update the state based on the next props
@ -34,10 +36,14 @@ export default class NavBar extends React.PureComponent {
const location = router.getCurrentLocation().pathname; const location = router.getCurrentLocation().pathname;
return (location.indexOf(keyword) !== -1) return (location.indexOf(keyword) !== -1)
} }
setExpanded(value) {
if (this.state.expanded === value) { return }
this.setState({ expanded: value });
}
render() { render() {
return ( return (
<div> <div>
<Navbar fluid fixedTop collapseOnSelect> <Navbar fluid fixedTop collapseOnSelect expanded={this.state.expanded} onToggle={this.setExpanded}>
<Navbar.Header> <Navbar.Header>
<LinkContainer to="/"> <LinkContainer to="/">
<Navbar.Brand><a href="#">Canapé</a></Navbar.Brand> <Navbar.Brand><a href="#">Canapé</a></Navbar.Brand>
@ -63,6 +69,7 @@ export default class NavBar extends React.PureComponent {
placeholder="Search movies" placeholder="Search movies"
router={this.props.router} router={this.props.router}
path='/movies/search' path='/movies/search'
setExpanded={this.setExpanded}
/> />
} }
{(this.state.displayShowsSearch && this.state.userLoggedIn) && {(this.state.displayShowsSearch && this.state.userLoggedIn) &&
@ -70,6 +77,7 @@ export default class NavBar extends React.PureComponent {
placeholder="Search shows" placeholder="Search shows"
router={this.props.router} router={this.props.router}
path='/shows/search' path='/shows/search'
setExpanded={this.setExpanded}
/> />
} }
</Navbar.Collapse> </Navbar.Collapse>
@ -86,6 +94,7 @@ class Search extends React.Component {
} }
handleSearch(ev) { handleSearch(ev) {
ev.preventDefault(); ev.preventDefault();
this.props.setExpanded(false);
this.props.router.push(`${this.props.path}/${encodeURI(this.input.value)}`); this.props.router.push(`${this.props.path}/${encodeURI(this.input.value)}`);
} }
render() { render() {

View File

@ -36,7 +36,11 @@ class AddTorrent extends React.PureComponent {
handleChange(event) { handleChange(event) {
this.setState({ url: event.target.value }); this.setState({ url: event.target.value });
} }
handleSubmit() { handleSubmit(ev) {
if (ev) {
ev.preventDefault();
}
if (this.state.url === "") { if (this.state.url === "") {
return; return;
} }

View File

@ -8,8 +8,14 @@ body {
} }
.thumbnail-selected { .thumbnail-selected {
border-color: @brand-primary; transition: border 400ms ease-in-out;
background-color: @brand-primary; animation-name: select-thumbnail;
animation-duration: 400ms;
animation-fill-mode: forwards;
}
@keyframes select-thumbnail {
0% { background-color: @gray-light; }
100% { background-color: @brand-primary; }
} }
.clickable { .clickable {
@ -65,3 +71,7 @@ div.sweet-alert > h2 {
display: inherit; display: inherit;
} }
} }
.player-modal {
width: 90%;
}