Skip to content

Commit fbd1fe9

Browse files
chore: creating new enum for avatar favicon size and removing circular dependency
1 parent 689bd8e commit fbd1fe9

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { AvatarBaseSize } from '../avatar-base';
2+
import { AvatarFaviconSize } from './AvatarFavicon.types';
3+
4+
export const AVATAR_FAVICON_TO_AVATAR_BASE_SIZE_MAP: Record<
5+
AvatarFaviconSize,
6+
AvatarBaseSize
7+
> = {
8+
[AvatarFaviconSize.Xs]: AvatarBaseSize.Xs,
9+
[AvatarFaviconSize.Sm]: AvatarBaseSize.Sm,
10+
[AvatarFaviconSize.Md]: AvatarBaseSize.Md,
11+
[AvatarFaviconSize.Lg]: AvatarBaseSize.Lg,
12+
[AvatarFaviconSize.Xl]: AvatarBaseSize.Xl,
13+
};

packages/design-system-react/src/components/avatar-favicon/AvatarFavicon.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22

33
import { AvatarBase, AvatarBaseShape, AvatarBaseSize } from '../avatar-base';
44
import type { AvatarFaviconProps } from './AvatarFavicon.types';
5+
import { AVATAR_FAVICON_TO_AVATAR_BASE_SIZE_MAP } from './AvatarFavicon.constants';
56

67
export const AvatarFavicon = React.forwardRef<
78
HTMLDivElement,
@@ -27,7 +28,7 @@ export const AvatarFavicon = React.forwardRef<
2728
<AvatarBase
2829
ref={ref}
2930
shape={AvatarBaseShape.Circle}
30-
size={size}
31+
size={AVATAR_FAVICON_TO_AVATAR_BASE_SIZE_MAP[size]}
3132
className={className}
3233
fallbackText={displayText}
3334
fallbackTextProps={fallbackTextProps}

packages/design-system-react/src/components/avatar-favicon/AvatarFavicon.types.ts

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
import type { ComponentProps } from 'react';
22

33
import type { TextProps } from '../text';
4-
import { AvatarFaviconSize } from '.';
4+
import type { AvatarBaseProps } from '../avatar-base';
55

6-
export type AvatarFaviconProps = Omit<
7-
ComponentProps<'img'>,
8-
'children' | 'size'
9-
> & {
6+
export enum AvatarFaviconSize {
7+
/**
8+
* Extra small size (16px)
9+
*/
10+
Xs = 'xs',
11+
/**
12+
* Small size (24px)
13+
*/
14+
Sm = 'sm',
15+
/**
16+
* Medium size (32px)
17+
*/
18+
Md = 'md',
19+
/**
20+
* Large size (40px)
21+
*/
22+
Lg = 'lg',
23+
/**
24+
* Extra large size (48px)
25+
*/
26+
Xl = 'xl',
27+
}
28+
29+
export type AvatarFaviconProps = Omit<AvatarBaseProps, 'size'> & {
1030
/**
1131
* Required name of the dapp
1232
* Used as alt text for image and first letter is used as fallback if no fallbackText provided
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { AvatarFavicon } from './AvatarFavicon';
2+
export { AvatarFaviconSize } from './AvatarFavicon.types';
23
export type { AvatarFaviconProps } from './AvatarFavicon.types';
3-
export { AvatarBaseSize as AvatarFaviconSize } from '../avatar-base';

0 commit comments

Comments
 (0)