From 24d4cc0b4e6553ab3fef0e55f7c43b2ca7a8916f Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 8 Jul 2024 11:06:00 -0700 Subject: [PATCH 1/2] feat: add header icon --- src/components/Header.test.tsx | 9 ++++-- src/components/Header.tsx | 15 +++++---- .../__snapshots__/Header.test.tsx.snap | 32 +++++++++++++++++-- src/routes/Accounts.tsx | 2 +- src/routes/Filters.tsx | 5 ++- src/routes/LoginWithOAuthApp.tsx | 5 +-- src/routes/LoginWithPersonalAccessToken.tsx | 5 +-- src/routes/Settings.tsx | 5 ++- .../__snapshots__/Accounts.test.tsx.snap | 16 +++++++++- .../__snapshots__/Filters.test.tsx.snap | 16 +++++++++- .../LoginWithOAuthApp.test.tsx.snap | 12 +++---- ...LoginWithPersonalAccessToken.test.tsx.snap | 12 +++---- .../__snapshots__/Settings.test.tsx.snap | 16 +++++++++- 13 files changed, 112 insertions(+), 38 deletions(-) diff --git a/src/components/Header.test.tsx b/src/components/Header.test.tsx index a381c8be8..7633858c7 100644 --- a/src/components/Header.test.tsx +++ b/src/components/Header.test.tsx @@ -1,3 +1,4 @@ +import { MarkGithubIcon } from '@primer/octicons-react'; import { fireEvent, render, screen } from '@testing-library/react'; import { AppContext } from '../context/App'; import { Header } from './Header'; @@ -16,13 +17,13 @@ describe('components/Header.tsx', () => { }); it('should render itself & its children', () => { - const tree = render(
Test Header
); + const tree = render(
Test Header
); expect(tree).toMatchSnapshot(); }); it('should navigate back', () => { - render(
Test Header
); + render(
Test Header
); fireEvent.click(screen.getByLabelText('Go Back')); @@ -36,7 +37,9 @@ describe('components/Header.tsx', () => { fetchNotifications, }} > -
Test Header
+
+ Test Header +
, ); diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 98698d861..c5e3c274c 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,4 +1,4 @@ -import { ArrowLeftIcon } from '@primer/octicons-react'; +import { ArrowLeftIcon, type Icon } from '@primer/octicons-react'; import { type FC, type ReactNode, useContext } from 'react'; import { useNavigate } from 'react-router-dom'; import { AppContext } from '../context/App'; @@ -6,13 +6,11 @@ import { Size } from '../types'; interface IHeader { children: ReactNode; + icon?: Icon; fetchOnBack?: boolean; } -export const Header: FC = ({ - children, - fetchOnBack = false, -}: IHeader) => { +export const Header: FC = (props: IHeader) => { const navigate = useNavigate(); const { fetchNotifications } = useContext(AppContext); @@ -25,7 +23,7 @@ export const Header: FC = ({ title="Go Back" onClick={() => { navigate(-1); - if (fetchOnBack) { + if (props.fetchOnBack) { fetchNotifications(); } }} @@ -37,7 +35,10 @@ export const Header: FC = ({ /> -

{children}

+

+ + {props.children} +

); }; diff --git a/src/components/__snapshots__/Header.test.tsx.snap b/src/components/__snapshots__/Header.test.tsx.snap index 98717155d..7907956c9 100644 --- a/src/components/__snapshots__/Header.test.tsx.snap +++ b/src/components/__snapshots__/Header.test.tsx.snap @@ -30,8 +30,22 @@ exports[`components/Header.tsx should render itself & its children 1`] = `

+ Test Header

@@ -63,8 +77,22 @@ exports[`components/Header.tsx should render itself & its children 1`] = `

+ Test Header

diff --git a/src/routes/Accounts.tsx b/src/routes/Accounts.tsx index 41a859ffa..60e77c572 100644 --- a/src/routes/Accounts.tsx +++ b/src/routes/Accounts.tsx @@ -45,7 +45,7 @@ export const AccountsRoute: FC = () => { return (
-
Accounts
+
Accounts
{auth.accounts.map((account) => ( diff --git a/src/routes/Filters.tsx b/src/routes/Filters.tsx index 295044fd9..8e44789ee 100644 --- a/src/routes/Filters.tsx +++ b/src/routes/Filters.tsx @@ -1,5 +1,6 @@ import { FeedPersonIcon, + FilterIcon, FilterRemoveIcon, NoteIcon, } from '@primer/octicons-react'; @@ -33,7 +34,9 @@ export const FiltersRoute: FC = () => { return (
-
Filters
+
+ Filters +
diff --git a/src/routes/LoginWithOAuthApp.tsx b/src/routes/LoginWithOAuthApp.tsx index bd3b26573..9d0e7df3e 100644 --- a/src/routes/LoginWithOAuthApp.tsx +++ b/src/routes/LoginWithOAuthApp.tsx @@ -128,10 +128,7 @@ export const LoginWithOAuthApp: FC = () => { return (
-
- - Login with OAuth App -
+
Login with OAuth App
{ return ( <> -
- - Login with Personal Access Token -
+
Login with Personal Access Token
{ const { resetSettings } = useContext(AppContext); return (
-
Settings
+
+ Settings +
diff --git a/src/routes/__snapshots__/Accounts.test.tsx.snap b/src/routes/__snapshots__/Accounts.test.tsx.snap index 30e6212d1..b8baa14c9 100644 --- a/src/routes/__snapshots__/Accounts.test.tsx.snap +++ b/src/routes/__snapshots__/Accounts.test.tsx.snap @@ -30,8 +30,22 @@ exports[`routes/Accounts.tsx General should render itself & its children 1`] = `

+ Accounts

diff --git a/src/routes/__snapshots__/Filters.test.tsx.snap b/src/routes/__snapshots__/Filters.test.tsx.snap index fc2c4fbae..fb33a5346 100644 --- a/src/routes/__snapshots__/Filters.test.tsx.snap +++ b/src/routes/__snapshots__/Filters.test.tsx.snap @@ -30,8 +30,22 @@ exports[`routes/Filters.tsx General should render itself & its children 1`] = `

+ Filters

diff --git a/src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap b/src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap index 582a63540..e404eb709 100644 --- a/src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap +++ b/src/routes/__snapshots__/LoginWithOAuthApp.test.tsx.snap @@ -31,17 +31,17 @@ exports[`routes/LoginWithOAuthApp.tsx renders correctly 1`] = `

+ Settings

From 89e4575bbd38030b60d19a254d72e86d2c566879 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 8 Jul 2024 11:08:45 -0700 Subject: [PATCH 2/2] feat: add header icon --- src/components/Header.tsx | 10 +-- .../__snapshots__/Header.test.tsx.snap | 66 +++++++++++-------- .../__snapshots__/Accounts.test.tsx.snap | 33 ++++++---- .../__snapshots__/Filters.test.tsx.snap | 33 ++++++---- .../LoginWithOAuthApp.test.tsx.snap | 66 +++++++++++-------- ...LoginWithPersonalAccessToken.test.tsx.snap | 66 +++++++++++-------- .../__snapshots__/Settings.test.tsx.snap | 33 ++++++---- 7 files changed, 176 insertions(+), 131 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index c5e3c274c..3ecddb9e4 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,12 +1,13 @@ import { ArrowLeftIcon, type Icon } from '@primer/octicons-react'; -import { type FC, type ReactNode, useContext } from 'react'; +import { type FC, useContext } from 'react'; import { useNavigate } from 'react-router-dom'; import { AppContext } from '../context/App'; import { Size } from '../types'; +import { Legend } from './settings/Legend'; interface IHeader { - children: ReactNode; - icon?: Icon; + icon: Icon; + children: string; fetchOnBack?: boolean; } @@ -36,8 +37,7 @@ export const Header: FC = (props: IHeader) => {

- - {props.children} + {props.children}

); diff --git a/src/components/__snapshots__/Header.test.tsx.snap b/src/components/__snapshots__/Header.test.tsx.snap index 7907956c9..b5bf11c58 100644 --- a/src/components/__snapshots__/Header.test.tsx.snap +++ b/src/components/__snapshots__/Header.test.tsx.snap @@ -32,21 +32,26 @@ exports[`components/Header.tsx should render itself & its children 1`] = `

- - Test Header + + Test Header +

@@ -79,21 +84,26 @@ exports[`components/Header.tsx should render itself & its children 1`] = `

- - Test Header + + Test Header +

, diff --git a/src/routes/__snapshots__/Accounts.test.tsx.snap b/src/routes/__snapshots__/Accounts.test.tsx.snap index b8baa14c9..da96fff28 100644 --- a/src/routes/__snapshots__/Accounts.test.tsx.snap +++ b/src/routes/__snapshots__/Accounts.test.tsx.snap @@ -32,21 +32,26 @@ exports[`routes/Accounts.tsx General should render itself & its children 1`] = `

- - Accounts + + Accounts +

- - Filters + + Filters +
- - Login with OAuth App + + Login with OAuth App +
- - Login with OAuth App + + Login with OAuth App +
- - Login with Personal Access Token + + Login with Personal Access Token +
- - Login with Personal Access Token + + Login with Personal Access Token +
- - Settings + + Settings +