diff --git a/lib/highlighter.js b/lib/highlighter.js
index 544935ab9c..e21aacc2ae 100644
--- a/lib/highlighter.js
+++ b/lib/highlighter.js
@@ -1,5 +1,7 @@
const hljs = require('highlight.js')
+hljs.registerLanguage('erb', require('highlight.js/lib/languages/erb'))
+
// Highlight Nunjucks as JavaScript
hljs.registerLanguage('njk', require('highlight.js/lib/languages/javascript'))
diff --git a/lib/nunjucks/globals.js b/lib/nunjucks/globals.js
index 701508dd08..8fabfaa688 100644
--- a/lib/nunjucks/globals.js
+++ b/lib/nunjucks/globals.js
@@ -27,6 +27,80 @@ exports.getNunjucksCode = function (path) {
return content.replace(/{%\s*extends\s*\S*\s*%}\s+/, '')
}
+/**
+ * This helper function takes a path of a *.erb file and
+ * returns the Rails syntax inside that file without markdown data
+ *
+ * @param {string} path - Path to ERb file
+ * @returns {string} ERb code for the file
+ */
+exports.getRubyOnRailsCode = (path) => {
+ const { content } = matter(readFileSync(path, 'utf-8'))
+
+ return content
+}
+
+/**
+ * This helper function takes an component name and returns
+ * a URL for the full documentation for that Rails helper.
+ *
+ * @param {string} componentName - Name of component
+ * @returns {string} URL - Link to documentation page
+ */
+exports.getRailsLink = (componentName) => {
+ const links = {
+ accordion: 'https://govuk-components.netlify.app/components/accordion/',
+ 'back-link': 'https://govuk-components.netlify.app/components/back-link/',
+ breadcrumb: 'https://govuk-components.netlify.app/components/breadcrumbs/',
+ 'character-count':
+ 'https://govuk-form-builder.netlify.app/form-elements/textarea/',
+ checkboxes:
+ 'https://govuk-form-builder.netlify.app/form-elements/checkboxes/',
+ 'cookie-banner':
+ 'https://govuk-components.netlify.app/components/cookie-banner/',
+ 'date-input':
+ 'https://govuk-form-builder.netlify.app/form-elements/date-input/',
+ details: 'https://govuk-components.netlify.app/components/details/',
+ 'error-message':
+ 'https://govuk-form-builder.netlify.app/introduction/error-handling/',
+ 'error-summary':
+ 'https://govuk-form-builder.netlify.app/introduction/error-handling/',
+ 'exit-this-page':
+ 'https://govuk-components.netlify.app/components/exit-this-page/',
+ fieldset:
+ 'https://govuk-form-builder.netlify.app/building-blocks/fieldsets/',
+ 'file-upload':
+ 'https://govuk-form-builder.netlify.app/form-elements/file-upload/',
+ footer: 'https://govuk-components.netlify.app/components/footer/',
+ header: 'https://govuk-components.netlify.app/components/header/',
+ 'inset-text': 'https://govuk-components.netlify.app/components/inset-text/',
+ 'notification-banner':
+ 'https://govuk-components.netlify.app/components/notification-banner/',
+ pagination: 'https://govuk-components.netlify.app/components/pagination/',
+ panel: 'https://govuk-components.netlify.app/components/panel/',
+ 'phase-banner':
+ 'https://govuk-components.netlify.app/components/phase-banner/',
+ radios: 'https://govuk-form-builder.netlify.app/form-elements/radios/',
+ select: 'https://govuk-form-builder.netlify.app/form-elements/select/',
+ 'skip-link': 'https://govuk-components.netlify.app/helpers/skip-link/',
+ 'summary-list':
+ 'https://govuk-components.netlify.app/components/summary-list/',
+ table: 'https://govuk-components.netlify.app/components/table/',
+ tabs: 'https://govuk-components.netlify.app/components/tabs/',
+ tag: 'https://govuk-components.netlify.app/components/tag/',
+ 'task-list': 'https://govuk-components.netlify.app/components/task-list/',
+ 'text-input':
+ 'https://govuk-form-builder.netlify.app/form-elements/text-input/',
+ textarea: 'https://govuk-form-builder.netlify.app/form-elements/textarea/',
+ 'warning-text':
+ 'https://govuk-components.netlify.app/components/warning-text/'
+ }
+
+ const fallbackLink = 'https://govuk-components.netlify.app/'
+
+ return links[componentName] || fallbackLink
+}
+
/**
* This helper function takes a path of a *.md.njk file and
* returns the frontmatter as an object
diff --git a/src/components/accordion/default/index.erb b/src/components/accordion/default/index.erb
new file mode 100644
index 0000000000..ceb35b7ceb
--- /dev/null
+++ b/src/components/accordion/default/index.erb
@@ -0,0 +1,14 @@
+<%= govuk_accordion do |accordion|
+ accordion.with_section(heading_text: "Writing well for the web") {
+ tag.p("This is the content for Writing well for the web.")
+ }
+ accordion.with_section(heading_text: "Writing well for specialists") {
+ tag.p("This is the content for Writing well for specialists.")
+ }
+ accordion.with_section(heading_text: "Know your audience") {
+ tag.p("This is the content for Know your audience.")
+ }
+ accordion.with_section(heading_text: "How people read") {
+ tag.p("This is the content for How people read.")
+ }
+end %>
diff --git a/src/components/accordion/index.md b/src/components/accordion/index.md
index 3eaf9fb262..ccfcbc1aee 100644
--- a/src/components/accordion/index.md
+++ b/src/components/accordion/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
The accordion component lets users show and hide sections of related content on a page.
-{{ example({ group: "components", item: "accordion", example: "default", html: true, nunjucks: true, open: false, size: "xl", loading: "eager" }) }}
+{{ example({group: "components", item: "accordion", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "xl", loading: "eager" }) }}
## When to use this component
@@ -79,7 +79,7 @@ The heading button includes all of these areas:
For users of screen readers, all the text in the button will be read as a single statement (separated by commas to allow for slight pauses). There’s also some visually hidden content in the heading text to help announce the call-to-action as 'show this section' or 'hide this section'.
-{{ example({ group: "components", item: "accordion", example: "default", html: true, nunjucks: true, open: false, size: "xl", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "accordion", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "xl", titleSuffix: "second" }) }}
#### Write clear button text
@@ -95,7 +95,7 @@ Only add a summary line if it’s actually needed, as it's likely to make the bu
If you’ve decided that you need the summary line, you must make it as short as possible.
-{{ example({ group: "components", item: "accordion", example: "with-summary-section", html: true, nunjucks: true, open: false, size: "xl" }) }}
+{{ example({ group: "components", item: "accordion", example: "with-summary-section", html: true, nunjucks: true, rails: true, open: false, size: "xl" }) }}
#### Structure section headings with the rest of the page
diff --git a/src/components/accordion/with-summary-section/index.erb b/src/components/accordion/with-summary-section/index.erb
new file mode 100644
index 0000000000..4e253635d1
--- /dev/null
+++ b/src/components/accordion/with-summary-section/index.erb
@@ -0,0 +1,81 @@
+<%= govuk_accordion do |accordion| end %>
+ <%= accordion.with_section(heading_text: "Understanding agile project management", summary_text: "Introductions, methods, core features.") do %>
+
` element of the component HTML. Or if you’re using Nunjucks, add `collapseOnMobile: true` to the Nunjucks macro as shown in this example.
-{{ example({ group: "components", item: "breadcrumbs", example: "collapse-mobile", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "breadcrumbs", example: "collapse-mobile", html: true, nunjucks: true, rails: true, open: false}) }}
### Breadcrumbs on dark backgrounds
@@ -66,4 +66,4 @@ Use the `govuk-breadcrumbs--inverse` modifier class to show white links and arro
Make sure all users can see the breadcrumbs – the background colour must have a contrast ratio of at least 4.5:1 with white to [meet WCAG 2.2 success criterion 1.4.3 Contrast (minimum), level AA](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html).
-{{ example({ group: "components", item: "breadcrumbs", example: "inverse", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "breadcrumbs", example: "inverse", html: true, nunjucks: true, rails: true, open: false}) }}
diff --git a/src/components/breadcrumbs/inverse/index.erb b/src/components/breadcrumbs/inverse/index.erb
new file mode 100644
index 0000000000..097bcd25d2
--- /dev/null
+++ b/src/components/breadcrumbs/inverse/index.erb
@@ -0,0 +1,5 @@
+<%= govuk_breadcrumbs(breadcrumbs: {
+ "Home" => "#",
+ "Passports, travel and living abroad" => "#",
+ "Travel abroad" => "#"
+}, inverse: true) %>
diff --git a/src/components/button/button-group/index.erb b/src/components/button/button-group/index.erb
new file mode 100644
index 0000000000..3bb9ff91bf
--- /dev/null
+++ b/src/components/button/button-group/index.erb
@@ -0,0 +1,3 @@
+<%= form.govuk_submit("Continue") do %>
+ <%= govuk_link_to("Cancel", "#") %>
+<% end %>
diff --git a/src/components/button/default/index.erb b/src/components/button/default/index.erb
new file mode 100644
index 0000000000..87cd1b2897
--- /dev/null
+++ b/src/components/button/default/index.erb
@@ -0,0 +1 @@
+<%= form.govuk_submit("Save and continue") %>
diff --git a/src/components/button/disabled/index.erb b/src/components/button/disabled/index.erb
new file mode 100644
index 0000000000..09c42f76b8
--- /dev/null
+++ b/src/components/button/disabled/index.erb
@@ -0,0 +1 @@
+<%= form.govuk_submit("Disabled button", disabled: true) %>
diff --git a/src/components/button/index.md b/src/components/button/index.md
index c2fdfd8226..715e2a3073 100644
--- a/src/components/button/index.md
+++ b/src/components/button/index.md
@@ -23,7 +23,7 @@ layout: layout-pane.njk
]
}) }}
-{{ example({ group: "components", item: "button", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({group: "components", item: "button", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -61,14 +61,14 @@ Use a default button for the main call to action on a page.
Avoid using multiple default buttons on a single page. Having more than one main call to action reduces their impact, and makes it harder for users to know what to do next.
-{{ example({ group: "components", item: "button", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({group: "components", item: "button", example: "default", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second"}) }}
### Start buttons
Use a start button for the main call to action on [your service’s Start page](/patterns/start-using-a-service/).
Start buttons do not usually submit form data, so use a link tag instead of a button tag.
-{{ example({ group: "components", item: "button", example: "start", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "start", html: true, nunjucks: true, rails: true, open: false}) }}
### Secondary buttons
@@ -76,7 +76,7 @@ Use secondary buttons for secondary calls to action on a page.
Pages with too many calls to action make it hard for users to know what to do next. Before adding lots of secondary buttons, try to simplify the page or break the content down across multiple pages.
-{{ example({ group: "components", item: "button", example: "secondary", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "secondary", html: true, nunjucks: true, rails: true, open: false}) }}
You can also [group default and secondary buttons together](#grouping-buttons).
@@ -84,7 +84,7 @@ You can also [group default and secondary buttons together](#grouping-buttons).
Warning buttons are designed to make users think carefully before they use them. They only work if used very sparingly. Most services should not need one.
-{{ example({ group: "components", item: "button", example: "warning", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "warning", html: true, nunjucks: true, rails: true, open: false}) }}
Only use warning buttons for actions with serious destructive consequences that cannot be easily undone by a user. For example, permanently deleting an account.
@@ -100,7 +100,7 @@ Use the `govuk-button--inverse` modifier class to show white buttons on dark bac
Make sure all users can see the button – the white button and background colour must have a contrast ratio of at least 4.5:1 to meet [WCAG 2.2 success criterion 1.4.3 Contrast (minimum), level AA](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html).
-{{ example({ group: "components", item: "button", example: "inverse", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "inverse", html: true, nunjucks: true, rails: true, open: false}) }}
### Disabled buttons
@@ -108,17 +108,17 @@ Disabled buttons have poor contrast and can confuse some users, so avoid them if
Only use disabled buttons if research shows it makes the user interface easier to understand.
-{{ example({ group: "components", item: "button", example: "disabled", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "disabled", html: true, nunjucks: true, rails: true, open: false}) }}
### Grouping buttons
Use a button group when two or more buttons are placed together.
-{{ example({ group: "components", item: "button", example: "secondary-combo", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "secondary-combo", html: true, nunjucks: true, rails: true, open: false}) }}
Any links within a button group will automatically align with the buttons.
-{{ example({ group: "components", item: "button", example: "button-group", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "button-group", html: true, nunjucks: true, rails: true, open: false}) }}
### Stop users from accidentally sending information more than once
@@ -136,7 +136,7 @@ If you are working in production and research shows that users are frequently se
To do this, set the `data-prevent-double-click` attribute to `true`. You can do this directly in the HTML or, if you’re using Nunjucks, you can use the Nunjucks macro as shown in this example.
-{{ example({ group: "components", item: "button", example: "prevent-double-click", html: true, nunjucks: true, open: false }) }}
+{{ example({group: "components", item: "button", example: "prevent-double-click", html: true, nunjucks: true, rails: true, open: false}) }}
This feature will prevent double clicks for users that have JavaScript enabled, however you should also think about the issue server-side to protect against attacks.
diff --git a/src/components/button/inverse/index.erb b/src/components/button/inverse/index.erb
new file mode 100644
index 0000000000..bd57b445dd
--- /dev/null
+++ b/src/components/button/inverse/index.erb
@@ -0,0 +1 @@
+<%= form.govuk_submit("Create an account", inverse: true) %>
diff --git a/src/components/button/prevent-double-click/index.erb b/src/components/button/prevent-double-click/index.erb
new file mode 100644
index 0000000000..78cc275379
--- /dev/null
+++ b/src/components/button/prevent-double-click/index.erb
@@ -0,0 +1 @@
+<%= form.govuk_submit("Confirm and send") %>
diff --git a/src/components/button/secondary-combo/index.erb b/src/components/button/secondary-combo/index.erb
new file mode 100644
index 0000000000..af4f23fe06
--- /dev/null
+++ b/src/components/button/secondary-combo/index.erb
@@ -0,0 +1,3 @@
+<%= form.govuk_submit("Continue") do %>
+ <%= form.govuk_submit("Save as draft", secondary: true) %>
+<% end %>
diff --git a/src/components/button/secondary/index.erb b/src/components/button/secondary/index.erb
new file mode 100644
index 0000000000..b5337cde2f
--- /dev/null
+++ b/src/components/button/secondary/index.erb
@@ -0,0 +1 @@
+<%= form.govuk_submit("Find address", secondary: true) %>
diff --git a/src/components/button/start/index.erb b/src/components/button/start/index.erb
new file mode 100644
index 0000000000..d1a8402855
--- /dev/null
+++ b/src/components/button/start/index.erb
@@ -0,0 +1 @@
+<%= govuk_start_button(text: "Start now", href: "#") %>
diff --git a/src/components/button/warning/index.erb b/src/components/button/warning/index.erb
new file mode 100644
index 0000000000..772035cebf
--- /dev/null
+++ b/src/components/button/warning/index.erb
@@ -0,0 +1 @@
+<%= form.govuk_submit("Delete account", warning: true) %>
diff --git a/src/components/character-count/default/index.erb b/src/components/character-count/default/index.erb
new file mode 100644
index 0000000000..51237d11d8
--- /dev/null
+++ b/src/components/character-count/default/index.erb
@@ -0,0 +1,11 @@
+<%= form.govuk_text_area :detail,
+ label: {
+ text: "Can you provide more detail?",
+ tag: "h1".
+ size: "l"
+ },
+ hint: {
+ text: "Do not include personal or financial information like your National Insurance number or credit card details."
+ },
+ max_chars: 200
+%>
diff --git a/src/components/character-count/error/index.erb b/src/components/character-count/error/index.erb
new file mode 100644
index 0000000000..a670708d55
--- /dev/null
+++ b/src/components/character-count/error/index.erb
@@ -0,0 +1,16 @@
+<%
+ # In the associated model, add:
+ # validates description: {
+ # maximum: 350,
+ # too_long: "Job description must be #{count} characters or less"
+ # }
+%>
+
+<%= form.govuk_text_area :description,
+ label: {
+ text: "Enter a job description",
+ tag: "h1".
+ size: "l"
+ },
+ max_chars: 350
+%>
diff --git a/src/components/character-count/index.md b/src/components/character-count/index.md
index d33f34cd66..dffacfe804 100644
--- a/src/components/character-count/index.md
+++ b/src/components/character-count/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
Help users know how much text they can enter when there is a limit on the number of characters.
-{{ example({ group: "components", item: "character-count", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({group: "components", item: "character-count", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -46,13 +46,13 @@ This component uses JavaScript. If JavaScript is not available, users will see a
There are 2 ways to use the character count component. You can use HTML or, if you’re using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.
-{{ example({ group: "components", item: "character-count", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "character-count", example: "default", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second" }) }}
### If you’re asking more than one question on the page
If you're asking more than one question on the page, do not set the contents of the `
` as the page heading. Read more about [asking multiple questions on Question pages](/patterns/question-pages/#asking-multiple-questions-on-a-page).
-{{ example({ group: "components", item: "character-count", example: "without-heading", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "character-count", example: "without-heading", html: true, nunjucks: true, rails: true, open: false }) }}
### Consider if a word count is more helpful
@@ -60,7 +60,7 @@ In some cases it may be more helpful to show a word count. For example, if your
Do this by setting `data-maxwords` in the component markup. For example, `data-maxwords="150"` will set a word limit of 150.
-{{ example({ group: "components", item: "character-count", example: "word-count", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "character-count", example: "word-count", html: true, nunjucks: true, rails: true, open: false }) }}
### Avoid narrow limits
@@ -74,13 +74,13 @@ To do this, set the threshold in the component markup as a percentage. For examp
Screen reader users will hear the character limit when they first interact with a textarea using the threshold option. Sighted users will not see anything until the count message is shown – though you might choose to include the character limit in the hint text.
-{{ example({ group: "components", item: "character-count", example: "threshold", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "character-count", example: "threshold", html: true, nunjucks: true, rails: true, open: false }) }}
### Error messages
Error messages should be styled like this:
-{{ example({ group: "components", item: "character-count", example: "error", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "character-count", example: "error", html: true, nunjucks: true, rails: true, open: false }) }}
If a user tries to send their response with too many characters, you must show an error message above the field as well as the count message below it.
diff --git a/src/components/character-count/threshold/index.erb b/src/components/character-count/threshold/index.erb
new file mode 100644
index 0000000000..46aa570b21
--- /dev/null
+++ b/src/components/character-count/threshold/index.erb
@@ -0,0 +1,9 @@
+<%= form.govuk_text_area :detail,
+ label: {
+ text: "Can you provide more detail?",
+ tag: "h1".
+ size: "l"
+ },
+ max_chars: 1000,
+ threshold: 85
+%>
diff --git a/src/components/character-count/without-heading/index.erb b/src/components/character-count/without-heading/index.erb
new file mode 100644
index 0000000000..8e0e5af702
--- /dev/null
+++ b/src/components/character-count/without-heading/index.erb
@@ -0,0 +1,6 @@
+<%= form.govuk_text_area :description,
+ label: {
+ text: "Describe the nature of your event"
+ },
+ max_chars: 200
+%>
diff --git a/src/components/character-count/word-count/index.erb b/src/components/character-count/word-count/index.erb
new file mode 100644
index 0000000000..0127863a74
--- /dev/null
+++ b/src/components/character-count/word-count/index.erb
@@ -0,0 +1,8 @@
+<%= form.govuk_text_area :description,
+ label: {
+ text: "Enter a job description",
+ tag: "h1".
+ size: "l"
+ },
+ max_words: 150
+%>
diff --git a/src/components/checkboxes/conditional-reveal/index.erb b/src/components/checkboxes/conditional-reveal/index.erb
new file mode 100644
index 0000000000..6d41da5a6f
--- /dev/null
+++ b/src/components/checkboxes/conditional-reveal/index.erb
@@ -0,0 +1,30 @@
+<%= f.govuk_check_boxes_fieldset :contact,
+ legend: {
+ text: "How would you like to be contacted?",
+ size: "l",
+ tag: "h1"
+ },
+ hint: {
+ text: "Select all options that are relevant to you."
+ }
+ do %>
+
+ <%= f.govuk_check_box :contact, :email,
+ label: { text: "Email" },
+ link_errors: true do %>
+ <%= f.govuk_text_field :email_address,
+ label: { text: 'Email address' } %>
+ <% end %>
+
+ <%= f.govuk_check_box :contact, :phone,
+ label: { text: "Phone" } do %>
+ <%= f.govuk_text_field :phone_number,
+ label: { text: 'Phone number' } %>
+ <% end %>
+
+ <%= f.govuk_check_box :contact, :text_message,
+ label: { text: "Text message" } %>
+ <%= f.govuk_text_field :sms_number,
+ label: { text: 'Mobile phone number' } %>
+ <% end %>
+<% end %>
diff --git a/src/components/checkboxes/default/index.erb b/src/components/checkboxes/default/index.erb
new file mode 100644
index 0000000000..058e0f8cdb
--- /dev/null
+++ b/src/components/checkboxes/default/index.erb
@@ -0,0 +1,22 @@
+<%
+ # waste_types would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+ waste_types = [
+ OpenStruct.new(id: "carcasses", name: "Waste from animal carcasses"),
+ OpenStruct.new(id: "mines", name: "Waste from mines or quarries"),
+ OpenStruct.new(id: "farm", name: "Farm or agricultural waste")
+ ]
+%>
+
+<%= f.govuk_collection_check_boxes :waste, waste_types,
+ :id,
+ :name,
+ legend: {
+ text: "Which types of waste do you transport?",
+ tag: "h1",
+ size: "l"
+ },
+ hint: {
+ text: "Select all that apply."
+ } %>
diff --git a/src/components/checkboxes/error/index.erb b/src/components/checkboxes/error/index.erb
new file mode 100644
index 0000000000..858d8ff94f
--- /dev/null
+++ b/src/components/checkboxes/error/index.erb
@@ -0,0 +1,28 @@
+<%
+ # nationalities would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+ nationalities = [
+ OpenStruct.new(id: "British", name: "British", hint: "including English, Scottish, Welsh and Northern Irish"),
+ OpenStruct.new(id: "irish", name: "Irish"),
+ OpenStruct.new(id: "other", name: "Citizen of another country")
+ ]
+
+ # In the associated model, add:
+ #
+ # validates :nationality,
+ # presence: { message: "Select if you are British, Irish or a citizen of a different country" }
+%>
+
+<%= f.govuk_collection_check_boxes :nationality, nationalities,
+ :id,
+ :name,
+ :hint,
+ legend: {
+ text: "What is your nationality?",
+ tag: "h1",
+ size: "l"
+ },
+ hint: {
+ text: "If you have dual nationality, select all options that are relevant to you."
+ } %>
diff --git a/src/components/checkboxes/hint/index.erb b/src/components/checkboxes/hint/index.erb
new file mode 100644
index 0000000000..02e65f7471
--- /dev/null
+++ b/src/components/checkboxes/hint/index.erb
@@ -0,0 +1,23 @@
+<%
+ # nationalities would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+ nationalities = [
+ OpenStruct.new(id: "British", name: "British", hint: "including English, Scottish, Welsh and Northern Irish"),
+ OpenStruct.new(id: "irish", name: "Irish"),
+ OpenStruct.new(id: "other", name: "Citizen of another country")
+ ]
+%>
+
+<%= f.govuk_collection_check_boxes :nationality, nationalities,
+ :id,
+ :name,
+ :hint,
+ legend: {
+ text: "What is your nationality?",
+ tag: "h1",
+ size: "l"
+ },
+ hint: {
+ text: "If you have dual nationality, select all options that are relevant to you."
+ } %>
diff --git a/src/components/checkboxes/index.md b/src/components/checkboxes/index.md
index 41e7f1f6af..414e2052f0 100644
--- a/src/components/checkboxes/index.md
+++ b/src/components/checkboxes/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
Let users select one or more options by using the checkboxes component.
-{{ example({ group: "components", item: "checkboxes", example: "default", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", loading: "eager" }) }}
## When to use this component
@@ -51,13 +51,13 @@ Read more about [why and how to set legends as headings](/get-started/labels-leg
There are 2 ways to use the checkboxes component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "checkboxes", example: "default", html: true, nunjucks: true, open: false, size: "m", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", titleSuffix: "second" }) }}
### If you’re asking more than one question on the page
If you're asking more than one question on the page, do not set the contents of the `` as the page heading. Read more about [asking multiple questions on Question pages](/patterns/question-pages/#asking-multiple-questions-on-a-page).
-{{ example({ group: "components", item: "checkboxes", example: "without-heading", html: true, nunjucks: true, open: false, size: "m" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "without-heading", html: true, nunjucks: true, rails: true, open: false, size: "m" }) }}
### Checkbox items with hints
@@ -67,7 +67,7 @@ Keep each hint to a single short sentence, without any full stops. Screen reader
Do not use links in hint text. While screen readers will read out the link text when describing the item, they usually do not tell users the text is a link.
-{{ example({ group: "components", item: "checkboxes", example: "hint", html: true, nunjucks: true, open: false, size: "s" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "hint", html: true, nunjucks: true, rails: true, open: false, size: "s" }) }}
### Add an option for ‘none’
@@ -83,11 +83,11 @@ For example, for the question 'Will you be travelling to any of these countries?
To enable some JavaScript that unchecks all other checkboxes when the user clicks 'None', add the `exclusive` behaviour to the 'none' checkbox.
-{{ example({ group: "components", item: "checkboxes", example: "with-none-option", html: true, nunjucks: true, open: false, size: "xl" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "with-none-option", html: true, nunjucks: true, rails: true, open: false, size: "xl" }) }}
If JavaScript is unavailable, and a user selects both the ‘none’ checkbox and another checkbox, display an error message.
-{{ example({ group: "components", item: "checkboxes", example: "with-none-option-in-error", html: true, nunjucks: true, open: false, size: "xl" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "with-none-option-in-error", html: true, nunjucks: true, rails: true, open: false, size: "xl" }) }}
### Conditionally revealing a related question
@@ -95,7 +95,7 @@ You can ask the user a related question when they select a particular checkbox,
This might make 2 related questions easier to answer by grouping them on the same page. For example, you could reveal a phone number input when the user selects the 'Contact me by phone' option.
-{{ example({ group: "components", item: "checkboxes", example: "conditional-reveal", html: true, nunjucks: true, open: false, size: "xl" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "conditional-reveal", html: true, nunjucks: true, rails: true, open: false, size: "xl" }) }}
Keep it simple. If the related question is complicated or has more than one part, show it on the next page in the process instead.
@@ -115,7 +115,7 @@ Use standard-sized checkboxes in most cases. However, smaller checkboxes work we
For example, on a page of search results, the main user need is to see the results. Using smaller checkboxes lets users see and change search filters without distracting them from the main content.
-{{ example({ group: "components", item: "checkboxes", example: "small", html: true, nunjucks: true, open: false, size: "m" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "small", html: true, nunjucks: true, rails: true, open: false, size: "m" }) }}
Small checkboxes can work well on information dense screens in services designed for repeat use, like caseworking systems.
@@ -125,7 +125,7 @@ In services like these, the risk that they will not be noticed is lower because
Error messages should be styled like this:
-{{ example({ group: "components", item: "checkboxes", example: "error", html: true, nunjucks: true, open: false, size: "s" }) }}
+{{ example({ group: "components", item: "checkboxes", example: "error", html: true, nunjucks: true, rails: true, open: false, size: "s" }) }}
Make sure errors follow the guidance in the [Error message component](/components/error-message/) and have specific error messages for specific error states.
diff --git a/src/components/checkboxes/small/index.erb b/src/components/checkboxes/small/index.erb
new file mode 100644
index 0000000000..36ff03ec71
--- /dev/null
+++ b/src/components/checkboxes/small/index.erb
@@ -0,0 +1,23 @@
+<%
+ # organisations would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+ organisations = [
+ OpenStruct.new(id: "hmrc", name: "HM Revenue and Customs (HMRC)"),
+ OpenStruct.new(id: "employment-tribunal", name: "Employment Tribunal"),
+ OpenStruct.new(id: "MOD", name: "Ministry of Defence"),
+ OpenStruct.new(id: "DfT", name: "Department for Transport")
+ ]
+%>
+
+<%= f.govuk_check_boxes_fieldset :organisation_id,
+ organisations,
+ :id,
+ :name,
+ small: true,
+ legend: {
+ text: "Organisation",
+ tag: "h1",
+ size: "m"
+ }
+%>
diff --git a/src/components/checkboxes/with-none-option-in-error/index.erb b/src/components/checkboxes/with-none-option-in-error/index.erb
new file mode 100644
index 0000000000..fe83945dab
--- /dev/null
+++ b/src/components/checkboxes/with-none-option-in-error/index.erb
@@ -0,0 +1,41 @@
+<%
+ # In the model, add this validation:
+ #
+ # validates :country_ids, presence: {
+ # message: "Select countries you will be travelling to, or select ‘No, I will not be travelling to any of these countries’"
+ # }
+ #
+ # Note: the first checkbox needs to have `link_errors: true`.
+%>
+
+<%= f.govuk_check_boxes_fieldset :country_ids,
+ legend: {
+ text: "Will you be travelling to any of these countries?",
+ tag: "h1",
+ size: "l"
+ },
+ hint: {
+ text: "Select all countries that apply"
+ } do %>
+
+ <%= f.govuk_check_box :countries,
+ :france,
+ label: { text: "France" },
+ link_errors: true %>
+
+ <%= f.govuk_check_box :countries,
+ :portugal,
+ label: { text: "Portugal" } %>
+
+ <%= f.govuk_check_box :countries,
+ :spain,
+ label: { text: "Spain" } %>
+
+ <%= f.govuk_check_box_divider %>
+
+ <%= f.govuk_check_box :countries,
+ :none,
+ exclusive: true,
+ label: { text: "No, I will not be travelling to any of these countries " } %>
+
+<% end %>
diff --git a/src/components/checkboxes/with-none-option/index.erb b/src/components/checkboxes/with-none-option/index.erb
new file mode 100644
index 0000000000..c2c9a4d970
--- /dev/null
+++ b/src/components/checkboxes/with-none-option/index.erb
@@ -0,0 +1,35 @@
+<%
+ # Note: the first checkbox needs to have `link_errors: true`.
+%>
+
+<%= f.govuk_check_boxes_fieldset :country_ids,
+ legend: {
+ text: "Will you be travelling to any of these countries?",
+ tag: "h1",
+ size: "l"
+ },
+ hint: {
+ text: "Select all countries that apply"
+ } do %>
+
+ <%= f.govuk_check_box :countries,
+ :france,
+ label: { text: "France" },
+ link_errors: true %>
+
+ <%= f.govuk_check_box :countries,
+ :portugal,
+ label: { text: "Portugal" } %>
+
+ <%= f.govuk_check_box :countries,
+ :spain,
+ label: { text: "Spain" } %>
+
+ <%= f.govuk_check_box_divider %>
+
+ <%= f.govuk_check_box :countries,
+ :none,
+ exclusive: true,
+ label: { text: "No, I will not be travelling to any of these countries " } %>
+
+<% end %>
diff --git a/src/components/checkboxes/without-heading/index.erb b/src/components/checkboxes/without-heading/index.erb
new file mode 100644
index 0000000000..2d18023fb0
--- /dev/null
+++ b/src/components/checkboxes/without-heading/index.erb
@@ -0,0 +1,20 @@
+<%
+ # waste_types would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+ waste_types = [
+ OpenStruct.new(id: "carcasses", name: "Waste from animal carcasses"),
+ OpenStruct.new(id: "mines", name: "Waste from mines or quarries"),
+ OpenStruct.new(id: "farm", name: "Farm or agricultural waste")
+ ]
+%>
+
+<%= f.govuk_collection_check_boxes :waste, waste_types,
+ :id,
+ :name,
+ legend: {
+ text: "Which types of waste do you transport?"
+ },
+ hint: {
+ text: "Select all that apply."
+ } %>
diff --git a/src/components/cookie-banner/default/index.erb b/src/components/cookie-banner/default/index.erb
new file mode 100644
index 0000000000..22f9db33a4
--- /dev/null
+++ b/src/components/cookie-banner/default/index.erb
@@ -0,0 +1,14 @@
+<%= govuk_cookie_banner do |cookie_banner|
+ cookie_banner.with_message(heading_text: "Cookies on [name of service]") do |messages|
+ messages.with_action { govuk_button_link_to("Accept analytics cookies", "#") }
+ messages.with_action { govuk_button_link_to("Reject analytics cookies", "#") }
+ messages.with_action { govuk_link_to("View cookies", "#") }
+%>
+
+ We use some essential cookies to make this service work.
+
+
+ We’d also like to use analytics cookies so we can understand
+ how you use the service and make improvements.
+
+<% end; end %>
diff --git a/src/components/cookie-banner/index.md b/src/components/cookie-banner/index.md
index e538e0a9e1..d52d9a81e0 100644
--- a/src/components/cookie-banner/index.md
+++ b/src/components/cookie-banner/index.md
@@ -29,7 +29,7 @@ Allow users to accept or reject cookies which are not essential to making your s
]
}) }}
-{{ example({ group: "components", item: "cookie-banner", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({group: "components", item: "cookie-banner", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -183,7 +183,7 @@ Keep the text as short as possible while making sure it’s an accurate descript
You can use this example text for a service which sets essential and analytics cookies. Analytics cookies are those set by your organisation to collect information about how people are using your digital service.
-{{ example({ group: "components", item: "cookie-banner", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({group: "components", item: "cookie-banner", example: "default", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second"}) }}
### If you’re using more than one type of non-essential cookie
diff --git a/src/components/date-input/date-of-birth/index.erb b/src/components/date-input/date-of-birth/index.erb
new file mode 100644
index 0000000000..42f18d2911
--- /dev/null
+++ b/src/components/date-input/date-of-birth/index.erb
@@ -0,0 +1,11 @@
+<%= f.govuk_date_field :dob,
+ date_of_birth: true,
+ legend: {
+ text: 'What is your date of birth?',
+ tag: 'h1',
+ size: 'l'
+ },
+ hint: {
+ text: 'For example, 27 3 2007'
+ }
+%>
diff --git a/src/components/date-input/default/index.erb b/src/components/date-input/default/index.erb
new file mode 100644
index 0000000000..e23bbf84d1
--- /dev/null
+++ b/src/components/date-input/default/index.erb
@@ -0,0 +1,10 @@
+<%= f.govuk_date_field :passport_issued,
+ legend: {
+ text: 'When was your passport issued?',
+ tag: 'h1',
+ size: 'l'
+ },
+ hint: {
+ text: 'For example, 27 3 2007'
+ }
+%>
diff --git a/src/components/date-input/error-single/index.erb b/src/components/date-input/error-single/index.erb
new file mode 100644
index 0000000000..5745b4224c
--- /dev/null
+++ b/src/components/date-input/error-single/index.erb
@@ -0,0 +1,22 @@
+<%
+ # In the associated model, add:
+
+ validate :passport_issued_must_contain_a_year
+
+ def passport_issued_must_contain_a_year
+ if passport_issued.present? && passport_issued.year.blank?
+ errors.add(:passport_issued, "The date your passport was issued must include a year")
+ end
+ end
+%>
+
+<%= f.govuk_date_field :passport_issued,
+ legend: {
+ text: 'When was your passport issued?',
+ tag: 'h1',
+ size: 'l'
+ },
+ hint: {
+ text: 'For example, 27 3 2007'
+ }
+%>
diff --git a/src/components/date-input/error/index.erb b/src/components/date-input/error/index.erb
new file mode 100644
index 0000000000..11ad99af06
--- /dev/null
+++ b/src/components/date-input/error/index.erb
@@ -0,0 +1,22 @@
+<%
+ # In the associated model, add:
+
+ validate :passport_issued_must_be_in_the_past
+
+ def passport_issued_must_be_in_the_past
+ if passport_issued.present? && passport_issued > Date.today
+ errors.add(:passport_issued, "The date your passport was issued must be in the past")
+ end
+ end
+%>
+
+<%= f.govuk_date_field :passport_issued,
+ legend: {
+ text: 'When was your passport issued?',
+ tag: 'h1',
+ size: 'l'
+ },
+ hint: {
+ text: 'For example, 27 3 2007'
+ }
+%>
diff --git a/src/components/date-input/index.md b/src/components/date-input/index.md
index 34fe5a9fc6..4538e28df6 100644
--- a/src/components/date-input/index.md
+++ b/src/components/date-input/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
Use the date input component to help users enter a memorable date or one they can easily look up.
-{{ example({ group: "components", item: "date-input", example: "default", html: true, nunjucks: true, open: false, size: "s", loading: "eager" }) }}
+{{ example({ group: "components", item: "date-input", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", loading: "eager" }) }}
## When to use this component
@@ -39,7 +39,7 @@ Accept month names written out in full or abbreviated form (for example, ‘janu
There are 2 ways to use the date input component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "date-input", example: "default", html: true, nunjucks: true, open: false, size: "s", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "date-input", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", titleSuffix: "second" }) }}
Never automatically tab users between the fields of the date input because this can be confusing and may clash with normal keyboard controls.
@@ -55,7 +55,7 @@ Use the `autocomplete` attribute on the date input component when you're asking
To do this, set the `autocomplete` attribute on the 3 fields to `bday-day`, `bday-month` and `bday-year`. See how to do this in the HTML and Nunjucks tabs in the following example.
-{{ example({ group: "components", item: "date-input", example: "date-of-birth", html: true, nunjucks: true, open: true, size: "s", id: "default-2" }) }}
+{{ example({ group: "components", item: "date-input", example: "date-of-birth", html: true, nunjucks: true, rails: true, open: true, size: "s", id: "default-2" }) }}
If you are working in production you’ll need to do this to meet [WCAG 2.2 success criterion 1.3.5: Identify input purpose, level AA](https://www.w3.org/WAI/WCAG22/Understanding/identify-input-purpose.html).
@@ -63,11 +63,11 @@ If you are working in production you’ll need to do this to meet [WCAG 2.2 succ
If you’re highlighting the whole date, style all the fields like this:
-{{ example({ group: "components", item: "date-input", example: "error", html: true, nunjucks: true, open: false, size: "m" }) }}
+{{ example({ group: "components", item: "date-input", example: "error", html: true, nunjucks: true, rails: true, open: false, size: "m" }) }}
If you’re highlighting just one field - either the day, month or year - only style the field that has an error. The error message must say which field has an error, like this:
-{{ example({ group: "components", item: "date-input", example: "error-single", html: true, nunjucks: true, open: false, size: "m" }) }}
+{{ example({ group: "components", item: "date-input", example: "error-single", html: true, nunjucks: true, rails: true, open: false, size: "m" }) }}
Make sure errors follow the guidance in the [Error message component](/components/error-message/) and have specific error messages for specific error states.
diff --git a/src/components/date-input/without-heading/index.erb b/src/components/date-input/without-heading/index.erb
new file mode 100644
index 0000000000..c2a9e5bc48
--- /dev/null
+++ b/src/components/date-input/without-heading/index.erb
@@ -0,0 +1,8 @@
+<%= f.govuk_date_field :passport_issued,
+ legend: {
+ text: 'When was your passport issued?'
+ },
+ hint: {
+ text: 'For example, 27 3 2007'
+ }
+%>
diff --git a/src/components/details/default/index.erb b/src/components/details/default/index.erb
new file mode 100644
index 0000000000..4c1a4d0230
--- /dev/null
+++ b/src/components/details/default/index.erb
@@ -0,0 +1,4 @@
+<%= govuk_details(
+ summary_text: "Help with nationality",
+ text: "We need to know your nationality so we can work out which elections you’re entitled to vote in. If you cannot provide your nationality, you’ll have to send copies of identity documents through the post."
+) %>
diff --git a/src/components/details/index.md b/src/components/details/index.md
index 2fa1fd5091..6a045f05a4 100644
--- a/src/components/details/index.md
+++ b/src/components/details/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
Make a page easier to scan by letting users reveal more detailed information only if they need it.
-{{ example({ group: "components", item: "details", example: "default", html: true, nunjucks: true, open: false, size: "s", loading: "eager" }) }}
+{{ example({ group: "components", item: "details", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", loading: "eager" }) }}
## When to use this component
@@ -35,7 +35,7 @@ The details component is a short link that shows more detailed help text when a
There are 2 ways to use the details component. You can use HTML or, if you are using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "details", example: "default", html: true, nunjucks: true, open: false, size: "s", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "details", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", titleSuffix: "second" }) }}
### Write clear link text
diff --git a/src/components/error-message/default/index.erb b/src/components/error-message/default/index.erb
new file mode 100644
index 0000000000..11ad99af06
--- /dev/null
+++ b/src/components/error-message/default/index.erb
@@ -0,0 +1,22 @@
+<%
+ # In the associated model, add:
+
+ validate :passport_issued_must_be_in_the_past
+
+ def passport_issued_must_be_in_the_past
+ if passport_issued.present? && passport_issued > Date.today
+ errors.add(:passport_issued, "The date your passport was issued must be in the past")
+ end
+ end
+%>
+
+<%= f.govuk_date_field :passport_issued,
+ legend: {
+ text: 'When was your passport issued?',
+ tag: 'h1',
+ size: 'l'
+ },
+ hint: {
+ text: 'For example, 27 3 2007'
+ }
+%>
diff --git a/src/components/error-message/index.md b/src/components/error-message/index.md
index aa0551366f..45f02fa3b4 100644
--- a/src/components/error-message/index.md
+++ b/src/components/error-message/index.md
@@ -27,7 +27,7 @@ This guidance is for government teams that build online services. [To find infor
Follow the [Validation pattern](/patterns/validation/) and show an error message when there is a validation error. In the error message explain what went wrong and how to fix it.
-{{ example({ group: "components", item: "error-message", example: "default", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
+{{ example({ group: "components", item: "error-message", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", loading: "eager" }) }}
## When to use this component
@@ -78,7 +78,7 @@ There are 2 ways to use the error message component. You can use HTML or, if you
### Legend
-{{ example({ group: "components", item: "error-message", example: "legend", html: true, nunjucks: true, open: false, size: "m" }) }}
+{{ example({ group: "components", item: "error-message", example: "legend", html: true, nunjucks: true, rails: true, open: false, size: "m" }) }}
### Label
diff --git a/src/components/error-message/legend/index.erb b/src/components/error-message/legend/index.erb
new file mode 100644
index 0000000000..858d8ff94f
--- /dev/null
+++ b/src/components/error-message/legend/index.erb
@@ -0,0 +1,28 @@
+<%
+ # nationalities would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+ nationalities = [
+ OpenStruct.new(id: "British", name: "British", hint: "including English, Scottish, Welsh and Northern Irish"),
+ OpenStruct.new(id: "irish", name: "Irish"),
+ OpenStruct.new(id: "other", name: "Citizen of another country")
+ ]
+
+ # In the associated model, add:
+ #
+ # validates :nationality,
+ # presence: { message: "Select if you are British, Irish or a citizen of a different country" }
+%>
+
+<%= f.govuk_collection_check_boxes :nationality, nationalities,
+ :id,
+ :name,
+ :hint,
+ legend: {
+ text: "What is your nationality?",
+ tag: "h1",
+ size: "l"
+ },
+ hint: {
+ text: "If you have dual nationality, select all options that are relevant to you."
+ } %>
diff --git a/src/components/error-summary/default/index.erb b/src/components/error-summary/default/index.erb
new file mode 100644
index 0000000000..5f3cf20888
--- /dev/null
+++ b/src/components/error-summary/default/index.erb
@@ -0,0 +1,14 @@
+<%
+ # The error summary content is built using activerecord
+ # forms validation API. This means that your validations are
+ # declared on the model. To include the error summary, use
+ # the govuk_error_summary helper.
+%>
+
+<%= form_with model: @user do |f| %>
+
+ <%= f.govuk_error_summary %>
+
+ <% # Form fields go here %>
+
+<% end %>
diff --git a/src/components/error-summary/index.md b/src/components/error-summary/index.md
index 8f8f3fd30f..5731c45f6e 100644
--- a/src/components/error-summary/index.md
+++ b/src/components/error-summary/index.md
@@ -13,7 +13,7 @@ Use this component at the top of a page to summarise any errors a user has made.
When a user makes an error, you must show both an error summary and an [Error message component](/components/error-message/) next to each answer that contains an error.
-{{ example({ group: "components", item: "error-summary", example: "default", html: true, nunjucks: true, open: false, size: "s", loading: "eager" }) }}
+{{ example({ group: "components", item: "error-summary", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", loading: "eager" }) }}
## When to use this component
diff --git a/src/components/exit-this-page/default/index.erb b/src/components/exit-this-page/default/index.erb
new file mode 100644
index 0000000000..fc4f44b480
--- /dev/null
+++ b/src/components/exit-this-page/default/index.erb
@@ -0,0 +1 @@
+<%= govuk_exit_this_page %>
diff --git a/src/components/exit-this-page/index.md b/src/components/exit-this-page/index.md
index f667887128..9fafafec1f 100644
--- a/src/components/exit-this-page/index.md
+++ b/src/components/exit-this-page/index.md
@@ -13,7 +13,7 @@ Give users a way to quickly and safely exit a service, website or application.
For service journeys, you must use this component with the [Exit a page quickly pattern](/patterns/exit-a-page-quickly/).
-{{ example({ group: "components", item: "exit-this-page", example: "default", html: true, nunjucks: true, open: false, size: "s", loading: "eager" }) }}
+{{ example({ group: "components", item: "exit-this-page", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", loading: "eager" }) }}
## When to use this component
@@ -59,7 +59,7 @@ Add the code for the 'secondary link' into the layout file of your service. The
When the user interacts with the 'secondary link', it will perform the same action as pressing the button to activate Exit this Page.
-{{ example({ group: "components", item: "exit-this-page", example: "secondary-link", html: true, nunjucks: true, open: false, size: "s" }) }}
+{{ example({ group: "components", item: "exit-this-page", example: "secondary-link", html: true, nunjucks: true, rails: true, open: false, size: "s" }) }}
The `href` for the 'secondary link' should be the same as the URL used for the button.
diff --git a/src/components/exit-this-page/secondary-link/index.erb b/src/components/exit-this-page/secondary-link/index.erb
new file mode 100644
index 0000000000..458a107def
--- /dev/null
+++ b/src/components/exit-this-page/secondary-link/index.erb
@@ -0,0 +1,3 @@
+To view the skip link component, tab to this example --- or click inside this example and press tab.
+
+<%= govuk_exit_this_page_link %>
diff --git a/src/components/fieldset/address-group/index.erb b/src/components/fieldset/address-group/index.erb
new file mode 100644
index 0000000000..26f6df23ae
--- /dev/null
+++ b/src/components/fieldset/address-group/index.erb
@@ -0,0 +1,30 @@
+<%= f.govuk_fieldset
+ legend: {
+ text: 'What is your address?',
+ size: 'l',
+ tag: 'h1'
+ } do %>
+
+ <%= f.govuk_text_field :address_one,
+ label: {
+ text: 'Address line 1'
+ } %>
+
+ <%= f.govuk_text_field :address_two,
+ label: {
+ text: 'Address line 2 (optional)'
+ } %>
+
+ <%= f.govuk_text_field :address_three,
+ label: {
+ text: 'Town or city'
+ },
+ width: 'two-thirds' %>
+
+ <%= f.govuk_text_field :postcode,
+ label: {
+ text: 'Postcode'
+ },
+ width: 'one-quarter' %>
+
+<% end %>
diff --git a/src/components/fieldset/default/index.erb b/src/components/fieldset/default/index.erb
new file mode 100644
index 0000000000..cb420a6fd0
--- /dev/null
+++ b/src/components/fieldset/default/index.erb
@@ -0,0 +1,8 @@
+<%= f.govuk_fieldset
+ legend: {
+ text: 'Legend as page heading',
+ size: 'l',
+ tag: 'h1'
+ } do %>
+
+<% end %>
diff --git a/src/components/fieldset/index.md b/src/components/fieldset/index.md
index 184d366351..0180a6e422 100644
--- a/src/components/fieldset/index.md
+++ b/src/components/fieldset/index.md
@@ -15,7 +15,7 @@ Use the fieldset component to group related form inputs.
Use the fieldset component when you need to show a relationship between multiple form inputs. For example, you may need to group a set of text inputs into a single fieldset when [asking for an address in your service](/patterns/addresses/).
-{{ example({ group: "components", item: "fieldset", example: "address-group", html: true, nunjucks: true, open: false, size: "xl", loading: "eager" }) }}
+{{ example({ group: "components", item: "fieldset", example: "address-group", html: true, nunjucks: true, rails: true, open: false, size: "xl", loading: "eager" }) }}
If you’re using the examples or macros for a [Radios component](/components/radios/), [Checkboxes component](/components/checkboxes/) or [Date input component](/components/date-input/), the fieldset will already be included.
@@ -27,7 +27,7 @@ If you’re asking just [one question per page in your service](/patterns/questi
Read more about [why and how to set legends as headings](/get-started/labels-legends-headings/).
-{{ example({ group: "components", item: "fieldset", example: "default", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "fieldset", example: "default", html: true, nunjucks: true, rails: true, open: false }) }}
On [Question pages in your service](/patterns/question-pages/) containing a group of inputs, including the question as the legend helps users of screen readers to understand that the inputs are all related to that question.
diff --git a/src/components/file-upload/default/index.erb b/src/components/file-upload/default/index.erb
new file mode 100644
index 0000000000..95b8a34d96
--- /dev/null
+++ b/src/components/file-upload/default/index.erb
@@ -0,0 +1,4 @@
+<%= f.govuk_file_field :file_upload_1,
+ label: {
+ text: 'Upload a file'
+ } %>
diff --git a/src/components/file-upload/error/index.erb b/src/components/file-upload/error/index.erb
new file mode 100644
index 0000000000..18b8dfc8c9
--- /dev/null
+++ b/src/components/file-upload/error/index.erb
@@ -0,0 +1,10 @@
+<%
+ # You’ll need to add any file size validations within your
+ # model code. This may require custom code or a ruby gem which
+ # provides these validations.
+%>
+
+<%= f.govuk_file_field :file_upload_1,
+ label: {
+ text: 'Upload a file'
+ } %>
diff --git a/src/components/file-upload/index.md b/src/components/file-upload/index.md
index 1cbe43e24a..01f43a4961 100644
--- a/src/components/file-upload/index.md
+++ b/src/components/file-upload/index.md
@@ -31,7 +31,7 @@ This guidance is for government teams that build online services. [To find infor
Help users select and upload a file.
-{{ example({ group: "components", item: "file-upload", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "file-upload", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -62,13 +62,13 @@ To upload a file, the user can either:
There are 2 ways to use the file upload component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "file-upload", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "file-upload", example: "default", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second" }) }}
### Error messages
Error messages should be styled like this:
-{{ example({ group: "components", item: "file-upload", example: "error", html: true, nunjucks: true, open: false, size: "m" }) }}
+{{ example({ group: "components", item: "file-upload", example: "error", html: true, nunjucks: true, rails: true, open: false, size: "m" }) }}
Make sure errors follow the guidance in the [Error message component](/components/error-message/) and have specific error messages for specific error states.
diff --git a/src/components/footer/default/index.erb b/src/components/footer/default/index.erb
new file mode 100644
index 0000000000..aee33c8729
--- /dev/null
+++ b/src/components/footer/default/index.erb
@@ -0,0 +1 @@
+<%= govuk_footer %>
diff --git a/src/components/footer/full/index.erb b/src/components/footer/full/index.erb
new file mode 100644
index 0000000000..1b73f28cfe
--- /dev/null
+++ b/src/components/footer/full/index.erb
@@ -0,0 +1,59 @@
+<%= govuk_footer do |footer| %>
+ <% footer.with_navigation do %>
+
+
+
+
+
+ <% end %>
+<% end %>
diff --git a/src/components/footer/index.md b/src/components/footer/index.md
index 770adb0f3a..c3e062f9ba 100644
--- a/src/components/footer/index.md
+++ b/src/components/footer/index.md
@@ -25,7 +25,7 @@ The GOV.UK footer provides copyright, licensing and other information about your
]
}) }}
-{{ example({ group: "components", item: "footer", example: "default", id: "default-1", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
+{{ example({ group: "components", item: "footer", example: "default", id: "default-1", html: true, nunjucks: true, rails: true, open: false, size: "m", loading: "eager" }) }}
If you use the page template, you'll also get the footer without having to add it, as it's included by default. However, if you want to customise the default footer, read the [page template guidance about customising components](/styles/page-template/#changing-template-content).
@@ -41,11 +41,11 @@ Make it clear whether content is available for re-use - and if it is, under what
### Footer without links
-{{ example({ group: "components", item: "footer", example: "default", titleSuffix: "second", html: true, nunjucks: true, open: false, size: "m", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "footer", example: "default", titleSuffix: "second", html: true, nunjucks: true, rails: true, open: false, size: "m", titleSuffix: "second" }) }}
### Footer with links
-{{ example({ group: "components", item: "footer", example: "with-meta", html: true, nunjucks: true, open: false, size: "m" }) }}
+{{ example({ group: "components", item: "footer", example: "with-meta", html: true, nunjucks: true, rails: true, open: false, size: "m" }) }}
## Adding links
@@ -71,8 +71,8 @@ Only add secondary GOV.UK navigation if you’re creating a GOV.UK service, and
### Footer with secondary navigation
-{{ example({ group: "components", item: "footer", example: "with-navigation", html: true, nunjucks: true, open: false, size: "xl" }) }}
+{{ example({ group: "components", item: "footer", example: "with-navigation", html: true, nunjucks: true, rails: true, open: false, size: "xl" }) }}
### Footer with links and secondary navigation
-{{ example({ group: "components", item: "footer", example: "full", html: true, nunjucks: true, open: false, size: "xl" }) }}
+{{ example({ group: "components", item: "footer", example: "full", html: true, nunjucks: true, rails: true, open: false, size: "xl" }) }}
diff --git a/src/components/footer/with-meta/index.erb b/src/components/footer/with-meta/index.erb
new file mode 100644
index 0000000000..d0c88896e6
--- /dev/null
+++ b/src/components/footer/with-meta/index.erb
@@ -0,0 +1,9 @@
+<%= govuk_footer(
+ meta_items_title: "Support links",
+ meta_items: {
+ "Item 1" => "#",
+ "Item 2" => "#",
+ "Item 3" => "#"
+ }
+
+) %>
diff --git a/src/components/footer/with-navigation/index.erb b/src/components/footer/with-navigation/index.erb
new file mode 100644
index 0000000000..1b73f28cfe
--- /dev/null
+++ b/src/components/footer/with-navigation/index.erb
@@ -0,0 +1,59 @@
+<%= govuk_footer do |footer| %>
+ <% footer.with_navigation do %>
+
+
+
+
+
+ <% end %>
+<% end %>
diff --git a/src/components/header/default/index.erb b/src/components/header/default/index.erb
new file mode 100644
index 0000000000..18c9ce5ba2
--- /dev/null
+++ b/src/components/header/default/index.erb
@@ -0,0 +1 @@
+<%= govuk_header(homepage_url: "#") %>
diff --git a/src/components/header/index.md b/src/components/header/index.md
index f0c8941e35..6739c8c39e 100644
--- a/src/components/header/index.md
+++ b/src/components/header/index.md
@@ -29,7 +29,7 @@ The GOV.UK header component tells users they’re using a service on GOV.UK and
]
}) }}
-{{ example({ group: "components", item: "header", example: "default", id: "default-1", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "header", example: "default", id: "default-1", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
If you use the page template, you'll also get the GOV.UK header without having to add it, as it's included by default. However, if you want to customise the default GOV.UK header, read the [page template guidance about customising components](/styles/page-template/#changing-template-content).
@@ -63,7 +63,7 @@ Most services on GOV.UK should use the default GOV.UK header.
It should only show the GOV.UK logo and any GOV.UK-wide links and tools to help your users. [Do not add the menu of GOV.UK topic links](https://insidegovuk.blog.gov.uk/2021/11/11/launching-gov-uks-new-menu-bar/) to your service’s GOV.UK header.
-{{ example({ group: "components", item: "header", example: "default", titleSuffix: "second", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "header", example: "default", titleSuffix: "second", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second" }) }}
### Previous variants of the GOV.UK header
diff --git a/src/components/header/with-service-name-and-navigation/index.erb b/src/components/header/with-service-name-and-navigation/index.erb
new file mode 100644
index 0000000000..1e41eb407a
--- /dev/null
+++ b/src/components/header/with-service-name-and-navigation/index.erb
@@ -0,0 +1,29 @@
+<%= govuk_header
+ homepage_url: "#",
+ service_name: "Service name",
+ service_url: "#"
+ do |header|
+%>
+
+<%= header.with_navigation_item(
+ text: "Navigation item 1",
+ href: "#",
+ active: true
+) %>
+
+<%= header.with_navigation_item(
+ text: "Navigation item 2",
+ href: "#"
+) %>
+
+<%= header.with_navigation_item(
+ text: "Navigation item 3",
+ href: "#"
+) %>
+
+<%= header.with_navigation_item(
+ text: "Navigation item 4",
+ href: "#"
+) %>
+
+<% end %>
diff --git a/src/components/header/with-service-name/index.erb b/src/components/header/with-service-name/index.erb
new file mode 100644
index 0000000000..427f4177d8
--- /dev/null
+++ b/src/components/header/with-service-name/index.erb
@@ -0,0 +1,5 @@
+<%= govuk_header
+ homepage_url: "#",
+ service_name: "Service name",
+ service_url: "#"
+%>
diff --git a/src/components/inset-text/default/index.erb b/src/components/inset-text/default/index.erb
new file mode 100644
index 0000000000..15cb8abe4a
--- /dev/null
+++ b/src/components/inset-text/default/index.erb
@@ -0,0 +1,3 @@
+<%= govuk_inset_text
+ text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application."
+%>
diff --git a/src/components/inset-text/index.md b/src/components/inset-text/index.md
index 8a2c30320d..1872d18eae 100644
--- a/src/components/inset-text/index.md
+++ b/src/components/inset-text/index.md
@@ -9,7 +9,7 @@ layout: layout-pane.njk
{% from "_example.njk" import example %}
-{{ example({ group: "components", item: "inset-text", example: "default", html: true, nunjucks: true, size: "s", loading: "eager" }) }}
+{{ example({ group: "components", item: "inset-text", example: "default", html: true, nunjucks: true, rails: true, size: "s", loading: "eager" }) }}
## When to use this component
@@ -31,4 +31,4 @@ Use inset text very sparingly - it’s less effective if it’s overused.
There are 2 ways to use the inset text component. You can use HTML or, if you’re using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.
-{{ example({ group: "components", item: "inset-text", example: "default", html: true, nunjucks: true, open: false, size: "s", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "inset-text", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", titleSuffix: "second" }) }}
diff --git a/src/components/notification-banner/default/index.erb b/src/components/notification-banner/default/index.erb
new file mode 100644
index 0000000000..834968ca6c
--- /dev/null
+++ b/src/components/notification-banner/default/index.erb
@@ -0,0 +1,8 @@
+<%= govuk_notification_banner title_text: "Important" do |nb| %>
+
+ <%= nb.with_heading(
+ text: 'You have 7 days left to send your application.',
+ link_text: 'View application',
+ link_href: '#'
+ )
+<% end %>
diff --git a/src/components/notification-banner/index.md b/src/components/notification-banner/index.md
index dfec71403e..ace6efb980 100644
--- a/src/components/notification-banner/index.md
+++ b/src/components/notification-banner/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.
-{{ example({ group: "components", item: "notification-banner", example: "default", html: true, nunjucks: true, open: false, size: "s", loading: "eager" }) }}
+{{ example({ group: "components", item: "notification-banner", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", loading: "eager" }) }}
## When to use this component
@@ -55,7 +55,7 @@ For example:
- in a service that lets the user register or apply for something, they might need to know that it’s taking longer than usual to process applications because of an emergency
- in an account-type service, the user might need to know that the service will be down for scheduled maintenance
-{{ example({ group: "components", item: "notification-banner", example: "whole-service", html: true, nunjucks: true, open: false, size: "s" }) }}
+{{ example({ group: "components", item: "notification-banner", example: "whole-service", html: true, nunjucks: true, rails: true, open: false, size: "s" }) }}
If your service is on GOV.UK and it’s affected by an emergency, ask your department’s content team to [request a change to the service start page](https://www.gov.uk/guidance/contact-the-government-digital-service/request-a-thing#change-govuk-content).
If your service is getting more demand than usual, check that you’ve set up [There is a problem with the service pages](/patterns/problem-with-the-service-pages/) and [Service unavailable pages](/patterns/service-unavailable-pages/), and the wording is up to date.
@@ -67,7 +67,7 @@ Use a ‘neutral’ notification banner if the user needs to know about somethin
- in a case working system, the user might need to know that there are new cases waiting for their attention
- in an account-type service, you might need to tell the user that there’s a deadline approaching or that a payment is overdue
-{{ example({ group: "components", item: "notification-banner", example: "default", html: true, nunjucks: true, open: false, size: "s", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "notification-banner", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", titleSuffix: "second" }) }}
## Reacting to something the user has done
@@ -79,7 +79,7 @@ Use a [Confirmation page in a linear service](/patterns/confirmation-pages/) to
Use the green version of the notification banner to confirm that something they’re expecting to happen has happened.
-{{ example({ group: "components", item: "notification-banner", example: "success", html: true, nunjucks: true, open: false, size: "s" }) }}
+{{ example({ group: "components", item: "notification-banner", example: "success", html: true, nunjucks: true, rails: true, open: false, size: "s" }) }}
Since you’re using the notification banner to tell the user about the outcome of something they’ve just done, add `role="alert"` so focus shifts to the notification banner on page load.
diff --git a/src/components/notification-banner/success/index.erb b/src/components/notification-banner/success/index.erb
new file mode 100644
index 0000000000..f025fa3df6
--- /dev/null
+++ b/src/components/notification-banner/success/index.erb
@@ -0,0 +1,8 @@
+<%= govuk_notification_banner
+ title_text: "Success", success: true
+ do |nb| %>
+
+ <%= nb.with_heading(text: "Training outcome recorded and trainee withdrawn") %>
+
+ Contact example@department.gov.uk if you think there’s a problem.
+<% end %>
diff --git a/src/components/notification-banner/whole-service/index.erb b/src/components/notification-banner/whole-service/index.erb
new file mode 100644
index 0000000000..270fd75221
--- /dev/null
+++ b/src/components/notification-banner/whole-service/index.erb
@@ -0,0 +1,6 @@
+<%= govuk_notification_banner
+ title_text: "Important"
+do |nb| %>
+
+ <%= nb.with_heading(text: "There may be a delay in processing your application because of the coronavirus outbreak.") %>
+<% end %>
diff --git a/src/components/pagination/default/index.erb b/src/components/pagination/default/index.erb
new file mode 100644
index 0000000000..bfba000740
--- /dev/null
+++ b/src/components/pagination/default/index.erb
@@ -0,0 +1,2 @@
+<% # This helper relies on the pagy gem %>
+<%= govuk_pagination(pagy: pagy) %>
diff --git a/src/components/pagination/index.md b/src/components/pagination/index.md
index 017fcf5b7f..56f70c0b54 100644
--- a/src/components/pagination/index.md
+++ b/src/components/pagination/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
Help users navigate forwards and backwards through a series of pages. For example, search results or guidance that's divided into multiple website pages – like [the GOV.UK mainstream guide format](https://prototype-kit.service.gov.uk/docs/templates/mainstream-guide).
-{{ example({ group: "components", item: "pagination", example: "default", html: true, nunjucks: true, loading: "eager" }) }}
+{{ example({ group: "components", item: "pagination", example: "default", html: true, nunjucks: true, rails: true, loading: "eager" }) }}
## When to use this component
diff --git a/src/components/panel/default/index.erb b/src/components/panel/default/index.erb
new file mode 100644
index 0000000000..572bc5b80b
--- /dev/null
+++ b/src/components/panel/default/index.erb
@@ -0,0 +1,3 @@
+<%= govuk_panel(title_text: "Application complete") do %>
+ Your reference numberHDJ2123F
+<% end %>
diff --git a/src/components/panel/index.md b/src/components/panel/index.md
index a38e369e5c..7d22a24526 100644
--- a/src/components/panel/index.md
+++ b/src/components/panel/index.md
@@ -10,7 +10,7 @@ layout: layout-pane.njk
{% from "_example.njk" import example %}
The panel component is a visible container used on confirmation or results pages to highlight important content.
-{{ example({ group: "components", item: "panel", example: "default", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
+{{ example({ group: "components", item: "panel", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", loading: "eager" }) }}
## When to use this component
@@ -26,7 +26,7 @@ Never use the panel component to highlight important information within body con
There are 2 ways to use the panel component. You can use HTML or, if you are using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "panel", example: "default", html: true, nunjucks: true, open: false, size: "m", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "panel", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", titleSuffix: "second" }) }}
### How to write panel text
diff --git a/src/components/phase-banner/beta/index.erb b/src/components/phase-banner/beta/index.erb
new file mode 100644
index 0000000000..e44fa2187f
--- /dev/null
+++ b/src/components/phase-banner/beta/index.erb
@@ -0,0 +1,2 @@
+<%= govuk_phase_banner(tag: { text: "Beta" } do %>This is a new service – your <%= govuk_link_to("feedback", "#") %> will help us to improve it.
+<% end %>
diff --git a/src/components/phase-banner/default/index.erb b/src/components/phase-banner/default/index.erb
new file mode 100644
index 0000000000..8bf47b1fa8
--- /dev/null
+++ b/src/components/phase-banner/default/index.erb
@@ -0,0 +1,2 @@
+<%= govuk_phase_banner(tag: { text: "Alpha" } do %>This is a new service – your <%= govuk_link_to("feedback", "#") %> will help us to improve it.
+<% end %>
diff --git a/src/components/phase-banner/index.md b/src/components/phase-banner/index.md
index 940808ea87..d8397cba05 100644
--- a/src/components/phase-banner/index.md
+++ b/src/components/phase-banner/index.md
@@ -25,7 +25,7 @@ Use the phase banner component to show users your service is still being worked
]
}) }}
-{{ example({ group: "components", item: "phase-banner", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "phase-banner", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -55,9 +55,9 @@ You can choose to place the Phase banner in a more appropriate place for your se
Use a ‘feedback’ link to collect on-page feedback about your service. This can open an email or take the user to a dedicated page or form.
-{{ example({ group: "components", item: "phase-banner", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "phase-banner", example: "default", html: true, nunjucks: true, railse: true, open: false, titleSuffix: "second" }) }}
-{{ example({ group: "components", item: "phase-banner", example: "beta", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "phase-banner", example: "beta", html: true, nunjucks: true, rails: true, open: false }) }}
Whatever option you use, make sure that users do not lose their place in the service and can return to the page they were on.
diff --git a/src/components/radios/default/index.erb b/src/components/radios/default/index.erb
new file mode 100644
index 0000000000..192070f2ad
--- /dev/null
+++ b/src/components/radios/default/index.erb
@@ -0,0 +1,22 @@
+<%
+ # areas would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+areas = [
+ OpenStruct.new(id: 'england', name: 'England'),
+ OpenStruct.new(id: 'scotland', name: 'Scotland'),
+ OpenStruct.new(id: 'wales', name: 'Wales'),
+ OpenStruct.new(id: 'northern-ireland', name: 'Northern Ireland')
+]
+%>
+
+<%= f.govuk_collection_radio_buttons :area_id,
+ areas,
+ :id,
+ :name,
+ legend: {
+ text: 'Where do you live?',
+ tag: 'h1',
+ size: 'l'
+ }
+%>
diff --git a/src/components/radios/index.md b/src/components/radios/index.md
index 51a874116a..65236ae2d7 100644
--- a/src/components/radios/index.md
+++ b/src/components/radios/index.md
@@ -9,7 +9,7 @@ layout: layout-pane.njk
{% from "_example.njk" import example %}
-{{ example({ group: "components", item: "radios", example: "default", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
+{{ example({ group: "components", item: "radios", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", loading: "eager" }) }}
## When to use this component
diff --git a/src/components/select/default/index.erb b/src/components/select/default/index.erb
new file mode 100644
index 0000000000..ddee68ceac
--- /dev/null
+++ b/src/components/select/default/index.erb
@@ -0,0 +1,20 @@
+<%
+ # sort_orders would normally be defined in code elsewhere,
+ # as either an activerecord collection or an array of structs:
+
+sort_orders = [
+ OpenStruct.new(id: 'published', name: 'Recently published'),
+ OpenStruct.new(id: 'updated', name: 'Recently updated'),
+ OpenStruct.new(id: 'views', name: 'Most views'),
+ OpenStruct.new(id: 'comments', name: 'Most comments')
+]
+%>
+
+<%= f.govuk_collection_select :sort,
+ sort_orders,
+ :id,
+ :name,
+ label: {
+ text: "Sort by"
+ }
+%>
diff --git a/src/components/select/index.md b/src/components/select/index.md
index 0bcaf03972..2d5f51cc41 100644
--- a/src/components/select/index.md
+++ b/src/components/select/index.md
@@ -23,7 +23,7 @@ layout: layout-pane.njk
]
}) }}
-{{ example({ group: "components", item: "select", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "select", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
diff --git a/src/components/service-navigation/default/index.erb b/src/components/service-navigation/default/index.erb
new file mode 100644
index 0000000000..3427696b78
--- /dev/null
+++ b/src/components/service-navigation/default/index.erb
@@ -0,0 +1,6 @@
+<%= govuk_service_navigation(
+ navigation_items: [
+ { text: "Navigation item 1", href: "#" },
+ { text: "Navigation item 3", href: "#", active: true },
+ { text: "Navigation item 3", href: "#" }
+]) %>
diff --git a/src/components/service-navigation/index.md b/src/components/service-navigation/index.md
index bcb0f6a0a4..25a67142d3 100644
--- a/src/components/service-navigation/index.md
+++ b/src/components/service-navigation/index.md
@@ -29,7 +29,7 @@ Service navigation helps users understand that they’re using your service and
]
}) }}
-{{ example({ group: "components", item: "service-navigation", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "service-navigation", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -51,7 +51,7 @@ To use the GOV.UK header and Service navigation and make them fit together visua
Apply a class `govuk-header--full-width-border` to the GOV.UK header.
-{{ example({ group: "components", item: "service-navigation", example: "with-govuk-header", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "service-navigation", example: "with-govuk-header", html: true, nunjucks: true, rails: true, open: false }) }}
### Showing your service name only
diff --git a/src/components/service-navigation/with-govuk-header/index.erb b/src/components/service-navigation/with-govuk-header/index.erb
new file mode 100644
index 0000000000..0eefc0eb00
--- /dev/null
+++ b/src/components/service-navigation/with-govuk-header/index.erb
@@ -0,0 +1,7 @@
+<%= govuk_header(classes: "govuk-header--full-width-border") %>
+<%= govuk_service_navigation(
+ navigation_items: [
+ { text: "Navigation item 1", href: "#" },
+ { text: "Navigation item 3", href: "#", active: true },
+ { text: "Navigation item 3", href: "#" }
+]) %>
diff --git a/src/components/skip-link/default/index.erb b/src/components/skip-link/default/index.erb
new file mode 100644
index 0000000000..b0a238134c
--- /dev/null
+++ b/src/components/skip-link/default/index.erb
@@ -0,0 +1 @@
+<%= govuk_skip_link(href: "#", text: "Skip to main content") %>
diff --git a/src/components/skip-link/index.md b/src/components/skip-link/index.md
index a43cf07b30..35f4c7e4c0 100644
--- a/src/components/skip-link/index.md
+++ b/src/components/skip-link/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
Use the skip link component to help keyboard-only users skip to the main content on a page.
-{{ example({ group: "components", item: "skip-link", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "skip-link", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
If you use the page template, you'll also get the skip link without having to add it, as it's included by default. However, if you want to customise the default skip link, read the [page template guidance about customising components](/styles/page-template/#changing-template-content).
@@ -31,4 +31,4 @@ The skip link component is visually hidden until a keyboard press activates it.
There are 2 ways to use the skip link component. You can use HTML or, if you are using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "skip-link", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "skip-link", example: "default", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second" }) }}
diff --git a/src/components/summary-list/default/index.erb b/src/components/summary-list/default/index.erb
new file mode 100644
index 0000000000..03ee92a49b
--- /dev/null
+++ b/src/components/summary-list/default/index.erb
@@ -0,0 +1,27 @@
+<%= govuk_summary_list do |summary_list| %>
+ <%= summary_list.with_row do |row| %>
+ <%= row.with_key { 'Name' } %>
+ <%= row.with_value { 'Sarah Philips' } %>
+ <%= row.with_action(text: "Change", href: '#', visually_hidden_text: 'name')
+ <% end %>
+
+ <%= summary_list.with_row do |row| %>
+ <%= row.with_key { 'Date of birth' } %>
+ <%= row.with_value { '5 January 1978' } %>
+ <%= row.with_action(text: "Change", href: '#', visually_hidden_text: 'date of birth')
+ <% end %>
+
+ <%= summary_list.with_row do |row| %>
+ <%= row.with_key { 'Address' } %>
+ <%= row.with_value { '72 Guild Street London SE23 6FH' } %>
+ <%= row.with_action(text: "Change", href: '#', visually_hidden_text: 'address')
+ <% end %>
+
+ <%= summary_list.with_row do |row| %>
+ <%= row.with_key { 'Contact details' } %>
+ <%= row.with_value { '07700 900457
sarah.phillips@example.com
' } %>
+ <%= row.with_action(text: "Add", href: '#', visually_hidden_text: 'contact details')
+ <%= row.with_action(text: "Change", href: '#', visually_hidden_text: 'contact details')
+ <% end %>
+
+<% end %>
diff --git a/src/components/summary-list/index.md b/src/components/summary-list/index.md
index e68293373c..8a82666f8b 100644
--- a/src/components/summary-list/index.md
+++ b/src/components/summary-list/index.md
@@ -29,7 +29,7 @@ Use a summary list to summarise information, for example, a user’s responses a
]
}) }}
-{{ example({ group: "components", item: "summary-list", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "summary-list", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
diff --git a/src/components/table/default/index.erb b/src/components/table/default/index.erb
new file mode 100644
index 0000000000..d141028c90
--- /dev/null
+++ b/src/components/table/default/index.erb
@@ -0,0 +1,29 @@
+<%= govuk_table do |table| %>
+ <%= table.with_caption(size: 'm', text: 'List of Pokémon') %>
+
+ <%= table.with_head do |head| %>
+ <%= head.with_row do |row| %>
+ <%= row.with_cell(text: 'Date') %>
+ <%= row.with_cell(text: 'Amount') %>
+ <% end %>
+ <% end %>
+
+ <%= table.with_body do |body| %>
+
+ <%= body.with_row do |row| %>
+ <%= row.with_cell(text: 'First 6 weeks') %>
+ <%= row.with_cell(text: '£109.80 per week') %>
+ <% end %>
+
+ <%= body.with_row do |row| %>
+ <%= row.with_cell(text: 'Next 33 weeks') %>
+ <%= row.with_cell(text: '£109.80 per week') %>
+ <% end %>
+
+ <%= body.with_row do |row| %>
+ <%= row.with_cell(text: 'Total estimated pay') %>
+ <%= row.with_cell(text: '£4,282.20') %>
+ <% end %>
+
+ <% end %>
+<% end %>
diff --git a/src/components/table/index.md b/src/components/table/index.md
index c4bbfd0385..96653ada7a 100644
--- a/src/components/table/index.md
+++ b/src/components/table/index.md
@@ -13,7 +13,7 @@ layout: layout-pane.njk
Use the table component to make information easier to compare and scan for users.
-{{ example({ group: "components", item: "table", example: "default", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
+{{ example({ group: "components", item: "table", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", loading: "eager" }) }}
## When to use this component
diff --git a/src/components/tabs/default/index.erb b/src/components/tabs/default/index.erb
new file mode 100644
index 0000000000..5d07699f4d
--- /dev/null
+++ b/src/components/tabs/default/index.erb
@@ -0,0 +1,8 @@
+<%= govuk_tabs(title: "Contents") do |tabs| %>
+
+ <%= tabs.with_tab(label: "Past day", text: "TODO" %>
+ <%= tabs.with_tab(label: "Past week", text: "TODO" %>
+ <%= tabs.with_tab(label: "Past month", text: "TODO" %>
+ <%= tabs.with_tab(label: "Past year", text: "TODO" %>
+
+<% end %>
diff --git a/src/components/tabs/index.md b/src/components/tabs/index.md
index 6686123b33..051db05864 100644
--- a/src/components/tabs/index.md
+++ b/src/components/tabs/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
The tabs component lets users navigate between related sections of content, displaying one section at a time.
-{{ example({ group: "components", item: "tabs", example: "default", html: true, nunjucks: true, open: false, size: "xl", loading: "eager" }) }}
+{{ example({ group: "components", item: "tabs", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "xl", loading: "eager" }) }}
## When to use this component
@@ -56,7 +56,7 @@ If you decide to use one of these components, consider if:
There are 2 ways to use the tabs component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "tabs", example: "default", html: true, nunjucks: true, open: false, size: "xl", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "tabs", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "xl", titleSuffix: "second" }) }}
The tabs component uses JavaScript. When JavaScript is not available, users will see the tabbed content on a single page, in order from first to last, with a table of contents that links to each of the sections.
diff --git a/src/components/tag/all-colours/index.erb b/src/components/tag/all-colours/index.erb
new file mode 100644
index 0000000000..ca48d3d267
--- /dev/null
+++ b/src/components/tag/all-colours/index.erb
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+ govuk-tag--grey
+
+
+ <%= govuk_tag(text: "Inactive", colour: "grey") %>
+
+
+
+
+ govuk-tag--green
+
+
+ <%= govuk_tag(text: "New", colour: "green") %>
+
+
+
+
+ govuk-tag--turquoise
+
+
+ <%= govuk_tag(text: "Active", colour: "turquoise") %>
+
+
+
+
+ govuk-tag--blue
+
+
+ <%= govuk_tag(text: "Pending", colour: "blue") %>
+
+
+
+
+ govuk-tag--light-blue
+
+
+ <%= govuk_tag(text: "In progress", colour: "light-blue") %>
+
+
+
+
+ govuk-tag--purple
+
+
+ <%= govuk_tag(text: "Received", colour: "purple") %>
+
+
+
+
+ govuk-tag--pink
+
+
+ <%= govuk_tag(text: "Sent", colour: "pink") %>
+
+
+
+
+ govuk-tag--red
+
+
+ <%= govuk_tag(text: "Rejected", colour: "red") %>
+
+
+
+
+ govuk-tag--orange
+
+
+ <%= govuk_tag(text: "Declined", colour: "orange") %>
+
+
+
+
+ govuk-tag--yellow
+
+
+ <%= govuk_tag(text: "Delayed", colour: "yellow") %>
+
+
+
+
diff --git a/src/components/tag/coloured-tags/index.erb b/src/components/tag/coloured-tags/index.erb
new file mode 100644
index 0000000000..74d6ec1191
--- /dev/null
+++ b/src/components/tag/coloured-tags/index.erb
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+ Joshua Wessel
+
+
+ <%= govuk_tag(text: "Urgent", colour: "red") %>
+
+
+
+
+ Rachel Silver
+
+
+ <%= govuk_tag(text: "New", colour: "blue") %>
+
+
+
+
+ Laura Frith
+
+
+ <%= govuk_tag(text: "New", colour: "blue") %>
+
+
+
+
+ Paul French
+
+
+ <%= govuk_tag(text: "New", colour: "blue") %>
+
+
+
+
+ Jesse Smith
+
+
+ <%= govuk_tag(text: "New", colour: "blue") %>
+
+
+
+
+ Rachael Pepper
+
+
+ <%= govuk_tag(text: "Finished", colour: "green") %>
+
+
+
+
+
+ Emma Tennant
+
+
+ <%= govuk_tag(text: "Waiting on", colour: "yellow") %>
+
+
+
+
diff --git a/src/components/tag/default/index.erb b/src/components/tag/default/index.erb
new file mode 100644
index 0000000000..e141c56f63
--- /dev/null
+++ b/src/components/tag/default/index.erb
@@ -0,0 +1 @@
+<%= govuk_tag(text: "Completed") %>
diff --git a/src/components/tag/index.md b/src/components/tag/index.md
index 40b9040247..c0e42d59de 100644
--- a/src/components/tag/index.md
+++ b/src/components/tag/index.md
@@ -25,7 +25,7 @@ Use the tag component to show users the status of something.
]
}) }}
-{{ example({ group: "components", item: "tag", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "tag", example: "default", html: true, nunjucks: true,rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -50,13 +50,13 @@ The [Complete multiple tasks pattern](/patterns/complete-multiple-tasks/) has an
Or it can make sense to have two statuses. For example you may find that there’s a need to have one tag for ‘Active’ users and one for ‘Inactive’ users.
-{{ example({ group: "components", item: "tag", example: "multiple-tags", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "tag", example: "multiple-tags", html: true, nunjucks: true, rails: true, open: false }) }}
## Showing multiple statuses
Tags should be helpful to users. The more you add, the harder it is for users to remember them. So start with the smallest number of statuses you think might work, then add more if your user research shows there’s a need for them.
-{{ example({ group: "components", item: "tag", example: "coloured-tags", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "tag", example: "coloured-tags", html: true, nunjucks: true, rails: true, open: false }) }}
{% call wcagNote({id: "wcag-tag-no-dragging-reorder"}) %}
@@ -73,7 +73,7 @@ Do not use colour alone to convey information, because it’s not accessible. If
If you need more tag colours, you can use the following colours.
-{{ example({ group: "components", item: "tag", example: "all-colours", html: true, nunjucks: true, open: false }) }}
+{{ example({ group: "components", item: "tag", example: "all-colours", html: true, nunjucks: true, rails: true, open: false }) }}
## Research on this component
diff --git a/src/components/tag/multiple-tags/index.erb b/src/components/tag/multiple-tags/index.erb
new file mode 100644
index 0000000000..74200cd30a
--- /dev/null
+++ b/src/components/tag/multiple-tags/index.erb
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+ Rachel Silver
+
+
+ <%= govuk_tag(text: "Inactive", colour: "grey") %>
+
+
+
+
+ Jesse Smith
+
+
+ <%= govuk_tag(text: "Inactive", colour: "grey") %>
+
+
+
+
+ Joshua Wessel
+
+
+ <%= govuk_tag(text: "Active") %>
+
+
+
+
+ Rachael Pepper
+
+
+ <%= govuk_tag(text: "Active") %>
+
+
+
+
+ Stuart Say
+
+
+ <%= govuk_tag(text: "Inactive", colour: "grey") %>
+
+
+
+
+ Laura Frith
+
+
+ <%= govuk_tag(text: "Active") %>
+
+
+
+
+ Tim Harvey
+
+
+ <%= govuk_tag(text: "Inactive", colour: "grey") %>
+
+
+
+
diff --git a/src/components/task-list/default/index.erb b/src/components/task-list/default/index.erb
new file mode 100644
index 0000000000..3f0a3e67e3
--- /dev/null
+++ b/src/components/task-list/default/index.erb
@@ -0,0 +1,34 @@
+<%= govuk_task_list(id_prefix: "company-details") do |task_list| %>
+
+ <%= task_list.with_item(
+ title: "Company Directors",
+ href: '#',
+ status: "Completed"
+ ) %>
+
+ <%= task_list.with_item(
+ title: "Registered company details",
+ href: '#',
+ status: govuk_tag(text: "Incomplete", colour: "blue")
+ ) %>
+
+ <%= task_list.with_item(
+ title: "Financial history",
+ hint: "Include 5 years of the company’s relevant financial information."
+ href: '#',
+ status: govuk_tag(text: "Incomplete", colour: "blue")
+ ) %>
+
+ <%= task_list.with_item(
+ title: "Business plan",
+ href: '#',
+ status: govuk_tag(text: "Incomplete", colour: "blue")
+ ) %>
+
+ <%= task_list.with_item(
+ title: "References",
+ href: '#',
+ status: govuk_tag(text: "Incomplete", colour: "blue")
+ ) %>
+
+end %>
diff --git a/src/components/task-list/index.md b/src/components/task-list/index.md
index aaf569ad3c..2d919ec8c2 100644
--- a/src/components/task-list/index.md
+++ b/src/components/task-list/index.md
@@ -11,7 +11,7 @@ layout: layout-pane.njk
The task list component displays all the tasks a user needs to do, and allows users to easily identify which ones are done and which they still need to do.
-{{ example({ group: "components", item: "task-list", example: "default", id: "default-1", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({ group: "components", item: "task-list", example: "default", id: "default-1", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -34,7 +34,7 @@ The task list should not be used as a way of showing users their answers. For th
There are 2 ways to use the task list component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://govuk-prototype-kit.herokuapp.com), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "task-list", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "task-list", example: "default", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second" }) }}
Users should be able to complete tasks in whatever order they like.
diff --git a/src/components/text-input/default/index.erb b/src/components/text-input/default/index.erb
new file mode 100644
index 0000000000..4ab349dcb1
--- /dev/null
+++ b/src/components/text-input/default/index.erb
@@ -0,0 +1,7 @@
+<%= f.govuk_text_field :event_name,
+ label: {
+ text: 'What is the name of the event?',
+ tag: 'h1',
+ size: 'l'
+ }
+%>
diff --git a/src/components/text-input/index.md b/src/components/text-input/index.md
index cc0032008a..4450940e66 100644
--- a/src/components/text-input/index.md
+++ b/src/components/text-input/index.md
@@ -9,7 +9,7 @@ layout: layout-pane.njk
{% from "_example.njk" import example %}
-{{ example({ group: "components", item: "text-input", example: "default", html: true, nunjucks: true, open: false, size: "s", loading: "eager" }) }}
+{{ example({ group: "components", item: "text-input", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", loading: "eager" }) }}
## When to use this component
@@ -41,13 +41,13 @@ Read more about [why and how to set legends as headings](/get-started/labels-leg
There are 2 ways to use the text input component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "text-input", example: "default", html: true, nunjucks: true, open: false, size: "s", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "text-input", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "s", titleSuffix: "second" }) }}
### If you’re asking more than one question on the page
If you're asking more than one question on the page, do not set the contents of the `` as the page heading. Read more about [asking multiple questions on Question pages](/patterns/question-pages/#asking-multiple-questions-on-a-page).
-{{ example({ group: "components", item: "text-input", example: "without-heading", html: true, nunjucks: true, open: false, size: "s" }) }}
+{{ example({ group: "components", item: "text-input", example: "without-heading", html: true, nunjucks: true, rails: true, open: false, size: "s" }) }}
### Use appropriately-sized text inputs
diff --git a/src/components/text-input/without-heading/index.erb b/src/components/text-input/without-heading/index.erb
new file mode 100644
index 0000000000..c55321fb91
--- /dev/null
+++ b/src/components/text-input/without-heading/index.erb
@@ -0,0 +1,5 @@
+<%= f.govuk_text_field :event_name,
+ label: {
+ text: 'What is the name of the event?'
+ }
+%>
diff --git a/src/components/textarea/default/index.erb b/src/components/textarea/default/index.erb
new file mode 100644
index 0000000000..e5bce73a1f
--- /dev/null
+++ b/src/components/textarea/default/index.erb
@@ -0,0 +1,9 @@
+<%= f.govuk_text_area :more_detail,
+ label: {
+ text: 'Can you provide more detail?',
+ tag: 'h1',
+ size: 'l'
+ },
+ hint: {
+ text: 'Do not include personal or financial information, like your National Insurance number or credit card details.'
+ } %>
diff --git a/src/components/textarea/error/index.erb b/src/components/textarea/error/index.erb
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/components/textarea/index.md b/src/components/textarea/index.md
index fda9e0e4dc..7c0aaa9c58 100644
--- a/src/components/textarea/index.md
+++ b/src/components/textarea/index.md
@@ -9,7 +9,7 @@ layout: layout-pane.njk
{% from "_example.njk" import example %}
-{{ example({ group: "components", item: "textarea", example: "default", html: true, nunjucks: true, open: false, size: "m", loading: "eager" }) }}
+{{ example({ group: "components", item: "textarea", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", loading: "eager" }) }}
## When to use this component
@@ -31,13 +31,13 @@ Labels must be aligned above the textarea they refer to. They should be short, d
There are 2 ways to use the textarea component. You can use HTML or, if you’re using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
-{{ example({ group: "components", item: "textarea", example: "default", html: true, nunjucks: true, open: false, size: "m", titleSuffix: "second" }) }}
+{{ example({ group: "components", item: "textarea", example: "default", html: true, nunjucks: true, rails: true, open: false, size: "m", titleSuffix: "second" }) }}
### Use appropriately-sized textareas
Make the height of a textarea proportional to the amount of text you expect users to enter. You can set the height of a textarea by specifying the `rows` attribute.
-{{ example({ group: "components", item: "textarea", example: "specifying-rows", html: true, nunjucks: true, open: false, size: "l" }) }}
+{{ example({ group: "components", item: "textarea", example: "specifying-rows", html: true, nunjucks: true, rails: true, open: false, size: "l" }) }}
### Do not disable copy and paste
@@ -47,7 +47,7 @@ Users will often need to copy and paste information into a textarea, so do not s
If you're asking more than one question on the page, do not set the contents of the `` as the page heading. Read more about [asking multiple questions on Question pages](/patterns/question-pages/#asking-multiple-questions-on-a-page).
-{{ example({ group: "components", item: "textarea", example: "without-heading", html: true, nunjucks: true, open: false, size: "l" }) }}
+{{ example({ group: "components", item: "textarea", example: "without-heading", html: true, nunjucks: true, rails: true, open: false, size: "l" }) }}
### Limiting the number of characters
diff --git a/src/components/textarea/specifying-rows/index.erb b/src/components/textarea/specifying-rows/index.erb
new file mode 100644
index 0000000000..c6b279ab54
--- /dev/null
+++ b/src/components/textarea/specifying-rows/index.erb
@@ -0,0 +1,10 @@
+<%= f.govuk_text_area :more_detail,
+ label: {
+ text: 'Can you provide more detail?',
+ tag: 'h1',
+ size: 'l'
+ },
+ hint: {
+ text: 'Do not include personal or financial information, like your National Insurance number or credit card details.'
+ },
+ rows: 8 %>
diff --git a/src/components/textarea/without-heading/index.erb b/src/components/textarea/without-heading/index.erb
new file mode 100644
index 0000000000..a9a78c98c8
--- /dev/null
+++ b/src/components/textarea/without-heading/index.erb
@@ -0,0 +1 @@
+<%= f.govuk_text_area :more_detail, label: { text: 'Can you provide more detail?' } %>
diff --git a/src/components/warning-text/default/index.erb b/src/components/warning-text/default/index.erb
new file mode 100644
index 0000000000..79c4736c27
--- /dev/null
+++ b/src/components/warning-text/default/index.erb
@@ -0,0 +1,4 @@
+<%= govuk_warning_text(
+ text: "You can be fined up to £5,000 if you do not register.",
+ icon_fallback_text: "Warning"
+) %>
diff --git a/src/components/warning-text/index.md b/src/components/warning-text/index.md
index aca752b186..d1475470ac 100644
--- a/src/components/warning-text/index.md
+++ b/src/components/warning-text/index.md
@@ -9,7 +9,7 @@ layout: layout-pane.njk
{% from "_example.njk" import example %}
-{{ example({ group: "components", item: "warning-text", example: "default", html: true, nunjucks: true, open: false, loading: "eager" }) }}
+{{ example({group: "components", item: "warning-text", example: "default", html: true, nunjucks: true, rails: true, open: false, loading: "eager" }) }}
## When to use this component
@@ -17,8 +17,12 @@ Use the warning text component when you need to warn users about something impor
## How it works
-There are 2 ways to use the warning text component. You can use HTML or, if you are using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
+There are 3 ways to use the warning text component:
-{{ example({ group: "components", item: "warning-text", example: "default", html: true, nunjucks: true, open: false, titleSuffix: "second" }) }}
+- HTML
+- Nunjucks – use this if you are using the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk)
+- Ruby on Rails
+
+{{ example({group: "components", item: "warning-text", example: "default", html: true, nunjucks: true, rails: true, open: false, titleSuffix: "second"}) }}
You might need to rewrite the hidden text (‘Warning’ in the example) to make it appropriate for your context.
diff --git a/views/partials/_example.njk b/views/partials/_example.njk
index b529b13e9a..bb7689f434 100644
--- a/views/partials/_example.njk
+++ b/views/partials/_example.njk
@@ -1,10 +1,14 @@
{% macro example(params) %}
+
{% set exampleRoot = "src/" + params.group + "/" + params.item + "/" + params.example + "/" %}
{% if params.customCode %}
{% set examplePath = exampleRoot + "code.njk" %}
{% else %}
{% set examplePath = exampleRoot + "index.njk" %}
{% endif %}
+
+{% set railsPath = exampleRoot + "index.erb" %}
+
{% set exampleURL = "/" + params.group + "/" + params.item + "/" + params.example + "/index.html" %}
{% set exampleTitle = getFrontmatter(examplePath).title %}
@@ -44,6 +48,10 @@
{% elif not (params.hideTab) %}
{% set tabType = "html" if params.html else ("nunjucks" if params.nunjucks ) %}
@@ -72,6 +80,22 @@
{% endif %}
+ {%- if (params.rails) %}
+