-
Notifications
You must be signed in to change notification settings - Fork 0
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
[ref] component result card #76
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
public/image/avatar1.png
Outdated
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.
For an example application, it's ok to put images in a git repo, but for real applications, we would need a storage service (block storage, S3, and others)
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 have an idea for a cool backlog, thank you for pointing that out!
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.
@Joel-leal for now. Remove the images from the repo, we don't want these assets here. Find some public image on the internet (use this https://picsum.photos/) and use it while our data is mocked please.
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.
ok!
@@ -1,8 +1,26 @@ | |||
import ResultCard from "@packages/components/ResultCard"; | |||
import candidates from "src/data/data"; |
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.
instead of getting the data directly, I'd create a DAO for candidates, abstracting the data access.
Therefore, when you switch your data source to a real DB, you won't need to change the data access interface
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.
agreed
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.
@Joel-leal please build this and mock until DAO level
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 am going to study this DAO-level topic and implement it.
@@ -0,0 +1,50 @@ | |||
"use client"; |
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.
why do we need this?
const AvatarFallback = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Fallback | ||
ref={ref} | ||
className={cn( | ||
"flex h-full w-full items-center justify-center rounded-full bg-muted", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; |
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 personally found this code kind of ugly, code :(
Maybe we can use something like: https://www.npmjs.com/package/tailwind-styled-components
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.
same issue for the shared components bellow
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.
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.
That's what shadcn components looks like. Then maybe choose something else? or just create the components from scratch?
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.
Exactly, this is also code that we're not suposed to maintain, as zenha mentioned, this is shadcn's component, I don't see value on re-writing it.
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.
this is so sad I wanna die 😢
Warning
I don't like shadcn
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.
Let me explain better my POV:
How can we see a displayName
and think this is ok?
We intended to share some styles, but instead we created forwardRef
components that feature complex and poorly readable types, utilizing spread operators - all of that do add some custom CSS 🤯
In my opinion, this code is challenging to maintain because it requires a deep understanding of the need for forwardRef
to customize shadcn components - not easy for a fresh junior or a 5y person to maintain
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.
If you guys are saying that this is the shadcn way, I won't block this PR, BUT still ugly as hell
Let's at least create a wrapper to hide this ugliness
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.
Suggested style wrapper WithStyles
:
const AvatarFallback = React.forwardRef< | |
React.ElementRef<typeof AvatarPrimitive.Fallback>, | |
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | |
>(({ className, ...props }, ref) => ( | |
<AvatarPrimitive.Fallback | |
ref={ref} | |
className={cn( | |
"flex h-full w-full items-center justify-center rounded-full bg-muted", | |
className, | |
)} | |
{...props} | |
/> | |
)); | |
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; | |
function WithStyles(ShadcnElement, styles) { | |
const CustomComponent = React.forwardRef< | |
React.ElementRef<typeof ShadcnElement>, | |
React.ComponentPropsWithoutRef<typeof ShadcnElement> | |
>(({ className, ...props }, ref) => ( | |
<ShadcnElement | |
ref={ref} | |
className={cn(styles, className)} | |
{...props} | |
/> | |
)); | |
CustomComponent.displayName = ShadcnElement.displayName; | |
return CustomComponent; | |
} |
Then you can do something like
const AvatarFallback = WithStyles(
AvatarPrimitive.Fallback,
"flex h-full w-full items-center justify-center rounded-full bg-muted",
)
const Avatar = WithStyles(
AvatarPrimitive.Root,
"flex h-full w-full items-center justify-center rounded-full bg-muted",
)
const AvatarImage = WithStyles(
AvatarPrimitive.Image,
"flex h-full w-full items-center justify-center rounded-full bg-muted",
)
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.
Great work my friend! Added some comments alongside with the guys! Let me know if you need any help
image, | ||
}: ElectionResult) { | ||
return ( | ||
<Card className="flex flex-row w-[60vw] p-4 shadow-md shadow-gray-200 border-[rgba(0,0,0,0)]"> |
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.
Is [rgba(0,0,0,0)] necessary? border-black wouldn't work?
candidate, | ||
vice, | ||
party, | ||
percentagem, |
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.
Variable in portuguese
vice, | ||
party, | ||
percentagem, | ||
votos, |
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.
same as above
<AvatarImage src={image} /> | ||
</Avatar> | ||
<div> | ||
<p className="font-bold">Presidente: {candidate}</p> |
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.
It's ok to have portuguese on the text displayed to the user (we can enhance that with internationalization) but code and variables, always in colonizador language
@@ -1,8 +1,26 @@ | |||
import ResultCard from "@packages/components/ResultCard"; | |||
import candidates from "src/data/data"; |
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.
@Joel-leal please build this and mock until DAO level
fa56ccd
to
adaa9d2
Compare
prisma/schema.prisma
Outdated
@@ -4,7 +4,7 @@ generator client { | |||
|
|||
datasource db { | |||
provider = "postgresql" | |||
url = env("DATABASE_URL") | |||
url = "postgres://test:test@localhost:5432/test" |
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.
(╯°□°)╯︵ ┻━┻ 💥
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.
There is a bug that we still don't understand, but there is a local error that doesn't accept this reference. However, on the remote side, it is accepted. I will push it corrected, and then I will investigate again to find out what might be causing it. Another sticker unlocked!
Description
Result card component created and rendered on the results page.
Changes
Board issue