Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions apps/site/components/MDX/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import type { ImageProps } from 'next/image';
import Image from 'next/image';
import type { FC } from 'react';

import { isSvgImage } from '#site/util/imageUtils';

const MDXImage: FC<ImageProps> = ({ width, height, alt, src, ...props }) => {
const isUnoptimizedImage = isSvgImage(src.toString());

if (!width || !height) {
// Since `width` and `height` are not provided in the Markdown image format,
// we provide the height and width automatically.
Expand All @@ -15,7 +11,6 @@ const MDXImage: FC<ImageProps> = ({ width, height, alt, src, ...props }) => {
<Image
{...props}
src={src}
unoptimized={isUnoptimizedImage}
alt={alt}
width={0}
height={0}
Expand All @@ -25,16 +20,7 @@ const MDXImage: FC<ImageProps> = ({ width, height, alt, src, ...props }) => {
);
}

return (
<Image
{...props}
alt={alt}
width={width}
height={height}
src={src}
unoptimized={isUnoptimizedImage}
/>
);
return <Image {...props} alt={alt} width={width} height={height} src={src} />;
};

export default MDXImage;
2 changes: 0 additions & 2 deletions apps/site/components/withAvatarGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import AvatarGroup from '@node-core/ui-components/Common/AvatarGroup';
import Image from 'next/image';
import type { ComponentProps, FC } from 'react';

import Link from '#site/components/Link';
Expand All @@ -27,7 +26,6 @@ const WithAvatarGroup: FC<WithAvatarGroupProps> = ({
clickable: clickable,
})}
as={Link}
img={Image}
{...props}
/>
);
Expand Down
1 change: 1 addition & 0 deletions apps/site/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const nextConfig = {
'@radix-ui/react-tabs',
'@radix-ui/react-toast',
'@radix-ui/react-tooltip',
'@radix-ui/react-avatar',
'@orama/highlight',
'@orama/react-components',
'@heroicons/react',
Expand Down
56 changes: 0 additions & 56 deletions apps/site/util/__tests__/imageUtils.test.mjs

This file was deleted.

19 changes: 0 additions & 19 deletions apps/site/util/imageUtils.ts

This file was deleted.

41 changes: 16 additions & 25 deletions packages/ui-components/Common/AvatarGroup/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as RadixAvatar from '@radix-ui/react-avatar';
import classNames from 'classnames';
import type { HTMLAttributes, ElementType } from 'react';
import type { HTMLAttributes } from 'react';
import { forwardRef } from 'react';

import type { LinkLike } from '#ui/types';
Expand All @@ -14,12 +15,8 @@ export type AvatarProps = {
size?: 'small' | 'medium';
url?: string;
as?: LinkLike | 'div';
img?: ElementType | 'img';
};

// @TODO: We temporarily removed the Avatar Radix UI primitive, since it was causing flashing
// during initial load and not being able to render nicely when images are already cached.
// @see https://github.com/radix-ui/primitives/pull/3008
const Avatar = forwardRef<
HTMLSpanElement,
HTMLAttributes<HTMLSpanElement> & AvatarProps
Expand All @@ -33,14 +30,13 @@ const Avatar = forwardRef<
url,
size = 'small',
as: Component = 'a',
img: Image = 'img',
...props
},
ref
) => {
if (!url) Component = 'div';
return (
<span
<RadixAvatar.Root
{...props}
ref={ref}
className={classNames(styles.avatar, styles[size], props.className)}
Expand All @@ -50,25 +46,20 @@ const Avatar = forwardRef<
target={url ? '_blank' : undefined}
className={styles.wrapper}
>
{image && (
<Image
width={40}
height={40}
loading="lazy"
decoding="async"
src={image}
alt={name || nickname}
className={styles.item}
/>
)}

{!image && (
<span className={classNames(styles.item, styles[size])}>
{fallback}
</span>
)}
<RadixAvatar.Image
loading="lazy"
decoding="async"
src={image}
alt={name || nickname}
className={styles.item}
/>
<RadixAvatar.Fallback
className={classNames(styles.item, styles[size])}
>
{fallback}
</RadixAvatar.Fallback>
</Component>
</span>
</RadixAvatar.Root>
);
}
);
Expand Down
2 changes: 0 additions & 2 deletions packages/ui-components/Common/AvatarGroup/Overlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const AvatarOverlay: FC<AvatarOverlayProps> = ({
fallback,
url,
as: Component = 'a',
img,
}) => (
<Component className={styles.overlay} href={url} target="_blank">
<Avatar
Expand All @@ -25,7 +24,6 @@ const AvatarOverlay: FC<AvatarOverlayProps> = ({
nickname={nickname}
fallback={fallback}
size="medium"
img={img}
/>

<div className={styles.user}>
Expand Down
7 changes: 2 additions & 5 deletions packages/ui-components/Common/AvatarGroup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import classNames from 'classnames';
import type { FC, ElementType } from 'react';
import type { FC } from 'react';
import { useState, useMemo } from 'react';

import type { AvatarProps } from '#ui/Common/AvatarGroup/Avatar';
Expand All @@ -20,7 +20,6 @@ type AvatarGroupProps = {
size?: AvatarProps['size'];
container?: HTMLElement;
as?: LinkLike;
img?: ElementType | 'img';
};

const AvatarGroup: FC<AvatarGroupProps> = ({
Expand All @@ -30,7 +29,6 @@ const AvatarGroup: FC<AvatarGroupProps> = ({
size = 'small',
container,
as,
img,
}) => {
const [showMore, setShowMore] = useState(false);

Expand All @@ -54,7 +52,7 @@ const AvatarGroup: FC<AvatarGroupProps> = ({
key={avatar.nickname}
asChild
container={container}
content={<AvatarOverlay {...avatar} as={as} img={img} />}
content={<AvatarOverlay {...avatar} as={as} />}
>
<Avatar
{...avatar}
Expand All @@ -64,7 +62,6 @@ const AvatarGroup: FC<AvatarGroupProps> = ({
'pointer-events-none': !avatar.url,
})}
as={as}
img={img}
/>
</Tooltip>
))}
Expand Down
1 change: 1 addition & 0 deletions packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"dependencies": {
"@heroicons/react": "^2.2.0",
"@radix-ui/react-avatar": "^1.1.9",
"@radix-ui/react-dialog": "^1.1.7",
"@radix-ui/react-dropdown-menu": "~2.1.6",
"@radix-ui/react-label": "~2.1.2",
Expand Down
Loading
Loading