From ef013bf64bde5cba0cca4f54d54697229b8d9644 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 2 Sep 2024 09:18:43 -0400 Subject: [PATCH 1/2] fix: default avatar icon size Signed-off-by: Adam Setch --- .../RepositoryNotifications.test.tsx.snap | 20 +++++++++---------- src/components/icons/AvatarIcon.tsx | 5 ++++- .../__snapshots__/AvatarIcon.test.tsx.snap | 8 ++++---- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap b/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap index 31eacbd20..716b1ccc1 100644 --- a/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap +++ b/src/components/__snapshots__/RepositoryNotifications.test.tsx.snap @@ -261,10 +261,10 @@ exports[`components/Repository.tsx should toggle account notifications visibilit class="text-gray-500 dark:text-gray-300" fill="currentColor" focusable="false" - height="12" + height="16" style="display: inline-block; user-select: none; vertical-align: text-bottom; overflow: visible;" viewBox="0 0 16 16" - width="12" + width="16" > = (props: IAvatarIcon) => { ); } + const defaultIconSize = + props.size === Size.XSMALL ? 16 : props.size === Size.SMALL ? 20 : 24; + return ( ); diff --git a/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap b/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap index b659b6fe0..2fefab8b2 100644 --- a/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap +++ b/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap @@ -10,10 +10,10 @@ exports[`components/icons/AvatarIcon.tsx should render default icon when no url class="text-gray-500 dark:text-gray-300" fill="currentColor" focusable="false" - height="12" + height="16" style="display: inline-block; user-select: none; vertical-align: text-bottom; overflow: visible;" viewBox="0 0 16 16" - width="12" + width="16" > Date: Mon, 2 Sep 2024 09:24:52 -0400 Subject: [PATCH 2/2] fix: default avatar icon size Signed-off-by: Adam Setch --- src/components/icons/AvatarIcon.test.tsx | 24 ++- .../__snapshots__/AvatarIcon.test.tsx.snap | 184 +++++++++++++++++- 2 files changed, 206 insertions(+), 2 deletions(-) diff --git a/src/components/icons/AvatarIcon.test.tsx b/src/components/icons/AvatarIcon.test.tsx index d1e986043..6dffd386d 100644 --- a/src/components/icons/AvatarIcon.test.tsx +++ b/src/components/icons/AvatarIcon.test.tsx @@ -37,7 +37,7 @@ describe('components/icons/AvatarIcon.tsx', () => { expect(tree).toMatchSnapshot(); }); - it('should render default icon when no url', () => { + it('should render default extra small icon when no url', () => { const props: IAvatarIcon = { defaultIcon: MarkGithubIcon, title: 'test', @@ -47,4 +47,26 @@ describe('components/icons/AvatarIcon.tsx', () => { const tree = render(); expect(tree).toMatchSnapshot(); }); + + it('should render default small icon when no url', () => { + const props: IAvatarIcon = { + defaultIcon: MarkGithubIcon, + title: 'test', + url: null, + size: Size.SMALL, + }; + const tree = render(); + expect(tree).toMatchSnapshot(); + }); + + it('should render default medium icon when no url', () => { + const props: IAvatarIcon = { + defaultIcon: MarkGithubIcon, + title: 'test', + url: null, + size: Size.MEDIUM, + }; + const tree = render(); + expect(tree).toMatchSnapshot(); + }); }); diff --git a/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap b/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap index 2fefab8b2..e114d0ee3 100644 --- a/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap +++ b/src/components/icons/__snapshots__/AvatarIcon.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`components/icons/AvatarIcon.tsx should render default icon when no url 1`] = ` +exports[`components/icons/AvatarIcon.tsx should render default extra small icon when no url 1`] = ` { "asFragment": [Function], "baseElement": @@ -91,6 +91,188 @@ exports[`components/icons/AvatarIcon.tsx should render default icon when no url } `; +exports[`components/icons/AvatarIcon.tsx should render default medium icon when no url 1`] = ` +{ + "asFragment": [Function], + "baseElement": +
+ +
+ , + "container":
+ +
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`components/icons/AvatarIcon.tsx should render default small icon when no url 1`] = ` +{ + "asFragment": [Function], + "baseElement": +
+ +
+ , + "container":
+ +
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + exports[`components/icons/AvatarIcon.tsx should render extra small avatar 1`] = ` { "asFragment": [Function],