Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port blog page to ts #2676

Merged
merged 13 commits into from
Nov 6, 2024
Merged

Port blog page to ts #2676

merged 13 commits into from
Nov 6, 2024

Conversation

RoyEJohnson
Copy link
Contributor

@RoyEJohnson RoyEJohnson commented Oct 23, 2024

@RoyEJohnson RoyEJohnson requested a review from bethshook October 23, 2024 21:41
@bethshook
Copy link
Contributor

are there specific files you'd like eyes on? because this is pretty tricky to follow. in the future you can use git mv to explicitly rename the file and then the diffs will work rather than count the files as removed/added.

@RoyEJohnson RoyEJohnson force-pushed the port-blog-page-to-ts branch 2 times, most recently from 013cfc5 to 49e8101 Compare October 29, 2024 21:57
@@ -5,6 +5,7 @@
background-color: ui-color(white);
justify-items: center;
width: 100%;
overflow: clip;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a layout bug I noticed in the blog article: there is a sticky item that shows how much time is left in the article. It was not being sticky.

@@ -41,8 +42,11 @@ export default function ToggleControlBar({ Indicator, children }) {
onClick={() => toggle()}
onKeyDown={onKeyDown}
ref={focusRef}
role="combobox"
aria-controls={listboxId}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an accessibility fix needed because the testing library identifies accessible objects and this wasn't one.

@RoyEJohnson
Copy link
Contributor Author

@bethshook I have retrofitted file moves into the git history. The "Files changed" tab still shows them as delete and add (because the diffs are not minor enough to show as simply modified -- I moved some code blocks), but if you look in the individual commits after the "mv" or "rename" commits, you can see the file diffs. I think there are four such files:
src/app/pages/blog/article/article.js -> tsx
src/app/pages/blog/article/use-progress.js -> tsx
src/app/pages/blog/search-results/use-all-articles.js -> tsx
test/src/pages/blog/blog.test.js -> tsx

Additionally, blog-pages.tsx was extracted from blog.js (which needed to be js due to dynamic import).

Many test files are simply new. I'm sorry it's such a big PR. Changes are generally these types:

  1. Adding or altering types for TS
  2. Rearranging blocks so that the export default is at the top rather than the bottom
  3. Some amount of reformatting by "prettier"
  4. Tests and changes to test-data files (there's no point in reading through files in test/src/data) I'm hopeful the tests themselves are reasonably readable.

I'll make some comments in the code to explain things that I think might be confusing, and of course if you have questions about stuff, you can comment there.

name?: string;
value: {collection: Collection}[];
};
type CollectionVariant =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types were simply wrong. They shouldn't have been recursive, they just have an optional wrapping layer.


type BlurbData = null | {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BlurbData and ArticleSummaryData were defined independently, but BlurbData is really an extension of ArticleSummaryData.

@@ -0,0 +1,267 @@
import BodyUnit from '~/components/body-units/body-units';
Copy link
Contributor Author

@RoyEJohnson RoyEJohnson Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review as diffs here. Or maybe don't. The rearrangement of blocks is hard to follow because the order is basically reversed.
There are no functional changes. It's all about adding types.

@@ -0,0 +1,51 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can review as differences here. The big-block changes are just reformatting. Other than that, types.

@@ -0,0 +1,212 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View as diffs here. For this one, it's just a bunch of types added. A big block of them at the top, and others peppered throughout.

@@ -0,0 +1,106 @@
import React, {useEffect} from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These routines were extracted from blog.js (the next file down). Types were added. If you had the two files in separate windows, it would be easy to see.

@@ -0,0 +1,33 @@
import {useState, useEffect} from 'react';
Copy link
Contributor Author

@RoyEJohnson RoyEJohnson Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As diffs here. The data.subheading change was due to subheading being a required field. Making the variable was just part of the figuring-it-out process; I should probably take that back out.

@@ -0,0 +1,186 @@
// Blog article data as returned by usePageData
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These next three are just test-data files.

type BodyData = {
type: string;
value:
| string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray |?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird choice of prettier. 🤷


jest.mock('~/pages/blog/pinned-article/pinned-article', () => jest.fn());
jest.mock('~/pages/blog/more-stories/more-stories', () => ({
LatestBlurbs: jest.fn()
}));
jest.mock('~/pages/blog/search-results/use-all-articles', () => jest.fn());
// jest.mock('~/pages/blog/search-results/use-all-articles', () => jest.fn());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

function useSubjectSnippetForTopic(topic?: string) {
const {subjectSnippet} = useBlogContext();

console.info('***', {subjectSnippet, topic});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for dev?


function SubjectSelector() {
const data = useDataFromSlug('snippets/subjects?locale=en');
const {subjectSnippet: data} = useBlogContext();
// const data = useDataFromSlug('snippets/subjects?locale=en');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Contributor

@bethshook bethshook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine to me - just noted a few lines that look like they were added for dev purposes

@RoyEJohnson RoyEJohnson merged commit c875d12 into main Nov 6, 2024
1 check passed
@RoyEJohnson RoyEJohnson deleted the port-blog-page-to-ts branch November 6, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants