Skip to content

Commit

Permalink
rating (#67)
Browse files Browse the repository at this point in the history
close #65
  • Loading branch information
ThuTinh committed Jan 5, 2020
1 parent a9598dd commit 14ba07c
Show file tree
Hide file tree
Showing 10 changed files with 455 additions and 34 deletions.
Binary file modified src/assets/parking.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 31 additions & 15 deletions src/components/BodyHomeDetail/index.js
@@ -1,8 +1,10 @@
/* eslint-disable jsx-a11y/accessible-emoji */
/* eslint-disable react/destructuring-assignment */
import React from 'react';
import { Grid, Box } from '@material-ui/core';
import Grow from '@material-ui/core/Grow';
import RoomIcon from '@material-ui/icons/Room';
import withWidth from '@material-ui/core/withWidth';
import SmallRoomItem from '../SmallRoomItem';
import { ReservationForm, DescriptionHomeDetail, InformationUserForm } from '../index';
import './style.css';
Expand All @@ -19,23 +21,37 @@ function BodyHomedetail() {
<Grid container spacing={2}>
<Grid item md={8} sm={8} xs={12}>
<div style={{ marginBottom: '15px' }}>
<Grid container direction="row" justify="space-between" alignItems="center">
<Box fontSize={25} fontWeight={600}>
Homestay Ngọc Nữ
</Box>
<Box fontSize={20} fontWeight={600}>
<span
style={{ textDecoration: 'line-through', marginRight: '10px', fontWeight: '400' }}
<Grid container>
<Grid item md={7} xs={12}>
<Box fontSize={25} fontWeight={600}>
DANA COZY⭐️HOMESTAY NGUYÊN CĂN GIÁ RẺ TẠI ĐÀ NẴNG
</Box>
</Grid>
<Grid item md={5} xs={12}>
<div
style={{
display: 'flex',
justifyContent: 'flex-end',
}}
>
1.500k/đêm
</span>
<span>1.235k/đêm</span>
</Box>
<Box fontSize={18} fontWeight={600}>
<span
style={{
textDecoration: 'line-through',
marginRight: '10px',
fontWeight: '400',
}}
>
1.500k/đêm
</span>
<span>1.235k/đêm</span>
</Box>
</div>
</Grid>
</Grid>

<Box style={{ display: 'flex' }}>
<Box style={{ display: 'flex', marginTop: '15px' }}>
<Box>
<RoomIcon style={{ fontSize: '18px', color: 'rgba(253, 136, 156, 1)' }} />
<RoomIcon style={{ fontSize: '22px', color: 'rgba(253, 136, 156, 1)' }} />
</Box>

<Box>Lâm Đồng, Đà Lạt</Box>
Expand Down Expand Up @@ -102,4 +118,4 @@ function BodyHomedetail() {
);
}

export default BodyHomedetail;
export default withWidth()(BodyHomedetail);
85 changes: 85 additions & 0 deletions src/components/CommentReview/index.js
@@ -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);
27 changes: 27 additions & 0 deletions src/components/CommentReview/style.css
@@ -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) {
}
92 changes: 92 additions & 0 deletions src/components/CommentReviews/index.js
@@ -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;
9 changes: 9 additions & 0 deletions src/components/CommentReviews/style.css
@@ -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;
}

0 comments on commit 14ba07c

Please sign in to comment.