Skip to content

Commit

Permalink
Add WeeklySongListItem component
Browse files Browse the repository at this point in the history
  • Loading branch information
nhim175 committed Dec 2, 2018
1 parent dd4d977 commit fde9a24
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import WeeklySongListItem from './components/WeeklySongListItem';

class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
return <div className="App">
<WeeklySongListItem
order="01"
title="Em Không Thể"
singer="Tiên Tiên, Touliver"
viewCount={3000} />
</div>;
}
}

Expand Down
32 changes: 32 additions & 0 deletions src/components/WeeklySongListItem.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.WeeklySongListItem {
display: flex;
align-items: center;
width: 100%;
padding: 16px 10px;
box-sizing: border-box;
border-bottom: 1px solid #DDD;
font-family: Arial, sans-serif;
}

.WeeklySongListItem .order {
font-size: 20px;
width: 35px;
text-align: center;
}

.WeeklySongListItem .info {
flex: 1;
}

.WeeklySongListItem .title {
font-size: 14px;
margin-bottom: 6px;
margin-top: 0;
}

.WeeklySongListItem .singer,
.WeeklySongListItem .view-count {
font-size: 12px;
color: #888;
margin: 0;
}
32 changes: 32 additions & 0 deletions src/components/WeeklySongListItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

import './WeeklySongListItem.css';

class WeeklySongListItem extends Component {
render() {
const { order, title, singer, viewCount } = this.props;
return <div className="WeeklySongListItem">
<div className="order">{order}</div>
<div className="info">
<p className="title">{title}</p>
<p className="singer">{singer}</p>
</div>
<div className="view-count">{viewCount.toLocaleString()}</div>
</div>
}
}

WeeklySongListItem.defaultProps = {
viewCount: 0
};

WeeklySongListItem.propTypes = {
order: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
singer: PropTypes.string.isRequired,
/** View count */
viewCount: PropTypes.number
};

export default WeeklySongListItem;

0 comments on commit fde9a24

Please sign in to comment.