Skip to content
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

Merged
merged 9 commits into from
Jun 20, 2018

Conversation

nazar
Copy link
Collaborator

@nazar nazar commented Jun 19, 2018

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.

@nazar nazar self-assigned this Jun 19, 2018
@nazar nazar requested a review from mikelax June 19, 2018 10:52
@nazar nazar added this to To Do in MVP via automation Jun 19, 2018
@nazar nazar moved this from To Do to In Progress in MVP Jun 19, 2018
}[size];
small: 80,
tiny: 45
}[size || 'tiny'];
Copy link
Owner

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}`;
Copy link
Owner

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.

screen shot 2018-06-19 at 4 44 10 pm

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

Copy link
Collaborator Author

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!

Copy link
Collaborator Author

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} />
);
}
Copy link
Owner

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
};

Copy link
Collaborator Author

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.

Copy link
Owner

@mikelax mikelax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@mikelax mikelax merged commit 5ed44e2 into master Jun 20, 2018
MVP automation moved this from In Progress to Done Jun 20, 2018
@mikelax mikelax deleted the 149_profiles branch June 20, 2018 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MVP
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants