Skip to content

Commit efb0cd8

Browse files
committed
Avatar - extract badge size into a global const for reuse
1 parent ad8494f commit efb0cd8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/avatar/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import Text from '../text';
1010
import Image from '../image';
1111
import AnimatedImage from '../../animations/animatedImage';
1212

13+
const BADGE_SIZE = 13.5;
14+
1315
export const STATUS_MODES = {
1416
ONLINE: 'ONLINE',
1517
OFFLINE: 'OFFLINE',
@@ -142,11 +144,10 @@ export default class Avatar extends BaseComponent {
142144

143145
getBadgePosition() {
144146
const {size} = this.props;
145-
const badgeSize = 13.5;
146147
const radius = size / 2;
147148
const x = Math.sqrt(radius ** 2 * 2);
148149
const y = x - radius;
149-
const shift = Math.sqrt(y ** 2 / 2) - badgeSize / 2;
150+
const shift = Math.sqrt(y ** 2 / 2) - BADGE_SIZE / 2;
150151
return {top: shift, right: shift};
151152
}
152153

@@ -272,8 +273,8 @@ function createStyles({size, labelColor}) {
272273
borderRadius,
273274
},
274275
onlineBadge: {
275-
height: 13.5,
276-
width: 13.5,
276+
height: BADGE_SIZE,
277+
width: BADGE_SIZE,
277278
padding: 1.5,
278279
borderRadius: 999,
279280
backgroundColor: Colors.white,

0 commit comments

Comments
 (0)