-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/motion' into develop
- Loading branch information
Showing
13 changed files
with
147 additions
and
85 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,75 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import ReactList from 'react-list'; | ||
import { Motion, spring } from 'react-motion'; | ||
import styles from './PlayList.scss'; | ||
|
||
export default class PlayList extends Component { | ||
static propTypes = { | ||
playList: PropTypes.array.isRequired, | ||
onJump: PropTypes.func.isRequired, | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { expand: false }; | ||
} | ||
|
||
handleCollapse = () => { | ||
this.setState({ expand: !this.state.expand }); | ||
} | ||
|
||
renderSongName = (index, key) => { | ||
const renderSong = this.props.playList[index]; | ||
|
||
return ( | ||
<div className="songItem" key={key} onClick={this.props.onJump(renderSong)} > | ||
{`${index + 1}. ${renderSong.name} - ${renderSong.artist}`} | ||
</div> | ||
); | ||
} | ||
|
||
renderContent = (expand, playList) => ({ top }) => { | ||
const contentStyle = { | ||
top: `${top}rem` | ||
}; | ||
|
||
return ( | ||
<div className={styles.playList} style={contentStyle}> | ||
<div className="listPanel"> | ||
<ReactList | ||
itemRenderer={this.renderSongName} | ||
length={playList.length} | ||
updateWhenThisValueChanges={playList} | ||
/> | ||
</div> | ||
<div className="indicator" onClick={this.handleCollapse} > | ||
<i className="material-icons" > | ||
{ expand ? 'eject' : 'play_for_work' } | ||
</i> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
renderStyles = (expand) => { | ||
const defaultStyle = { | ||
top: spring(-20, { damping: 14, stiffness: 120 }), | ||
}; | ||
const motionStyle = { | ||
top: spring(0, { damping: 14 }) | ||
}; | ||
|
||
return expand ? motionStyle : defaultStyle; | ||
} | ||
|
||
render() { | ||
const { playList } = this.props; | ||
const { expand } = this.state; | ||
return ( | ||
<Motion style={this.renderStyles(expand)}> | ||
{this.renderContent(expand, playList)} | ||
</Motion> | ||
); | ||
} | ||
} |
This file contains 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,47 @@ | ||
.playList { | ||
position: fixed; | ||
left: 0; | ||
top: -20rem; | ||
width: 100%; | ||
height: 20rem; | ||
background: rgba(255, 255, 255, 0.8); | ||
box-shadow: 0px 1px 3px #CCC; | ||
|
||
:global { | ||
.listPanel { | ||
max-height: 18rem; | ||
overflow: auto; | ||
|
||
.songItem { | ||
font-size: 0.8rem; | ||
border: 0.1rem #CCC solid; | ||
padding: 1rem 0.5rem; | ||
margin: 0.4rem 0.8rem; | ||
color: #9b9b9b; | ||
font-weight: bold; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
background: #ceecd2; | ||
color: #4a4a4a; | ||
transition: .5s; | ||
} | ||
} | ||
} | ||
.indicator { | ||
position: absolute; | ||
left: 50%; | ||
bottom: 0; | ||
width: 2rem; | ||
height: 2rem; | ||
background: #6bbd7a; | ||
text-align: center; | ||
line-height: 3rem; | ||
border-radius: 100%; | ||
color: white; | ||
transform: translate(-50%, 50%); | ||
box-shadow: 0px 1px 3px #CCC; | ||
cursor: pointer; | ||
} | ||
} | ||
} |
This file contains 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 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 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 +1,2 @@ | ||
export Player from './Player/Player'; | ||
export PlayList from './PlayList/PlayList'; |
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
@extend %flexbox; | ||
height: 3.5rem; | ||
padding: 0.6rem; | ||
margin-top: 1rem; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
|