Skip to content

Commit

Permalink
Merge pull request #100 from Congress-Dev/bill-page-and-tags
Browse files Browse the repository at this point in the history
Code Formatting and Relative Imports
  • Loading branch information
brooksryba authored Dec 21, 2024
2 parents 414c811 209f29c commit 9f5aa52
Show file tree
Hide file tree
Showing 71 changed files with 3,096 additions and 2,692 deletions.
1 change: 1 addition & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 66,7 @@ services:
- ../frontend/public:/usr/src/app/public
- ../frontend/src:/usr/src/app/src
- ../frontend/package.json:/usr/src/app/package.json
- ../frontend/config-overrides.js:/usr/src/app/config-overrides.js
ports:
- "3000:3000"
networks:
Expand Down
5 changes: 5 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
node_modules
build
dist
public
.docker
8 changes: 8 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 1,8 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"tabWidth": 4
}
16 changes: 15 additions & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,7 1,21 @@
# Congress.Dev Frontend

This is a standard react app. It is intended to be served via docker, so you should follow the instructions to run the entire app from the top level readme.

## Running

```bash
yarn start
```
```

## Windows Development w/ VSCode

- Install Node.js for Windows (reboot after installing)
- Run Powershell as Administrator
- Execute `Set-ExecutionPolicy Unrestricted`
- Run `yarn install`
- Install Prettier extension for VSCode
- Under Preferences > Settings set `Default Formatter` to Prettier
- To format code:
- Open command pallete in VSCode with `Ctrl Shift P` and run `Format Document`
- OR: Run `yarn format` to format code for all files before creating pull request
63 changes: 35 additions & 28 deletions frontend/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,32 1,39 @@
const webpack = require("webpack");
const path = require("path");

module.exports = function override(config, env) {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve("crypto-browserify"), // require.resolve("crypto-browserify") can be polyfilled here if needed
stream: require.resolve("stream-browserify"), // require.resolve("stream-browserify") can be polyfilled here if needed
assert: false, // require.resolve("assert") can be polyfilled here if needed
http: false, // require.resolve("stream-http") can be polyfilled here if needed
https: false, // require.resolve("https-browserify") can be polyfilled here if needed
os: false, // require.resolve("os-browserify") can be polyfilled here if needed
url: false, // require.resolve("url") can be polyfilled here if needed
zlib: false, // require.resolve("browserify-zlib") can be polyfilled here if needed
});
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: "process/browser",
Buffer: ["buffer", "Buffer"],
}),
]);
config.ignoreWarnings = [/Failed to parse source map/];
config.module.rules.push({
test: /\.(js|mjs|jsx)$/,
enforce: "pre",
loader: require.resolve("source-map-loader"),
resolve: {
fullySpecified: false,
},
});
return config;
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve("crypto-browserify"), // require.resolve("crypto-browserify") can be polyfilled here if needed
stream: require.resolve("stream-browserify"), // require.resolve("stream-browserify") can be polyfilled here if needed
assert: false, // require.resolve("assert") can be polyfilled here if needed
http: false, // require.resolve("stream-http") can be polyfilled here if needed
https: false, // require.resolve("https-browserify") can be polyfilled here if needed
os: false, // require.resolve("os-browserify") can be polyfilled here if needed
url: false, // require.resolve("url") can be polyfilled here if needed
zlib: false, // require.resolve("browserify-zlib") can be polyfilled here if needed
});
config.resolve.alias = {
common: path.resolve(__dirname, "src/common"),
components: path.resolve(__dirname, "src/components"),
pages: path.resolve(__dirname, "src/pages"),
styles: path.resolve(__dirname, "src/styles"),
};
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: "process/browser",
Buffer: ["buffer", "Buffer"],
}),
]);
config.ignoreWarnings = [/Failed to parse source map/];
config.module.rules.push({
test: /\.(js|mjs|jsx)$/,
enforce: "pre",
loader: require.resolve("source-map-loader"),
resolve: {
fullySpecified: false,
},
});
return config;
};
101 changes: 51 additions & 50 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,51 1,52 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@blueprintjs/core": "^3.23.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"buffer": "^6.0.3",
"crypto": "^1.0.1",
"crypto-browserify": "^3.12.0",
"diff": "^4.0.2",
"env-cmd": "^10.1.0",
"process": "^0.11.10",
"query-string": "^6.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "5.0.1",
"react-spinners": "^0.8.0",
"sass": "^1.69.5",
"stream-browserify": "^3.0.0",
"web-vitals": "^2.1.4",
"xmldoc": "^1.1.2"
},
"scripts": {
"start": "WATCHPACK_POLLING=true react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-app-rewired": "^2.2.1"
}
}
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@blueprintjs/core": "^5.0.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"buffer": "^6.0.3",
"crypto": "^1.0.1",
"crypto-browserify": "^3.12.0",
"diff": "^4.0.2",
"env-cmd": "^10.1.0",
"process": "^0.11.10",
"query-string": "^6.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "5.0.1",
"sass": "^1.69.5",
"stream-browserify": "^3.0.0",
"web-vitals": "^2.1.4",
"xmldoc": "^1.1.2"
},
"scripts": {
"start": "WATCHPACK_POLLING=true react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"format": "prettier --write ."
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-app-rewired": "^2.2.1",
"prettier": "^3.4.2"
}
}
2 changes: 1 addition & 1 deletion frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 23,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Congress Dot Dev</title>
<title>Congress.dev</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file removed frontend/public/logo192.png
Binary file not shown.
Binary file removed frontend/public/logo512.png
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 1,5 @@
{
"short_name": "Congress Dot Dev",
"short_name": "Congress.dev",
"name": "Federal Legislation Analyzer",
"icons": [
{
Expand Down
42 changes: 0 additions & 42 deletions frontend/src/App.css

This file was deleted.

92 changes: 47 additions & 45 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,54 1,56 @@
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import { Route, BrowserRouter as Router, Switch } from "react-router-dom";

import NavBar from "./components/navbar";
// Pages
import FrontPage from "./pages/frontpage";
import AboutUs from "./pages/aboutus";
import ContactUs from "./pages/contactus";
import BillViewer from "./pages/billviewer";
import USCodeRevisionList from "./pages/uscodemain";
import USCodeViewer from "./pages/uscodeviewer";
import BillSearch from "./pages/billsearch";
import MemberViewer from "./pages/members";
import { AppBar } from "components";
import {
AboutUs,
BillSearch,
BillViewer,
Home,
MemberViewer,
USCodeRevisionList,
USCodeViewer,
} from "pages";

import "./styles/common.scss";
import "./App.css";
import "styles/common.scss";

function App() {
return (
<Router>
<NavBar />
<Switch>
<Route
exact
path="/bill/:congress/:chamber/:billNumber/:billVersion?/diffs/:uscTitle/:uscSection"
component={BillViewer}
/>
<Route
exact
path="/bill/:congress/:chamber/:billNumber/:billVersion?/diffs/:uscTitle/:uscSection#:hasher"
component={BillViewer}
/>
<Route
exact
path="/bill/:congress/:chamber/:billNumber/:billVersion?"
component={BillViewer}
/>
return (
<Router>
<AppBar />
<Switch>
<Route
exact
path="/bill/:congress/:chamber/:billNumber/:billVersion?/diffs/:uscTitle/:uscSection"
component={BillViewer}
/>
<Route
exact
path="/bill/:congress/:chamber/:billNumber/:billVersion?/diffs/:uscTitle/:uscSection#:hasher"
component={BillViewer}
/>
<Route
exact
path="/bill/:congress/:chamber/:billNumber/:billVersion?"
component={BillViewer}
/>

<Route exact path="/bills" component={BillSearch} />
<Route exact path="/about" component={AboutUs} />
<Route exact path="/contact" component={ContactUs} />
<Route exact path="/uscode" component={USCodeRevisionList} />
<Route exact path="/member/:bioguideId" component={MemberViewer} />
<Route
path="/uscode/:uscReleaseId/:uscTitle?/:uscSection?"
component={USCodeViewer}
/>
<Route path={["/", "/home"]} component={FrontPage} />
</Switch>
</Router>
);
<Route exact path="/bills" component={BillSearch} />
<Route exact path="/about" component={AboutUs} />
<Route exact path="/uscode" component={USCodeRevisionList} />
<Route
exact
path="/member/:bioguideId"
component={MemberViewer}
/>
<Route
path="/uscode/:uscReleaseId/:uscTitle?/:uscSection?"
component={USCodeViewer}
/>
<Route path={["/", "/home"]} component={Home} />
</Switch>
</Router>
);
}

export default App;
9 changes: 0 additions & 9 deletions frontend/src/App.test.js

This file was deleted.

Loading

0 comments on commit 9f5aa52

Please sign in to comment.