-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
G
committed
Aug 28, 2024
1 parent
3ff0cfd
commit 6a37abe
Showing
21 changed files
with
400 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/build | ||
/public/build | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import electron from "electron" | ||
export default electron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { MetaFunction } from "@remix-run/node" | ||
import { | ||
Links, | ||
LiveReload, | ||
Meta, | ||
Outlet, | ||
Scripts, | ||
ScrollRestoration, | ||
} from "@remix-run/react" | ||
|
||
export const meta: MetaFunction = () => { | ||
return [{ title: "New Remix App" }] | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf8" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Outlet /> | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
{process.env.NODE_ENV === "development" && <LiveReload />} | ||
</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useLoaderData } from "@remix-run/react" | ||
import { useState } from "react" | ||
import electron from "~/electron.server" | ||
|
||
export function loader() { | ||
return { | ||
userDataPath: electron.app.getPath("userData"), | ||
} | ||
} | ||
|
||
export default function Index() { | ||
const data = useLoaderData<typeof loader>() | ||
const [count, setCount] = useState(0) | ||
return ( | ||
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}> | ||
<h1>Welcome to Remix</h1> | ||
<p data-testid="user-data-path">{data.userDataPath}</p> | ||
<button | ||
type="button" | ||
data-testid="counter" | ||
onClick={() => setCount(count + 1)} | ||
> | ||
{count} | ||
</button> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
type ActionFunctionArgs, | ||
NodeOnDiskFile, | ||
json, | ||
unstable_createFileUploadHandler, | ||
unstable_parseMultipartFormData, | ||
} from "@remix-run/node" | ||
import { Form, useActionData } from "@remix-run/react" | ||
|
||
export async function action({ request }: ActionFunctionArgs) { | ||
const formData = await unstable_parseMultipartFormData( | ||
request, | ||
unstable_createFileUploadHandler(), | ||
) | ||
|
||
const file = formData.get("file") | ||
if (!(file instanceof NodeOnDiskFile)) { | ||
throw new Error("No file uploaded") | ||
} | ||
|
||
const text = await file.text() | ||
return json({ text }) | ||
} | ||
|
||
export default function MultipartUploadsTest() { | ||
const data = useActionData<typeof action>() | ||
return ( | ||
<> | ||
<Form method="post" encType="multipart/form-data"> | ||
<input type="file" name="file" /> | ||
<button type="submit">Submit</button> | ||
</Form> | ||
<p data-testid="result">{data?.text}</p> | ||
</> | ||
) | ||
} |
13 changes: 13 additions & 0 deletions
13
workspaces/test-app-esm/app/routes/referrer-redirect.action.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { ActionFunction } from "@remix-run/node" | ||
import { redirect } from "@remix-run/node" | ||
|
||
export const action: ActionFunction = async ({ request }) => { | ||
const { redirects } = Object.fromEntries(await request.formData()) | ||
const referrer = request.headers.get("referer") | ||
if (!referrer) { | ||
throw new Error("No referrer header") | ||
} | ||
const url = new URL(referrer) | ||
url.searchParams.set("redirects", String(Number(redirects) + 1)) | ||
return redirect(url.toString()) | ||
} |
21 changes: 21 additions & 0 deletions
21
workspaces/test-app-esm/app/routes/referrer-redirect.form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useFetcher, useSearchParams } from "@remix-run/react" | ||
|
||
export default function RedirectForm() { | ||
const fetcher = useFetcher() | ||
const [params] = useSearchParams() | ||
const redirects = params.get("redirects") | ||
return ( | ||
<> | ||
<p data-testid="redirects">{redirects ?? 0}</p> | ||
<fetcher.Form | ||
action="/referrer-redirect/action" | ||
method="post" | ||
data-testid="referrer-form" | ||
> | ||
<button type="submit" name="redirects" value={redirects ?? 0}> | ||
submit | ||
</button> | ||
</fetcher.Form> | ||
</> | ||
) | ||
} |
Oops, something went wrong.