Skip to content

Commit 20a47b7

Browse files
authored
Forms: add gravatars on dashboard rows (#45555)
* changelog * allow gravatar component receive size as prop * use gravatar component on dataviews rows * adjust dataviews cell content wrapper gap and tweak unread marker to continue to work well
1 parent dcef658 commit 20a47b7

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: added
3+
4+
Forms: show gravatar on dataviews list

projects/packages/forms/src/dashboard/components/gravatar/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import './style.scss';
1111
type GravatarProps = {
1212
displayName?: string;
1313
email: string;
14+
size?: number;
1415
};
1516

1617
/**
@@ -22,7 +23,11 @@ type GravatarProps = {
2223
* @param {GravatarProps} props - The component props.
2324
* @return {JSX.Element} The Gravatar component
2425
*/
25-
export default function Gravatar( { displayName, email }: GravatarProps ): JSX.Element | null {
26+
export default function Gravatar( {
27+
displayName,
28+
email,
29+
size = 48,
30+
}: GravatarProps ): JSX.Element | null {
2631
const profileImageRef = useRef( null );
2732
const hovercardRef = useRef( null );
2833

@@ -68,6 +73,8 @@ export default function Gravatar( { displayName, email }: GravatarProps ): JSX.E
6873
className="jp-forms__gravatar"
6974
ref={ profileImageRef }
7075
src={ `https://0.gravatar.com/avatar/${ hashedEmail }?d=initials&name=${ displayName }` }
76+
width={ size }
77+
height={ size }
7178
/>
7279
);
7380
}

projects/packages/forms/src/dashboard/components/gravatar/style.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
background-color: var(--jp-gray-5);
33
border-radius: 50%;
44
flex-shrink: 0; // Prevent shrinking when Gravatar is inside flex containers
5-
height: 48px;
65
overflow: hidden;
7-
width: 48px;
86
}

projects/packages/forms/src/dashboard/inbox/dataviews/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useSearchParams } from 'react-router';
1717
/**
1818
* Internal dependencies
1919
*/
20+
import Gravatar from '../../components/gravatar';
2021
import InboxStatusToggle from '../../components/inbox-status-toggle';
2122
import { ResponseMobileView, SingleResponseView } from '../../components/response-view';
2223
import useInboxData from '../../hooks/use-inbox-data';
@@ -231,6 +232,14 @@ export default function InboxView() {
231232
232233
</span>
233234
) }
235+
{ item.author_email && (
236+
<Gravatar
237+
email={ item.author_email }
238+
displayName={ authorInfo }
239+
key={ decodeEntities( item.author_email ) }
240+
size={ 32 }
241+
/>
242+
) }
234243
{ wrapperUnread( item.is_unread, authorInfo ) }
235244
</>
236245
);

projects/packages/forms/src/dashboard/inbox/style.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@
377377
width: calc(100% - var(--forms-admin-sidebar-width, variables.$admin-sidebar-width));
378378
}
379379
}
380+
381+
.dataviews-view-table__cell-content-wrapper {
382+
gap: 16px;
383+
}
380384
}
381385

382386
/*
@@ -560,4 +564,5 @@ body.jetpack_page_jetpack-forms-admin {
560564
margin-right: 4.5px;
561565
margin-left: -12px;
562566
vertical-align: middle;
567+
position: absolute;
563568
}

0 commit comments

Comments
 (0)