refactor: session list

This commit is contained in:
zerosoul
2022-06-15 14:18:26 +08:00
parent 0526ce16fd
commit 47b165f64a
8 changed files with 49 additions and 29 deletions
+2 -1
View File
@@ -10,10 +10,11 @@ const Styled = styled.span`
cursor: pointer;
}
`;
export default function Mention({ uid, popover = true, cid }) {
export default function Mention({ uid, popover = true, cid, textOnly = false }) {
const contactsData = useSelector((store) => store.contacts.byId);
const user = contactsData[uid];
if (!user) return null;
if (textOnly) return `@${user.name}`;
return (
<Tippy
disabled={!popover}
+4 -4
View File
@@ -123,10 +123,10 @@ export const getInitialsAvatar = ({
context.rect(0, 0, canvas.width, canvas.height);
context.fillStyle = background;
context.fill();
// 两个字符,自动缩放40
context.font = `${weight} ${
((initial_size || height) - (initials.length == 2 ? 40 : 0)) / 2
}px ${fontFamily}`;
// 多于两个字符,自动缩放
const subtract =
initials.length > 3 ? 50 : initials.length > 2 ? 40 : initials.length == 2 ? 30 : 0;
context.font = `${weight} ${((initial_size || height) - subtract) / 2}px ${fontFamily}`;
context.textAlign = "center";
context.textBaseline = "middle";