-
Notifications
You must be signed in to change notification settings - Fork 1
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
Swap wouter to preact-router #6
Conversation
**Why**: Better support for querystring-based routing
src/report-filter-controls.js
Outdated
const formData = /** @type {string[][]} */ (Array.from(new FormData(form))); | ||
route(`${path}?${new URLSearchParams(formData).toString()}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting case of: it works, mostly, with just new URLSearchParams(new FormData(form))
, but TypeScript is extra strict about the possibility of the form including file inputs not being compatible as search parameters 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! added #6 to take advantage of these changes
* Remove unused effect dependencies * Update src/report-filter-controls.js * Simplify agency parsing now that formatting is in update() Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
Just noticed the router updates and drops the base path in Federalist. Did that happen before as well? Edit: Related: preactjs/preact-router#279 |
The old form posts kept the path: https://federalist-14721e0a-0772-4dcd-b62f-ee9d20dcc5fd.app.cloud.gov/daily-auths-report?start=2021-08-15&finish=2021-08-22&ial=2&agency= but also they route to a real page that 404s, so maybe we need to add some HTTP meta redirects to catch those? |
The problem is it's not keeping the base path, e.g. The wrapper workaround mentioned in the above issue could work. |
Ah ok, so can we update vite to detect the BASEURL and conditionally embed a |
- Treat it as null so we don't get duplicate paths like "///"
- Don't double-add BASE_PATH - Remove leading and trailing slashes from parts so they don't double up
To allow otherProps to work like a link
It hadn't occurred to me that Federalist doesn't appear to have great single-page app support out of the box as far as allowing subpaths to match back to the Couple thoughts:
|
If I had to rank those options, I'd go in this order:
WDYT? |
With the copy option, I was imagining a post-build script where we'd auto-generate these by "rendering" the routes in-memory, getting the full list of paths, then |
🚢 !! |
fix some typos
@@ -0,0 +1,11 @@ | |||
import { mkdir, copyFile } from "fs/promises"; | |||
import { join } from "path"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait is there a version of this in the browser? could we simplify a ton of logic in getFullPath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the browser, no. This is run in Node as part of the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭 too bad
src/routes/report.js
Outdated
function ReportRoute() { | ||
return html`<${ReportFilterControls}><${DailyAuthsReport} /><//>`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to me like something we could inline in the ROUTES
constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to me like something we could inline in the
ROUTES
constant?
Yeah, possibly. I feel like what we're currently treating as top-level "page" components for the report page is something we'd want to have some organization of, hence the dedicated directory and component, vs. a sprawling directory of every sort of component. So for me I'd see this moving more in the direction of absorbing most of DailyAuthsReport here I guess.
I could imagine an alternative where we keep things more as they are, and have a single routes.js
with our constant and (maybe) "Route" component†.
† The reason I had to move this out of main.js
is because ESBuild doesn't know how to handle the CSS import statement (or does it? 🤔 either way, saw errors).
Federalist drops querystrings in un-suffixed path redirects
src/router.js
Outdated
return ( | ||
"/" + | ||
[basePath, path] | ||
.map((p) => p.replace(/^\/|\/$/g, "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we added trailing slashes in the router, we probably want to change this to drop trailing slashes only on basePath
, and preserve trailing slashes for path
Why: Better support for querystring-based routing