{navItems.map(navlink => (
diff --git a/components/Nav/NavMobile/__tests__/NavMobile.test.js b/components/Nav/NavMobile/__tests__/NavMobile.test.tsx
similarity index 89%
rename from components/Nav/NavMobile/__tests__/NavMobile.test.js
rename to components/Nav/NavMobile/__tests__/NavMobile.test.tsx
index 5feacb8d1..494b8482d 100644
--- a/components/Nav/NavMobile/__tests__/NavMobile.test.js
+++ b/components/Nav/NavMobile/__tests__/NavMobile.test.tsx
@@ -49,7 +49,9 @@ describe('NavMobile', () => {
/>,
);
- fireEvent.click(wrapper.queryByTestId('Hamburger Button'));
+ const hamburgerButton = wrapper.queryByTestId('Hamburger Button')!;
+
+ fireEvent.click(hamburgerButton);
expect(mockOpen).toHaveBeenCalled();
});
@@ -61,7 +63,9 @@ describe('NavMobile', () => {
{}} closeMenu={mockClose} />,
);
- fireEvent.click(wrapper.queryByTestId(CLOSE_BUTTON));
+ const closeButton = wrapper.queryByTestId(CLOSE_BUTTON)!;
+
+ fireEvent.click(closeButton);
expect(mockClose).toHaveBeenCalled();
});
diff --git a/components/Nav/NavMobile/__tests__/__snapshots__/NavMobile.test.js.snap b/components/Nav/NavMobile/__tests__/__snapshots__/NavMobile.test.tsx.snap
similarity index 100%
rename from components/Nav/NavMobile/__tests__/__snapshots__/NavMobile.test.js.snap
rename to components/Nav/NavMobile/__tests__/__snapshots__/NavMobile.test.tsx.snap
From f03f239474422d4250a0c5190b2fc3bb49ecf16f Mon Sep 17 00:00:00 2001
From: Michael Stedman <46408716+recondesigns@users.noreply.github.com>
Date: Tue, 5 Mar 2024 01:53:40 -0600
Subject: [PATCH 04/16] removed commented code and added default null value to
props type
---
components/Nav/NavListItem/NavListItem.tsx | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/components/Nav/NavListItem/NavListItem.tsx b/components/Nav/NavListItem/NavListItem.tsx
index 6f1a47f77..58eee068c 100644
--- a/components/Nav/NavListItem/NavListItem.tsx
+++ b/components/Nav/NavListItem/NavListItem.tsx
@@ -29,12 +29,7 @@ export type NavListItemPropsType = {
icon?: React.ReactElement | null;
};
-NavListItem.defaultProps = {
- sublinks: [],
- icon: null,
-};
-
-function NavListItem({ sublinks, href, name, icon }: NavListItemPropsType) {
+function NavListItem({ sublinks, href, name, icon = null }: NavListItemPropsType) {
const [areSublinksVisible, setSublinksVisible] = useState(false);
const handleKeyDown = (event: React.KeyboardEvent, indexKeyedOn: number) => {
From b4a153fbe5705c23a55a1556731dde8cff248423 Mon Sep 17 00:00:00 2001
From: Michael Stedman <46408716+recondesigns@users.noreply.github.com>
Date: Tue, 5 Mar 2024 18:34:51 -0600
Subject: [PATCH 05/16] migrated Nav files to .tsx and updated snapshot
---
components/Nav/{Nav.js => Nav.tsx} | 3 ++-
components/Nav/__tests__/{Nav.test.js => Nav.test.tsx} | 5 ++++-
.../__snapshots__/{Nav.test.js.snap => Nav.test.tsx.snap} | 0
3 files changed, 6 insertions(+), 2 deletions(-)
rename components/Nav/{Nav.js => Nav.tsx} (96%)
rename components/Nav/__tests__/{Nav.test.js => Nav.test.tsx} (91%)
rename components/Nav/__tests__/__snapshots__/{Nav.test.js.snap => Nav.test.tsx.snap} (100%)
diff --git a/components/Nav/Nav.js b/components/Nav/Nav.tsx
similarity index 96%
rename from components/Nav/Nav.js
rename to components/Nav/Nav.tsx
index af6cea340..7419692c6 100644
--- a/components/Nav/Nav.js
+++ b/components/Nav/Nav.tsx
@@ -25,7 +25,7 @@ export const Nav = () => {
document.body.style.overflow = 'auto';
};
- const redirectRightClick = event_ => {
+ const redirectRightClick = (event_: React.MouseEvent) => {
event_.preventDefault();
Router.push('/branding');
};
@@ -66,6 +66,7 @@ export const Nav = () => {
key={navItem.name}
{...navItem}
icon={
+ // @ts-expect-error
navItem.icon === 'UserLogo' ? : null
}
/>
diff --git a/components/Nav/__tests__/Nav.test.js b/components/Nav/__tests__/Nav.test.tsx
similarity index 91%
rename from components/Nav/__tests__/Nav.test.js
rename to components/Nav/__tests__/Nav.test.tsx
index 065d3adca..c79eb0ecf 100644
--- a/components/Nav/__tests__/Nav.test.js
+++ b/components/Nav/__tests__/Nav.test.tsx
@@ -1,3 +1,4 @@
+// @ts-expect-error
import cookie from 'js-cookie';
import { fireEvent, render, screen } from '@testing-library/react';
import { CLOSE_BUTTON } from 'common/constants/testIDs';
@@ -25,7 +26,9 @@ describe('Nav', () => {
expect(screen.queryByTestId('Mobile Nav')).toBeNull();
- fireEvent.click(screen.queryByTestId('Hamburger Button'));
+ const hamburgerButton = screen.queryByTestId('Hamburger Button')!;
+
+ fireEvent.click(hamburgerButton);
expect(await screen.findByTestId('Mobile Nav')).not.toBeNull();
});
diff --git a/components/Nav/__tests__/__snapshots__/Nav.test.js.snap b/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap
similarity index 100%
rename from components/Nav/__tests__/__snapshots__/Nav.test.js.snap
rename to components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap
From 0384517889e357f00d6daa7e9aa1f15372050dd5 Mon Sep 17 00:00:00 2001
From: Michael Stedman <46408716+recondesigns@users.noreply.github.com>
Date: Tue, 5 Mar 2024 18:49:25 -0600
Subject: [PATCH 06/16] migrated OutboudLink files to .tsx and updated
snapshots
---
.../__snapshots__/Footer.test.tsx.snap | 1 -
.../{OutboundLink.js => OutboundLink.tsx} | 44 ++++++++++++-------
.../__stories__/OutboundLink.stories.js | 17 -------
.../__stories__/OutboundLink.stories.tsx | 21 +++++++++
...oundLink.test.js => OutboundLink.test.tsx} | 0
...est.js.snap => OutboundLink.test.tsx.snap} | 0
.../__snapshots__/PressLinks.test.js.snap | 44 -------------------
.../__snapshots__/Timeline.test.js.snap | 14 ------
8 files changed, 48 insertions(+), 93 deletions(-)
rename components/OutboundLink/{OutboundLink.js => OutboundLink.tsx} (65%)
delete mode 100644 components/OutboundLink/__stories__/OutboundLink.stories.js
create mode 100644 components/OutboundLink/__stories__/OutboundLink.stories.tsx
rename components/OutboundLink/__tests__/{OutboundLink.test.js => OutboundLink.test.tsx} (100%)
rename components/OutboundLink/__tests__/__snapshots__/{OutboundLink.test.js.snap => OutboundLink.test.tsx.snap} (100%)
diff --git a/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap b/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap
index 11b93c839..67ddec067 100644
--- a/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap
+++ b/components/Footer/__tests__/__snapshots__/Footer.test.tsx.snap
@@ -219,7 +219,6 @@ exports[`Footer > should render with no props passed 1`] = `
Privacy
diff --git a/components/OutboundLink/OutboundLink.js b/components/OutboundLink/OutboundLink.tsx
similarity index 65%
rename from components/OutboundLink/OutboundLink.js
rename to components/OutboundLink/OutboundLink.tsx
index 18fa8a9f9..5a534f3b5 100644
--- a/components/OutboundLink/OutboundLink.js
+++ b/components/OutboundLink/OutboundLink.tsx
@@ -1,23 +1,33 @@
-import { bool, node, string } from 'prop-types';
import { gtag } from 'common/utils/thirdParty/gtag';
import ExternalLinkIcon from 'static/images/icons/FontAwesome/external-link-square-alt-solid.svg';
import ScreenReaderOnly from 'components/ScreenReaderOnly/ScreenReaderOnly';
import classNames from 'node_modules/classnames/index';
-OutboundLink.propTypes = {
- // will report this label plus the URL from where it was clicked
- analyticsEventLabel: string.isRequired,
- children: node.isRequired,
- className: string,
- 'data-testid': string,
- hasIcon: bool,
- href: string.isRequired,
-};
-
-OutboundLink.defaultProps = {
- className: undefined,
- 'data-testid': undefined,
- hasIcon: true,
+export type OutboundLinkPropsType = {
+ /**
+ * will report this label plus the URL from where it was clicked
+ */
+ analyticsEventLabel: string;
+ /**
+ * Url path for the link.
+ */
+ href: string;
+ /**
+ * Content to be rendered as the link.
+ */
+ children: React.ReactNode;
+ /**
+ * Name of style class to use.
+ */
+ className?: string;
+ /**
+ * Sets an id to the base element for testing.
+ */
+ 'data-testid'?: string;
+ /**
+ * Adds an an icon to identify link is an external link.
+ */
+ hasIcon?: boolean;
};
function OutboundLink({
@@ -25,9 +35,9 @@ function OutboundLink({
children,
'data-testid': testID,
className,
- hasIcon,
+ hasIcon = true,
href,
-}) {
+}: OutboundLinkPropsType) {
const isNotMailToLink = !href.startsWith('mailto:');
const trackOutboundLinkClick = () => {
diff --git a/components/OutboundLink/__stories__/OutboundLink.stories.js b/components/OutboundLink/__stories__/OutboundLink.stories.js
deleted file mode 100644
index 27d91369e..000000000
--- a/components/OutboundLink/__stories__/OutboundLink.stories.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { descriptions } from 'common/constants/descriptions';
-import OutboundLink from '../OutboundLink';
-
-export default {
- component: OutboundLink,
- title: 'OutboundLink',
-};
-
-const Template = arguments_ => ;
-
-// Default OutboundLink supplied with only required args
-export const Default = Template.bind({});
-Default.args = {
- analyticsEventLabel: 'Event label',
- children: descriptions.short,
- href: '#',
-};
diff --git a/components/OutboundLink/__stories__/OutboundLink.stories.tsx b/components/OutboundLink/__stories__/OutboundLink.stories.tsx
new file mode 100644
index 000000000..29fbf9894
--- /dev/null
+++ b/components/OutboundLink/__stories__/OutboundLink.stories.tsx
@@ -0,0 +1,21 @@
+import { Meta, StoryObj } from '@storybook/react';
+import { descriptions } from 'common/constants/descriptions';
+import OutboundLink from '../OutboundLink';
+
+type OutboudLinkStoryType = StoryObj;
+
+const meta: Meta = {
+ title: 'OutboundLink',
+ component: OutboundLink,
+ args: {
+ analyticsEventLabel: 'Event label',
+ children: descriptions.short,
+ href: '#',
+ },
+};
+
+export default meta;
+
+export const Default: OutboudLinkStoryType = {
+ render: args => ,
+};
diff --git a/components/OutboundLink/__tests__/OutboundLink.test.js b/components/OutboundLink/__tests__/OutboundLink.test.tsx
similarity index 100%
rename from components/OutboundLink/__tests__/OutboundLink.test.js
rename to components/OutboundLink/__tests__/OutboundLink.test.tsx
diff --git a/components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.js.snap b/components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.tsx.snap
similarity index 100%
rename from components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.js.snap
rename to components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.tsx.snap
diff --git a/components/Press/PressLinks/__tests__/__snapshots__/PressLinks.test.js.snap b/components/Press/PressLinks/__tests__/__snapshots__/PressLinks.test.js.snap
index b316be82d..0f5bdc2e0 100644
--- a/components/Press/PressLinks/__tests__/__snapshots__/PressLinks.test.js.snap
+++ b/components/Press/PressLinks/__tests__/__snapshots__/PressLinks.test.js.snap
@@ -45,7 +45,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
New program aims to help veterans land jobs in tech industry
@@ -54,7 +53,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Veterans in Residence
@@ -63,7 +61,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
After Flying Solo, Veterans Find Others Who Have Their Backs
@@ -77,7 +74,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
How Tech Pros Can Volunteer in Fun Ways
@@ -86,7 +82,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
MassChallenge Finalists: Finnest, Operation Code, Sunrise Health
@@ -95,7 +90,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
TechBreakfast at Microsoft NERD
@@ -104,7 +98,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Operation Code - #BNT80 Boston New Technology Startup Demo
@@ -113,7 +106,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
MassChallenge Finalist | Operation Code | Conrad Hollomon
@@ -122,7 +114,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Operation Code – Creating a Coding Community with Veterans and Citizens
@@ -131,7 +122,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Innovation Spotlight: Operation Code
@@ -140,7 +130,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
tech4vets Masschallenge Veterans
@@ -154,7 +143,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
TechHire Educator Spotlight: Operation Code
@@ -163,7 +151,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Why Veterans Will Make Excellent Programmers
@@ -172,7 +159,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
THOUSANDS OF VETERANS WANT TO LEARN TO CODE — BUT CAN’T
@@ -181,7 +167,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Hacking Entrepreneurship — An Interview with David Molina of Operation Code
@@ -190,7 +175,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Operation Code: Connecting Veterans with Code Skills
@@ -199,7 +183,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Operation Code: connecting tech and veterans
@@ -208,7 +191,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
When the call of duty is technology, veterans rally to support each other through Operation Code
@@ -217,7 +199,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Get Coding Now with Operation Code Army Veteran and Founder David Molina
@@ -226,7 +207,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
The New Developer - Operation Code - GitHub Universe 2016
@@ -235,7 +215,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
What happens when military veterans learn to code - CodeConf 2016
@@ -244,7 +223,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
How Operation Code helps veterans learn programming skills
@@ -253,7 +231,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Helping Veterans Learn to Code with David Molina
@@ -262,7 +239,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Podcast: a developing story as told by developers
@@ -271,7 +247,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Instagram: David Molina
@@ -280,7 +255,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
From Aviation Electrician to Back End Engineering: Bret Funk’s Operation Code story
@@ -289,7 +263,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Navy Veteran to Software Developer: Geno Guerrero’s Operation Code Story
@@ -298,7 +271,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
From Marine Corps Veteran to Front End Developer: Billy Le’s Operation Code Story
@@ -307,7 +279,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Few Options For Veterans Looking To Enter Tech
@@ -316,7 +287,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Coding Boot Camps Go After Veterans To Take Silicon Valley's Vacant Tech Jobs
@@ -325,7 +295,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
20 Diversity and Inclusion Leaders to Follow in 2018
@@ -334,7 +303,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Tech innovation meets military service: GeekWire’s Memorial Day remembrance and update
@@ -343,7 +311,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
MAP HOSTS CONGRESSIONAL BRIEFING ON VETERANS' READINESS IN TECH CAREERS
@@ -352,7 +319,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Analytics Pros, Inc. Hosts Training for Veterans and Veterans' Spouses
@@ -361,7 +327,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Episode 36 – How to pick a programming language to learn for new developers – Part 2
@@ -370,7 +335,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
How to “upskill” Veterans’ training for technology jobs
@@ -379,7 +343,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Instagram: Operation Code made the front cover of Oregon Veterans News Magazine
@@ -388,7 +351,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Jameel: From Marines to SoftwareEngineer
@@ -397,7 +359,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Seattle coding-school tuition to be covered by GI Bill
@@ -406,7 +367,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Veteran: GI Bill should cover code school
@@ -415,7 +375,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Patriot Boot Camp And Operation Code Join Forces To Help Military Veterans Become Technology Entrepreneurs
@@ -424,7 +383,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Operation Code wants veterans to work in tech
@@ -433,7 +391,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Coding Bootcamps Accepts GI Bill
@@ -442,7 +399,6 @@ exports[`PressLinks > should render with no props passed 1`] = `
Operation Code Looks to Help Veterans Land IT Careers
diff --git a/components/Timeline/__tests__/__snapshots__/Timeline.test.js.snap b/components/Timeline/__tests__/__snapshots__/Timeline.test.js.snap
index f31947bd8..980aeb6e2 100644
--- a/components/Timeline/__tests__/__snapshots__/Timeline.test.js.snap
+++ b/components/Timeline/__tests__/__snapshots__/Timeline.test.js.snap
@@ -36,7 +36,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
AngelHack,
@@ -81,7 +80,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
"Bmore on Rails"
@@ -92,7 +90,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
One Month's Rails
@@ -103,7 +100,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
Patriot Boot Camp
@@ -163,7 +159,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
Cascadia Ruby,
@@ -174,7 +169,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
Code Fellows,
@@ -185,7 +179,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
GitHub
@@ -204,7 +197,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
Code Fellows,
@@ -215,7 +207,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
hack.summit,
@@ -294,7 +285,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
VET TEC
@@ -305,7 +295,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
VET TEC
@@ -350,7 +339,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
Guidestar.org,
@@ -402,7 +390,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
Platinum Seal of Transparency
@@ -413,7 +400,6 @@ exports[`Timeline > should render with no props passed passed 1`] = `
Guidestar.org,
From 901db7fef2a9514460b4a9128c8c363ae1b48207 Mon Sep 17 00:00:00 2001
From: Michael Stedman <46408716+recondesigns@users.noreply.github.com>
Date: Tue, 5 Mar 2024 19:17:46 -0600
Subject: [PATCH 07/16] migrated Pagination files and components to .tsx and
updated snapshots
---
.../{Pagination.js => Pagination.tsx} | 34 ++++++++++----
.../{PaginationItem.js => PaginationItem.tsx} | 47 ++++++++++++-------
...onItem.test.js => PaginationItem.test.tsx} | 0
...t.js.snap => PaginationItem.test.tsx.snap} | 0
.../__stories__/Pagination.stories.js | 37 ---------------
.../__stories__/Pagination.stories.tsx | 44 +++++++++++++++++
...Pagination.test.js => Pagination.test.tsx} | 4 +-
....test.js.snap => Pagination.test.tsx.snap} | 0
8 files changed, 101 insertions(+), 65 deletions(-)
rename components/Pagination/{Pagination.js => Pagination.tsx} (88%)
rename components/Pagination/PaginationItem/{PaginationItem.js => PaginationItem.tsx} (56%)
rename components/Pagination/PaginationItem/__tests__/{PaginationItem.test.js => PaginationItem.test.tsx} (100%)
rename components/Pagination/PaginationItem/__tests__/__snapshots__/{PaginationItem.test.js.snap => PaginationItem.test.tsx.snap} (100%)
delete mode 100644 components/Pagination/__stories__/Pagination.stories.js
create mode 100644 components/Pagination/__stories__/Pagination.stories.tsx
rename components/Pagination/__tests__/{Pagination.test.js => Pagination.test.tsx} (97%)
rename components/Pagination/__tests__/__snapshots__/{Pagination.test.js.snap => Pagination.test.tsx.snap} (100%)
diff --git a/components/Pagination/Pagination.js b/components/Pagination/Pagination.tsx
similarity index 88%
rename from components/Pagination/Pagination.js
rename to components/Pagination/Pagination.tsx
index 3e05a05e5..792d88536 100644
--- a/components/Pagination/Pagination.js
+++ b/components/Pagination/Pagination.tsx
@@ -1,24 +1,38 @@
-import { number, string, object } from 'prop-types';
import LeftAngleIcon from 'static/images/icons/FontAwesome/angle-left-solid.svg';
import RightAngleIcon from 'static/images/icons/FontAwesome/angle-right-solid.svg';
import { PREV_PAGE_BUTTON, NEXT_PAGE_BUTTON } from '../../common/constants/testIDs';
import PaginationItem from './PaginationItem/PaginationItem';
-Pagination.propTypes = {
- currentPage: number.isRequired,
- pathname: string.isRequired,
- query: object.isRequired,
- totalPages: number.isRequired,
+export type PaginationPropsType = {
+ /**
+ * Sets the current page number to indicate which PaginationItem is styled differently.
+ */
+ currentPage: number;
+ /**
+ * Sets the current page number to indicate which PaginationItem is styled differently.
+ */
+ pathname: string;
+ /**
+ * Sets the URL path.
+ */
+ query: Record;
+ /**
+ * Sets the total number of pages.
+ */
+ totalPages: number;
};
export const developmentErrors = {
- currentPageValue: value => `The value passed for currentPage is ${value}.`,
+ currentPageValue: (value: number) => `The value passed for currentPage is ${value}.`,
currentPageTooSmall: '"currentPage" cannot be less than 1.',
currentPageTooBig: '"currentPage" cannot be larger than "totalPages".',
mustUsePageAsPathParam: `Your path parameter must be "[page]". See https://nextjs.org/docs/routing/dynamic-routes for more`,
};
-const getPagination = (currentPage, totalPages) => {
+const getPagination = (
+ currentPage: PaginationPropsType['currentPage'],
+ totalPages: PaginationPropsType['totalPages'],
+) => {
// maximum length of the Pagination Bar, should be an odd integer, default is 11
const MAX_VISIBLE_ELEMENTS = 11;
const ELEMENTS_ON_ONE_SIDE = (MAX_VISIBLE_ELEMENTS - 1) / 2; // 5
@@ -59,7 +73,7 @@ const getPagination = (currentPage, totalPages) => {
};
// eslint-disable-next-line react/prop-types
-const PaginationItems = ({ currentPage, pathname, query, totalPages }) => {
+const PaginationItems = ({ currentPage, pathname, query, totalPages }: PaginationPropsType) => {
const { paginationStart, paginationLength, shouldTruncateStart, shouldTruncateEnd } =
getPagination(currentPage, totalPages);
@@ -118,7 +132,7 @@ const PaginationItems = ({ currentPage, pathname, query, totalPages }) => {
);
};
-function Pagination({ currentPage, pathname, query, totalPages }) {
+function Pagination({ currentPage, pathname, query, totalPages }: PaginationPropsType) {
/* Developer Errors */
if (process.env.NODE_ENV !== 'production') {
const isCurrentPageTooSmall = currentPage < 1;
diff --git a/components/Pagination/PaginationItem/PaginationItem.js b/components/Pagination/PaginationItem/PaginationItem.tsx
similarity index 56%
rename from components/Pagination/PaginationItem/PaginationItem.js
rename to components/Pagination/PaginationItem/PaginationItem.tsx
index 340f66cfb..81e8c813c 100644
--- a/components/Pagination/PaginationItem/PaginationItem.js
+++ b/components/Pagination/PaginationItem/PaginationItem.tsx
@@ -1,28 +1,43 @@
import Link from 'next/link';
import omit from 'lodash/omit';
-import { bool, node, number, object, string } from 'prop-types';
import classNames from 'classnames';
import ScreenReaderOnly from 'components/ScreenReaderOnly/ScreenReaderOnly';
import styles from './PaginationItem.module.css';
-PaginationItem.propTypes = {
- children: node.isRequired,
- isCurrent: bool,
- pathname: string.isRequired,
- query: object,
- testId: string.isRequired,
- value: number,
+export type PaginationItemPropsType = {
+ /**
+ * Content to be rendered as the link.
+ */
+ children: React.ReactNode;
+ /**
+ * Sets the URL path
+ */
+ pathname: string;
+ /**
+ * Sets an id to the base element for testing.
+ */
+ testId: string;
+ /**
+ * Sets styles to indicate the current item is selected.
+ */
+ isCurrent?: boolean;
+ query?: Record;
+ value?: number;
};
-PaginationItem.defaultProps = {
- isCurrent: false,
- query: {},
- value: undefined,
-};
-
-function PaginationItem({ children, isCurrent, pathname, query, testId, value }) {
+function PaginationItem({
+ children,
+ isCurrent = false,
+ pathname,
+ query,
+ testId,
+ value,
+}: PaginationItemPropsType) {
const relevantQueryStringObject = omit(query, ['page']);
- const realURL = { pathname: pathname.replace('[page]', value), query: relevantQueryStringObject };
+ const realURL = {
+ pathname: pathname.replace('[page]', String(value)),
+ query: relevantQueryStringObject,
+ };
const isClickable = !!value;
diff --git a/components/Pagination/PaginationItem/__tests__/PaginationItem.test.js b/components/Pagination/PaginationItem/__tests__/PaginationItem.test.tsx
similarity index 100%
rename from components/Pagination/PaginationItem/__tests__/PaginationItem.test.js
rename to components/Pagination/PaginationItem/__tests__/PaginationItem.test.tsx
diff --git a/components/Pagination/PaginationItem/__tests__/__snapshots__/PaginationItem.test.js.snap b/components/Pagination/PaginationItem/__tests__/__snapshots__/PaginationItem.test.tsx.snap
similarity index 100%
rename from components/Pagination/PaginationItem/__tests__/__snapshots__/PaginationItem.test.js.snap
rename to components/Pagination/PaginationItem/__tests__/__snapshots__/PaginationItem.test.tsx.snap
diff --git a/components/Pagination/__stories__/Pagination.stories.js b/components/Pagination/__stories__/Pagination.stories.js
deleted file mode 100644
index db6a7f0f5..000000000
--- a/components/Pagination/__stories__/Pagination.stories.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import Pagination from '../Pagination';
-
-const totalPages = 20;
-
-export default {
- component: Pagination,
- title: 'Pagination',
- argTypes: {
- currentPage: {
- control: {
- type: 'number',
- min: 1,
- max: totalPages,
- },
- },
- },
-};
-
-const Template = arguments_ => {
- return (
- <>
-
- NOTE: This component cannot be interactive outside of the context of a Next.js router.
-
- To see the different states, adjuct controls.
-
-
- >
- );
-};
-export const Default = Template.bind({});
-Default.args = {
- currentPage: 1,
- pathname: '/resources/[page]',
- query: {},
- totalPages,
-};
diff --git a/components/Pagination/__stories__/Pagination.stories.tsx b/components/Pagination/__stories__/Pagination.stories.tsx
new file mode 100644
index 000000000..a56a8dd8c
--- /dev/null
+++ b/components/Pagination/__stories__/Pagination.stories.tsx
@@ -0,0 +1,44 @@
+import { Meta, StoryObj } from '@storybook/react';
+import Pagination from '../Pagination';
+
+type PaginationStoryType = StoryObj;
+
+const totalPages = 20;
+
+const meta: Meta = {
+ title: 'Pagination',
+ component: Pagination,
+ args: {
+ currentPage: 1,
+ pathname: '/resources/[page]',
+ query: {},
+ totalPages,
+ },
+ argTypes: {
+ currentPage: {
+ control: {
+ type: 'number',
+ min: 1,
+ max: totalPages,
+ },
+ },
+ },
+ decorators: [
+ PaginationStory => (
+ <>
+
+ NOTE: This component cannot be interactive outside of the context of a Next.js router.
+
+ To see the different states, adjuct controls.
+
+
+ >
+ ),
+ ],
+};
+
+export default meta;
+
+export const Default: PaginationStoryType = {
+ render: args => ,
+};
diff --git a/components/Pagination/__tests__/Pagination.test.js b/components/Pagination/__tests__/Pagination.test.tsx
similarity index 97%
rename from components/Pagination/__tests__/Pagination.test.js
rename to components/Pagination/__tests__/Pagination.test.tsx
index 005ab379e..2add635eb 100644
--- a/components/Pagination/__tests__/Pagination.test.js
+++ b/components/Pagination/__tests__/Pagination.test.tsx
@@ -52,7 +52,7 @@ describe('Pagination', () => {
it('should throw an error if given value of currentPage is less than 1', () => {
/* eslint-disable function-paren-newline */
expect(() =>
- Pagination({ currentPage: 0, totalPages: 5, pathname: requiredProps.pathname }),
+ Pagination({ currentPage: 0, totalPages: 5, pathname: requiredProps.pathname, query: {} }),
).toThrow(developmentErrors.currentPageTooSmall);
/* eslint-enable function-paren-newline */
});
@@ -60,7 +60,7 @@ describe('Pagination', () => {
it('should throw an error if given value of currentPage is greater than totalPages', () => {
/* eslint-disable function-paren-newline */
expect(() =>
- Pagination({ currentPage: 6, totalPages: 5, pathname: requiredProps.pathname }),
+ Pagination({ currentPage: 6, totalPages: 5, pathname: requiredProps.pathname, query: {} }),
).toThrow(developmentErrors.currentPageTooBig);
/* eslint-enable function-paren-newline */
});
diff --git a/components/Pagination/__tests__/__snapshots__/Pagination.test.js.snap b/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap
similarity index 100%
rename from components/Pagination/__tests__/__snapshots__/Pagination.test.js.snap
rename to components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap
From 3d8b7e3f5e3fd64c46de072070d5da22bf19c65f Mon Sep 17 00:00:00 2001
From: Michael Stedman <46408716+recondesigns@users.noreply.github.com>
Date: Tue, 5 Mar 2024 19:27:56 -0600
Subject: [PATCH 08/16] migrated ParterLogoLink files to .tsx and updated
snaptshot
---
...PartnerLogoLink.js => PartnerLogoLink.tsx} | 37 +++++++++++++------
.../__stories__/PartnerLogoLink.stories.js | 16 --------
.../__stories__/PartnerLogoLink.stories.tsx | 21 +++++++++++
...oLink.test.js => PartnerLogoLink.test.tsx} | 1 -
....js.snap => PartnerLogoLink.test.tsx.snap} | 0
5 files changed, 47 insertions(+), 28 deletions(-)
rename components/PartnerLogoLink/{PartnerLogoLink.js => PartnerLogoLink.tsx} (52%)
delete mode 100644 components/PartnerLogoLink/__stories__/PartnerLogoLink.stories.js
create mode 100644 components/PartnerLogoLink/__stories__/PartnerLogoLink.stories.tsx
rename components/PartnerLogoLink/__tests__/{PartnerLogoLink.test.js => PartnerLogoLink.test.tsx} (99%)
rename components/PartnerLogoLink/__tests__/__snapshots__/{PartnerLogoLink.test.js.snap => PartnerLogoLink.test.tsx.snap} (100%)
diff --git a/components/PartnerLogoLink/PartnerLogoLink.js b/components/PartnerLogoLink/PartnerLogoLink.tsx
similarity index 52%
rename from components/PartnerLogoLink/PartnerLogoLink.js
rename to components/PartnerLogoLink/PartnerLogoLink.tsx
index a3208d7dd..86da5422b 100644
--- a/components/PartnerLogoLink/PartnerLogoLink.js
+++ b/components/PartnerLogoLink/PartnerLogoLink.tsx
@@ -1,16 +1,26 @@
-import { string, oneOf } from 'prop-types';
import Image from 'next/image';
import OutboundLink from 'components/OutboundLink/OutboundLink';
-PartnerLogoLink.propTypes = {
- logoSource: string.isRequired,
- name: string.isRequired,
- url: string.isRequired,
- size: oneOf(['small', 'medium', 'large']),
-};
+type SizeType = 'small' | 'medium' | 'large';
-PartnerLogoLink.defaultProps = {
- size: 'medium',
+export type PartnerLogoLinkPropsType = {
+ /**
+ * Path to the logo image.
+ */
+ logoSource: string;
+ /**
+ * Applies a name for analytics label and alt text for the image.
+ */
+ name: string;
+ /**
+ * Url for the partner.
+ */
+ url: string;
+ /**
+ * Sets the size of the logo.
+ * @default 'medium'
+ */
+ size?: SizeType;
};
const sizeMappings = {
@@ -28,12 +38,17 @@ const sizeMappings = {
},
};
-export default function PartnerLogoLink({ logoSource, name, url, size }) {
+export default function PartnerLogoLink({
+ logoSource,
+ name,
+ url,
+ size = 'medium',
+}: PartnerLogoLinkPropsType) {
return (