Next.js Discord

Discord Forum

I need a bit of help with programming some visual elements for my User Profile UI

Answered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
Hey, I have a user profile card in which I have 2 sections:

- Work History
- Education History

1. For the most recent entry in both of those sections I'd like the code to spawn a line segment element which looks like a corner. For this segment there's a few spawning rules that the code needs to follow:

- The horizontal line of the corner should be vertically centred to the middle of the height of the text row, and its starting position should be to the horizontal middle of the length of the Icon of the Section Title, basically if the icon is 24px by 24px, the horizontal line should start from the 12px point and expand for another 12px, basically for half of the length of the icon.

- The vertical line should start from the same position as the horizontal line, and it should expand down until between it and the logo element there's a spacing of a fixed value, which can be set, such as 2px, 6px or whatnot.

For the logo element, it should be spawned next to the row that contains the company name and it should have a fixed size which can be set, such as 16x16px for example.

2. For the rest of the entries of each of the sections, instead of spawning a corner element we would instead spawn a circle element with a fixed radius which will be horizontally centred to the middle of the logo (since both would be the same size anyway)

In between these circles there would be additional line segments added, with a fixed spacing between them and the circle elements / company logos. The length of these lines needs to be adaptive, in the sense that if the spacing between rows is changed, the spawned segments should grow or shrink in size automatically.

For the last entry in either section, bellow the logo element no line should be spawned.

This is my code for the User Profile Card component:
https://paste.ec/paste/r9icuqTT#9p41hcde2ibUKNEtrWOl0sgA1j9AEY7TZ9GsEsp+Ojw
Answered by Anay-208
There'll be basically 3 if conditions for each item
View full answer

391 Replies

Well, For horizontal lines, You can use horizontal hr, and check if its the first item
an {index === 1 || index === arr.length - 1 ? <Horizontal/> : <Dot/> }
and if you ask for some vertical line disappearing, the dot could have a background
Sun bearOP
The last entry in the list would have no vertical line spawned bellow the logo basically.
Yes, that can also be achieved by an if condition easily
There'll be basically 3 if conditions for each item
Answer
For The horizontal line/Dot, vertical line 1, vertical line 2
If you want, I can provide you a github repo tomorrow
@Anay-208 If you want, I can provide you a github repo tomorrow
Sun bearOP
That would be awesome, cause I think this is going to be quite complex to implement.

You could add some placeholders for the text:
- Job Date
- Job Title
- Company Name
- Job Location
- Job Schedule

And then add the code for the segments. Also it needs to work like if you increase the size between the placeholders, as in the vertical spacing, the lines should adapt to that automatically (if possible), so basically they should go or shrink in size until they meet the spacing between them and the net vertical element.

Theoretically that should be possible if the Job Date text in each entry can be made to act as an anchor point, and I think the company logo can be its own anchor to in combination with the Company Name text cause the company logo should always spawn in relation to that, just like the segments do for the Job Date row, and since there would need to be vertical space between the circle and the line segments and between the logo and the line segments that should be possible to set-up programatically.

Let me know if you can make it to work like that 😁
@Sun bear Within 2 days, I'll surely try to do that.

For now, I'll use placeholders only.

I'll adjust everything accordingly.
Sun bearOP
That sounds awesome. The reason why I'd really like the segment lines to automatically grow/shrink is because I may need to play around with the spacing between the rows or between each entry, and if the segments don't adapt automatically but have fixed sizes, then I'd have to manually change their size and it would be pretty cumbersome to do that everytime I may make changes to the spacing between stuff.

Also I think I over complicated my explanation a bit. As long as the circle elements for example always spawn on the same row or next to the Job Date, and there is a fixed spacing of let's say 2px between the circle and the segments bellow and above it, the lines should automatically grow or shrink in size.
Cause if the line knows that between it and the logo elements it needs to be a vertical spacing of 2px, and between it and the circle elements needs to be a vertical spacing of 2px then if the spacing between the text rows would change the line would simply grow or shrink until it meets that 2px vertical spacing value.
Hey there,
I just want to tell you that, I'll just give you an example of how its exactly gonna work.

So you might have to do some optimizations yourself.

If you're unable to do, you're free to ask!
Sun bearOP
No worries, that helps too. Also if it's going to be too difficult to do just let me know and I'll try to do it by myself 😁
I'll try doing it by myself anyway in the meantime, so if I manage to do it in the meantime I'll let you know.
@Anay-208 Yes, that can also be achieved by an if condition easily
You can surely try this. I'd recommend you to try it yourself.

And anyways, I'll be getting free to do this tomorrow only, so you can let me know if you're done or not
Sun bearOP
I managed to add the circle elements and center them but Claude has issues with placing the company logo squares like the circles. I'm not sure what I need to update in the code for that to happen.
Array.from({ length: numJobHistoryEntries }).map((_, index) => (
                <div key={index} style={{ marginBottom: '20px', display: 'flex', alignItems: 'flex-start' }}>
                  <span style={{ fontSize: '12px', verticalAlign: 'middle', marginRight: '14px' }}>&#9675;</span>
                  <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
                    <p style={{ color: 'var(--text-default)', fontSize: '14px' }}>Job Date</p>
                    <p style={{ color: 'var(--text-default)', fontSize: '16px' }}>Job Title</p>
                    <div style={{ display: 'inline-flex', alignItems: 'center' }}>
                      <div style={{ width: '24px', height: '24px', backgroundColor: 'black', marginRight: '4px' }}></div>
                      <p style={{ color: 'var(--text-default)', fontSize: '14px' }}>Company Name</p>
                    </div>
                    <p style={{ color: 'var(--text-default)', fontSize: '14px' }}>Job Location</p>
                    <p style={{ color: 'var(--text-default)', fontSize: '14px' }}>Job Schedule</p>
                  </div>
                </div>
              ))
            )}
          </div>
          <div style={{ marginLeft: 'auto' }}>
            <div style={{ display: 'flex', alignItems: 'center', marginBottom: '12px' }}>
Sun bearOP
@riský Claude says this should work as an independent page which can be imported in an empty project and it should work
can you give a demo url to try with tho (ie cf tunnel or vscode tunnel)
as im not the best css interperator without seeing whats happening and what you want
also why isnt there syntax highlighting 😭
(im too lazy to make new project with react-icons)
lol
Sun bearOP
lol
oh what i meant was vscode port forwarding not tunnel, sorry: https://code.visualstudio.com/docs/editor/port-forwarding
Sun bearOP
Let me know if it works please
@Sun bear Let me know if it works please
it wants me to login in to github, but then i do and its broken... is it "public"?
Sun bearOP
It's private
well only your github can view it then
public means anyone with link can, and you dont have link lasting long anyway
yay i see
now which page
Sun bearOP
The user profile page
You need to go to Jobs -> My Profle 😁
wow this site is quite decently featured
yeah i cant make account to go to section
@Anay-208 Click to see attachment
Sun bearOP
Hmm it may be because you're not logged in ?
I'm trying to log in
Sun bearOP
You can create an account @riský
thats how i got the error that anay showed
Sun bearOP
Wait, when did you see that error, when going to the sign-up page or on the last step ?
last step
Sun bearOP
Huh, I might've broken my sign-up, that's bad.
Uhh try signing up on the website in the meantime
idk if it made me the account, but your dev site didnt let me login
@riský idk if it made me the account, but your dev site didnt let me login
Sun bearOP
Let e check with the db
@riský idk if it made me the account, but your dev site didnt let me login
Sun bearOP
It did create your account
yay, it finally sent me an email !
Sun bearOP
What does it say ?
all it says is "invalid server actions request"
Sun bearOP
Wtf it worked just fine let me try on my side, give me a moment.
I'll create an account and try to log in
maybe vscode isnt as good as cloudflare and nextjs is getting sad with not localhost header?
cloudflare tunnels work so well i dont even realise im using it
Sun bearOP
I can't even log out of my localhost now
Because I deleted the account before logging out
😭
Sun bearOP
Give me a few minutes I'm trying to fix this mess and I'll update the website when things are fixed. I apologise, I had no idea about these issues. @riský @Anay-208
@Sun bear You can look into this. I'll work on my other projects, and will assist you in about 3 hours!
Sun bearOP
Sun bearOP
The issues should be fixed now, you should be able to sign-up and log-in on the website and also access the my profile page @riský @Anay-208
@Sun bear When Risky will get online, ping me and forward port. We both will help!
Sun bearOP
@riský are you available ?
oh uhh i was
if its quick then yeah
me about to sleep again, but it can wait
Sun bearOP
I'm just trying to move a square and add 2 lines @riský
It's just CSS
Or tailwind, whatever you prefer
lol what are you trying to do, i kinda couldnt work it out from queestion
Sun bearOP
Do you see those segments on the left ?
Like there's like a corner segment at the top
the company logo
then a circle
then it repeats
but the others don't have that corner, only the first entries have a corner segment
and the last entries don''t have a line under the logo
you can see the arrow points at an empty place
that's all I'm trying to do 😄
Now if you go to the website you can see how it currently looks like, I fixed the website.
I only managed to add the circles and the squares but the squares are misplaced
And I don't know how to move them properly to be like in my design
and add the rest of the elemnts
oh and rn you have this madness
@riský oh and rn you have this madness
Sun bearOP
Yes!
The black squares are basically placeholders for the company logos
I told Claude I don't want the squares like in the same group as the text
But it doesn't understand what I want
getting company icon was easy tho :) margin-inline-start: -29px;
you can use margin-left too, but i like to be fancy for not breaking for rtl
Sun bearOP
And how can I add the other lines ?
Like for the first entry it's not supposed to be a circle
also i dont think its 29px, i just did close enough
Sun bearOP
Yeah it's supposed to be 14px
I can open the port again if you can help me with this.
ngl css isnt fully what you need here, like for first, you should use code to work it out and do the diferent thing
Sun bearOP
So you think I should first take care of having it functional and not use placeholders ?
And then come back to these elements ?
you cant as simply make it a grid and use height of 100% because you are having many things change
i think your obsessing over kinda minor things rn, but also i do the same
also where did you get this picture from, did you make it in fancy thingy?
@riský also where did you get this picture from, did you make it in fancy thingy?
Sun bearOP
It's from my Prototype in Adobe XD
I have most of the website designed already that's what I started with before getting to programming 😁
so i dont really know, but can you make a grid/table for these sections and then for grey bar make it height:100% and hope it is nice (and for second part add bottom padding)
like from my experance, all elements in same row have the same height with table
and i think grid should be good like that too
@Sun bear I have most of the website designed already that's what I started with before getting to programming 😁
nice, i just try to do whatever and think to go back but then say good enough 😆
also for circle get an svg instead of that unicode char
@riský also for circle get an svg instead of that unicode char
Sun bearOP
I can look into react icons to see if they have that.
its just rending so horribly for me lol
Sun bearOP
oh that's noot good then, yes I need it to be crystal clear
And yeah svg is better cause I may need to increase its radius
somehow you have a way more chaotic setup then what i normally have on mine 😭
like the things that would work for me, are just breaking so... idk
@riský like the things that would work for me, are just breaking so... idk
Sun bearOP
What is breaking ?
I can try and fix it
like the css isnt acting how i would imagine
@riský like the css isnt acting how i would imagine
Sun bearOP
It could be because the UI is segmented into 2 separate parts ?
And I will have more parts cause I need to make one for the Education History too
And for my other sections
there i got close
Sun bearOP
Yes you did! 😮
here is the code after my messing of things, there is many comments, but you should be able to work out where it was and add images i think
this is prob better
come on why did firefox not be nice with formatting
@riský this is prob better
Sun bearOP
Yes that's a mess in terms of formatting lol
but i think you should be able to work out what i did with grids
i didnt delete your older things, and just copied ones
its so much nicer editing with tailwind, but i googled what the tailwind did and added inline lol
Sun bearOP
The only thing missing is the squares and the corner at the top
yeah, but i think this is a better start and you can work that part out
:)
Sun bearOP
Yes thank you I'll see if I can take it from here
yay!
i think the main things i did was add grid thingy and then make another div for circle and div for long pole
and move where the padding bottom from rooter div to the more nested one
Sun bearOP
I'm curious to see if Claude can apply that to my code
and you should tbh fix the double scrollboxes
@Sun bear I'm curious to see if Claude can apply that to my code
ngl im surprised you have even gotten anywhere with it
Sun bearOP
nicee
Sun bearOP
Okay it removed everything at the top lmao
But at least it was able to integrate your concept
Now i have to figure out how to add the other stuff back
oh lol add gap:10px per say to make them not so squished
you could use margin, but gap is way cooler
@riský and you should tbh fix the double scrollboxes
Sun bearOP
Now what do you mean by this ?
you prob use overflow auto, but there should be a way to use the main page scroll (or not have it, but having 2 is pain)
Sun bearOP
Normally there shouldn't be a main page scroll unless you're on mobile or tablet.
@riský oh lol add gap:10px per say to make them not so squished
and after this, you should be able to seperate the "job date" and "company name" part to its one grid group to include icon and still have 100%ness for line
i just made lots of history
Sun bearOP
Hmm, hold on, cause on my side that is not an issue.
That's how it's supposed to work on everyone's side, is it not the same on your side ?
make the "work history" have so many more elements
@riský i just made lots of history
Sun bearOP
Ohh I get it now! Let me try lol.
@riský make the "work history" have so many more elements
Sun bearOP
Oh I see! Now I have the same issue! 😄
hahah
Sun bearOP
Yes that's because I didn't do what I did for the Sidebar
Normally it should work like the sidebar
But I didn't get to test it until today 😄
if the scrol is self contained to that box, cool, but i just didnt like the double where i thought i was at end and then realised there was more
Sun bearOP
So I wasn't aware of this issue
also have you added the gap now?
and fixed the bottom padding of line to be consistent (idk why i made it 3px when top was only 1px ;()
@riský also have you added the gap now?
Sun bearOP
Hmm I didn't on which line do I need to add the gap exactly ?
one with grid
Sun bearOP
  <div style={{ display: 'grid', gridAutoRows: '1fr', gridAutoFlow: 'column' }}>
on you made it work with flex, nice?
@riský on you made it work with flex, nice?
Sun bearOP
Claude did 😁 I didn't tell it that lol
Nice
Sun bearOP
<div style={{ display: 'grid', gridAutoRows: '1fr', gridAutoFlow: 'column', gap: '10px' }}>
@riský on you made it work with flex, nice?
wait it is there, just nesting not accurate
Sun bearOP
Okay let me try
if you have grid or flex, you can use gap and its effectivly margin between them, but nicer
Sun bearOP
I added 14px
nice
Sun bearOP
Cause that's the same spacing between it and the left edge
So now it should be even spacing
to the left and right
now do you understand how to finish your remaining things :)
Sun bearOP
Well I'm not sure how to add the company logo (the square placeholder) next to the company name
and the corner for the first entry
excuse my drawing, but you split up the grids
and like how the circle is on top for first, you would put the company icon there
and then on the company div, you would have the margin bottom (or have another element under job scedule thats the height and empty)
Sun bearOP
Hold on I am noticing one issue, the spacing isn't even between the top and bottom of the circle, can you see that ?
Is it because I'm not using SVG ?
If you could show me please
the div is the line
Sun bearOP
I can only see 1fr
But not 3fr
3px != 1fr...
im talking about this
@riský 3px != 1fr...
Sun bearOP
If 3px is 1fr and there are 1fr elements then how does it look even when I change 3px to 1px ?
I'm confused lol 😁
the line is simple, margin top is 2px and the bottom is 3px... this isnt consistent and thus you can see the issues
Any updates about this issue?
@riský the line is simple, margin top is 2px and the bottom is 3px... this isnt consistent and thus you can see the issues
Sun bearOP
Oh I was looking at this I thought this was the top spacing!
That's why I was confused 😄
I highly recommend using [tailwind](https://tailwindcss.com/)
+1
so do you now think you can split up the jobs to the include image?
Sun bearOP
Hmm yes that's what I want to get to but the issue is things are not looking even now
So I made both top and bottom 2px right ?
yeah what does it look like now?
Sun bearOP
Like this
it looks like the top has more spacing for some reason
like 1px more
i mean you could make bottom less ig
Sun bearOP
Yes if I make it 1px it looks even
can you send shar link to whatever you have done tho
Sun bearOP
But why is that ?
i dont know what state of things your in
like its fine for my madness modifications
Sun bearOP
Yup give me a moment
-
you fixed it?
Sun bearOP
How ? It works on my side and it's the same code like on the website
me not know
Sun bearOP
It could be because your next js is out of date ?
I'm using the latest version
its your nextjs tho
Sun bearOP
That could be it
What's the command for updating ?
its not i dont think... i believe the issue is the host being broken (not claiming to be localhost, and then confusing the security feature or smth)
Sun bearOP
Ohh hold on, when I make the port, I only wrote 3000
Do I need to write the actual link ?
can you try to download cloudflare tunnels and try with that (it has worked with no issue there)
you need no account and its just cloudflared tunnel --url="localhost:3000"
@riský can you try to download cloudflare tunnels and try with that (it has worked with no issue there)
Sun bearOP
Sure thing, it could be an issue because I'm on mac or something
Now I'm confused whats going on here
hmm maybe, but i dont know how nextjs is being sad
could it also be supabase maybe?
@Anay-208 Now I'm confused whats going on here
Sun bearOP
Port forwarding doesn't work on Risky's side
just disable auth for that page :)
Why don't you run vercel and share us a production build, if local is not workin
yes thats a good idea
true
@riský can you try to download cloudflare tunnels and try with that (it has worked with no issue there)
Sun bearOP
It looks like it's paid
no its not
...
idk how one installes on mac, but on windows i can use the exe or install the msi
brew install cloudflared
anyway i really should sleep now, so gn
and hopefully anay/you can work out how to finish 🙂
Sun bearOP
it's installed
nice
Its only 12:30 am @riský
...
i need to wake up kinda earlier then normal
@riský anyway i really should sleep now, so gn
Sun bearOP
Goodnight Risky and thank you very much for helping me out!
@Sun bear If possible, can you remove auth from that page temporarily, and host in production?
so I can check
no need to remove auth if hosting prod
you can use my username and password jix8l1m@temp.emailthing.xyz :)
I’ll check it soon
Sun bearOP
Awesome
@riský hmm maybe, but i dont know how nextjs is being sad
Sun bearOP
Oh I found this in the terminal! I think it's related to the issue.
thats the error i thought it was tbh (wait why arnt i sleeping)
@riský thats the error i thought it was tbh (wait why arnt i sleeping)
Sun bearOP
I thought you were, I left this in here for when you wake up lol. Anyway I'll let you sleep, goodnight Risky! ❤️
@Sun bear tunnel url?
or prod?
@Anay-208 <@998405690718703696> tunnel url?
Sun bearOP
Do you want to connect ?
yes
You just have to install the liveshare extension.
sure doing that
Sun bearOP
I see you!
umm I'm here
Sun bearOP
Now you should be able to help me, are you seeing the user profile card component ?
yes
Sun bearOP
You should be able to also run the localhost
And update the code
How do I run the server?
Sun bearOP
Just open localhost on your side I think
Like in your browser
I think it should load my project
Oh hold on
I think i need to share that from my side
nope
Sun bearOP
I shared the terminal as well
alright
Sun bearOP
Try now
I also restarted the server
ya I can access
Sun bearOP
So now you can use localhost right ?
yes
Sun bearOP
Awesome!
Now if you make changes to the code you should be able to see the results on your side ❤️
Alright, I see this
Sun bearOP
Awesome!
Australia has joined the chat 😎
its @riský's acc
Risky you still awake?
👀
@Anay-208 its <@657067112434499595>'s acc
Sun bearOP
Ohh
@Sun bear so now tell what you want to be done
i havent joined tho
I'm fron india
@riský i havent joined tho
Sun bearOP
Risky you can easily join now!
I think you were sleeping, right?
i am now*
Sun bearOP
Ray taught me a fancy way to collaborate
i just had to judge someones pr
Sun bearOP
We're using an extension called Live Share @riský
So @Sun bear so tell what needs to be done so I can check?
vscode extension
@Anay-208 So <@998405690718703696> so tell what needs to be done so I can check?
Sun bearOP
This basically
So we need to add the missing pieces here
The company logos (we can use a filled square placeholder for now for those)
And the corners at the top
umm got this message from my brother
@Anay-208 umm got this message from my brother
Sun bearOP
No worries Anay, you can help me when you have some time.
I still have 5-10 mins
Sun bearOP
Okay so first thing I think we should try and add the square placeholder for the company logos.
sure I'm seeing
Sun bearOP
Anay I wanted to ask if we could make it like how you made it, cause things were repeating too much, thank you for fixing that 🙏🏻
@Sun bear check out the preview!
@Anay-208 <@998405690718703696> check out the preview!
Sun bearOP
I am right now
just 1 bug with line thickness
Sun bearOP
Ohh it's getting there!
Yes that plus oh we're missing the icon next to the Work History for some reason lol
I have imported the icon into the project
nrn
brb
Sun bearOP
No worries I have added it
@Sun bear I need to help my brother with some work. I just gav e you a idea how it works, maybe you can do it?
if not, I'll help you in an hour
I've closed my vscode
Sun bearOP
Of course, I'll try
@Sun bear any updates?
Sun bearOP
Not yet, I also took a break.
alright, lmk
@Anay-208 alright, lmk
Sun bearOP
I tried fixing it but it only made it worse. Claude has a hard time understanding how it should look.
Sun bearOP
It did fix the alingment though
Of the vertical line at the top
but otherwise it's a mess
@Sun bear in about 20-30 mins, if you want, I can help you fix the issues in vscode share
Sun bearOP
That would be awesome
@Sun bear Let me know when you have some time.
I just closed my laptop
So tomorrow only
Sun bearOP
I'm making slow progress.
Sun bearOP
@Sun bear so is there anything else you need help with
@Anay-208 <@998405690718703696> so is there anything else you need help with
Sun bearOP
Yes, but it will take some time until I can resume because I'm currently working on replacing the placeholders with real data, otherwise the code doesn't make sense.

I'm currently setting up stuff in the database and once I have some "real" data to work with I'll come back here to resume.

I may need help with lowering the corner, adding the company logo properly, fixing the alignment and removing some stuff for the last entry in the list.
Also, I'm highly suggesting you to use tailwind
This is a really bad structure
Or if you'd like, you can also use it with typewind
So you'll do rest of the development in this way?
not recommended
@Anay-208 Also, I'm highly suggesting you to use tailwind
Sun bearOP
I'll convert all the code to tailwind before I start working on responsive design.
umm ok
It'll still be a pain to convert, but it'll be necessary
Sun bearOP
Because my Adobe XD prototype uses px values so it makes it easier for me to work with px at the moment.
I may do it sooner but at the moment that is not a priority, I do have some components which use tailwind already.
got it, let me know if you need any help
Sun bearOP
Thank you Anay, I will if I do, currently it's okay 😁
@Sun bear is this resolved?
@Anay-208 <@998405690718703696> is this resolved?
Sun bearOP
Not yet, this is currently postphoned until I set-up my database and the rest of the functionality for the component. I can close this thread but I'd have to open a similar thread anyway afterwards, which would lead to duplication. So I'm keeping this opened in the meantime until I have the database set-up.

The fault is mine, I should've not start working on this part until the rest of the component was ready so that I can properly test the changes, this was a bit of a miscalculation on my part.
@Anay-208 There'll be basically 3 if conditions for each item
If you don't need any help with this as of now, mark this message as a solution. For future help, you can always create a new thread!
can't believe i'm saying this, but this thread is locked because people are somehow using this to crosspost their own questions/threads