Skip to content

Commit

Permalink
feat(AvatarBadge): fix rtl view
Browse files Browse the repository at this point in the history
  • Loading branch information
EldarMuhamethanov committed Dec 20, 2024
1 parent 446b1cd commit c93cf62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
transform: translate(50%, 50%);
}

.rtl.presetOnline,
.rtl.presetOnlineMobile {
transform: translate(-50%, 50%);
}

/**
* Перебиваем свойства `ImageBaseBadge` для этих кейсов
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { useDirection } from '../../../hooks/useDirection';
import { useExternRef } from '../../../hooks/useExternRef';
import {
getBadgeIconSizeByImageBaseSize,
ImageBase,
Expand All @@ -24,8 +26,12 @@ export interface AvatarBadgeWithPresetProps
export const AvatarBadgeWithPreset: React.FC<AvatarBadgeWithPresetProps> = ({
preset = 'online',
className,
getRootRef,
...restProps
}: AvatarBadgeWithPresetProps) => {
const [directionRef, textDirection = 'ltr'] = useDirection<HTMLDivElement>();
const isRtl = textDirection === 'rtl';
const rootRef = useExternRef(getRootRef, directionRef);
const { size } = React.useContext(ImageBaseContext);
const badgeSize = getBadgeIconSizeByImageBaseSize(size);
const isOnlinePreset = preset === 'online';
Expand All @@ -35,7 +41,8 @@ export const AvatarBadgeWithPreset: React.FC<AvatarBadgeWithPresetProps> = ({
return (
<ImageBase.Badge
background="stroke"
className={classNames(styles.host, presetClassName, className)}
className={classNames(styles.host, isRtl && styles.rtl, presetClassName, className)}
getRootRef={rootRef}
{...restProps}
>
<Icon width={badgeSize} height={badgeSize} />
Expand Down

0 comments on commit c93cf62

Please sign in to comment.