-
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
closes #149 - Refactor Game Details page to use existing Profile Image Component #151
Conversation
…ends up being a Semantic Image
}[size]; | ||
small: 80, | ||
tiny: 45 | ||
}[size || 'tiny']; |
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.
@nazar I don't think this snippet size || 'tiny'
is working.
Currently when i was logged in with a user that had a cloudinary url, i saw a broken image in the header, it was because the header was sending in a size
value of mini
. I think width should be (not sure about the 45 value for mini):
const width = {
small: 80,
tiny: 45,
mini: 45
}[size];
tiny: 45 | ||
}[size || 'tiny']; | ||
|
||
const url = `https://res.cloudinary.com/${cloudName}/image/upload/c_crop,g_auto,h_${width*4},r_max,w_${width*4}/c_fill,w_${width}/${publicId}`; |
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.
@nazar there is something wrong with the width value used here vs. what is being displayed on the page.
On the game details page, the logic works, a 45px image is displayed at 45px.
on the lounge and messages pages though, the image is displayed at 80px but the source image is only 45px.
Also, I am not sure if the logic for a c_fill
after the c_crop
is correct. For example look at this image, the focus is just my eye. That started happening with the time before this was refactored.
What about something like this instead? replace c_crop
with c_fill
:
https://res.cloudinary.com/forgingadventures/image/upload/c_fill,g_auto,h_180,r_max,w_180/w_45/SkxvtMSDz
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.
Oh wow! Is c_crop
zooming into the eye?? c_fill
looks 10000% better!
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.
on the lounge and messages pages though, the image is displayed at 80px but the source image is only 45px.
Nice catch @mikelax 👁 - looks like the cloudinary example I copypastaed first did a crop then a fill. I've tweaked it a little now just to do a fill
return ( | ||
<CloudinaryImageAvatar publicId={publicId} size={size} /> | ||
); | ||
} |
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.
@nazar for both this function and NoProfileIcon
functions, what do you think about adding prop types and a default prop for the publicId
?
You can do that even with stateless functions
something like:
NoAvatarIcon.propTypes = {
size: PropTypes.string.isRequired,
publicId: PropTypes.string
};
NoAvatarIcon.defaultProps = {
publicId: process.env.REACT_APP_CLOUDINARY_AVATAR_PLACEHOLDER
};
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.
NoAvatarIcon.propTypes = {
size: PropTypes.string.isRequired,
publicId: PropTypes.string
};
I should be adding propTypes
more. I'd add these to public components (i.e. ones the are exported).
NoAvatarIcon.defaultProps = {
publicId: process.env.REACT_APP_CLOUDINARY_AVATAR_PLACEHOLDER
};
I'm not too keen on the defaultProps
usage here as the constant is defined outside the body of the function, which itself is small. In this instance, I prefer it the way it is.
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.
🚀
Hey @mikelax
It was proving tricky trying to size fonts (and icons) to have the same behaviour as % size images so I uploaded a couple of placeholder profile/character images to Cloudinary (I tried to go for something androgynous but feel free to replace and update the image's publicId in the .env file.