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 Spinner from Gatsby to Next.js(TS) #1462

Merged
merged 10 commits into from
Jan 20, 2021

Conversation

c3ho
Copy link
Contributor

@c3ho c3ho commented Nov 26, 2020

Issue This PR Addresses

Fixes #1479

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

Porting from Gatsby to Next JS + changing JS to TS for the Spinner component.

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@c3ho c3ho changed the title Search page Port SearchPage from Gatsby to Next.js(TS) Nov 26, 2020
@@ -0,0 +1,54 @@
import React, { FC, FormEvent, useState } from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

In this thread:

Next.js automatically adds the React import when JSX is used indeed. However keep in mind that we do still need to import React from 'react' when the React variable is used.

Comment on lines 10 to 13
type SearchPageProps = {
text: string;
filter: string;
};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
type SearchPageProps = {
text: string;
filter: string;
};
interface SearchPageProps {
text: string | null;
filter: string | null;
};

@c3ho c3ho added Blocked Can't do this, until something else is done area: front-end labels Nov 27, 2020
@c3ho c3ho self-assigned this Nov 27, 2020
@rogercyyu rogercyyu marked this pull request as ready for review November 30, 2020 16:47
@rogercyyu
Copy link
Contributor

whoops, sorry. Accidentally clicked that button.

@rogercyyu rogercyyu marked this pull request as draft November 30, 2020 16:50
@c3ho c3ho changed the title Port SearchPage from Gatsby to Next.js(TS) Port SearchPage + Spinner from Gatsby to Next.js(TS) Dec 3, 2020
@c3ho c3ho linked an issue Dec 3, 2020 that may be closed by this pull request
@c3ho c3ho marked this pull request as ready for review December 4, 2020 00:33
@humphd
Copy link
Contributor

humphd commented Jan 15, 2021

@c3ho could you rebase this for package.json changes?

@humphd humphd added this to the 1.5 Release milestone Jan 19, 2021
@humphd humphd added area: nextjs Nextjs related issues Priority: High labels Jan 19, 2021
"react-dom": "^16.13.1"
"react-dom": "^16.13.1",
"swr": "^0.3.9",
"use-query-params": "^1.1.9"
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these are already merged into next now

Comment on lines 1 to 14
import { FC } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import CircularProgress from '@material-ui/core/CircularProgress';

const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
'& > * + *': {
marginLeft: theme.spacing(2),
},
},
}));

const Spinner: FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { FC } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import CircularProgress from '@material-ui/core/CircularProgress';
const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
'& > * + *': {
marginLeft: theme.spacing(2),
},
},
}));
const Spinner: FC = () => {
import { makeStyles } from '@material-ui/core/styles';
import CircularProgress from '@material-ui/core/CircularProgress';
const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
'& > * + *': {
marginLeft: theme.spacing(2),
},
},
}));
const Spinner = () => {

AFAIK we don't need to import FC

@@ -0,0 +1,54 @@
import { FC, FormEvent, useState } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { FC, FormEvent, useState } from 'react';
import { FormEvent, useState } from 'react';

},
}));

const SearchPage: FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const SearchPage: FC = () => {
const SearchPage = () => {

// via `textParam` and `filterParam`. The <SearchBar> UI uses our internal
// state values, and the <SearchResults> only update on page load or when
// the user submits the form.
const [textParam = '', setTextParam] = useQueryParam('text', StringParam);
Copy link
Contributor

Choose a reason for hiding this comment

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

So I merged in the current master to this pr and I'm getting errors when trying to render <SearchPage />:

Error: useQueryParams must be used within a QueryParamProvider

Got any ideas?

@@ -0,0 +1,85 @@
import { FC } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { FC } from 'react';

},
}));

const SearchResults: FC<SearchPageProps> = ({ text, filter }: SearchPageProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const SearchResults: FC<SearchPageProps> = ({ text, filter }: SearchPageProps) => {
const SearchResults = ({ text, filter }: SearchPageProps) => {

if (error) {
return (
<Container className={classes.searchResults}>
<Box className={classes.root} boxShadow={2} marginTop={10}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting Property 'root' does not exist on type 'Record<"spinner" | "searchResults", string>'. with the latest master merge, same with line 52 and 53.

But I'm getting No search results when rendering the component so I think it's fine.

@chrispinkney
Copy link
Contributor

So that was a lot, to the point where I feel like I might be doing something wrong on my end, haha. Let me know what you think, plz n thanks!

@c3ho c3ho changed the title Port SearchPage + Spinner from Gatsby to Next.js(TS) Port Spinner from Gatsby to Next.js(TS) Jan 20, 2021
@c3ho c3ho removed the Blocked Can't do this, until something else is done label Jan 20, 2021
Copy link
Member

@manekenpix manekenpix left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Peek 2021-01-20 10-17

Copy link
Contributor

@chrispinkney chrispinkney left a comment

Choose a reason for hiding this comment

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

😍

@chrispinkney chrispinkney merged commit 46f2c4c into Seneca-CDOT:master Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: front-end area: nextjs Nextjs related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port Spinner from Gatsby to Next.js(TS)
5 participants