-
Notifications
You must be signed in to change notification settings - Fork 10
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
Challenge tabs #90
base: main
Are you sure you want to change the base?
Challenge tabs #90
Changes from 4 commits
1e841a5
14b30be
1be63b8
f86e7dd
aada9cc
f9f77f4
5cb02e5
1c9dd6a
63afbfc
275a3a6
423999f
a277544
8140d41
a9b9d3a
ec678c3
ebb4cc9
ae61fe4
2d476a0
0f1a795
acbb1a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { Comment } from '../../../types/types'; | ||
import { ReactComponent as Reply } from '/components/icons/reply.svg'; | ||
import { ReactComponent as Liked } from '/components/icons/liked.svg'; | ||
import { getTimeDiffFromTimestamp } from 'utils/timeDifference/getTimeDiffFromTimestamp'; | ||
import { UserAvatar } from 'molecules/userAvatar/userAvatar'; | ||
|
||
type CommentItemWithReplyProps = Comment; | ||
|
||
export const CommentReply = ({ | ||
avatar, | ||
author, | ||
timestamp, | ||
comment, | ||
}: CommentItemWithReplyProps) => { | ||
// TODO: Add reply functionality | ||
return ( | ||
<> | ||
<hr className="my-2 ml-16 border-gray-200" /> | ||
<div className="flex flex-row pt-1 md-10 md:ml-16"> | ||
<UserAvatar avatar={avatar} size={12} /> | ||
<div className="flex-col mt-1"> | ||
<div className="flex items-center flex-1 px-4 font-bold leading-tight"> | ||
{author} | ||
<span className="ml-2 text-xs font-normal text-gray-500"> | ||
{getTimeDiffFromTimestamp(timestamp)} | ||
</span> | ||
</div> | ||
<div className="flex-1 px-2 ml-2 text-sm font-medium leading-loose text-gray-600"> | ||
{comment} | ||
</div> | ||
<button className="inline-flex items-center px-1 pt-2 ml-1 flex-column"> | ||
<div className="w-5 h-5"> | ||
<Reply /> | ||
</div> | ||
</button> | ||
<button className="inline-flex items-center px-1 -ml-1 flex-column"> | ||
<div className="w-5 h-5"> | ||
<Liked /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This buttons with icons are a good candidate for a separate component as well ;) |
||
</div> | ||
</button> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,25 @@ import type { Opinion } from '../../../types/types'; | |
|
||
export const opinions: Opinion[] = [ | ||
{ | ||
author: 'Jan Kowalski', | ||
author: 'Adam Nowak', | ||
avatar: | ||
'https://images.unsplash.com/photo-1633332755192-727a05c4013d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2960&q=80', | ||
rating: 5, | ||
comment: | ||
'Zadanie programistyczne, które otrzymałem, było dobrze sformułowane i precyzyjnie opisywało wymagania dotyczące tworzenia aplikacji internetowej. Zadanie miało na celu zaimplementowanie funkcjonalności wyszukiwania produktów w bazie danych i wyświetlenia wyników na stronie internetowej.', | ||
}, | ||
{ | ||
author: 'Jan Kowalski', | ||
author: 'Maria Wójcik', | ||
avatar: | ||
'https://images.unsplash.com/photo-1633332755192-727a05c4013d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2960&q=80', | ||
'https://images.unsplash.com/photo-1509839862600-309617c3201e?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80', | ||
rating: 5, | ||
comment: | ||
'Zadanie programistyczne, które otrzymałem, było dobrze sformułowane i precyzyjnie opisywało wymagania dotyczące tworzenia aplikacji internetowej. Zadanie miało na celu zaimplementowanie funkcjonalności wyszukiwania produktów w bazie danych i wyświetlenia wyników na stronie internetowej.', | ||
}, | ||
{ | ||
author: 'Jan Kowalski', | ||
author: 'Piotr Kowalczyk', | ||
avatar: | ||
'https://images.unsplash.com/photo-1633332755192-727a05c4013d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2960&q=80', | ||
'https://images.unsplash.com/photo-1556157382-97eda2d62296?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80', | ||
rating: 4, | ||
comment: | ||
'Zadanie programistyczne, które otrzymałem, było dobrze sformułowane i precyzyjnie opisywało wymagania dotyczące tworzenia aplikacji internetowej. Zadanie miało na celu zaimplementowanie funkcjonalności wyszukiwania produktów w bazie danych i wyświetlenia wyników na stronie internetowej.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is mock data but it would be cool to see some variety and how it looks and behaves with different lengths of the comments. 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User can't give negative or above 5 rating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any validation for that on the backend? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think not now |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { Card, Heading } from 'ui'; | ||
import type { Opinion } from '../../../types/types'; | ||
import { OpinionPolishPlurals } from 'molecules/opinonStats/opinionStats.utils'; | ||
import { opinionPolishPlurals } from 'molecules/opinonStats/opinionStats.utils'; | ||
|
||
type OpinionStatsProps = { | ||
opinions: Opinion[]; | ||
|
@@ -69,7 +69,7 @@ export const OpinionStats = ({ opinions }: OpinionStatsProps) => { | |
<p className="ml-2 text-sm font-medium">4.95 / 5</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calculate the average, based on the opinions. And map it to display the stars instead of copying them. |
||
</div> | ||
<p className="text-sm font-medium text-gray-500 dark:text-gray-400"> | ||
{OpinionPolishPlurals(opinions.length)} | ||
{opinionPolishPlurals(opinions.length)} | ||
</p> | ||
</div> | ||
</Card> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Image from 'next/image'; | ||
import clsx from 'clsx'; | ||
|
||
type CommentUserAvatarProps = { | ||
avatar: string; | ||
size?: number; | ||
}; | ||
|
||
export const UserAvatar = ({ avatar, size = 24 }: CommentUserAvatarProps) => { | ||
const sizeClass = `w-${size} h-${size}`; | ||
return ( | ||
<Image | ||
alt="" | ||
src={avatar} | ||
ssynowiec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
width={1000} | ||
height={1000} | ||
className={clsx( | ||
'object-cover border-2 border-gray-300 rounded-full', | ||
sizeClass, | ||
)} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make a
comment: Comment
prop accepting an object. No need for spreading then and you have everything contained in one objectThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but you neeed to destructure it later or write redundant object prop calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather have a param destructurization than something like that tbh.
As for now the
CommentItemProps
is redundant as the props could be directly typed asComment
.I used to spread props but over the time I learned in most of the cases it is better to explicitly pass props. There are some exceptions ofc (for example
register
function for form libs)