generated from cuongndc/react-boilerplate
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #65
- Loading branch information
Showing
10 changed files
with
455 additions
and
34 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,85 @@ | ||
/* eslint-disable no-plusplus */ | ||
/* eslint-disable react/jsx-no-duplicate-props */ | ||
/* eslint-disable react/destructuring-assignment */ | ||
import React from 'react'; | ||
import { Grid } from '@material-ui/core'; | ||
import StarIcon from '@material-ui/icons/Star'; | ||
import withWidth from '@material-ui/core/withWidth'; | ||
|
||
import './style.css'; | ||
|
||
function CommentReview(props) { | ||
const RenderRating = () => { | ||
// eslint-disable-next-line prefer-const | ||
let result = []; | ||
for (let i = 1; i <= props.rating; i++) { | ||
result.push( | ||
<div key={i}> | ||
<StarIcon style={{ fontSize: '18px', color: '#FF9EB5' }} /> | ||
</div>, | ||
); | ||
} | ||
for (let j = props.rating + 1; j <= 5; j++) { | ||
result.push( | ||
<div key={j}> | ||
<StarIcon style={{ fontSize: '18px', color: 'rgba(150, 150, 150, 0.2)' }} /> | ||
</div>, | ||
); | ||
} | ||
return result; | ||
}; | ||
|
||
return ( | ||
<Grid container className="container-comment-review"> | ||
<Grid item md={1} xs={2}> | ||
<div className="container-avatar"> | ||
<img | ||
src={props.avatar} | ||
alt="img" | ||
style={{ width: '100%', height: '100%', borderRadius: '50%' }} | ||
/> | ||
</div> | ||
</Grid> | ||
<Grid item md={11} xs={10}> | ||
<div className="container-content-comment"> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
display: props.width === 'xs' ? 'block' : 'flex', | ||
alignItems: 'center', | ||
}} | ||
> | ||
{console.log('klaka', props.width)} | ||
<div> | ||
<h6 | ||
style={{ | ||
fontSize: '16px', | ||
color: '#000000', | ||
fontWeight: 'bold', | ||
marginRight: '15px', | ||
}} | ||
> | ||
{props.name} | ||
</h6> | ||
</div> | ||
<div style={{ display: 'flex', alignItems: 'center' }}> | ||
<RenderRating /> | ||
</div> | ||
</div> | ||
<div style={{ marginLeft: props.width === 'xs' ? '0px' : '40px' }}> | ||
<small>{props.minutes} phút</small> | ||
</div> | ||
</div> | ||
<div style={{ fontSize: '16px', fontWeight: '300px' }}>{props.message}</div> | ||
</div> | ||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default withWidth()(CommentReview); |
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,27 @@ | ||
.container-content-comment { | ||
background: #f0f2f5; | ||
border-radius: 10px; | ||
width: fit-content; | ||
min-width: 200px; | ||
padding:15px | ||
} | ||
|
||
.container-avatar{ | ||
width: 50px; | ||
height: 50px; | ||
border-radius: 50%; | ||
} | ||
|
||
.container-comment-review{ | ||
margin: 20px 0; | ||
} | ||
|
||
@media (max-width: 375px) { | ||
.container-avatar{ | ||
width: 38px !important; | ||
height: 38px !important; | ||
} | ||
} | ||
|
||
@media (min-width: 376px) and (max-width: 767px) { | ||
} |
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,92 @@ | ||
/* eslint-disable react/button-has-type */ | ||
/* eslint-disable react/no-array-index-key */ | ||
/* eslint-disable no-underscore-dangle */ | ||
/* eslint-disable array-callback-return */ | ||
/* eslint-disable no-shadow */ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable react/destructuring-assignment */ | ||
import React, { useState } from 'react'; | ||
import { CommentReview } from '../index'; | ||
|
||
import './style.css'; | ||
|
||
function CommentReviews() { | ||
const data = [ | ||
{ | ||
id: 1, | ||
avatar: | ||
'https://images.unsplash.com/photo-1506901437675-cde80ff9c746?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80', | ||
name: 'Lâm Trần', | ||
message: 'Phòng rộng quá. Giá cả hợp lý, chất lượng, phục vụ tốt', | ||
minutes: 40, | ||
rating: 5, | ||
}, | ||
{ | ||
id: 2, | ||
avatar: | ||
'https://images.unsplash.com/photo-1567131308523-383d0fea9671?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60', | ||
name: 'Thư Nguyễn', | ||
message: 'Giá cũng ổn, lễ này triển ngay', | ||
|
||
minutes: 10, | ||
rating: 3, | ||
}, | ||
{ | ||
id: 3, | ||
avatar: | ||
'https://images.unsplash.com/photo-1506901437675-cde80ff9c746?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80', | ||
name: 'Thanh Thảo', | ||
message: 'Cảnh đẹp, chủ nhà thân thiện', | ||
|
||
minutes: 19, | ||
rating: 4, | ||
}, | ||
{ | ||
id: 4, | ||
avatar: | ||
'https://images.unsplash.com/photo-1506901437675-cde80ff9c746?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80', | ||
name: 'Ngọc Mẫn', | ||
message: 'Nói chung là rất tốt, mà chủ nhà xấu trai quá nên cho 3 sao', | ||
minutes: 25, | ||
rating: 3, | ||
}, | ||
{ | ||
id: 5, | ||
avatar: | ||
'https://images.unsplash.com/photo-1506901437675-cde80ff9c746?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80', | ||
name: 'Linh Lan', | ||
message: 'Không có gì để chê cả', | ||
minutes: 10, | ||
rating: 5, | ||
}, | ||
]; | ||
|
||
const RenderComments = () => { | ||
let result = []; | ||
if (data.length > 0) { | ||
result = data.map((item, index) => { | ||
return ( | ||
<CommentReview | ||
key={index} | ||
name={item.name} | ||
message={item.message} | ||
minutes={item.minutes} | ||
avatar={item.avatar} | ||
rating={item.rating} | ||
/> | ||
); | ||
}); | ||
} | ||
return result; | ||
}; | ||
return ( | ||
<> | ||
<RenderComments /> | ||
<button type="button" className="button-xemthem"> | ||
XEM THÊM | ||
</button> | ||
</> | ||
); | ||
} | ||
|
||
export default CommentReviews; |
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,9 @@ | ||
.button-xemthem { | ||
padding: 6px 0; | ||
text-align: center; | ||
color: #ffffff; | ||
background-color: #fc6c85; | ||
border: 0.5px solid #fc6c85; | ||
width: 100%; | ||
border-radius: 5px; | ||
} |
Oops, something went wrong.