diff --git a/README.md b/README.md index 88d689a8e..340d7fff8 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ - Modular Jekyll components - Post category support in the form of a single post index page grouped by category - Built in live search using JavaScript -- **Contact form** built in using [Formspree](https://formspree.io/) +- **Contact form** built in using [Formspree](https://formspree.io/) or [Netlify Forms](https://www.netlify.com/features/#forms) - Designed with **[Siteleaf](http://www.siteleaf.com/)** in mind - Has 9 of the most popular networks as performant sharing buttons - Has documentation @@ -219,11 +219,16 @@ Available options: - `id`: The map ID for the video _required_ ### `site-form.html` -Adds a contact form to the page. +Adds a contact form to the page. This can be used with [Formspree](https://formspree.io/) or [Netlify Forms](https://www.netlify.com/docs/form-handling/) depending on your setup. Example usage: `{% include site-form.html %}` -This include has no options. Use the `email` option in the `/_config.yml` to change to the desired email. +Available options: +- `netlify_form=true`: Set whether you would like to use Netlify Forms, otherwise the form will default to Formspree +- `name`: Give the form a name, by default the form is called "Contact". The name will be reflected when form submissions come through in Netlify or in your email client. The name is also used in the label and input elements for accessibility + + +Use the `email` option in the `/_config.yml` to change to the desired email. ### `site-search.html` Adds a search form to the page. diff --git a/_includes/site-form.html b/_includes/site-form.html index b99745b6b..d5374bf29 100644 --- a/_includes/site-form.html +++ b/_includes/site-form.html @@ -1,27 +1,53 @@ -
-
- - +{% if include.name %} + {% assign name = include.name %} +{% else %} + {% assign name = "Contact" %} +{% endif %} - - +{% assign name_id = name | downcase | replace: " ", "-" %} - - +{% if include.thanks_url %} + {% assign thanks_url = include.thanks_url %} +{% else %} + {% assign thanks_url = "/thanks/" %} +{% endif %} + + +
+ {{ name }} + + + + + + + +
* indicates a required field - - - - -
- - + {% if include.netlify_form %} + + {% else %} + + + + {% endif %} + + +{% unless include.netlify_form %} + + +{% endunless %} diff --git a/_sass/_theme.scss b/_sass/_theme.scss index 21a101dd6..9bb68d1bb 100644 --- a/_sass/_theme.scss +++ b/_sass/_theme.scss @@ -260,7 +260,8 @@ img { .figure, .video, -.map { +.map, +.form { margin-bottom: .8rem; } @@ -271,6 +272,18 @@ video { // Form elements and buttons +.form { + position: relative; + &__legend { + font-style: italic; + color: $captionColour; + position: absolute; + overflow: hidden; + right: 0; + clip: rect(0 0 0 0); + } +} + button, .button, input[type="text"],