Skip to content

Commit

Permalink
fix: avatar placeholder (if no image provided) now inverts below back…
Browse files Browse the repository at this point in the history
…ground-color
  • Loading branch information
andirueckel committed Aug 30, 2023
1 parent e9ae29f commit 809dcd7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
15 changes: 14 additions & 1 deletion pages/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ const Avatar = styled.img`
grid-column: 1;
width: calc(var(--margin) * 7.3);
aspect-ratio: 1;
/*
background: var(--color-foreground);
border-color: var(--color-foreground);
border-style: solid;
border-width: calc(var(--margin) * 0.2);
*/
&.placeholder {
backdrop-filter: invert(100%);
}
@media (min-width: 40em) {
grid-row: 1 / 3;
Expand Down Expand Up @@ -192,7 +199,13 @@ export default function Account() {
<>
<h2>/account</h2>
<ProfileSection>
<Avatar src={profileInfo.avatar_url ? matrixClient.mxcUrlToHttp(profileInfo.avatar_url, 500, 500, 'crop') : 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='} />
{ profileInfo.avatar_url ? (
// Render the avatar if we have one
<Avatar src={matrixClient.mxcUrlToHttp(profileInfo.avatar_url, 500, 500, 'crop')} />
) : (
// Render an empty GIF if we don't have an avatar
<Avatar className="placeholder" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />
) }
<AvatarButtonContainer>
<input type="file" onChange={uploadAvatar} ref={avatarFileUploadInput} style={{ display: 'none' }} accept="image/*" />
<button type="button" disabled={isChangingAvatar} onClick={() => { avatarFileUploadInput.current.click(); }}>{ t('Upload') }</button>
Expand Down
9 changes: 8 additions & 1 deletion pages/chat/[[...roomId]].js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ const Avatar = styled.img`
width: 2rem;
height: 2rem;
margin-right: 0.6rem;
/*
background: var(--color-foreground);
*/
&.placeholder {
backdrop-filter: invert(100%);
}
`;

const SidebarListEntryWrapper = styled.a`
Expand Down Expand Up @@ -62,7 +69,7 @@ const SidebarListEntry = function({ room }) {
<Avatar src={room.avatar} alt={room.name} />
) : (
// Render an empty GIF if we don't have an avatar
<Avatar src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />
<Avatar className="placeholder" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />
) }
<RoomName>{ room.name }</RoomName>
{ room.notificationCount > 0 && (
Expand Down

0 comments on commit 809dcd7

Please sign in to comment.