mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added user profile popup
This commit is contained in:
parent
43450dff54
commit
1242c04587
10 changed files with 162 additions and 57 deletions
31
src/components/common/Avatar/index.tsx
Normal file
31
src/components/common/Avatar/index.tsx
Normal file
|
@ -0,0 +1,31 @@
|
|||
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';
|
||||
import { DivProps } from '~/utils/types';
|
||||
|
||||
interface Props extends DivProps {
|
||||
url?: string;
|
||||
username?: string;
|
||||
size?: number;
|
||||
innerRef?: React.Ref<any>;
|
||||
}
|
||||
|
||||
const Avatar: FC<Props> = ({ url, username, size, className, innerRef, ...rest }) => {
|
||||
const backgroundImage = !!url ? `url('${getURLFromString(url, PRESETS.avatar)}')` : undefined;
|
||||
const onOpenProfile = useCallback(() => openUserProfile(username), [username]);
|
||||
|
||||
return (
|
||||
<div
|
||||
{...rest}
|
||||
className={classNames(styles.avatar, className)}
|
||||
style={{ backgroundImage }}
|
||||
onClick={onOpenProfile}
|
||||
ref={innerRef}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export { Avatar };
|
19
src/components/common/Avatar/styles.module.scss
Normal file
19
src/components/common/Avatar/styles.module.scss
Normal file
|
@ -0,0 +1,19 @@
|
|||
@import "~/styles/variables";
|
||||
|
||||
.avatar {
|
||||
@include outer_shadow;
|
||||
|
||||
width: $comment_height;
|
||||
height: $comment_height;
|
||||
background-color: transparentize(black, 0.9);
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
border-radius: $radius;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
cursor: pointer;
|
||||
|
||||
img {
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue