@hippo-digital/hippocampus 1.0.0-rc.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +88 -3
  2. package/README.md +36 -0
  3. package/assets/dist/hippocampus.css +1 -1
  4. package/assets/hippocampus.scss +994 -133
  5. package/assets/javascript/blueprint.js +21 -0
  6. package/assets/javascript/trace.js +54 -0
  7. package/bin/hippocampus.js +9 -3
  8. package/index.js +2 -1
  9. package/lib/breadcrumb.js +80 -0
  10. package/lib/create-router.js +246 -6
  11. package/lib/discover-projects.js +5 -0
  12. package/lib/filter.js +81 -0
  13. package/lib/flow-map.js +214 -0
  14. package/lib/lint-knowledge.js +31 -0
  15. package/lib/load-knowledge.js +335 -34
  16. package/lib/record-links.js +51 -0
  17. package/lib/templates.js +174 -0
  18. package/package.json +1 -1
  19. package/scripts/doctor.js +10 -0
  20. package/scripts/lib/make-blueprint-template.py +107 -0
  21. package/scripts/smoke-routes.js +19 -0
  22. package/templates/service-blueprint.xlsx +0 -0
  23. package/views/hippocampus/_layout.html +116 -3
  24. package/views/hippocampus/blueprint-classic.html +0 -1
  25. package/views/hippocampus/blueprint.html +0 -1
  26. package/views/hippocampus/components/_blueprint-cell.njk +6 -3
  27. package/views/hippocampus/components/_blueprint-controls.njk +2 -1
  28. package/views/hippocampus/components/_breadcrumb.njk +29 -0
  29. package/views/hippocampus/components/_connections.njk +38 -0
  30. package/views/hippocampus/components/_filters.njk +56 -0
  31. package/views/hippocampus/components/_journey-step.njk +11 -7
  32. package/views/hippocampus/components/_screen-preview.njk +41 -0
  33. package/views/hippocampus/doc.html +0 -1
  34. package/views/hippocampus/docs.html +67 -6
  35. package/views/hippocampus/evidence-impact.html +66 -33
  36. package/views/hippocampus/graph.html +137 -31
  37. package/views/hippocampus/handover-empty.html +0 -1
  38. package/views/hippocampus/handover.html +0 -1
  39. package/views/hippocampus/index.html +102 -13
  40. package/views/hippocampus/journey-flow.html +0 -1
  41. package/views/hippocampus/journey.html +21 -6
  42. package/views/hippocampus/journeys.html +63 -0
  43. package/views/hippocampus/project.html +19 -2
  44. package/views/hippocampus/record.html +33 -0
  45. package/views/hippocampus/research.html +14 -2
  46. package/views/hippocampus/route-review.html +0 -1
  47. package/views/hippocampus/scenarios.html +21 -3
  48. package/views/hippocampus/screens.html +45 -0
  49. package/views/hippocampus/trace.html +35 -22
  50. package/views/hippocampus/user-needs.html +55 -19
  51. package/views/hippocampus/user.html +131 -79
  52. package/views/hippocampus/users.html +33 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hippo-digital/hippocampus",
3
- "version": "1.0.0-rc.8",
3
+ "version": "1.0.0",
4
4
  "description": "A design-knowledge base for NHS Prototype Kit projects: research, insights, needs, journeys and screens, traceable end to end.",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
package/scripts/doctor.js CHANGED
@@ -62,6 +62,16 @@ function main () {
62
62
  (smoke.stderr || smoke.stdout || '').trim().split('\n').slice(0, 4).join('\n '))
63
63
  }
64
64
 
65
+ // Working on the package against a real project means symlinking it into that
66
+ // project's node_modules, and then the viewer is running code that is not
67
+ // published. That is the right way to do the work and the wrong thing to
68
+ // forget: a page that works here may not exist for anybody else yet.
69
+ const installedAt = path.join(root, 'node_modules/@hippo-digital/hippocampus')
70
+ if (fs.existsSync(installedAt) && fs.lstatSync(installedAt).isSymbolicLink()) {
71
+ notes.push(`hippocampus is LINKED, not installed - the viewer is running ${fs.realpathSync(installedAt)}`)
72
+ notes.push(' Anything you see here is unpublished. `npm install` restores the released version.')
73
+ }
74
+
65
75
  for (const note of notes) console.log(` note ${note}`)
66
76
 
67
77
  if (problems.length) {
@@ -0,0 +1,107 @@
1
+ """Generate the blank blueprint template the package ships.
2
+
3
+ The lane names are not invented here - they are the exact labels the importer's
4
+ swimlane triage matches, so a team filling this in lands in a mapped
5
+ destination rather than in the unmapped pile. The canonical list lives in
6
+ import-blueprint-spreadsheet.js and is passed in, so the two cannot drift.
7
+ """
8
+ import json, sys
9
+ from openpyxl import Workbook
10
+ from openpyxl.styles import Font, Alignment, PatternFill, Border, Side
11
+ from openpyxl.utils import get_column_letter
12
+
13
+ LANES = json.loads(sys.argv[1])
14
+ OUT = sys.argv[2]
15
+
16
+ wb = Workbook()
17
+ thin = Side(style="thin", color="D8DDE0")
18
+ box = Border(left=thin, right=thin, top=thin, bottom=thin)
19
+ head = Font(bold=True)
20
+ wrap = Alignment(wrap_text=True, vertical="top")
21
+
22
+ # --- How to use -----------------------------------------------------------
23
+ ws = wb.active
24
+ ws.title = "How to use"
25
+ ws.column_dimensions["A"].width = 100
26
+ rows = [
27
+ ("Service blueprint", True),
28
+ ("", False),
29
+ ("Fill in the Blueprint sheet, then import it:", False),
30
+ (" hippocampus import blueprint <this-file.xlsx>", False),
31
+ ("", False),
32
+ ("That writes a draft for you to check. Nothing reaches the knowledge base", False),
33
+ ("until you promote it.", False),
34
+ ("", False),
35
+ ("The Blueprint sheet", True),
36
+ ("", False),
37
+ ("One column per step, left to right, in the order the user meets them.", False),
38
+ ("One row per swimlane. The row labels in column A are the ones the importer", False),
39
+ ("recognises - keep them as they are and your content lands in the right", False),
40
+ ("place. A label it does not recognise is not lost: it is reported as", False),
41
+ ("unmapped for you to decide about.", False),
42
+ ("", False),
43
+ ("Put one item per line inside a cell. Blank cells are fine - a lane that", False),
44
+ ("does not apply to a step is a fact about the step, not a gap to fill.", False),
45
+ ("", False),
46
+ ("The Evidence sheet", True),
47
+ ("", False),
48
+ ("What each step rests on: the need it serves, the research behind it, or", False),
49
+ ("the document it came from. One row per link.", False),
50
+ ("", False),
51
+ ("The Sources sheet", True),
52
+ ("", False),
53
+ ("Where the evidence came from, so a reader can get back to the original.", False),
54
+ ]
55
+ for i, (text, bold) in enumerate(rows, start=1):
56
+ c = ws.cell(row=i, column=1, value=text)
57
+ if bold:
58
+ c.font = head
59
+
60
+ # --- Blueprint ------------------------------------------------------------
61
+ bp = wb.create_sheet("Blueprint")
62
+ bp.column_dimensions["A"].width = 28
63
+ for col in range(2, 8):
64
+ bp.column_dimensions[get_column_letter(col)].width = 34
65
+
66
+ bp.cell(row=1, column=1, value="Swimlane").font = head
67
+ for step in range(1, 7):
68
+ c = bp.cell(row=1, column=step + 1, value=f"{step}. ")
69
+ c.font = head
70
+ c.alignment = wrap
71
+ c.border = box
72
+ bp.cell(row=1, column=1).border = box
73
+
74
+ for r, lane in enumerate(LANES, start=2):
75
+ c = bp.cell(row=r, column=1, value=lane)
76
+ c.font = head
77
+ c.alignment = wrap
78
+ c.border = box
79
+ for step in range(1, 7):
80
+ cell = bp.cell(row=r, column=step + 1, value="")
81
+ cell.alignment = wrap
82
+ cell.border = box
83
+ bp.row_dimensions[r].height = 56
84
+ bp.freeze_panes = "B2"
85
+
86
+ # --- Evidence -------------------------------------------------------------
87
+ ev = wb.create_sheet("Evidence")
88
+ ev_cols = ["Step", "Screen", "Route", "Type", "Round", "Participants", "Statement", "Source ID"]
89
+ for i, name in enumerate(ev_cols, start=1):
90
+ c = ev.cell(row=1, column=i, value=name)
91
+ c.font = head
92
+ c.border = box
93
+ ev.column_dimensions[get_column_letter(i)].width = 22 if name != "Statement" else 60
94
+ ev.freeze_panes = "A2"
95
+
96
+ # --- Sources --------------------------------------------------------------
97
+ sr = wb.create_sheet("Sources")
98
+ sr_cols = ["Source ID", "Source title", "Reference", "Used for"]
99
+ for i, name in enumerate(sr_cols, start=1):
100
+ c = sr.cell(row=1, column=i, value=name)
101
+ c.font = head
102
+ c.border = box
103
+ sr.column_dimensions[get_column_letter(i)].width = 30 if i > 1 else 14
104
+ sr.freeze_panes = "A2"
105
+
106
+ wb.save(OUT)
107
+ print("wrote", OUT)
@@ -1,6 +1,7 @@
1
1
  const { spawn } = require('child_process')
2
2
  const { createContextOrExit } = require('../lib/context')
3
3
  const { listDocs } = require('../lib/docs')
4
+ const { allTemplates } = require('../lib/templates')
4
5
  const ctx = createContextOrExit()
5
6
 
6
7
  const port = process.env.SMOKE_PORT || 4587
@@ -53,11 +54,13 @@ function buildRoutes (basePath, knowledge) {
53
54
  `${basePath}/users`,
54
55
  `${basePath}/user-needs`,
55
56
  `${basePath}/scenarios`,
57
+ `${basePath}/journeys`,
56
58
  `${basePath}/research`,
57
59
  `${basePath}/graph`,
58
60
  `${basePath}/trace`,
59
61
  `${basePath}/handover`,
60
62
  `${basePath}/docs`,
63
+ `${basePath}/screens`,
61
64
  // The viewer serves these itself. If they 404 the pages load unstyled and
62
65
  // the blueprint stops working, which is exactly the kind of breakage a
63
66
  // smoke test should catch rather than a person noticing later.
@@ -65,10 +68,26 @@ function buildRoutes (basePath, knowledge) {
65
68
  `${basePath}/assets/blueprint.js`
66
69
  ])
67
70
 
71
+ for (const template of allTemplates()) {
72
+ routes.add(`${basePath}/templates/${template.file}`)
73
+ }
74
+
68
75
  for (const doc of listDocs()) {
69
76
  routes.add(`${basePath}/docs/${doc.slug}`)
70
77
  }
71
78
 
79
+ // Detail pages are generated per record, so check a sample rather than all
80
+ // of them - 132 needs would make the smoke test a load test.
81
+ for (const collection of [
82
+ { items: knowledge.needs, path: 'needs' },
83
+ { items: knowledge.insights, path: 'insights' },
84
+ { items: knowledge.screens, path: 'screens' }
85
+ ]) {
86
+ for (const item of (collection.items || []).slice(0, 3)) {
87
+ routes.add(`${basePath}/${collection.path}/${item.id}`)
88
+ }
89
+ }
90
+
72
91
  for (const journey of knowledge.journeys) {
73
92
  routes.add(`${basePath}/journeys/${journey.id}`)
74
93
  routes.add(`${basePath}/journeys/${journey.id}/blueprint`)
Binary file
@@ -8,6 +8,7 @@
8
8
  no sass entry point and no stylesheet link to the host project.
9
9
  #}
10
10
  {% extends "prototype-kit-template.njk" %}
11
+ {% from "hippocampus/components/_breadcrumb.njk" import breadcrumb as breadcrumbTrail %}
11
12
 
12
13
  {% block head %}
13
14
  <link href="/nhsuk-frontend/nhsuk-frontend.min.css" rel="stylesheet">
@@ -17,14 +18,112 @@
17
18
  {% block header %}
18
19
  {{ header({
19
20
  service: {
20
- text: serviceName or knowledge.project.name or "Knowledge base",
21
+ text: serviceName or serviceTitle or "Knowledge base",
21
22
  href: basePath
22
23
  }
23
24
  }) }}
24
25
  {% endblock %}
25
26
 
27
+ {#
28
+ A navigation bar on every page.
29
+
30
+ Until now the only way between sections was back to the landing page and out
31
+ again - two clicks and a lost train of thought for every sideways move. The
32
+ current section is marked with aria-current so it is announced, not only
33
+ coloured.
34
+ #}
35
+ {% block main %}
36
+ <nav class="knowledge-nav" aria-label="Knowledge base sections">
37
+ <div class="nhsuk-width-container-fluid knowledge-nav__inner">
38
+ {#
39
+ Which tool you are in, kept on screen at all times.
40
+
41
+ The header names the SERVICE, which is also what the prototype's own
42
+ pages are called - so without this, a page of needs and a patient
43
+ search screen carry the same banner. This says which of the two you are
44
+ looking at, and it rides with the navigation so it never scrolls away.
45
+ #}
46
+ <a class="knowledge-nav__wordmark" href="{{ basePath }}">Knowledge base</a>
47
+ <ul class="knowledge-nav__list">
48
+ {#
49
+ `match` lists the URL prefixes that belong to a section. A detail page
50
+ lives at a different path from its list - a need is /needs/:id while
51
+ the list is /user-needs - so matching on the list's own href alone
52
+ leaves every detail page with nothing marked.
53
+ #}
54
+ {% for item in [
55
+ { href: "", text: "Overview", match: [] },
56
+ { href: "/project", text: "Project", match: ["/project"] },
57
+ { href: "/users", text: "Users", match: ["/users"] },
58
+ { href: "/user-needs", text: "Needs", match: ["/user-needs", "/needs"] },
59
+ { href: "/scenarios", text: "Scenarios", match: ["/scenarios"] },
60
+ { href: "/journeys", text: "Journeys", match: ["/journeys", "/handover"] },
61
+ { href: "/screens", text: "Screens", match: ["/screens"] },
62
+ { href: "/research", text: "Research", match: ["/research", "/insights"] },
63
+ { href: "/graph", text: "Graph", match: ["/graph"] },
64
+ { href: "/trace", text: "Trace", match: ["/trace"] },
65
+ { href: "/docs", text: "Docs", match: ["/docs"] }
66
+ ] %}
67
+ {% set target = basePath + item.href %}
68
+ {% set isCurrent = currentPage == target %}
69
+ {% for prefix in item.match %}
70
+ {% if currentPage == basePath + prefix or currentPage.startsWith(basePath + prefix + "/") %}
71
+ {% set isCurrent = true %}
72
+ {% endif %}
73
+ {% endfor %}
74
+ <li class="knowledge-nav__item">
75
+ <a class="knowledge-nav__link{% if isCurrent %} knowledge-nav__link--current{% endif %}"
76
+ href="{{ target }}"
77
+ {% if isCurrent %}aria-current="page"{% endif %}>{{ item.text }}</a>
78
+ </li>
79
+ {% endfor %}
80
+ </ul>
81
+ </div>
82
+ </nav>
83
+ {{ super() }}
84
+ {% endblock %}
85
+
86
+ {#
87
+ The breadcrumb goes in `beforeContent`, the block the NHS template provides
88
+ just inside the container for exactly this. Putting it here rather than in
89
+ `content` matters: every view overrides `content`, so a breadcrumb placed
90
+ there would be replaced by each page and never render.
91
+
92
+ Rendering it once, centrally, is also the point - the per-page back links it
93
+ replaces were written one at a time and had drifted into saying five
94
+ different things.
95
+
96
+ The locals are called `breadcrumbItems`, not `breadcrumb`, because the kit's
97
+ template-with-imports.njk does `import breadcrumb` at its top level, which
98
+ shadows any context value of that name for every template extending it. A
99
+ `breadcrumb` passed from a route silently arrives here as the NHS macro, and
100
+ the trail renders as nothing at all with no error to explain it.
101
+ #}
102
+ {% block beforeContent %}
103
+ {{ breadcrumbTrail(breadcrumbItems) }}
104
+ {% endblock %}
105
+
106
+ {#
107
+ Integrity belongs in the footer, not on the landing page.
108
+
109
+ A green "validation passed" panel at the top of the home page took the most
110
+ prominent slot on the site to say that nothing was wrong - and only ever said
111
+ it to whoever opened the home page. As a footer line it rides every page, it
112
+ costs no room above the fold, and the date tells you whether the tick is
113
+ about the data you are actually looking at.
114
+
115
+ Failure keeps its callout on the landing page, where the list of what broke
116
+ is; the footer only carries the flag and the way back to it.
117
+ #}
26
118
  {% block footer %}
27
- {{ footer({
119
+ {#
120
+ An empty `copyright` removes the line rather than overriding it. "© NHS
121
+ England" is the macro's default and it is wrong here twice over: these
122
+ pages are a design tool, not an NHS.UK page, and the notice belongs to
123
+ whatever the prototype itself publishes - which is a different footer.
124
+ #}
125
+ {% call footer({
126
+ copyright: "",
28
127
  meta: {
29
128
  items: [
30
129
  {
@@ -37,7 +136,21 @@
37
136
  }
38
137
  ]
39
138
  }
40
- }) }}
139
+ }) %}
140
+ {% if knowledgeValidation.valid %}
141
+ <p class="nhsuk-body-s knowledge-integrity">
142
+ {{ nhsukIcon("tick", { classes: "knowledge-integrity__icon" }) }}
143
+ Knowledge checked{% if knowledgeSourcesUpdated %} · sources updated {{ knowledgeSourcesUpdated }}{% endif %}
144
+ </p>
145
+ {% else %}
146
+ <p class="nhsuk-body-s knowledge-integrity knowledge-integrity--failed">
147
+ <a class="nhsuk-footer__list-item-link" href="{{ basePath }}">
148
+ Knowledge validation failed: {{ knowledgeValidation.errors | length }}
149
+ problem{% if knowledgeValidation.errors | length != 1 %}s{% endif %}
150
+ </a>
151
+ </p>
152
+ {% endif %}
153
+ {% endcall %}
41
154
  {% endblock %}
42
155
 
43
156
  {% block bodyEnd %}
@@ -4,7 +4,6 @@
4
4
  {% block pageTitle %}{{ blueprint.meta.journeyTitle }} matrix{% endblock %}
5
5
 
6
6
  {% block content %}
7
- <a class="nhsuk-back-link" href="{{ basePath }}/journeys/{{ blueprint.journey.id }}/blueprint">Back to stacked blueprint</a>
8
7
  <span class="nhsuk-caption-l">Classic service blueprint</span>
9
8
  <h1>{{ blueprint.meta.journeyTitle }}</h1>
10
9
 
@@ -6,7 +6,6 @@
6
6
  {% block pageTitle %}{{ blueprint.meta.journeyTitle }} blueprint{% endblock %}
7
7
 
8
8
  {% block content %}
9
- <a class="nhsuk-back-link" href="{{ basePath }}/journeys/{{ blueprint.journey.id }}">Back to journey</a>
10
9
  <span class="nhsuk-caption-l">Stacked service blueprint</span>
11
10
  <h1>{{ blueprint.meta.journeyTitle }}</h1>
12
11
  <p class="nhsuk-lede-text">{{ blueprint.meta.scenarioTitle }}</p>
@@ -1,13 +1,16 @@
1
+ {% from "hippocampus/components/_screen-preview.njk" import screenPreview %}
1
2
  {% from "hippocampus/components/_list.njk" import bulletList %}
2
3
 
3
4
  {% macro renderCell(step, laneKey) %}
4
5
  {% if laneKey == "screens" %}
5
6
  {% if step.screens.length %}
6
- <ul class="nhsuk-list">
7
+ {# The screens lane is where a reader is most often trying to picture the
8
+ screen, and a title is the one thing that does not help them do it. #}
9
+ <div class="knowledge-screen-preview-row">
7
10
  {% for screen in step.screens %}
8
- <li><a href="{{ screen.route }}">{{ screen.title }}</a></li>
11
+ {{ screenPreview(screen, "inline") }}
9
12
  {% endfor %}
10
- </ul>
13
+ </div>
11
14
  {% else %}
12
15
  <span class="knowledge-muted">No linked screens</span>
13
16
  {% endif %}
@@ -1,6 +1,7 @@
1
1
  {% macro renderBlueprintControls(lanes) %}
2
2
  <div class="knowledge-blueprint-controls" data-blueprint-controls>
3
- <div class="knowledge-blueprint-controls__lenses" role="group" aria-label="Blueprint lens presets">
3
+ <div class="knowledge-blueprint-controls__lenses" role="group" aria-labelledby="blueprint-lens-legend">
4
+ <p class="knowledge-blueprint-controls__legend" id="blueprint-lens-legend">Show a view for</p>
4
5
  <button type="button" class="knowledge-lens-btn" data-lens="all" aria-pressed="true">All</button>
5
6
  <button type="button" class="knowledge-lens-btn" data-lens="executive" aria-pressed="false">Executive</button>
6
7
  <button type="button" class="knowledge-lens-btn" data-lens="technical" aria-pressed="false">Technical</button>
@@ -0,0 +1,29 @@
1
+ {# The trail, on every page.
2
+
3
+ NHS.UK's own breadcrumb component renders ancestors only and has no crumb
4
+ for the page you are on, so this uses its classes with a final, unlinked
5
+ crumb carrying aria-current. That is the part that answers "where am I",
6
+ which a row of ancestors alone does not. #}
7
+ {# On the overview there is one crumb and it is the page you are on, so the
8
+ trail says nothing a sighted reader cannot see from the h1 below it. It stays
9
+ in the markup rather than being dropped: a screen reader user arriving by
10
+ landmark still gets told where this page sits, and a breadcrumb that exists
11
+ on every page but one is a landmark that disappears without explanation. #}
12
+ {% macro breadcrumb(items) %}
13
+ {% if items.length %}
14
+ {% set soleCrumb = items.length < 2 %}
15
+ <nav class="nhsuk-breadcrumb knowledge-breadcrumb{% if soleCrumb %} knowledge-breadcrumb--quiet nhsuk-u-visually-hidden{% endif %}" aria-label="Breadcrumb">
16
+ <ol class="nhsuk-breadcrumb__list">
17
+ {% for item in items %}
18
+ <li class="nhsuk-breadcrumb__list-item">
19
+ {% if item.href and not loop.last %}
20
+ <a class="nhsuk-breadcrumb__link" href="{{ item.href }}">{{ item.text }}</a>
21
+ {% else %}
22
+ <span aria-current="page">{{ item.text }}</span>
23
+ {% endif %}
24
+ </li>
25
+ {% endfor %}
26
+ </ol>
27
+ </nav>
28
+ {% endif %}
29
+ {% endmacro %}
@@ -0,0 +1,38 @@
1
+ {# The connections panel every detail page shares.
2
+
3
+ Each group says what the relationship means from this record's point of
4
+ view, so a reader knows why a thing is listed rather than inferring it.
5
+ A record type with no page of its own renders as plain text - a dead link
6
+ is worse than an honest one. #}
7
+ {% macro connections(groups) %}
8
+ {% if groups.length %}
9
+ {# A grid rather than fixed halves: a record with one group left half the
10
+ row empty, and one with three wrapped a lone third onto its own line. #}
11
+ <div class="knowledge-card-grid knowledge-card-grid--wide">
12
+ {% for group in groups %}
13
+ <div>
14
+ <section class="knowledge-section nhsuk-u-margin-bottom-0">
15
+ <h2 class="nhsuk-heading-s">{{ group.label }} <span class="nhsuk-u-font-weight-normal nhsuk-u-secondary-text-color">({{ group.items.length }})</span></h2>
16
+ <ul class="nhsuk-list nhsuk-list--bullet knowledge-connection-list">
17
+ {% for item in group.items %}
18
+ <li>
19
+ {% if item.href %}
20
+ <a href="{{ item.href }}">{{ item.label }}</a>
21
+ {% else %}
22
+ {{ item.label }}
23
+ {% endif %}
24
+ <span class="nhsuk-u-secondary-text-color nhsuk-body-s">{{ item.type }}</span>
25
+ </li>
26
+ {% endfor %}
27
+ </ul>
28
+ </section>
29
+ </div>
30
+ {% endfor %}
31
+ </div>
32
+ {% else %}
33
+ <div class="nhsuk-inset-text">
34
+ <p>This record has no connections recorded. That is usually a gap in the
35
+ graph rather than a fact about the record.</p>
36
+ </div>
37
+ {% endif %}
38
+ {% endmacro %}
@@ -0,0 +1,56 @@
1
+ {# The find bar every list page shares.
2
+
3
+ A plain GET form, so it works without JavaScript, the browser remembers it,
4
+ and a filtered list has a URL worth sending to somebody. The result count is
5
+ always shown: with 132 records, "showing 9" is the difference between
6
+ trusting the page and wondering what it is hiding. #}
7
+
8
+ {% macro findBar(action, searchLabel, searchHint, query, facets, shown, total, activeFilters, clearHref) %}
9
+ <form class="knowledge-find" method="get" action="{{ action }}" role="search">
10
+ <div class="nhsuk-form-group nhsuk-u-margin-bottom-3">
11
+ <label class="nhsuk-label" for="find-q">{{ searchLabel }}</label>
12
+ {% if searchHint %}<div class="nhsuk-hint" id="find-q-hint">{{ searchHint }}</div>{% endif %}
13
+ <input class="nhsuk-input" id="find-q" name="q" type="search"
14
+ value="{{ query.q or '' }}"
15
+ {% if searchHint %}aria-describedby="find-q-hint"{% endif %}>
16
+ </div>
17
+
18
+ {% for facet in facets %}
19
+ {% if facet.options.length > 1 %}
20
+ <div class="nhsuk-form-group nhsuk-u-margin-bottom-3">
21
+ <label class="nhsuk-label" for="find-{{ facet.key }}">{{ facet.label }}</label>
22
+ <select class="nhsuk-select" id="find-{{ facet.key }}" name="{{ facet.key }}">
23
+ <option value="">All</option>
24
+ {% for option in facet.options %}
25
+ <option value="{{ option.value }}" {% if option.selected %}selected{% endif %}>
26
+ {{ option.label }} ({{ option.count }})
27
+ </option>
28
+ {% endfor %}
29
+ </select>
30
+ </div>
31
+ {% endif %}
32
+ {% endfor %}
33
+
34
+ <button class="nhsuk-button nhsuk-u-margin-bottom-3" type="submit">Apply</button>
35
+ {% if activeFilters.length %}
36
+ <a class="nhsuk-u-margin-left-3" href="{{ clearHref }}">Clear all</a>
37
+ {% endif %}
38
+ </form>
39
+
40
+ <p class="nhsuk-body-s knowledge-find__count" role="status">
41
+ {% if shown == total %}
42
+ Showing all {{ total }}
43
+ {% else %}
44
+ Showing <strong>{{ shown }}</strong> of {{ total }}
45
+ {% endif %}
46
+ </p>
47
+ {% endmacro %}
48
+
49
+ {# Shown instead of the list when nothing matches. Says what to do next rather
50
+ than only what went wrong. #}
51
+ {% macro noMatches(clearHref, what) %}
52
+ <div class="nhsuk-inset-text">
53
+ <h2 class="nhsuk-heading-s">No {{ what }} match those filters</h2>
54
+ <p>Try fewer words, or <a href="{{ clearHref }}">clear all filters</a>.</p>
55
+ </div>
56
+ {% endmacro %}
@@ -1,15 +1,19 @@
1
+ {% from "hippocampus/components/_screen-preview.njk" import screenPreview %}
1
2
  {% macro journeyStep(step, knowledge) %}
2
3
  <li class="knowledge-timeline__item">
3
4
  <h2 class="nhsuk-heading-m">{{ step.label }}</h2>
4
5
  <p>{{ step.userAction }}</p>
5
6
 
6
- <h3 class="nhsuk-heading-s">Linked screens</h3>
7
- <ul class="nhsuk-list">
8
- {% for screenId in step.screenIds %}
9
- {% set screen = knowledge.index.screens[screenId] %}
10
- <li><a href="{{ screen.route }}">{{ screen.title }}</a></li>
11
- {% endfor %}
12
- </ul>
7
+ {% if step.screenIds.length %}
8
+ {# What the user is actually looking at during this step. #}
9
+ <h3 class="nhsuk-heading-s">Linked screens</h3>
10
+ <div class="knowledge-screen-preview-row">
11
+ {% for screenId in step.screenIds %}
12
+ {% set screen = knowledge.index.screens[screenId] %}
13
+ {% if screen %}{{ screenPreview(screen, "inline") }}{% endif %}
14
+ {% endfor %}
15
+ </div>
16
+ {% endif %}
13
17
 
14
18
  <h3 class="nhsuk-heading-s">User needs</h3>
15
19
  <ul class="nhsuk-list nhsuk-list--bullet">
@@ -0,0 +1,41 @@
1
+ {# A live look at the screen, not a picture of one.
2
+
3
+ An iframe of the route the host already serves, scaled down. A captured
4
+ image would be sharper and cheaper to render, and it would start going stale
5
+ the moment somebody edits the page - which is the exact failure this viewer
6
+ exists to catch. A preview that can disagree with the prototype is worse than
7
+ no preview, because it is believed.
8
+
9
+ `loading="lazy"` matters on the list: seven of these is seven page loads, and
10
+ only the ones scrolled to should cost anything. #}
11
+
12
+ {% macro screenPreview(screen, size = "card") %}
13
+ {% if screen.external %}
14
+ <div class="knowledge-screen-preview knowledge-screen-preview--{{ size }} knowledge-screen-preview--absent">
15
+ <p class="knowledge-note nhsuk-u-margin-bottom-0">
16
+ Served elsewhere, so it cannot be previewed from here.
17
+ </p>
18
+ </div>
19
+ {% elif screen.route %}
20
+ <figure class="knowledge-screen-preview knowledge-screen-preview--{{ size }}">
21
+ <div class="knowledge-screen-preview__frame">
22
+ {#
23
+ Not interactive. A reader clicking inside a shrunken copy of a page
24
+ navigates a viewport they cannot see, and the back button then leaves
25
+ the frame somewhere unrelated to the record it is meant to illustrate.
26
+ The caption carries the real link.
27
+ #}
28
+ <iframe src="{{ screen.route }}"
29
+ title="Preview of {{ screen.title }}"
30
+ loading="lazy"
31
+ tabindex="-1"
32
+ aria-hidden="true"
33
+ scrolling="no"></iframe>
34
+ </div>
35
+ <figcaption>
36
+ <a href="{{ screen.route }}">Open {{ screen.title }}</a>
37
+ <code>{{ screen.route }}</code>
38
+ </figcaption>
39
+ </figure>
40
+ {% endif %}
41
+ {% endmacro %}
@@ -3,7 +3,6 @@
3
3
  {% block pageTitle %}{{ doc.title }}{% endblock %}
4
4
 
5
5
  {% block content %}
6
- <a class="nhsuk-back-link" href="{{ basePath }}/docs">Back to documentation</a>
7
6
  <article class="knowledge-doc">
8
7
  {{ doc.html | safe }}
9
8
  </article>