Skip to content

Upgrade Dependencies - React 18 #372

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

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
v16.17.0
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/gallium
33 changes: 20 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
{
"name": "jsnes-web",
"version": "0.1.0",
"version": "1.0.0",
"license": "Apache-2.0",
"private": true,
"dependencies": {
"bootstrap": "4.2.1",
"jsnes": "git://github.com/bfirsh/jsnes.git",
"node-sass": "^4.13.1",
"prop-types": "^15.7.2",
"bootstrap": "5.2.0",
"jsnes": "git+ssh://[email protected]/bfirsh/jsnes.git",
"prop-types": "^15.8.1",
"raven-js": "^3.27.2",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-ga": "^2.5.7",
"react-router-dom": "^5.0.0",
"reactstrap": "^7.1.0",
"ringbufferjs": "^1.1.0"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-router-dom": "^6.3.0",
"reactstrap": "^9.1.3",
"ringbufferjs": "^1.1.0",
"sass": "^1.54.5"
},
"devDependencies": {
"canvas": "^2.6.1",
"canvas": "^2.9.3",
"prettier": "^1.16.4",
"prettier-check": "^2.0.0",
"react-scripts": "3.4.1"
"react-scripts": "5.0.1",
"@svgr/webpack": "^6.3.1"
},
"overrides": {
"@svgr/webpack": "$@svgr/webpack"
},
"resolutions": {
"@svgr/webpack": "^6.3.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
12 changes: 7 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";
import GoogleAnalytics from "react-ga";
import { BrowserRouter, Route } from "react-router-dom";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import ListPage from "./ListPage";
import RunPage from "./RunPage";
import config from "./config";
Expand Down Expand Up @@ -31,10 +31,12 @@ class App extends Component {
return (
<BrowserRouter>
<div className="App">
<Route exact path="/" component={ListPage} />
<Route exact path="/run" component={RunPage} />
<Route exact path="/run/:slug" component={RunPage} />
<Route path="/" render={this.recordPageview} />
<Routes>
<Route exact path="/" element={<ListPage />} />
<Route path="/run/:slug" element={<RunPage />} />
<Route path="/run" element={<RunPage />} />
<Route path="/" element={this.recordPageview} />
</Routes>
</div>
</BrowserRouter>
);
Expand Down
12 changes: 12 additions & 0 deletions src/ListPage.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
.ListPage {
padding-bottom: 1.5rem!important;
}

.ListPage .list-group-item {
position: relative;
display: block;
padding: 0.75rem 1.25rem;
background-color: #000;
border: 1px solid #dee2e6;
}

.ListPage .list-group-item .delete {
color: red;
margin-left: 0.8em;
Expand Down
4 changes: 2 additions & 2 deletions src/ListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ListPage extends Component {
className="list-group-item"
>
{config.ROMS[key]["name"]}
<span className="float-right">&rsaquo;</span>
<span className="float-end">&rsaquo;</span>
</Link>
))}
</ListGroup>
Expand Down Expand Up @@ -77,7 +77,7 @@ class ListPage extends Component {
>
&times;
</span>
<span className="float-right">&rsaquo;</span>
<span className="float-end">&rsaquo;</span>
</Link>
))}
</ListGroup>
Expand Down
13 changes: 6 additions & 7 deletions src/ListPage.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from "react";
import ReactDOM from "react-dom";
import { StaticRouter, Route } from "react-router-dom";
import {createRoot} from "react-dom/client";
import { Routes, Route } from "react-router-dom";
import ListPage from "./ListPage";

describe("ListPage", () => {
it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(
<StaticRouter location="/" context={{}}>
const root = createRoot(div)
root.render(
<Routes location="/" context={{}}>
<Route exact path="/" component={ListPage} />
</StaticRouter>,
div
</Routes>
);
});
});
21 changes: 14 additions & 7 deletions src/RunPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";
import { Button, Progress } from "reactstrap";
import { Link } from "react-router-dom";
import { Link, useLocation, useParams } from "react-router-dom";

import config from "./config";
import ControlsModal from "./ControlsModal";
Expand All @@ -10,6 +10,12 @@ import { loadBinary } from "./utils";

import "./RunPage.css";

function withParams(Component) {
return props => (
<Component {...props} params={useParams()} location={useLocation()} />
);
}

/*
* The UI for the emulator. Also responsible for loading ROM from URL or file.
*/
Expand Down Expand Up @@ -44,9 +50,9 @@ class RunPage extends Component {
</Link>
</li>
</ul>
<ul className="navbar-nav ml-auto mr-auto">
<ul className="navbar-nav ms-auto me-auto">
<li className="navitem">
<span className="navbar-text mr-3">{this.state.romName}</span>
<span className="navbar-text me-3">{this.state.romName}</span>
</li>
</ul>
<ul className="navbar-nav" style={{ width: "200px" }}>
Expand All @@ -55,7 +61,7 @@ class RunPage extends Component {
outline
color="primary"
onClick={this.toggleControlsModal}
className="mr-3"
className="me-3"
>
Controls
</Button>
Expand Down Expand Up @@ -134,8 +140,9 @@ class RunPage extends Component {
}

load = () => {
if (this.props.match.params.slug) {
const slug = this.props.match.params.slug;
console.log("load");
if (this.props.params.slug) {
const slug = this.props.params.slug;
const isLocalROM = /^local-/.test(slug);
const romHash = slug.split("-")[1];
const romInfo = isLocalROM
Expand Down Expand Up @@ -205,4 +212,4 @@ class RunPage extends Component {
};
}

export default RunPage;
export default withParams(RunPage);
14 changes: 7 additions & 7 deletions src/RunPage.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from "react";
import ReactDOM from "react-dom";
import { StaticRouter, Route } from "react-router-dom";
import {createRoot} from "react-dom/client";
import { Routes, Route } from "react-router-dom";
import RunPage from "./RunPage";

describe("RunPage", () => {
it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(
<StaticRouter location="/roms/foo.nes" context={{}}>
const root = createRoot(div);

root.render(
<Routes location="/roms/foo.nes" context={{}}>
<Route exact path="/run/:rom" component={RunPage} />
</StaticRouter>,
div
</Routes>
);
});
});
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Raven from "raven-js";
import React from "react";
import ReactDOM from "react-dom";
import { createRoot } from "react-dom/client";
import App from "./App";
import config from "./config";
import "./index.scss";
Expand All @@ -10,5 +10,7 @@ if (config.SENTRY_URI) {
}

Raven.context(function() {
ReactDOM.render(<App />, document.getElementById("root"));
const container = document.getElementById("root");
const root = createRoot(container);
root.render(<App />);
});
70 changes: 64 additions & 6 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ $link-decoration: underline;
$link-hover-color: $gray-500;
$link-hover-decoration: underline;

$theme-colors: map-merge($theme-colors, (
primary: $white,
));
$theme-colors: map-merge(
$theme-colors,
(
primary: $white
)
);

$list-group-bg: $black;
$list-group-border-color: $gray-300;
Expand All @@ -39,8 +42,47 @@ $close-text-shadow: none;
}
}

html, body, #root {
html,
body,
#root {
height: 100%;
color: #f8f9fa;
}

a:hover {
color: #adb5bd;
}

.navbar-text,
.navbar-text a,
.nav-link {
color: #f8f9fa;
}

.nav-link:focus {
color: #adb5bd !important;
}

.navbar-text a:focus,
.navbar-text a:active,
.navbar-text a:hover,
.nav-link:hover {
color: #adb5bd;
}
.nav-link {
display: block;
padding: 0.5rem 1rem;
}

.navbar-nav .nav-link {
padding-right: 0.5rem;
padding-left: 0.5rem;
flex-direction: row;
}

.navbar-expand {
padding-left: 16px;
padding-right: 16px;
}

.nav-link {
Expand All @@ -49,19 +91,35 @@ html, body, #root {

.list-group-item {
text-decoration: none;
color: #f8f9fa;
}

.list-group-item:hover {
text-decoration: none;
}

.table thead th {
border-bottom: 2px solid white;
border-top: none;
}

.table th,
.table td {
padding: 0.75rem;
vertical-align: top;
border-top: 1px solid #212529;
}

.close {
opacity: 1;
}

img.controller-icon {
width: 40px;
height: 40px;
width: 40px;
height: 40px;
margin-top: -20px;
}

h1 {
font-size: 2.5rem;
}
Loading