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

Add some links to platforms that use the form builder #392

Merged
merged 4 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This library provides an easy-to-use form builder for the [GOV.UK Design System]

It is intended to make creating forms **quick**, **easy** and **familiar** for Ruby on Rails developers.

## Documentation 📚
## Documentation

The gem comes with [a full guide](https://govuk-form-builder.netlify.app/) that
covers most aspects of day-to-day use, along with code and output examples. The
Expand All @@ -23,7 +23,7 @@ be up to date.

[![Netlify Status](https://api.netlify.com/api/v1/badges/d4c50b8d-6ca3-4797-9ab3-6e0731c72b44/deploy-status)](https://app.netlify.com/sites/govuk-form-builder/deploys)

## What's included 🧳
## What's included

* 100% compatibility with the GOV.UK Design System
* Full control of labels, legends, hints, captions and fieldsets
Expand All @@ -38,7 +38,7 @@ be up to date.
* An exhaustive test suite
* [Extensive technical documentation](https://www.rubydoc.info/gems/govuk_design_system_formbuilder/GOVUKDesignSystemFormBuilder/Builder)

## Installation 🏗
## Installation

You can install the form builder gem by running the `gem install
govuk_design_system_formbuilder` or by adding the following line
Expand All @@ -58,7 +58,7 @@ pre-configured template:
* [DfE Rails Template](https://github.com/DFE-Digital/rails-template)
* [DEFRA Ruby Template](https://github.com/DEFRA/defra-ruby-template)

## Setup 🔧
## Setup

To use the form builder in an ad hoc basis you can specify it as an argument to
`form_for` or `form_with`. These examples are written in [Slim](https://github.com/slim-template/slim) but
Expand Down Expand Up @@ -97,7 +97,7 @@ Now we can get started!
= f.govuk_submit 'Away we go!'
```

## Developing and running the tests 👨🏻‍🏭
## Developing and running the tests

The form builder is tested with RSpec. To run all the tests first ensure that
the development and testing prerequisite gems are installed. At the root of a
Expand All @@ -113,7 +113,7 @@ Now, if everything was successful, run RSpec:
bundle exec rspec
```

## Contributing 📦
## Contributing

Bug reports and feature requests are most welcome, please raise an issue or
submit a pull request.
Expand Down Expand Up @@ -143,7 +143,12 @@ here are a few from the <abbr title="Department for Education">DfE</abbr>, <abbr
* [Trade Tariff duty calculator](https://www.github.com/trade-tariff/trade-tariff-duty-calculator)
* [Report your official development assistance](https://www.github.com/UKGovernmentBEIS/beis-report-official-development-assistance)

## Thanks 👩🏽‍⚖️
## Form building services using this library

* [MoJ Forms](https://moj-forms.service.justice.gov.uk/)
* [GOV.UK Forms](https://www.forms.service.gov.uk/)

## Thanks

This project was inspired by [Ministry of Justice's GovukElementsFormBuilder](https://github.com/ministryofjustice/govuk_elements_form_builder),
but is leaner, more modular and written in a more idiomatic style.
7 changes: 6 additions & 1 deletion guide/layouts/partials/links.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
| Every component of the form builder is designed to produce accessible
HTML that meet all of the design system’s requirements without having
to spend time reinventing the wheel.
p.govuk-inset-text
| This tool is aimed at developers. If you need a service that
lets you build forms without writing any code, you can
use one of the platforms that wrap this library like
#{link_to_in_new_tab("GOV.UK Forms", govuk_forms_link).html_safe} or
#{link_to_in_new_tab("MoJ Forms", moj_forms_link).html_safe}.

nav class="govuk-grid-row govuk-!-margin-bottom-4"
.govuk-grid-column-one-third
Expand All @@ -27,7 +33,6 @@
li== link_to 'Injecting content', '/building-blocks/injecting-content'
li== link_to 'Fieldsets', '/building-blocks/fieldsets'
li== link_to 'Localisation', '/building-blocks/localisation'
/ li== link_to 'Other design systems', '/building-blocks/other-design-systems'

.govuk-grid-column-one-third
h2.govuk-heading-m Form elements
Expand Down
6 changes: 6 additions & 0 deletions guide/lib/helpers/formatters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ def block_has_content?(block)
block.call
end

def link_to_in_new_tab(*args, **kwargs, &block)
new_tab_args = { rel: "noreferrer noopener", target: "_blank" }

link_to(*args, **new_tab_args.merge(kwargs), &block)
end

def format_slim(raw, **args)
# FIXME: not sure why when we're several
# blocks deep we need to unescape more
Expand Down
8 changes: 8 additions & 0 deletions guide/lib/helpers/link_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,13 @@ def rails_option_groups_from_collection_for_select_link
def rails_options_from_collection_for_select_link
'https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-options_from_collection_for_select'
end

def govuk_forms_link
"https://www.forms.service.gov.uk/"
end

def moj_forms_link
"https://moj-forms.service.justice.gov.uk/"
end
end
end