Skip to content

Commit

Permalink
hide and show user avatars (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: Christy Presler <[email protected]>
Co-authored-by: Christy Presler <[email protected]>
  • Loading branch information
3 people authored Apr 17, 2024
1 parent 5bb1e9b commit 04c679b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
11 changes: 11 additions & 0 deletions widget-src/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -107,6 +108,12 @@ function Widget() {
propertyName: 'logTypes',
isToggled: showLogTypes,
},
{
itemType: 'toggle',
tooltip: 'Avatars',
propertyName: 'avatars',
isToggled: showAvatars,
},
{
itemType: 'toggle',
tooltip: 'Branding',
Expand Down Expand Up @@ -142,6 +149,9 @@ function Widget() {
case 'logTypes':
setShowLogTypes(!showLogTypes);
break;
case 'avatars':
setShowAvatars(!showAvatars);
break;
case 'isLocked':
setIsLocked(!isLocked);
break;
Expand Down Expand Up @@ -191,6 +201,7 @@ function Widget() {
deleteChange={deleteChange}
setUpdatedDate={setUpdatedDate}
showTypes={showLogTypes}
showAvatars={showAvatars}
isLocked={isLocked}
/>
)}
Expand Down
3 changes: 3 additions & 0 deletions widget-src/components/ChangeLogList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ChangeLogListProps {
deleteChange: (changeId: string) => void;
setUpdatedDate: (updatedDate: number) => void;
showTypes: boolean;
showAvatars: boolean;
isLocked: boolean;
}

Expand All @@ -22,6 +23,7 @@ export const ChangeLogList = ({
deleteChange,
setUpdatedDate,
showTypes,
showAvatars,
isLocked,
}: ChangeLogListProps) => {
useEffect(() => {
Expand Down Expand Up @@ -58,6 +60,7 @@ export const ChangeLogList = ({
deleteChange={() => deleteChange(changeLogId)}
setUpdatedDate={setUpdatedDate}
showTypes={showTypes}
showAvatars={showAvatars}
locked={isLocked}
/>
);
Expand Down
9 changes: 8 additions & 1 deletion widget-src/components/ChangeLogRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ChangeLogRowProps {
deleteChange: () => void;
setUpdatedDate: (updatedDate: number) => void;
showTypes: boolean;
showAvatars: boolean;
locked: boolean;
}

Expand All @@ -30,6 +31,7 @@ export const ChangeLogRow = ({
deleteChange,
setUpdatedDate,
showTypes,
showAvatars,
locked,
}: ChangeLogRowProps) => {
return (
Expand All @@ -42,7 +44,12 @@ export const ChangeLogRow = ({
width="fill-parent"
>
<AutoLayout name="Wrapper" overflow="visible" spacing={GAP.md} width="fill-parent">
<User userName={changeLog.user?.name} userPhotoUrl={changeLog.user?.photoUrl} isLastRow={isLastRow} />
<User
userName={changeLog.user?.name}
userPhotoUrl={changeLog.user?.photoUrl}
showAvatars={showAvatars}
isLastRow={isLastRow}
/>
{!!changeLog.state?.editing && !locked ? (
<ChangeLogEditing
changeLog={changeLog}
Expand Down
65 changes: 32 additions & 33 deletions widget-src/components/log/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ const { AutoLayout, Image, Rectangle, Text } = widget;
interface UserProps {
userName: string | undefined;
userPhotoUrl: string | null | undefined;
showAvatars: boolean;
isLastRow: boolean;
}

export const User = ({ userName, userPhotoUrl, isLastRow }: UserProps) => {
export const User = ({ userName, userPhotoUrl, showAvatars, isLastRow }: UserProps) => {
return (
<AutoLayout
name="User"
Expand All @@ -18,43 +19,41 @@ export const User = ({ userName, userPhotoUrl, isLastRow }: UserProps) => {
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"
>
<AutoLayout name="Avatar" overflow="visible" spacing={GAP.md} verticalAlignItems="center">
{userPhotoUrl ? (
<Image name="UserImage" cornerRadius={RADIUS.lg} width={SPACE.sm} height={SPACE.sm} src={userPhotoUrl} />
) : (
<Rectangle name="Placeholder" fill={COLOR.grey} cornerRadius={RADIUS.lg} width={SPACE.sm} height={SPACE.sm} />
)}
<Text
name="UserName"
hidden={true}
fill={COLOR.black}
lineHeight={FONT.lineHeight.sm}
fontFamily={FONT.family}
fontSize={FONT.size.sm}
letterSpacing={FONT.letterSpacing.sm}
textCase="upper"
>
{userName || 'Unknown User'}
</Text>
</AutoLayout>
<Rectangle
name="Divider"
fill={COLOR.grey}
cornerRadius={{
topLeft: RADIUS.none,
topRight: RADIUS.none,
bottomRight: RADIUS.md,
bottomLeft: RADIUS.md,
}}
width={SPACE.one}
height="fill-parent"
/>
{showAvatars && (
<AutoLayout name="Avatar" overflow="visible" spacing={GAP.md} verticalAlignItems="center">
{userPhotoUrl ? (
<Image name="UserImage" cornerRadius={RADIUS.lg} width={SPACE.sm} height={SPACE.sm} src={userPhotoUrl} />
) : (
<Rectangle
name="Placeholder"
fill={COLOR.grey}
cornerRadius={RADIUS.lg}
width={SPACE.sm}
height={SPACE.sm}
/>
)}
<Text
name="UserName"
hidden={true}
fill={COLOR.black}
lineHeight={FONT.lineHeight.sm}
fontFamily={FONT.family}
fontSize={FONT.size.sm}
letterSpacing={FONT.letterSpacing.sm}
textCase="upper"
>
{userName || 'Unknown User'}
</Text>
</AutoLayout>
)}
<Rectangle name="Divider" fill={COLOR.grey} cornerRadius={RADIUS.md} width={SPACE.one} height="fill-parent" />
</AutoLayout>
);
};

0 comments on commit 04c679b

Please sign in to comment.