Skip to content
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

Fix honeypot #93

Open
wants to merge 2 commits into
base: main
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
106 changes: 54 additions & 52 deletions src/components/FeedbackForm.astro
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
---
---

<p>Here's an example of a Netlify Form! When you fill this out, the submissions can be found in the Netlify Admin site.</p>
<div class="feedback-form">
<form
netlify
netlify-honeypot
name="feedback"
method="POST"
action="/success"
>
<p class="hidden">
<label>
Don’t fill this out if you’re human: <input name="bot-field" />
</label>
</p>
<input type="hidden" name="form-name" value="feedback" />
<label for="name">Name</label>
<input id="name" type="text" name="name" />
<label for="email">Email</label>
<input id="email" type="email" name="email" required />
<label for="feedback">What is your feedback?</label>
<textarea id="feedback" wrap="soft" name="feedback" required></textarea>
<button type="submit">Submit</button>
</form>
</div>
<p>
Here's an example of a Netlify Form! When you fill this out, the submissions
can be found in the Netlify Admin site.
</p>
<div class="feedback-form">
<form
netlify
netlify-honeypot="bot-field"
name="feedback"
method="POST"
action="/success"
>
<p class="hidden">
<label>
Don’t fill this out if you’re human: <input name="bot-field" />
</label>
</p>
<input type="hidden" name="form-name" value="feedback" />
<label for="name">Name</label>
<input id="name" type="text" name="name" />
<label for="email">Email</label>
<input id="email" type="email" name="email" required />
<label for="feedback">What is your feedback?</label>
<textarea id="feedback" wrap="soft" name="feedback" required></textarea>
<button type="submit">Submit</button>
</form>
</div>

<style>
.feedback-form {
margin: 40px 40px;
min-width: 250px;
width: 45%;
}
input,
textarea,
button {
font-size: inherit;
margin: 15px 0;
padding: 12px 20px;
width: 100%;
}
button {
background-color: teal;
border: 1px solid black;
color: white;
width: 50%;
}
.hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
margin: 40px 40px;
min-width: 250px;
width: 45%;
}
input,
textarea,
button {
font-size: inherit;
margin: 15px 0;
padding: 12px 20px;
width: 100%;
}
button {
background-color: teal;
border: 1px solid black;
color: white;
width: 50%;
}
.hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
</style>

6 changes: 6 additions & 0 deletions src/custom-attributes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare namespace astroHTML.JSX {
interface HTMLAttributes {
netlify?: true;
'netlify-honeypot'?: string;
}
}