generated from inherentlee/11ty
form stuff
This commit is contained in:
38
_includes/layouts/index.njk
Normal file
38
_includes/layouts/index.njk
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
layout: page.njk
|
||||
---
|
||||
{% css %}{% include "css/form.css" %}{% endcss %}
|
||||
|
||||
{{ content | safe }}
|
||||
|
||||
<form action="https://formgrid.dev/api/f/842wiwnz" method="POST" class="contact-form">
|
||||
<h2 class="center">Contact Us</h2>
|
||||
<p class="center">All fields
|
||||
<span aria-hidden="true">marked with an asterisk (<span class="red">*</span>)</span>
|
||||
are required.</p>
|
||||
|
||||
<div class="name-email">
|
||||
<div class="form-field">
|
||||
<label for="name">Name <span class="red" aria-hidden="true">*</span></label>
|
||||
<input id="name" type="text" name="name" placeholder="Your Name"
|
||||
required aria-required="true" aria-describedby="name-error">
|
||||
<p id="name-error" class="error">Name cannot be empty</p>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="email">Email <span class="red" aria-hidden="true">*</span></label>
|
||||
<input id="email" type="email" name="email" placeholder="you@example.com"
|
||||
required aria-required="true" aria-describedby="email-error">
|
||||
<p id="email-error" class="error">Email cannot be empty</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="message">Message <span class="red" aria-hidden="true">*</span></label>
|
||||
<textarea id="message" name="message" rows="4" placeholder="What's your message?"
|
||||
required aria-required="true" aria-describedby="message-error"></textarea>
|
||||
<p id="message-error" class="error">Message cannot be empty</p>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="form-button">Send message</button>
|
||||
</form>
|
||||
64
css/form.css
Normal file
64
css/form.css
Normal file
@ -0,0 +1,64 @@
|
||||
form label {
|
||||
display: block;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: .5rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
form input,
|
||||
form textarea,
|
||||
form button {
|
||||
display: block;
|
||||
border-radius: .25rem;
|
||||
border-color: var(--color-accent);
|
||||
}
|
||||
|
||||
form input,
|
||||
form textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input:user-invalid,
|
||||
textarea:user-invalid {
|
||||
border-color: var(--color-red);
|
||||
outline: .2rem solid var(--color-red);
|
||||
outline-offset: .2rem;
|
||||
}
|
||||
|
||||
input:user-invalid:focus-visible,
|
||||
textarea:user-invalid:focus-visible {
|
||||
outline: .1rem solid var(--color-accent);
|
||||
outline-offset: .1rem;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin-top: .5rem;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
input:user-invalid + .error,
|
||||
textarea:user-invalid + .error {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
form button {
|
||||
padding: 0 .5rem;
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
.name-email {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 650px) {
|
||||
.name-email {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.red {
|
||||
color: var(--color-red);
|
||||
}
|
||||
@ -5,10 +5,13 @@
|
||||
--color-light: #e4edf3;
|
||||
--color-blue-dark: #0c436d;
|
||||
--color-blue-light: #5ca6ce;
|
||||
--color-red-light: #bb362a;
|
||||
--color-red-dark: #b82e1f;
|
||||
|
||||
--color-text: light-dark(var(--color-dark), var(--color-light));
|
||||
--color-bg: light-dark(var(--color-light), var(--color-dark));
|
||||
--color-accent: light-dark(var(--color-blue-dark), var(--color-blue-light));
|
||||
--color-red: light-dark(var(--color-red-dark), var(--color-red-light));
|
||||
}
|
||||
|
||||
/* numbered components are from https://www.joshwcomeau.com/css/custom-css-reset/ */
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
---
|
||||
title: Welcome
|
||||
hero: null
|
||||
layout: index.njk
|
||||
___mb_schema: /.mattrbld/schemas/page.json
|
||||
---
|
||||
## About
|
||||
|
||||
Reference in New Issue
Block a user