Skip to main content

This is an exploration of how to prototype the GOV.UK app, not something to build on yet.

Reference

Every part of the schema a prototype is written to, from the schema itself.

The schema is in schema/0/. What each component may have is generated from the component library’s own definitions: see components for how to write one, and the component library for what each takes.

Prototype

prototype.schema.json

A prototype of a journey through the GOV.UK app: the screens, what is on them, and how a person moves between them. A prototype carries no data of its own. It takes people and facts from the data bank, which it names in `uses`.

prototype

A prototype of a journey through the GOV.UK app: the screens, what is on them, and how a person moves between them. A prototype carries no data of its own. It takes people and facts from the data bank, which it names in `uses`.

Property Takes What it’s for
version (needed) "0" Which version of this schema the prototype is written in.
id (needed) identifier
title (needed) text What the journey is called, for the people choosing which prototype to open. Not shown inside the prototype.
start (needed) identifier The screen the journey begins on.
presentation an object with style, cancel How the journey appears. `modal` opens it over the app. With `cancel`, the top bar has a control that leaves the journey from any screen.
uses names, each to text The data bank datasets this prototype depends on, each with the version of its shape it was written against: `{ "personas": "0", "councils": "0" }`.
personas a list of identifier The personas this prototype was written to be tried with. Each should take a different path through it.
derived names, each to derivation Values worked out from other values rather than typed by the person. Each is recalculated whenever what it depends on changes, and can be referred to by name like any other value.
screens (needed) names, each to screen Every screen in the journey, by name.

derivation

How a derived value is worked out: by looking it up in the data bank, by picking an item of a list, by whether a condition holds, or by the items of a list a condition holds for. Each is worked out the same wherever it is used.

Takes an object with lookup, or an object with pick, or an object with condition, or an object with filter.

filter

The items of the list at `from` that `where` holds for, in order. Inside `where`, `item` is the item and `index` its position, from 0. An empty list if none, which a `missing` condition can test for.

Property Takes What it’s for
from (needed) path
where (needed) condition

pick

The item of the list at `from` whose position, from 0, is the value at `at`, such as the council at the position of the row chosen in a group with `each`. Missing if there is no such item.

Property Takes What it’s for
from (needed) path
at (needed) path

lookup

Finds the entry in a data bank dataset whose key is the value at `key`. Missing if there is no such entry, which a `missing` condition can test for.

Property Takes What it’s for
table (needed) identifier The dataset to look in. Must also be named in `uses`.
key (needed) path The path to the value to look up.
normalise a list of one of "uppercase", "remove-spaces" Changes made to the value before it is looked up, in order. The value itself is left as it was typed.

screen

One screen: what is on it, and where submitting it leads.

Property Takes What it’s for
attributes the screen's attributes The screen's own attributes, as the component library defines them for its screen, such as `background`.
scroll "end" `end` opens the screen scrolled to its end, as a Chat conversation opens at its newest message.
after an object with seconds, go, history Goes on by itself after a while, unless the person moves on first, as Chat's reply arrives after it has been generating: `{ "seconds": 2, "go": "answer", "history": "replace" }`.
status-bar "light" `light` for a white status bar, for a screen dark at its top, such as Home under its green header. Without it, the status bar is the system's, dark on a light screen and white in dark mode.
components (needed) a list of a component What is on the screen, top to bottom.
next a list of transition Where a `submit` button leads once the screen's inputs are valid. Tried in order; the first whose `when` holds — or that has no `when` — is followed.

transition

One possible outcome of submitting a screen: either `go` to another screen, or stay and show an `error`.

Property Takes What it’s for
when condition
set names, each to path Values to keep before going on, each copied from a path: `{ "council": "match.council" }`.
go identifier
history history
error an object with field, message Stay on this screen and show `message` against the input called `field`.

Components

components.schema.json

The building blocks a screen is made of: what every component may have, here, and each of the component library's elements, which tools/build.js adds from the library's own definitions. Every component has a `type`, which decides what else it may have, and may have a `when`, which decides whether it is shown.

when

Show this component only while the condition holds. Without it, the component is always shown.

Takes condition.

group

Holds other components so they can be shown or hidden together with one `when`, or shown once for each item of a list with `each`. Has no appearance of its own.

Property Takes What it’s for
type (needed) "group"
when when
each path A path to a list, such as `match.councils`. Its children are shown once for each item, and can refer to it as `item`, and to its position, from 0, as `index`.
children (needed) a list of a component

action

What pressing a button does. `submit` checks the screen's inputs and, if they are valid, follows the screen's `next`. `exit` leaves the prototype. `dismiss` closes the sheet the screen is in, however far into it, as Done at the end of a task does. `back` goes back a screen, as the navigation bar's back button does, and from a sheet's first screen closes the sheet, as its close button or Cancel does. An object with `go` goes straight to another screen without checking anything. An object with `set` keeps the values it gives, by name, and stays on the screen. An object with `tab` shows the tab that starts on that screen, where it was left, as the tab bar does; choosing the tab on show goes back to its first screen.

Takes "submit", or "exit", or "back", or "dismiss", or an object with go, history, or an object with set, or an object with tab.

history

How going to a screen affects the back button. `push` lets the person go back. `present` does too, and shows the screen in a sheet over the one it came from, as the app presents a task to finish or cancel, such as signing out; the screens it goes on to are in the sheet too, until going back from its first screen closes it. `replace` swaps the current screen out, so they cannot go back to it. `reset` leaves nothing to go back to, and closes any sheet, as signing out does.

Takes one of "push", "present", "replace", "reset".

validation

Checks made when the screen is submitted, in order. The first that fails shows its message and the person stays on the screen.

Takes a list of validation-rule.

validation-rule

One check. These match the checks the GOV.UK app makes on its own inputs.

Property Takes What it’s for
rule (needed) one of "required", "pattern", "min-length", "max-length"

Common definitions

common.schema.json

Small pieces shared by every other schema: how things are named, how one value points at another, and how text may include values.

identifier

A name for a screen, an input, a persona or a dataset. Lower case letters, digits and hyphens, starting with a letter: `choose-council`.

Takes text.

path

Points at a value by name, with a dot to step inside it: `council.parent.name`. A path names a value; it never computes one. There is no arithmetic, no function call and no default.

Takes text.

text

Words shown to the person using the prototype. May include a value by writing its path in double braces: `Your local council is {{ council.name }}`. Only a path may go inside the braces — never an expression — which is what keeps text from becoming code.

Takes text.

contains

Whether the text at `text` has any of `words` in it: `{ "text": "asked", "words": ["caring", "carer"] }`. A word is found at the start of a word in the text, whatever its case and the punctuation around it, so `passport` is found in `Passports?`. Several words, such as `council tax`, are found as those words, in that order. `words` is a list, or a path to one, or to one word, such as each item's `item.keywords`.

Property Takes What it’s for
text (needed) path
words (needed) a list of text, or path

condition

Whether something is so. `present` holds when the path leads to a value, and an empty list is no value; `missing` holds when it does not; `is`, such as `{ "topics": "all" }`, holds when the value at the path is exactly that, text or true or false; `contains` holds when some text has any of some words in it; `all`, `any` and `one` hold when all, any, or exactly one of the conditions they list do; `not` holds when its condition does not. Exactly one of these.

Property Takes What it’s for
present path
missing path
all a list of condition
any a list of condition
one a list of condition
not condition
contains contains
is names, each to text, or boolean