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.
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.
I have an idea for a cool backlog, thank you for pointing that out!
There was a problem hiding this comment.
@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.
| @@ -1,8 +1,26 @@ | |||
| import ResultCard from "@packages/components/ResultCard"; | |||
| import candidates from "src/data/data"; | |||
There was a problem hiding this comment.
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.
@Joel-leal please build this and mock until DAO level
There was a problem hiding this comment.
I am going to study this DAO-level topic and implement it.
| @@ -0,0 +1,50 @@ | |||
| "use client"; | |||
| 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.
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.
same issue for the shared components bellow
There was a problem hiding this comment.
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.
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.
this is so sad I wanna die 😢
Warning
I don't like shadcn
There was a problem hiding this comment.
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.
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.
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",
)
frattezi
left a comment
There was a problem hiding this comment.
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.
Is [rgba(0,0,0,0)] necessary? border-black wouldn't work?
| candidate, | ||
| vice, | ||
| party, | ||
| percentagem, |
| vice, | ||
| party, | ||
| percentagem, | ||
| votos, |
| <AvatarImage src={image} /> | ||
| </Avatar> | ||
| <div> | ||
| <p className="font-bold">Presidente: {candidate}</p> |
There was a problem hiding this comment.
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.
@Joel-leal please build this and mock until DAO level
fa56ccd to
adaa9d2
Compare
prisma/schema.prisma
Outdated
| datasource db { | ||
| provider = "postgresql" | ||
| url = env("DATABASE_URL") | ||
| url = "postgres://test:test@localhost:5432/test" |
There was a problem hiding this comment.
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