mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed shadows, added author panel
This commit is contained in:
parent
c1279c538a
commit
f2fbca80e1
21 changed files with 209 additions and 55 deletions
28
src/components/comment/CommentAvatar/index.tsx
Normal file
28
src/components/comment/CommentAvatar/index.tsx
Normal file
|
@ -0,0 +1,28 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import { getURLFromString } from '~/utils/dom';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
import styles from './styles.module.scss';
|
||||
import classNames from 'classnames';
|
||||
import { openUserProfile } from '~/utils/user';
|
||||
|
||||
interface Props {
|
||||
url?: string;
|
||||
username?: string;
|
||||
size?: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const CommentAvatar: FC<Props> = ({ url, username, size, className }) => {
|
||||
const backgroundImage = !!url ? `url('${getURLFromString(url, PRESETS.avatar)}')` : undefined;
|
||||
const onOpenProfile = useCallback(() => openUserProfile(username), [username]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(styles.avatar, className)}
|
||||
style={{ backgroundImage }}
|
||||
onClick={onOpenProfile}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export { CommentAvatar };
|
Loading…
Add table
Add a link
Reference in a new issue