Files
Masto/app/javascript/flavours/glitch/components/avatar.tsx
T
Zoë Bijl 39b0552b6a [bugfix] various CSS fixes (#100)
Some fixes for the CSS / Phosphor revamp

- Corrected avatar position
- Corrected various button/icon sizes
- Change the way a status background is set
- Improved icon-button disabled state
- Improved contrast and light theme colours

commit b307fa93b4
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 17:49:11 2025 +0200

    [chore] lint

commit 1352425b81
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 17:46:42 2025 +0200

    [chore] lint

commit 276480b5a4
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 17:46:32 2025 +0200

    [bugfix] set direct message background

commit 4e5764a70b
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 17:44:46 2025 +0200

    [bugfix] improve obviousness of disabled icon button state

commit dec5bb66e7
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 16:52:55 2025 +0200

    [chore] lint

commit 72869917ab
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 16:52:44 2025 +0200

    [bugfix] start work on status content spacing

commit 5aa8333f71
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 15:57:56 2025 +0200

    lint

commit df0bb84ce4
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 15:57:48 2025 +0200

    [bugfix] correctly set status background (on focus)

    fixes an issue where a weird gradient would show up in the status__info section

commit 2fab5ff2e7
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 09:40:28 2025 +0200

    [bugfix] fix lint issues

commit 5d823b2195
Author: Zoë Bijl <code@moiety.me>
Date:   Wed Oct 15 01:19:01 2025 +0200

    [bugfix] set avatars to cover available space

    no more squashed avatars
2025-10-15 18:10:58 +02:00

57 lines
1.3 KiB
TypeScript

import * as React from "react";
import classNames from "classnames";
import { useHovering } from "flavours/glitch/hooks/useHovering";
import { autoPlayGif } from "flavours/glitch/initial_state";
import { type Account } from "flavours/glitch/types/resources";
interface Props {
account: Account | undefined,
className?: string,
size: number,
style?: React.CSSProperties,
inline?: boolean,
}
export const Avatar: React.FC<Props> = ({
account,
className,
size = 20,
inline = false,
style: styleFromParent,
}) => {
const { hovering, handleMouseEnter, handleMouseLeave } =
useHovering(autoPlayGif);
const style = {
...styleFromParent,
width: `${size}px`,
height: `${size}px`,
backgroundSize: "cover",
backgroundPosition: "center",
};
if (account) {
style.backgroundImage = `url(${account.get(
hovering ? "avatar" : "avatar_static",
)})`;
}
return (
<div
className={classNames(
"account__avatar",
{ "account__avatar-inline": inline },
className,
)}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
style={style}
data-avatar-of={account && `@${account.get("acct")}`}
role='img'
aria-label={account?.get("acct")}
/>
);
};