Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment component #55

Open
wants to merge 6 commits into
base: B_master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/components/Comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import Avatar from '@mui/material/Avatar';
import "./comment.css";
import propTypes from 'prop-types';

function Comment({userName, text, creationDate, imgUrl}) {

const day = creationDate.getDate();
const month = creationDate.getMonth() + 1;
const year = creationDate.getFullYear();
const h = creationDate.getHours();
const m = creationDate.getMinutes();

return (
<>
<div className='wrapper'>
<Avatar alt='zdj' src={imgUrl} />
<div>
<div className='wrapper'>
<p className='user'>{userName}</p>
<p className='text'>{text}</p>
</div>
<p className='date'>{`${day}-${month}-${year} ${h}h ${m}min`}</p>
</div>
</div>
</>
);
}

Comment.propTypes = {
userName: propTypes.string,
text: propTypes.string,
creationDate: propTypes.instanceOf(Date),
imgUrl: propTypes.string
}

export default Comment;
25 changes: 25 additions & 0 deletions src/components/comment.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.user {
font-weight: bold;
}

.wrapper {
display: flex;
align-items: center;
}

.text {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

p {
padding-left: 0.6rem;
margin-bottom: 0;
margin-top: 0;
}

.date {
color: gray;
}
Binary file added src/images/dog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.