Profile page redesign #510
Reference in New Issue
Block a user
Delete Branch "profile-page"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Major Changes
Minor Changes
ImageFallbackcomponent fromImageUploaderwithout the upload functionality, because I couldn't have a button within a button forPopoverrework to migrate to HeadlessUI.ProjectCardKeyValue's key to appear below or above its value (for use with Name and UserName in profile)@Irev-Dev let me know if my habit I've picked up of breaking things into a config file makes things more confusing, that's what I think the weakest point of this is.
I do think that what I've done does an alright job of showing just what data is available to a given profile field within
UserProfile.tsx, so at a glance you can see if a field is editable if it takes thehasPermissionToEditprop.@@ -187,0 +142,4 @@<Svg name="camera" className="w-6 h-6 text-ch-blue-400" /></TopButton>)}/>Not sure this is the right move but I made it so a component could override the default buttons by bringing their own as children to it. It let me remove them by providing a dummy element without effecting any other pages.
Nothing new in here, just moved into its own component for the override ability above.
@@ -11,6 +11,26 @@ import Svg from 'src/components/Svg'const CLOUDINARY_UPLOAD_PRESET = 'CadHub_project_images'const CLOUDINARY_UPLOAD_URL = 'https://api.cloudinary.com/v1_1/irevdev/upload'export function ImageFallback({Having a component that got that fallback user image without the image uploading functionality made me able to migrate the signed-in popover to HeadlessUI from MaterialUI, because I couldn't have a button within a button. I figured it's okay because the use case for the top nav (and
ProjectCard) don't ever need the upload functionality.@@ -0,0 +29,4 @@interface KeyValueType {keyName: stringchildren: React.ReactNodebottom?: booleanAllows the key to appear below (only visually) using CSS
orderproperty,@@ -0,0 +34,4 @@edit?: EditToggleType}const KeyValue = ({Broke out into its own component to be used across both
PartProfileandUserProfileInitializes values from
userstate into the config object. Is this a code smell?@@ -0,0 +19,4 @@loading: booleanerror: booleanonSave: Functionprojects: {}[]Is there a
ProjectTypedefined anywhere? I couldn't find one.@@ -147,3 +171,3 @@</button></Popover></li>) : (Migration from MaterialUI to HeadlessUI Popover.
@@ -11,6 +11,26 @@ import Svg from 'src/components/Svg'const CLOUDINARY_UPLOAD_PRESET = 'CadHub_project_images'const CLOUDINARY_UPLOAD_URL = 'https://api.cloudinary.com/v1_1/irevdev/upload'export function ImageFallback({That button within a button error in the console has been annoying me for ages, but obviously I hadn't done anything about, so thanks!
@@ -187,0 +142,4 @@<Svg name="camera" className="w-6 h-6 text-ch-blue-400" /></TopButton>)}/>Hmm I was trying to figure out what this even needed to be modified for the profile page but because this essentially the top nav bar.
I think this approach is good.
Perhaps later we'll look to remove
MainLayout.jsand replace it with the component everywhere. i.e. it can be the have the search bar for the projects explorer etc. If we do that than displaying children ONLY is probably better, i.e. it will needDefaultTopButtonsto be passed in, in this case.This is good though.
@@ -13,1 +13,4 @@export function ImageFallback({width = 100,imageId = 'CadHub/eia1kwru54g2kf02s2xx',not relevant to this PR, but I do think there must be a better way of doing a fallback/empty-state than this image.
@@ -0,0 +47,4 @@<divclassName={'text-ch-blue-400 font-fira-code flex items-center leading-4 text-sm whitespace-nowrap ' +(bottom ? 'order-2' : '')I'm not requesting a change this is just an observation. I noticed in the headlessui docs they follow a pattern like this for condition classes
At first I didn't like it because the result will often be
className="false"so evenclassName="false false"if you have more of them, but I guess there's no harm in having classes that don't do anything in there@@ -0,0 +34,4 @@edit?: EditToggleType}const KeyValue = ({I know you like this component but I kinda hate it, well hate is a sting word but the amount of input params is off putting for such a simple component. If we pulling it out to be reused I might be good to make a few changes.
isEditableis a terrible name, The variable is for when the component is in a edit state, but i reads like whether the component is allowed to be edited or something. perhaps 'inEditMode`hasPermissionToEditcould we renamecanEditto that as well? much clearer.How does that sound, would you mind?
Whats the purpose of these comments?
Well I at least made a start this time.
I'm happy with everything I've looked at so far, but I skipped
UserProfile.tsx. Seems to be the most intense part of the PR and it's past my bedtime. I'll get back to it soon.@@ -13,1 +13,4 @@export function ImageFallback({width = 100,imageId = 'CadHub/eia1kwru54g2kf02s2xx',I hear that. I'll add to my list, maybe Cloudinary has a documented best.
@@ -0,0 +47,4 @@<divclassName={'text-ch-blue-400 font-fira-code flex items-center leading-4 text-sm whitespace-nowrap ' +(bottom ? 'order-2' : '')Oh interesting, yeah that's what I was avoiding here, but it would be shorter code their way. I guess the
falses would have a negligible impact on things really.Sorry I was debugging an issue, I'll get these removed.
Couple things I noticed, I had trouble with editing the bio and having the change remain after a refresh, not sure if this a bug in existing code or not:
https://user-images.githubusercontent.com/29681384/133326590-f94cac32-4498-45a2-ad8c-13f7d67c651d.mov
And I noticed that the toast pops in quickly when navigation to one of the projects.
https://user-images.githubusercontent.com/29681384/133327626-a8e53dbf-89e1-4035-b8e5-38fb1185a282.mov
I think this is because
<Toaster />isn't on this page anywhere but is trying to be used after editing fields so it quickly shows when you go to a page that does have the component.Other than that looks good, UserProfile seems a little complex but that might just be because I'm not used to this style.
I think the good part of putting everything in a config is that your thinking about the UI in terms of data, though one thing to watch out for is not to get too carried away with abstractions, It's not directly related but I found the perspective in this blog post to be pretty handy https://overreacted.io/goodbye-clean-code/
@@ -0,0 +34,4 @@edit?: EditToggleType}const KeyValue = ({Yeah totally, love these ideas. I hear you it about the input params too.
@@ -187,0 +142,4 @@<Svg name="camera" className="w-6 h-6 text-ch-blue-400" /></TopButton>)}/>Yes I like that idea about
MainLayout, it's feeling about ready to be taken out after a little refactor of this header to cover more use cases.@Irev-Dev Alright I feel a lot better about this now. Here's what I got done:
@@ -0,0 +34,4 @@edit?: EditToggleType}const KeyValue = ({I think I found something better with it! Take a look at it.
@@ -0,0 +69,4 @@</IdeHeader></div><div className="relative flex-grow h-full"><div className="grid md:grid-cols-profile-layout grid-flow-row-dense absolute inset-0">Check this out @Irev-Dev, I think I found something way better here. Using components instead of that big old config object.
Also such a good catch on the
<Toaster/>issue@@ -0,0 +29,4 @@interface KeyValueType {keyName: stringchildren: React.ReactNodebottom?: booleanThese comments aren't showing up as out of date which is worrying me @Irev-Dev , so weird. This component was overhauled, see this commit
Looks really god.
Sorry it took so long for me to get back to this.