fix: avatar uploader size

This commit is contained in:
Tristan Yang
2022-12-23 22:22:40 +08:00
parent f55d25cd43
commit 498e456632
3 changed files with 9 additions and 6 deletions
+1
View File
@@ -16,6 +16,7 @@ function getFontSize(width: number): number {
if (width <= 24) return 12; if (width <= 24) return 12;
if (width <= 32) return 16; if (width <= 32) return 16;
if (width <= 40) return 18; if (width <= 40) return 18;
if (width <= 56) return 22;
if (width <= 80) return 48; if (width <= 80) return 48;
return 64; return 64;
} }
+7 -5
View File
@@ -4,9 +4,9 @@ import Avatar from "./Avatar";
import uploadIcon from "../../assets/icons/upload.image.svg?url"; import uploadIcon from "../../assets/icons/upload.image.svg?url";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
const StyledWrapper = styled.div` const StyledWrapper = styled.div<{ size: number }>`
width: 96px; width: ${({ size }) => `${size}px`};
height: 96px; height: ${({ size }) => `${size}px`};
position: relative; position: relative;
cursor: pointer; cursor: pointer;
.avatar { .avatar {
@@ -67,6 +67,7 @@ const StyledWrapper = styled.div`
type UID = number; type UID = number;
interface Props { interface Props {
size?: number;
uid?: UID; uid?: UID;
className?: string; className?: string;
url?: string; url?: string;
@@ -77,6 +78,7 @@ interface Props {
} }
const AvatarUploader: FC<Props> = ({ const AvatarUploader: FC<Props> = ({
size = 96,
uid, uid,
className = "", className = "",
url = "", url = "",
@@ -101,9 +103,9 @@ const AvatarUploader: FC<Props> = ({
}; };
return ( return (
<StyledWrapper className={className}> <StyledWrapper size={size} className={className}>
<div className="avatar"> <div className="avatar">
<Avatar width={96} height={96} type={type} src={url} name={name} className={className} /> <Avatar width={size} height={size} type={type} src={url} name={name} className={className} />
{!disabled && ( {!disabled && (
<> <>
<div className="tip"> <div className="tip">
+1 -1
View File
@@ -78,7 +78,7 @@ export default function BotConfig() {
const { uid, name, avatar } = bot; const { uid, name, avatar } = bot;
return <tr key={uid} className="bg-white border-b transition duration-300 ease-in-out hover:bg-gray-100"> return <tr key={uid} className="bg-white border-b transition duration-300 ease-in-out hover:bg-gray-100">
<td className="px-4 py-2"> <td className="px-4 py-2">
<AvatarUploader uid={uid} url={avatar} uploadImage={updateAvatar} name={name} className="!w-14 !h-14" /> <AvatarUploader uid={uid} url={avatar} uploadImage={updateAvatar} name={name} size={56} />
</td> </td>
<td className={`${tdClass}`}> <td className={`${tdClass}`}>