From 04c679bf84ff40e3e37c20eeffa62f6fdf301678 Mon Sep 17 00:00:00 2001 From: Ryan Srofe Date: Wed, 17 Apr 2024 11:50:44 -0400 Subject: [PATCH] hide and show user avatars (#82) Co-authored-by: Christy Presler <6210279+cpresler@users.noreply.github.com> Co-authored-by: Christy Presler --- widget-src/Widget.tsx | 11 +++++ widget-src/components/ChangeLogList.tsx | 3 ++ widget-src/components/ChangeLogRow.tsx | 9 +++- widget-src/components/log/User.tsx | 65 ++++++++++++------------- 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/widget-src/Widget.tsx b/widget-src/Widget.tsx index 4c14ae5..12257a8 100644 --- a/widget-src/Widget.tsx +++ b/widget-src/Widget.tsx @@ -16,6 +16,7 @@ function Widget() { const [showVersion, setShowVersion] = useSyncedState('showVersion', false); const [showBranding, setShowBranding] = useSyncedState('showBradning', true); // fixing the typo messes with branding state on existing widgets const [showLogTypes, setShowLogTypes] = useSyncedState('showLogTypes', true); + const [showAvatars, setShowAvatars] = useSyncedState('showAvatars', true); const [isLocked, setIsLocked] = useSyncedState('isLocked', false); // Meta Data const [createdDate, setCreatedDate] = useSyncedState('createdDate', 0); @@ -107,6 +108,12 @@ function Widget() { propertyName: 'logTypes', isToggled: showLogTypes, }, + { + itemType: 'toggle', + tooltip: 'Avatars', + propertyName: 'avatars', + isToggled: showAvatars, + }, { itemType: 'toggle', tooltip: 'Branding', @@ -142,6 +149,9 @@ function Widget() { case 'logTypes': setShowLogTypes(!showLogTypes); break; + case 'avatars': + setShowAvatars(!showAvatars); + break; case 'isLocked': setIsLocked(!isLocked); break; @@ -191,6 +201,7 @@ function Widget() { deleteChange={deleteChange} setUpdatedDate={setUpdatedDate} showTypes={showLogTypes} + showAvatars={showAvatars} isLocked={isLocked} /> )} diff --git a/widget-src/components/ChangeLogList.tsx b/widget-src/components/ChangeLogList.tsx index e314bfc..742bd44 100644 --- a/widget-src/components/ChangeLogList.tsx +++ b/widget-src/components/ChangeLogList.tsx @@ -12,6 +12,7 @@ interface ChangeLogListProps { deleteChange: (changeId: string) => void; setUpdatedDate: (updatedDate: number) => void; showTypes: boolean; + showAvatars: boolean; isLocked: boolean; } @@ -22,6 +23,7 @@ export const ChangeLogList = ({ deleteChange, setUpdatedDate, showTypes, + showAvatars, isLocked, }: ChangeLogListProps) => { useEffect(() => { @@ -58,6 +60,7 @@ export const ChangeLogList = ({ deleteChange={() => deleteChange(changeLogId)} setUpdatedDate={setUpdatedDate} showTypes={showTypes} + showAvatars={showAvatars} locked={isLocked} /> ); diff --git a/widget-src/components/ChangeLogRow.tsx b/widget-src/components/ChangeLogRow.tsx index d339a2b..da6d8e1 100644 --- a/widget-src/components/ChangeLogRow.tsx +++ b/widget-src/components/ChangeLogRow.tsx @@ -17,6 +17,7 @@ interface ChangeLogRowProps { deleteChange: () => void; setUpdatedDate: (updatedDate: number) => void; showTypes: boolean; + showAvatars: boolean; locked: boolean; } @@ -30,6 +31,7 @@ export const ChangeLogRow = ({ deleteChange, setUpdatedDate, showTypes, + showAvatars, locked, }: ChangeLogRowProps) => { return ( @@ -42,7 +44,12 @@ export const ChangeLogRow = ({ width="fill-parent" > - + {!!changeLog.state?.editing && !locked ? ( { +export const User = ({ userName, userPhotoUrl, showAvatars, isLastRow }: UserProps) => { return ( { spacing={GAP.none} padding={{ top: PADDING.xl, + right: showAvatars ? PADDING.none : PADDING.sm, bottom: isLastRow ? PADDING.xxs : PADDING.xl, - horizontal: PADDING.none, + left: PADDING.none, }} height="fill-parent" horizontalAlignItems="center" > - - {userPhotoUrl ? ( - - ) : ( - - )} - - - + {showAvatars && ( + + {userPhotoUrl ? ( + + ) : ( + + )} + + + )} + ); };