Skip to content

Commit 7705820

Browse files
authored
Apply minor UI fixes and improvements (#31)
* Fix adding error messages to checkbox and radio questions * Demote user guide headings, but start help file markdown headings at h1 Demoting the headings in the UI ensures the user guide aligns to the rest of the site. Promoting the help file markdown headings to h1 ensures that we don't need to ignore the linting error. * Move the 'before you start' text above the start now button on generated prototypes * Allow the user to jump to a specific live preview page from the structure tab * Replace javascript: href with onclick function * Reorder client-side JavaScript * Update comments and variable names in form.js
1 parent 9f3f89d commit 7705820

12 files changed

+46
-35
lines changed

docs/help/create-a-new-prototype.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Create a new prototype <!-- markdownlint-disable-line first-line-h1 -->
1+
# Create a new prototype
22

33
Visit the [create a prototype page](/create) to create a new prototype.
44

@@ -9,7 +9,7 @@ For example:
99
1010
Once created, the high-level structure of the prototype can be previewed in the "Structure" tab.
1111

12-
### Supported form and question fields
12+
## Supported form and question fields
1313

1414
Each form contains the following data:
1515

docs/help/introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Introduction <!-- markdownlint-disable-line first-line-h1 -->
1+
# Introduction
22

33
This tool lets you rapidly create prototype forms from a simple description using Generative AI.
44

@@ -8,12 +8,12 @@ You can test prototypes live, share them with others, and download them to run t
88

99
**Warning: Always check the prototypes generated by this tool, as they may contain inaccurate information.**
1010

11-
### How does it work?
11+
## How does it work?
1212

1313
1. The user describes the form they want using the free text input in the interface.
1414
2. The LLM takes this and a JSON schema, and uses this to generate a JSON representation of the form that follows the schema.
1515
3. The tool uses the schema to build the prototype using Nunjucks components. This prototype is then shown live for the user, or zipped up for the user to download.
1616

17-
### Known limitations
17+
## Known limitations
1818

1919
- The JSON fields cannot contain double quotes `"`; these are replaced with ``.

docs/help/manage-your-prototypes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Manage your prototypes <!-- markdownlint-disable-line first-line-h1 -->
1+
# Manage your prototypes
22

33
On the ["Your prototypes" page](/history), you can view all the prototypes you can access.
44

docs/help/manage-your-workspaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Manage your workspaces <!-- markdownlint-disable-line first-line-h1 -->
1+
# Manage your workspaces
22

33
Workspaces are like folders. Every prototype belongs to a workspace, and every workspace has one or more users.
44

docs/help/share-a-prototype.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
## Share a prototype <!-- markdownlint-disable-line first-line-h1 -->
1+
# Share a prototype
22

33
A prototype can be shared with users in a workspace or with specific users. The live demo of a prototype can also be shared publicly. You can manage prototype sharing using the "Sharing" tab.
44

55
Note that the user who creates a prototype does not always keep access, for example, if it is moved to a workspace the creator cannot access.
66

7-
### Share a prototype in a workspace
7+
## Share a prototype in a workspace
88

99
All prototypes belong to a workspace. This can be your private workspace, or it can be a shared workspace that one or more users can access. Everyone in a workspace can access, update, and share the prototypes within that workspace. You can move prototypes between workspaces.
1010

1111
If a prototype is updated, the previous workspace is reused unless you choose a different one.
1212

1313
If you are removed from a workspace, you will lose access to all the prototypes in that workspace (except for any prototypes shared with you individually).
1414

15-
### Share a prototype with individual users
15+
## Share a prototype with individual users
1616

1717
Prototypes can also be shared with specific users. These users can access and update the prototype, but cannot share it (unless they are also a member of the workspace).
1818

1919
If a prototype is updated by a user who is not a member of the prototype's workspace, the new version will be added to their private workspace. It will still be shared with the users that the previous prototype was shared with.
2020

21-
### Share a live demo publicly
21+
## Share a live demo publicly
2222

2323
The live demo of prototypes can also be shared publicly, letting anyone try out the prototype. This does not let it be updated or for any other information about the prototype to be viewed.
2424

2525
You can set a password when sharing the live demo publicly. The chosen password is visible to all users who can access the prototype.
2626

2727
Data entered into the live demo is unique for each user.
2828

29-
### Prototype Permissions
29+
## Prototype Permissions
3030

3131
| **<center>User Type</center>** | <center>Change Sharing Settings</center> | <center>Update Prototype</center> | <center>View Prototype</center> | <center>View Live Prototype</center> |
3232
|--------------------------|:-----------------------:|:---------------:|:--------------:|:------------------:|

docs/help/test-a-prototype.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
## Test a prototype <!-- markdownlint-disable-line first-line-h1 -->
1+
# Test a prototype
22

33
You can interact with a live demo of the prototype produced using the viewer on the right hand side; you can also reset this view.
44

55
Data entered into the live demo is unique for each user. You can reset this for the current user using the "Reset demo" button.
66

7-
### Running the generated prototype locally
7+
## Running the generated prototype locally
88

99
The Nunjucks template files and associated files can also be downloaded in a ZIP file within an Express (Node.js TypeScript) project, which you can use to run the prototype locally.
1010

docs/help/update-a-prototype.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Update a prototype <!-- markdownlint-disable-line first-line-h1 -->
1+
# Update a prototype
22

33
You can update a prototype by:
44

@@ -7,7 +7,7 @@ You can update a prototype by:
77

88
Updating a prototype creates a new version with a new URL. Previous versions are stored in the "History" tab.
99

10-
### Sharing
10+
## Sharing
1111

1212
The previous workspace is reused unless you choose a different one. If you are not a member of the workspace, your personal workspace is used instead.
1313

public/form.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ document.addEventListener('DOMContentLoaded', function () {
515515
form.addEventListener('submit', validateForm);
516516
}
517517

518-
// Create the error message element for all non-date inputs
518+
// Create the error message element for all non-fieldset inputs
519519
let labelElements = document.querySelectorAll(
520-
'.govuk-label:not(.govuk-date-input__label)'
520+
'.govuk-label:not(.govuk-date-input__label, .govuk-checkboxes__label, .govuk-radios__label)'
521521
);
522522
labelElements.forEach((labelElement, index) => {
523523
const errorElement = document.createElement('p');
@@ -529,19 +529,21 @@ document.addEventListener('DOMContentLoaded', function () {
529529
);
530530
});
531531

532-
// Create the error message element for all date inputs
532+
// Create the error message element for all fieldset inputs (date, checkbox, radio)
533533
labelElements = document.querySelectorAll(
534-
'.govuk-label.govuk-date-input__label'
534+
'.govuk-label.govuk-date-input__label, .govuk-label.govuk-checkboxes__label, .govuk-label.govuk-radios__label'
535535
);
536536
labelElements.forEach((labelElement, index) => {
537-
const dateInputGroup = labelElement.closest('.govuk-date-input');
538-
if (!dateInputGroup.parentNode.querySelector('.govuk-error-message')) {
537+
const inputGroup = labelElement.closest(
538+
'.govuk-date-input, .govuk-checkboxes, .govuk-radios'
539+
);
540+
if (!inputGroup.parentNode.querySelector('.govuk-error-message')) {
539541
const errorElement = document.createElement('p');
540542
errorElement.className = 'govuk-error-message';
541543
errorElement.style.display = 'none';
542-
dateInputGroup.parentNode.insertBefore(
544+
inputGroup.parentNode.insertBefore(
543545
errorElement,
544-
dateInputGroup.previousSibling
546+
inputGroup.previousSibling
545547
);
546548
}
547549
});

src/filters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export function arrayOrStringIncludes(
2626
* Convert a Markdown string to GOV.UK HTML
2727
* @param {string} markdown the Markdown string to convert
2828
* @param {Partial<MarkedExtension>} options optional options for the conversion
29+
* @param {string} options.headingsStartWith optional heading level to start from, defaults to 'xl'
2930
* @returns {string} the converted HTML string
3031
*/
3132
export function convertToGovukMarkdown(

src/form-constants.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,18 @@ export function getStartPage(
341341
``,
342342
` <p class="govuk-body">Completing this form takes around ${String(data.duration)} minute${data.duration === 1 ? '' : 's'}.</p>`,
343343
``,
344-
` {{ govukButton({`,
345-
` text: "Start now",`,
346-
` href: "/${urlPrefix}/question-1",`,
347-
` isStartButton: true`,
348-
` }) }}`,
349-
``,
350344
` <h2 class="govuk-heading-m">`,
351345
` Before you start`,
352346
` </h2>`,
353347
``,
354348
` {{ "${data.before_you_start.replace(/\n/g, '\\n').replace(/"/g, '\\"')}" | govukMarkdown | safe }}`,
355349
``,
350+
` {{ govukButton({`,
351+
` text: "Start now",`,
352+
` href: "/${urlPrefix}/question-1",`,
353+
` isStartButton: true`,
354+
` }) }}`,
355+
``,
356356
` </div>`,
357357
``,
358358
` <div class="govuk-grid-column-one-third">`,

0 commit comments

Comments
 (0)