File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { Center, type FlexboxProps } from 'react-layout-kit';
3
3
4
4
import { IconType } from '@/types' ;
5
5
6
+ import { roundToEven } from './util' ;
7
+
6
8
export interface IconAvatarProps extends Omit < FlexboxProps , 'children' > {
7
9
Icon ?: IconType ;
8
10
background ?: string ;
@@ -42,7 +44,13 @@ const IconAvatar = forwardRef<HTMLDivElement, IconAvatarProps>(
42
44
...style ,
43
45
} }
44
46
>
45
- { Icon && < Icon className = { iconClassName } size = { size * iconMultiple } style = { iconStyle } /> }
47
+ { Icon && (
48
+ < Icon
49
+ className = { iconClassName }
50
+ size = { roundToEven ( size * iconMultiple ) }
51
+ style = { iconStyle }
52
+ />
53
+ ) }
46
54
</ Center >
47
55
) ;
48
56
} ,
Original file line number Diff line number Diff line change
1
+ export const roundToEven = ( number : number ) => {
2
+ const rounded = Math . round ( number ) ;
3
+ const diff = Math . abs ( number - rounded ) ;
4
+
5
+ if ( diff === 0.5 ) {
6
+ return rounded % 2 === 0 ? rounded : rounded - 1 ;
7
+ }
8
+ return rounded ;
9
+ } ;
You can’t perform that action at this time.
0 commit comments