-
Notifications
You must be signed in to change notification settings - Fork 742
Expand file tree
/
Copy pathFormsSection.tsx
More file actions
83 lines (78 loc) · 2.69 KB
/
FormsSection.tsx
File metadata and controls
83 lines (78 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { PageSection } from "../PageSection.tsx";
import { SideBySide } from "../SideBySide.tsx";
import { CodeWindow } from "../CodeWindow.tsx";
import { CodeBlock } from "../CodeBlock.tsx";
import { SectionHeading } from "../homepage/SectionHeading.tsx";
import { DemoBox } from "../homepage/DemoBox.tsx";
import { ExampleArrow } from "../homepage/ExampleArrow.tsx";
import { FancyLink } from "../FancyLink.tsx";
import { FormSubmitDemo } from "../../islands/FormSubmitDemo.tsx";
const routingCode = `import { define } from "../utils.ts";
export const handler = define.handlers({
async POST(ctx) {
const form = await ctx.req.formData();
// Do something with the form data here,
// then redirect user to thank you page
return new Response(null, {
status: 303,
headers: { location: "/thanks" },
});
},
});`;
export function FormsSection() {
return (
<PageSection id="forms-section">
<SideBySide mdColSplit="2/3" lgColSplit="2/3" class="!items-start">
<div class="flex flex-col gap-4 md:sticky md:top-4">
<div class="leading-none text-[4rem]">
<svg
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-route-square-2 text-fresh"
width="4rem"
height="4rem"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M14 5a2 2 0 0 0 -2 2v10a2 2 0 0 1 -2 2" />
<path d="M3 17h4v4h-4z" />
<path d="M17 3h4v4h-4z" />
</svg>
</div>
<SectionHeading>
Forms, the right way
</SectionHeading>
<p>
Don't fight the browser. Fresh helps you handle form submissions and
other dynamic requests server-side, from any route.
</p>
<p>
Since Fresh is built on{" "}
<a href="https://deno.com" class="underline">Deno</a>, it's built on
web standards.
</p>
<FancyLink href="/docs/advanced/forms" class="mt-2">
Forms in Fresh
</FancyLink>
</div>
<div class="flex flex-col gap-4">
<CodeWindow name="routes/index.tsx">
<CodeBlock
code={routingCode}
lang="jsx"
/>
</CodeWindow>
<ExampleArrow />
<DemoBox>
<FormSubmitDemo />
</DemoBox>
</div>
</SideBySide>
</PageSection>
);
}