mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-19 04:00:51 -05:00
fix(client): profile image size and alignment (#52263)
This commit is contained in:
@@ -46,7 +46,7 @@ function AvatarRenderer({
|
||||
{isPlaceHolderImage ? (
|
||||
<DefaultAvatar className='avatar default-avatar' />
|
||||
) : (
|
||||
<Image alt='' className='avatar' src={picture} />
|
||||
<Image alt='' className='avatar' src={picture} responsive />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -2,16 +2,16 @@ import React from 'react';
|
||||
import { ImageProps } from './image.types';
|
||||
|
||||
export const Image = React.forwardRef<HTMLImageElement, ImageProps>(
|
||||
({ alt, src, responsive, ...props }, ref): JSX.Element => {
|
||||
({ alt, src, responsive, className, ...props }, ref): JSX.Element => {
|
||||
// If `responsive` is `true`:
|
||||
// - Set `display` to `block`
|
||||
// - Set a maximum relative to the parent
|
||||
// - Set a maximum width relative to the parent
|
||||
// - Scale the height according to the width, otherwise the image is stretched
|
||||
const className = responsive ? 'block max-w-full h-auto' : '';
|
||||
const classes = responsive
|
||||
? [className, 'block max-w-full h-auto'].join(' ')
|
||||
: className;
|
||||
|
||||
return (
|
||||
<img ref={ref} alt={alt} src={src} className={className} {...props} />
|
||||
);
|
||||
return <img ref={ref} alt={alt} src={src} className={classes} {...props} />;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user