Skip to content

Conversation

@jcheringer
Copy link
Contributor

Proposed Changes

This PR updates the Hovercards to show a default header image when the user doesn't have an uploaded image.

It also introduces the field hideDefaultHeaderImage to allow users to hide the default header image.
The field is opt-out by default, which means it will show a default header image (when appropriate) unless the user chooses to opt out.

Screenshot 2025-08-13 at 16 08 37

Testing Instructions

  • Checkout this branch and run the Hovercards playground
  • Hover the mouse over an avatar without a header image - it should show the default header image
  • Adjust the playground data to set hideDefaultHeaderImage to true - the affected card should not show the default header image now

@github-actions
Copy link

github-actions bot commented Aug 13, 2025

Size Change: +580 B (+0.89%)

Total Size: 66.1 kB

Filename Size Change
dist/index.esm.js 9.7 kB +85 B (+0.88%)
dist/index.js 9.84 kB +85 B (+0.87%)
dist/index.mjs 9.7 kB +84 B (+0.87%)
dist/index.react.js 12 kB +83 B (+0.7%)
dist/index.react.mjs 11.9 kB +84 B (+0.71%)
dist/index.react.umd.js 6.97 kB +79 B (+1.15%)
dist/index.umd.js 6 kB +80 B (+1.35%)

compressed-size-action

@jcheringer jcheringer requested a review from a team August 14, 2025 11:15
@jcheringer jcheringer self-assigned this Aug 14, 2025
Copy link
Contributor

@wellyshen wellyshen left a comment

Choose a reason for hiding this comment

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

Not related to this PR: I’m not sure the header image height matches the design. It appears different between the card and the profile.

Profile Card
截圖 2025-08-25 晚上9 40 21 截圖 2025-08-25 晚上9 40 38

transform: translateX(-50%);
overflow-y: hidden;

img {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the lib, we use the class name instead of the element so that developers can override styles in a more DX-friendly way :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this really necessary?
A developer could easily override the CSS using .gravatar-hovercard__header-image img { }.

To add a CSS class to the element we would need to 'create' a class name that might not make much sense, like .gravatar-hovercard__header-image-img or .gravatar-hovercard__header-image-background.

Or we would need to change the current CSS structure to create a CSS hierarchy that makes sense, like:

<div class="gravatar-hovercard__header-image-wrapper">
   <img class="gravatar-hovercard__header-image" />
</div

And that would require changes in the code that would make it less readable and organized.

In the end, the benefit, if any, would be a developer writing 4 or 5 characters less.

.gravatar-hovercard__header-image img { }
.gravatar-hovercard__header-image-img { }
.gravatar-hovercard__header-image-background { }
.gravatar-hovercard__header-image { } // a few less characters but would require structural changes

Copy link
Contributor

Choose a reason for hiding this comment

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

From a library perspective, classes are the best practice: predictable specificity and refactor-safe. That’s why we use class names instead of element selectors 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not entirely convinced this is the best solution for this particular situation, but I made the changes to avoid blocking the PR.

jobTitle?: string;
company?: string;
headerImage?: string;
hideDefaultHeaderImage?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

In the library, ProfileData was designed to mirror the API payload. I’m fine not adding an additional opt-out option here. If the user doesn’t have a header image, we can show the blurred placeholder directly, which is more aligned with Gravatar profiles. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the profile editor and profile page, we added an option for users to hide the default header image if they prefer.
We need to add the same option on the Hovercards to be consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

What, I didn't know that, where is the option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, is there. Now the prop makes sense!

@jcheringer
Copy link
Contributor Author

Not related to this PR: I’m not sure the header image height matches the design. It appears different between the card and the profile.

The height difference is intentional. It was designed this way to maintain the image's proportion, so we don't have to crop it.

image image

Copy link
Contributor

@wellyshen wellyshen left a comment

Choose a reason for hiding this comment

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

LGTM, feel free to move forward once the consistent CSS selector issue has been addressed.

Copy link
Contributor

@wellyshen wellyshen left a comment

Choose a reason for hiding this comment

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

@jcheringer Oops! I forgot to mention. To allow the editor to show or hide the hovercard’s default header image. We also need to pass the new data (from the API payload) to the method, from here.

@jcheringer jcheringer merged commit 16c8df7 into trunk Aug 25, 2025
2 checks passed
@jcheringer jcheringer deleted the update/add-default-header-image branch August 25, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants