fix(core): center align user avatar in doc property (#12908)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added an option to center-align user labels in components displaying
user information, improving visual alignment of avatars and usernames.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Cats Juice
2025-06-24 13:01:56 +08:00
committed by GitHub
parent 4e6f40b30e
commit 616e755dde
2 changed files with 16 additions and 3 deletions

View File

@@ -2,7 +2,12 @@ import { Avatar, Tooltip } from '@affine/component';
import { useCurrentServerService } from '@affine/core/components/providers/current-server-scope';
import { useI18n } from '@affine/i18n';
import { useLiveData } from '@toeverything/infra';
import { type ComponentType, useLayoutEffect, useMemo } from 'react';
import {
type ComponentType,
type CSSProperties,
useLayoutEffect,
useMemo,
} from 'react';
import { PublicUserService } from '../services/public-user';
import * as styles from './public-user.css';
@@ -12,11 +17,13 @@ export const PublicUserLabel = ({
size = 20,
showName = true,
tooltip: NameTip,
align = 'baseline',
}: {
id: string;
size?: number;
showName?: boolean;
tooltip?: ComponentType<{ userName: string }>;
align?: CSSProperties['alignItems'];
}) => {
const serverService = useCurrentServerService();
const publicUser = useMemo(() => {
@@ -59,7 +66,7 @@ export const PublicUserLabel = ({
) : null
}
>
<span className={styles.publicUserLabel}>
<span className={styles.publicUserLabel} style={{ alignItems: align }}>
<Avatar
url={user?.avatar}
name={user?.name ?? ''}