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

[Avatar] Add avatar component #1210

Merged
merged 21 commits into from
Feb 4, 2025
Merged

[Avatar] Add avatar component #1210

merged 21 commits into from
Feb 4, 2025

Conversation

acomanescu
Copy link
Contributor

@acomanescu acomanescu commented Dec 21, 2024

Preview: https://deploy-preview-1210--base-ui.netlify.app/react/components/avatar

This PR adds the Avatar component. I wasn't able to run the tests due to some Mocha run errors that happen even when I run the tests on a fresh clone.

Closes #1347

@mui-bot
Copy link

mui-bot commented Dec 21, 2024

Netlify deploy preview

https://deploy-preview-1210--base-ui.netlify.app/

Generated by 🚫 dangerJS against e2dd254

@mnajdova
Copy link
Member

Hey @acomanescu thanks for the contribution. We will be working soon on the roadmap for Base UI, where we will share the next components we have in the pipeline. As of now, the Avatar component is not planned, but please keep an eye on the GH Roadmap/issues if you want to contribute with something else.

If you are interested in Base UI introducing an Avatar component, please create an issue for it.

Thank you!

@acomanescu
Copy link
Contributor Author

Hi @mnajdova, thank you for your response. I am closing this PR.

@acomanescu acomanescu closed this Dec 24, 2024
@zannager zannager added the component: avatar This is the name of the generic UI component, not the React module! label Dec 27, 2024
@colmtuite
Copy link
Contributor

I've created an issue for Avatar and added it to the current cycle. I'll reopen this PR and take a look soon. Thanks @acomanescu!

@colmtuite colmtuite reopened this Jan 20, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 20, 2025
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Looks great, I left some initial feedback. I will let Colm review the docs demo

@colmtuite
Copy link
Contributor

@acomanescu Good work 🙏

  • Let's use a different image. I don't have a preference, just something different.
  • Let's go with 48px width + height.
  • On Root, inline-flex would be better than flex, since it's usually an inline component.
  • Root will need user-select: none for when there is text content inside.
  • Root will need vertical-align: middle to easier accommodate alignment with other inline components and fix x-browser rendering issues with img.
  • I see you're using alphabetical order for properties (which is admirable), but we don't follow that convention currently. Instead, we group properties by association. So flex properties should go together, dimensions/size properties should go together etc.
  • Rather than the hard-coded background-color value, use var(--color-gray-100) instead.
  • Rather than the hard-coded color value, use var(--color-gray-900) instead.
  • Fallback will need a font-size. 16px should be good (but use rem). It will also need line-height: 1;
  • All px values should be converted to rem.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 27, 2025
Copy link

netlify bot commented Jan 27, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9bdba31
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67a0cc48e06f8300083b1485
😎 Deploy Preview https://deploy-preview-1210--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dartess
Copy link

dartess commented Jan 27, 2025

We will be working soon on the roadmap for Base UI, where we will share the next components we have in the pipeline.

@mnajdova Hi! It's great that the roadmap will be shared! Is there any ETA for this? Or at least what format it will be published in? Looking forward to it.

@mnajdova
Copy link
Member

@mnajdova Hi! It's great that the roadmap will be shared! Is there any ETA for this? Or at least what format it will be published in? Looking forward to it.

It will likely be shared here on GitHub as a project, but we can share more info on Discord when it'll be ready.

packages/react/src/avatar/image/useImageLoadingStatus.ts Outdated Show resolved Hide resolved

export function useImageLoadingStatus(
src?: string,
referrerPolicy?: React.HTMLAttributeReferrerPolicy,
Copy link
Member

Choose a reason for hiding this comment

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

referrerPolicy seems unused anywhere

Copy link
Member

Choose a reason for hiding this comment

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

Fixed in cc939fc

Copy link
Member

Choose a reason for hiding this comment

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

We could use a test that verifies if the fallback is displayed when the image fails to load and a one testing the delay prop.

Copy link
Member

Choose a reason for hiding this comment

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

Added in 98457eb

const {
className,
render,
onLoadingStatusChange: onLoadingStatusChangeProp,
Copy link
Member

Choose a reason for hiding this comment

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

onLoadingStatusChange wasn't reflected in the API docs before, fixed in df65f19

Copy link
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

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

@colmtuite @michaldudak @mnajdova This PR should be ready to review again, I've gone through the existing comments fixed them all, also made some extra fixes.

In particular: I've removed useAvatarRoot and moved everything to the AvatarRoot component, the prop getter seems unnecessary and without that there's only a simple useState remaining 8c0e720

@colmtuite
Copy link
Contributor

Perhaps add width and height attributes on the img? No big deal.

@mj12albert
Copy link
Member

Perhaps add width and height attributes on the img? No big deal.

Added 👍

@mj12albert mj12albert merged commit 37590c5 into mui:master Feb 4, 2025
22 checks passed
@mnajdova
Copy link
Member

mnajdova commented Feb 4, 2025

@dartess we updated the project with the near future plans/initiatives, you can check it here: https://github.com/orgs/mui/projects/1/views/13. We will keep updating it for each iteration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: avatar This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Avatar] Implement Avatar
8 participants