govuk_publishing_components 66.4.1 → 66.4.2

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 (22) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +80 -47
  3. data/app/assets/stylesheets/component_guide/application.scss +27 -11
  4. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +40 -11
  5. data/app/models/govuk_publishing_components/component_doc.rb +6 -2
  6. data/app/models/govuk_publishing_components/component_docs.rb +8 -2
  7. data/app/models/govuk_publishing_components/component_example.rb +4 -0
  8. data/app/models/govuk_publishing_components/shared_accessibility_criteria.rb +2 -2
  9. data/app/views/govuk_publishing_components/applications_page/show.html.erb +2 -2
  10. data/app/views/govuk_publishing_components/audit/_component_contents.html.erb +1 -1
  11. data/app/views/govuk_publishing_components/audit/show.html.erb +1 -1
  12. data/app/views/govuk_publishing_components/component_guide/_component_list.html.erb +5 -1
  13. data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb +11 -6
  14. data/app/views/govuk_publishing_components/component_guide/component_doc/_component_output.html.erb +11 -2
  15. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  16. data/app/views/govuk_publishing_components/component_guide/index.html.erb +7 -0
  17. data/app/views/govuk_publishing_components/component_guide/preview.html.erb +9 -1
  18. data/app/views/govuk_publishing_components/component_guide/show.html.erb +35 -14
  19. data/config/routes.rb +10 -2
  20. data/lib/govuk_publishing_components/config.rb +4 -0
  21. data/lib/govuk_publishing_components/version.rb +1 -1
  22. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19af51f046dbc68b76e065963974758d205b625bd2b025f15a9cf317429c05ca
4
- data.tar.gz: b83ab22b5b85c12abf3b22294482c7575c2b822d2d8553c7f72c3b8bab58f881
3
+ metadata.gz: fd72494a66aaa74f9aaae8ad23d1f728ce1cde7af9eaad8bf7f2796e3ebacdf0
4
+ data.tar.gz: a698a3a427cc0443f5a1d83fe27d8794caa129c9ff02a9d2572a6b19e2a02c37
5
5
  SHA512:
6
- metadata.gz: 334265c53864c184cd064d7a1f16933db51c9bbac48eeed29accd96d59d4db690eb4c7752797a4e1156fca2f7b0172422f36412600fe809aa3e1051ff289e57e
7
- data.tar.gz: bef35d323f9fa89eee4b65bb5d22dee1aaec5e1312c11f1b0acf99ada4f9e7f67fa43d8c33261a5f4683a3ae480ee9d4ff2b4a0403d5b5313f020269454202aa
6
+ metadata.gz: dd7c76ecfc56805e155ff091a41079d764b6f4fa9bdd4a4eaf29b9759b0773fa8b691e02c7cebd046d27de7b97bd8ab9e109e5fe6e128b3ce1a93426bdfc1200
7
+ data.tar.gz: 0eb74f2a10610b60e6beb6be3cda9a10b234fa1e340e7f63532f88463e481a488ebf26df6004729a86b4496738475c1f57668dd3ed58c2118373a8aced66ae71
@@ -74,7 +74,7 @@
74
74
  if (performance.navigation && typeof performance.navigation.type !== "undefined") {
75
75
  return performance.navigation.type;
76
76
  }
77
- return "";
77
+ return undefined;
78
78
  }
79
79
  /**
80
80
  * Returns the delivery type for the current document. To differentiate between the valid empty
@@ -286,7 +286,19 @@
286
286
  return sinceNavigationStart;
287
287
  }
288
288
 
289
- var version = "4.4.3";
289
+ var sendBeaconFallback = function (url, data) {
290
+ var xhr = new XMLHttpRequest();
291
+ xhr.open("POST", url, true);
292
+ xhr.setRequestHeader("content-type", "application/json");
293
+ xhr.send(data);
294
+ return true;
295
+ };
296
+ var sendBeaconImpl = "sendBeacon" in navigator ? navigator.sendBeacon.bind(navigator) : sendBeaconFallback;
297
+ function postJson(url, data) {
298
+ return sendBeaconImpl(url, data);
299
+ }
300
+
301
+ var version = "4.5.0";
290
302
  var pkg = {
291
303
  version: version};
292
304
 
@@ -309,14 +321,6 @@
309
321
  return parseFloat(parts[0] + "." + padStart(parts[1], 2, "0") + padStart(parts[2], 2, "0"));
310
322
  }
311
323
 
312
- var sendBeaconFallback = function (url, data) {
313
- var xhr = new XMLHttpRequest();
314
- xhr.open("POST", url, true);
315
- xhr.setRequestHeader("content-type", "application/json");
316
- xhr.send(String(data));
317
- return true;
318
- };
319
- var sendBeacon = "sendBeacon" in navigator ? navigator.sendBeacon.bind(navigator) : sendBeaconFallback;
320
324
  /**
321
325
  * Some values should only be reported if they are non-zero. The exception to this is when the page
322
326
  * was prerendered or restored from BF cache
@@ -455,7 +459,7 @@
455
459
  startTime: this.startTime,
456
460
  }, metricData);
457
461
  try {
458
- if (sendBeacon(beaconUrl, JSON.stringify(payload))) {
462
+ if (postJson(beaconUrl, JSON.stringify(payload))) {
459
463
  this.isSent = true;
460
464
  this.logger.logEvent(83 /* LogEvent.PostBeaconSent */, [beaconUrl, payload]);
461
465
  emit("beacon", payload);
@@ -501,20 +505,21 @@
501
505
  return {
502
506
  allowEmptyPostBeacon: getProperty(obj, "allowEmptyPostBeacon", false),
503
507
  auto: autoMode,
508
+ errorBeaconDelay: getProperty(obj, "errorBeaconDelay", 2000),
504
509
  beaconUrl: getProperty(obj, "beaconUrl", luxOrigin + "/lux/"),
505
510
  beaconUrlFallback: getProperty(obj, "beaconUrlFallback"),
506
511
  beaconUrlV2: getProperty(obj, "beaconUrlV2", "https://beacon.speedcurve.com/store"),
507
512
  conversions: getProperty(obj, "conversions"),
508
513
  cookieDomain: getProperty(obj, "cookieDomain"),
509
514
  customerid: getProperty(obj, "customerid"),
510
- errorBeaconUrl: getProperty(obj, "errorBeaconUrl", luxOrigin + "/error/"),
515
+ errorBeaconUrl: getProperty(obj, "errorBeaconUrl", "https://beacon.speedcurve.com/store/error"),
511
516
  interactionBeaconDelay: getProperty(obj, "interactionBeaconDelay", 200),
512
517
  jspagelabel: getProperty(obj, "jspagelabel"),
513
518
  label: getProperty(obj, "label"),
514
519
  maxAttributionEntries: getProperty(obj, "maxAttributionEntries", 25),
515
520
  maxBeaconUrlLength: getProperty(obj, "maxBeaconUrlLength", 8190),
516
521
  maxBeaconUTEntries: getProperty(obj, "maxBeaconUTEntries", 20),
517
- maxErrors: getProperty(obj, "maxErrors", 5),
522
+ maxErrors: getProperty(obj, "maxErrors", 64),
518
523
  maxMeasureTime: getProperty(obj, "maxMeasureTime", 60000),
519
524
  measureUntil: getProperty(obj, "measureUntil", spaMode ? "pagehidden" : "onload"),
520
525
  minMeasureTime: getProperty(obj, "minMeasureTime", 0),
@@ -645,6 +650,47 @@
645
650
  return selector;
646
651
  }
647
652
 
653
+ // This is the same value as MAX_ERRORS_PER_BEACON in speedcurve-rum-beacons-edge-service
654
+ var MAX_ERRORS_PER_BEACON = 64;
655
+ var buffer = [];
656
+ var pendingContext = null;
657
+ var pendingConfig = null;
658
+ var flushTimer = null;
659
+ function queueErrorBeacon(config, error, errorTime, context) {
660
+ // If the page ID has changed since the last error (e.g. due to a SPA navigation), or if the
661
+ // buffer is full, flush the current beacon before adding the new error.
662
+ var pageChanged = pendingContext && pendingContext.pageId !== context.pageId;
663
+ var bufferFull = buffer.length >= MAX_ERRORS_PER_BEACON;
664
+ if (pageChanged || bufferFull) {
665
+ flushErrorBeacon();
666
+ }
667
+ pendingContext = context;
668
+ pendingConfig = config;
669
+ buffer.push({
670
+ errorTime: errorTime,
671
+ filename: error.filename,
672
+ lineno: error.lineno,
673
+ colno: error.colno,
674
+ message: error.message,
675
+ });
676
+ if (flushTimer === null) {
677
+ flushTimer = setTimeout(flushErrorBeacon, config.errorBeaconDelay);
678
+ }
679
+ }
680
+ function flushErrorBeacon() {
681
+ if (flushTimer !== null) {
682
+ clearTimeout(flushTimer);
683
+ flushTimer = null;
684
+ }
685
+ if (buffer.length === 0 || !pendingContext || !pendingConfig) {
686
+ return;
687
+ }
688
+ postJson(pendingConfig.errorBeaconUrl, JSON.stringify(Object.assign({}, pendingContext, { errors: buffer })));
689
+ buffer = [];
690
+ pendingContext = null;
691
+ pendingConfig = null;
692
+ }
693
+
648
694
  var KNOWN_TRACKING_PARAMS = [
649
695
  "utm_source",
650
696
  "utm_campaign",
@@ -1268,28 +1314,21 @@
1268
1314
  var isLuxError = e.filename.indexOf("/lux.js?") > -1 || e.message.indexOf("LUX") > -1;
1269
1315
  if (isLuxError || (nErrors <= globalConfig.maxErrors && _sample())) {
1270
1316
  // Sample & limit other errors.
1271
- // Send the error beacon.
1272
- new Image().src =
1273
- globalConfig.errorBeaconUrl +
1274
- "?v=" +
1275
- versionAsFloat() +
1276
- "&id=" +
1277
- getCustomerId() +
1278
- "&fn=" +
1279
- encodeURIComponent(e.filename) +
1280
- "&ln=" +
1281
- e.lineno +
1282
- "&cn=" +
1283
- e.colno +
1284
- "&msg=" +
1285
- encodeURIComponent(e.message) +
1286
- "&l=" +
1287
- encodeURIComponent(_getPageLabel()) +
1288
- (connectionType() ? "&ct=" + connectionType() : "") +
1289
- "&HN=" +
1290
- encodeURIComponent(document.location.hostname) +
1291
- "&PN=" +
1292
- encodeURIComponent(document.location.pathname);
1317
+ queueErrorBeacon(globalConfig, e, msSincePageInit(), {
1318
+ customerId: getCustomerId(),
1319
+ pageId: gSyncId,
1320
+ sessionId: gUid,
1321
+ scriptVersion: VERSION,
1322
+ hostname: document.location.hostname,
1323
+ pathname: document.location.pathname,
1324
+ pageLabel: _getPageLabel(),
1325
+ connectionType: connectionType(),
1326
+ deliveryType: deliveryType(),
1327
+ navigationType: navigationType(),
1328
+ deviceMemory: typeof navigator.deviceMemory === "number" ? round(navigator.deviceMemory) : undefined,
1329
+ flags: gFlags,
1330
+ customData: getAllCustomData(),
1331
+ });
1293
1332
  }
1294
1333
  }
1295
1334
  }
@@ -2272,23 +2311,16 @@
2272
2311
  return getNavigationEntry().encodedBodySize || 0;
2273
2312
  }
2274
2313
  // Return the connection type based on Network Information API.
2275
- // Note this API is in flux.
2276
2314
  function connectionType() {
2277
2315
  var c = navigator.connection;
2278
- var connType = "";
2279
2316
  if (c && c.effectiveType) {
2280
- connType = c.effectiveType;
2317
+ var connType = c.effectiveType;
2281
2318
  if ("slow-2g" === connType) {
2282
- connType = "Slow 2G";
2283
- }
2284
- else if ("2g" === connType || "3g" === connType || "4g" === connType || "5g" === connType) {
2285
- connType = connType.toUpperCase();
2286
- }
2287
- else {
2288
- connType = connType.charAt(0).toUpperCase() + connType.slice(1);
2319
+ return "Slow 2G";
2289
2320
  }
2321
+ return connType.toUpperCase();
2290
2322
  }
2291
- return connType;
2323
+ return undefined;
2292
2324
  }
2293
2325
  // Return an array of image elements that are in the top viewport.
2294
2326
  function imagesATF() {
@@ -2506,6 +2538,7 @@
2506
2538
  var ds = docSize();
2507
2539
  var ct = connectionType();
2508
2540
  var dt = deliveryType();
2541
+ var navType = navigationType();
2509
2542
  // Note some page stat values (the `PS` query string) are non-numeric. To make extracting these
2510
2543
  // values easier, we append an underscore "_" to the value. Values this is used for include
2511
2544
  // connection type (ct) and delivery type (dt).
@@ -2547,7 +2580,7 @@
2547
2580
  "er" +
2548
2581
  nErrors +
2549
2582
  "nt" +
2550
- navigationType() +
2583
+ (typeof navType !== "undefined" ? navType : "") +
2551
2584
  (navigator.deviceMemory ? "dm" + round(navigator.deviceMemory) : "") + // device memory (GB)
2552
2585
  (sIx ? "&IX=" + sIx : "") +
2553
2586
  (typeof gFirstInputDelay !== "undefined" ? "&FID=" + gFirstInputDelay : "") +
@@ -457,10 +457,6 @@ $code-delete-bg: #fadddd;
457
457
  background: govuk-colour("white");
458
458
  }
459
459
 
460
- .component-doc__content-list {
461
- margin-top: govuk-spacing(5);
462
- }
463
-
464
460
  .component__application-name {
465
461
  display: block;
466
462
  font-weight: normal;
@@ -477,22 +473,42 @@ $code-delete-bg: #fadddd;
477
473
  }
478
474
  }
479
475
 
480
- .table-container {
476
+ .gem-full-width__container {
481
477
  container-type: inline-size;
482
- container-name: page;
478
+ container-name: gem_page;
483
479
  }
484
480
 
485
- .table-wrapper {
481
+ .full-width__table-wrapper {
486
482
  .govuk-table {
487
483
  display: block;
488
484
  overflow-x: scroll;
489
485
  }
490
486
  }
491
487
 
492
- @container page (width > 1040px) {
488
+ .gem-full-width__element {
489
+ padding: 0;
490
+ padding-bottom: 0.1px; // forces child margin inside
491
+ border: 0;
492
+ margin-left: -(govuk-spacing(3));
493
+ margin-right: -(govuk-spacing(3));
494
+ border-top: solid 1px $govuk-border-colour;
495
+ border-bottom: solid 1px $govuk-border-colour;
496
+
497
+ @include govuk-media-query($from: tablet) {
498
+ margin-left: -(govuk-spacing(6));
499
+ margin-right: -(govuk-spacing(6));
500
+ }
501
+ }
502
+
503
+ @container gem_page (width > 1040px) {
493
504
  $w: 960px;
494
505
 
495
- .table-wrapper {
506
+ .gem-full-width__element {
507
+ margin-left: calc((-100cqw + $w) / 2);
508
+ margin-right: calc((-100cqw + $w) / 2);
509
+ }
510
+
511
+ .full-width__table-wrapper {
496
512
  position: relative;
497
513
  z-index: 0;
498
514
  box-sizing: border-box;
@@ -513,8 +529,8 @@ $code-delete-bg: #fadddd;
513
529
  .govuk-tabs {
514
530
  $w: 920px;
515
531
 
516
- @container page (width > 1040px) {
517
- .table-wrapper {
532
+ @container gem_page (width > 1040px) {
533
+ .full-width__table-wrapper {
518
534
  margin-left: calc(((-100cqw + $w) / 2) - 1px);
519
535
  margin-right: calc(((-100cqw + $w) / 2) - 1px);
520
536
 
@@ -1,6 +1,7 @@
1
1
  module GovukPublishingComponents
2
2
  class ComponentGuideController < GovukPublishingComponents::ApplicationController
3
3
  append_view_path Rails.root.join("app", "views", GovukPublishingComponents::Config.component_directory_name).to_s
4
+ append_view_path Rails.root.join("app", "views", GovukPublishingComponents::Config.flexible_sections_directory_name).to_s
4
5
 
5
6
  MATCH_COMPONENTS = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/
6
7
 
@@ -13,28 +14,45 @@ module GovukPublishingComponents
13
14
  @unused_components = unused_components_names.get_component_docs
14
15
  @components_in_use_sass = components_in_use_sass
15
16
  @components_in_use_js = components_in_use_js
17
+ @flexible_section_docs = flexible_section_docs.all
16
18
  end
17
19
 
18
20
  def show
19
- @component_doc = component_docs.get(params[:component])
20
- @guide_breadcrumbs = [index_breadcrumb, component_breadcrumb(@component_doc)]
21
+ if params[:flexible_section]
22
+ @component_doc = flexible_section_docs.get(params[:flexible_section])
23
+ @example_path = flexible_section_example_path(@component_doc.id, "default")
24
+ @preview_path = flexible_section_preview_path(@component_doc.id, "default")
25
+ @preview_all_path = flexible_section_preview_all_path(@component_doc.id)
26
+
27
+ @guide_breadcrumbs = [index_breadcrumb, flexible_section_breadcrumb(@component_doc)]
28
+ else
29
+ @component_doc = component_docs.get(params[:component])
30
+ @example_path = component_example_path(@component_doc.id, "default")
31
+ @preview_path = component_preview_path(@component_doc.id, "default")
32
+ @preview_all_path = component_preview_all_path(@component_doc.id)
33
+
34
+ @guide_breadcrumbs = [index_breadcrumb, component_breadcrumb(@component_doc)]
35
+ end
21
36
  end
22
37
 
23
38
  def example
24
- @component_doc = component_docs.get(params[:component])
39
+ @component_doc = params[:flexible_section] ? flexible_section_docs.get(params[:flexible_section]) : component_docs.get(params[:component])
25
40
  @component_example = @component_doc.examples.find { |f| f.id == params[:example] }
26
- @guide_breadcrumbs = [
27
- index_breadcrumb,
28
- component_breadcrumb(@component_doc, @component_example),
29
- {
30
- title: @component_example.name,
31
- },
32
- ]
41
+
42
+ @guide_breadcrumbs = [index_breadcrumb]
43
+ if params[:flexible_section]
44
+ @preview_path = flexible_section_preview_path(@component_doc.id, @component_example.id)
45
+ @guide_breadcrumbs << flexible_section_breadcrumb(@component_doc, @component_example)
46
+ else
47
+ @preview_path = component_preview_path(@component_doc.id, @component_example.id)
48
+ @guide_breadcrumbs << component_breadcrumb(@component_doc, @component_example)
49
+ end
50
+ @guide_breadcrumbs << { title: @component_example.name }
33
51
  end
34
52
 
35
53
  def preview
36
54
  @component_examples = []
37
- @component_doc = component_docs.get(params[:component])
55
+ @component_doc = params[:flexible_section] ? flexible_section_docs.get(params[:flexible_section]) : component_docs.get(params[:component])
38
56
  @preview = true
39
57
 
40
58
  if params[:example].present?
@@ -73,6 +91,10 @@ module GovukPublishingComponents
73
91
  @gem_component_docs ||= ComponentDocs.new(gem_components: true)
74
92
  end
75
93
 
94
+ def flexible_section_docs
95
+ @flexible_section_docs ||= ComponentDocs.new(flexible_sections: true)
96
+ end
97
+
76
98
  def used_components_names
77
99
  @used_components_names ||= ComponentDocs.new(gem_components: true, limit_to: get_used_component_names)
78
100
  end
@@ -166,5 +188,12 @@ module GovukPublishingComponents
166
188
  h[:url] = component_doc_path(component_doc.id) if component_example
167
189
  end
168
190
  end
191
+
192
+ def flexible_section_breadcrumb(component_doc, component_example = nil)
193
+ {}.tap do |h|
194
+ h[:title] = "#{component_doc.name} (flexible section)"
195
+ h[:url] = flexible_section_doc_path(component_doc.id) if component_example
196
+ end
197
+ end
169
198
  end
170
199
  end
@@ -7,9 +7,10 @@ module GovukPublishingComponents
7
7
  :component,
8
8
  :accessibility_excluded_rules,
9
9
  :source,
10
- :embed
10
+ :embed,
11
+ :type
11
12
 
12
- def initialize(component)
13
+ def initialize(component, type)
13
14
  @component = component
14
15
  @id = component[:id]
15
16
  @name = component[:name]
@@ -18,6 +19,7 @@ module GovukPublishingComponents
18
19
  @accessibility_excluded_rules = component[:accessibility_excluded_rules]
19
20
  @source = component[:source]
20
21
  @embed = component[:embed]
22
+ @type = type
21
23
  end
22
24
 
23
25
  def accessibility_criteria
@@ -88,6 +90,8 @@ module GovukPublishingComponents
88
90
  def partial_path
89
91
  if source == "gem"
90
92
  "govuk_publishing_components/components/#{id}"
93
+ elsif type == "flexible section"
94
+ "#{GovukPublishingComponents::Config.flexible_sections_directory_name}/#{id}"
91
95
  else
92
96
  "#{GovukPublishingComponents::Config.component_directory_name}/#{id}"
93
97
  end
@@ -1,9 +1,11 @@
1
1
  module GovukPublishingComponents
2
2
  # @private
3
3
  class ComponentDocs
4
- def initialize(gem_components: false, limit_to: false)
4
+ def initialize(gem_components: false, limit_to: false, flexible_sections: false)
5
5
  @limit_to = limit_to
6
6
  @documentation_directory = gem_components ? gem_documentation_directory : app_documentation_directory
7
+ @documentation_directory = flexible_sections_documentation_directory if flexible_sections
8
+ @type = flexible_sections ? "flexible section" : "component"
7
9
  end
8
10
 
9
11
  def get(id)
@@ -22,7 +24,7 @@ module GovukPublishingComponents
22
24
  private
23
25
 
24
26
  def build(component)
25
- ComponentDoc.new(component)
27
+ ComponentDoc.new(component, @type)
26
28
  end
27
29
 
28
30
  def fetch_component_doc_files
@@ -56,5 +58,9 @@ module GovukPublishingComponents
56
58
  def gem_documentation_directory
57
59
  Pathname.new(GovukPublishingComponents::Config.gem_directory).join("app", "views", "govuk_publishing_components", "components", "docs")
58
60
  end
61
+
62
+ def flexible_sections_documentation_directory
63
+ Rails.root.join("app", "views", GovukPublishingComponents::Config.flexible_sections_directory_name, "docs")
64
+ end
59
65
  end
60
66
  end
@@ -83,6 +83,10 @@ module GovukPublishingComponents
83
83
  !!context["black_background"]
84
84
  end
85
85
 
86
+ def full_width?
87
+ context["full_width"].present?
88
+ end
89
+
86
90
  def html_description
87
91
  markdown_to_html(description) if description.present?
88
92
  end
@@ -2,7 +2,7 @@ module GovukPublishingComponents
2
2
  module SharedAccessibilityCriteria
3
3
  def self.link
4
4
  "
5
- Links in the component must:
5
+ Links must:
6
6
 
7
7
  - accept focus
8
8
  - be focusable with a keyboard
@@ -19,7 +19,7 @@ Links in the component must:
19
19
 
20
20
  def self.button
21
21
  "
22
- Buttons in the component must:
22
+ Buttons must:
23
23
 
24
24
  - accept focus
25
25
  - be focusable with a keyboard
@@ -1,5 +1,5 @@
1
1
  <% content_for :title, "Applications consistency" %>
2
- <% content_for :body_classes, "table-container" %>
2
+ <% content_for :body_classes, "gem-full-width__container" %>
3
3
 
4
4
  <%= render "govuk_publishing_components/components/back_link", {
5
5
  href: "/component-guide",
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
 
19
19
  <div data-module="filter-list">
20
- <div class="table-wrapper">
20
+ <div class="full-width__table-wrapper">
21
21
  <table class="govuk-table">
22
22
  <thead class="govuk-table__head">
23
23
  <tr class="govuk-table__row">
@@ -1,7 +1,7 @@
1
1
  <p class="govuk-body">
2
2
  Numbers in table headers show column totals. Numbers in table cells show number of lines in files. Note that component test files cannot currently be detected in applications that use minitest instead of Rspec.</p>
3
3
  </p>
4
- <div class="table-wrapper">
4
+ <div class="full-width__table-wrapper">
5
5
  <table class="govuk-table">
6
6
  <thead class="govuk-table__head">
7
7
  <tr class="govuk-table__row" <% if show_application_name %> data-audit-headings<% end %>>
@@ -1,5 +1,5 @@
1
1
  <% content_for :title, "Component audit" %>
2
- <% content_for :body_classes, "table-container" %>
2
+ <% content_for :body_classes, "gem-full-width__container" %>
3
3
 
4
4
  <%= render "govuk_publishing_components/components/back_link", {
5
5
  href: "/component-guide",
@@ -5,7 +5,11 @@
5
5
  <ul class="govuk-list govuk-list--bullet govuk-list--spaced">
6
6
  <% local_assigns[:components].each do |component_doc| %>
7
7
  <li data-filter-item>
8
- <%= link_to component_doc.name, component_doc_path(component_doc.id), class: "govuk-link" %>
8
+ <% if local_assigns[:type] == "flexible_section" %>
9
+ <%= link_to component_doc.name, flexible_section_doc_path(component_doc.id), class: "govuk-link" %>
10
+ <% else %>
11
+ <%= link_to component_doc.name, component_doc_path(component_doc.id), class: "govuk-link" %>
12
+ <% end %>
9
13
  <p class="govuk-body">
10
14
  <%= component_doc.description %>
11
15
  </p>
@@ -1,7 +1,12 @@
1
- <div class="component-guide-preview component-guide-preview--no-margin
2
- <% if example.right_to_left? %>direction-rtl<% end %>
3
- <% if example.dark_background? %>dark-background<% end %>
4
- <% if example.black_background? %>black-background<% end %>
5
- <% if preview_page %>component-guide-preview--simple<% end %>">
1
+ <%
2
+ classes = %w[component-guide-preview component-guide-preview--no-margin]
3
+ classes << "direction-rtl" if example.right_to_left?
4
+ classes << "dark-background" if example.dark_background?
5
+ classes << "black-background" if example.black_background?
6
+ classes << "component-guide-preview--simple" if preview_page
7
+ classes << "gem-full-width__element" if example.full_width?
8
+ %>
9
+
10
+ <%= tag.div class: classes do %>
6
11
  <%= render "govuk_publishing_components/component_guide/component_doc/component_output", example: example, component_doc: component_doc %>
7
- </div>
12
+ <% end %>
@@ -1,10 +1,19 @@
1
+ <% content_for :body_classes, "gem-full-width__container", flush: true %>
2
+ <%
3
+ if @component_doc.type == "component"
4
+ data = example.html_safe_data
5
+ else
6
+ flexible_section_class = "FlexiblePage::FlexibleSection::#{@component_doc.id.titleize.gsub(" ", "")}".constantize
7
+ data = { flexible_section: flexible_section_class.new(**example.html_safe_data.deep_symbolize_keys)}
8
+ end
9
+ %>
1
10
  <% component = capture do %>
2
11
  <% if example.has_block? %>
3
- <%= render component_doc.partial_path, example.html_safe_data do %>
12
+ <%= render component_doc.partial_path, data do %>
4
13
  <%= render inline: example.block %>
5
14
  <% end %>
6
15
  <% else %>
7
- <%= render component_doc.partial_path, example.html_safe_data %>
16
+ <%= render component_doc.partial_path, data %>
8
17
  <% end %>
9
18
  <% end %>
10
19
 
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
  <h2 class="govuk-heading-m">
26
26
  How it looks
27
- <small class="govuk-!-font-size-16">(<a href="<%= component_preview_path(@component_doc.id, @component_example.id) %>" class="govuk-link">preview</a>)</small>
27
+ <small class="govuk-!-font-size-16">(<a href="<%= @preview_path %>" class="govuk-link">preview</a>)</small>
28
28
  </h2>
29
29
  <%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc, example: @component_example } %>
30
30
 
@@ -17,6 +17,13 @@
17
17
 
18
18
  <div data-module="filter-list" data-filter-label="Search components">
19
19
  <% if !ENV["MAIN_COMPONENT_GUIDE"] %>
20
+ <%= render partial: "component_list", locals: {
21
+ heading: "Flexible sections in this application",
22
+ size: @flexible_section_docs.length,
23
+ components: @flexible_section_docs,
24
+ type: "flexible_section",
25
+ } %>
26
+
20
27
  <%= render partial: "component_list", locals: {
21
28
  heading: "Components in this application",
22
29
  size: @component_docs.length,
@@ -5,9 +5,17 @@
5
5
  <% end %>
6
6
 
7
7
  <% @component_examples.each do |example| %>
8
+ <%
9
+ if @component_doc.type == "component"
10
+ example_path = component_example_path(@component_doc.id, example.id)
11
+ else
12
+ example_path = flexible_section_example_path(@component_doc.id, example.id)
13
+ end
14
+ %>
15
+
8
16
  <div class="component-guide-preview-page">
9
17
  <% if @component_examples.length > 1 %>
10
- <h2 class="preview-title"><a href="<%= component_example_path(@component_doc.id, example.id) %>"><%= example.name %></a></h2>
18
+ <h2 class="preview-title"><a href="<%= example_path %>"><%= example.name %></a></h2>
11
19
  <% end %>
12
20
  <div data-module="test-a11y" data-excluded-rules="<%= @component_doc.accessibility_excluded_rules %>">
13
21
  <%= render "govuk_publishing_components/component_guide/component_doc/component", component_doc: @component_doc, example: example, preview_page: true %>
@@ -1,4 +1,5 @@
1
- <% content_for :title, "#{@component_doc.name} component" %>
1
+ <% content_for :title, "#{@component_doc.name} #{@component_doc.type}" %>
2
+
2
3
  <% content_for :application_stylesheet do %>
3
4
  <% if @component_doc.source == "application" %>
4
5
  <%= render "application_stylesheet" %>
@@ -7,7 +8,7 @@
7
8
 
8
9
  <%= render "govuk_publishing_components/components/heading", {
9
10
  text: @component_doc.name,
10
- context: "Component",
11
+ context: @component_doc.type.capitalize,
11
12
  heading_level: 1,
12
13
  font_size: "xl",
13
14
  margin_bottom: 8,
@@ -30,7 +31,9 @@
30
31
  </div>
31
32
  </div>
32
33
  <% end %>
33
- <p class="govuk-body"><%= link_to "Search for usage of this component on GitHub", @component_doc.github_search_url, class: "govuk-link" %>.</p>
34
+ <% if @component_doc.type == "component" %>
35
+ <p class="govuk-body"><%= link_to "Search for usage of this component on GitHub", @component_doc.github_search_url, class: "govuk-link" %>.</p>
36
+ <% end %>
34
37
  </div>
35
38
  </div>
36
39
 
@@ -52,8 +55,8 @@
52
55
  href: "#overview",
53
56
  text: "Overview",
54
57
  items: [
55
- { href: "#how-it-looks", text: "How it looks" },
56
- { href: "#how-to-call-this-component", text: "How to call this component" },
58
+ ({ href: "#how-it-looks", text: "How it looks" } if @component_doc.display_preview? || @component_doc.display_html?),
59
+ { href: "#how-to-call-this-component", text: @component_doc.type == "component" ? "How to call this component" : "Passing data to this flexible section" },
57
60
  ({ href: "#govuk-design-system", text: "GOV.UK Design System" } if @component_doc.govuk_frontend_components.any?),
58
61
  ({ href: "#accessibility-acceptance-criteria", text: "Accessibility acceptance criteria" } if @component_doc.accessibility_criteria.present?),
59
62
  ].compact,
@@ -72,14 +75,23 @@
72
75
  </div>
73
76
 
74
77
  <h2 class="govuk-heading-l" id="overview">Overview</h2>
75
- <h3 class="govuk-heading-m" id="how-it-looks">
76
- <a href="<%= component_example_path(@component_doc.id, "default") %>" class="govuk-link">How it looks</a>
77
- <small class="govuk-!-font-size-16">(<a href="<%= component_preview_path(@component_doc.id, "default") %>" class="govuk-link">preview</a>)</small>
78
- <small class="govuk-!-font-size-16">(<a href="<%= component_preview_all_path(@component_doc.id) %>" class="govuk-link">preview all</a>)</small>
79
- </h3>
80
- <%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: @component_doc.example %>
78
+ <% if @component_doc.display_preview? || @component_doc.display_html? %>
79
+ <h3 class="govuk-heading-m" id="how-it-looks">
80
+ <a href="<%= @example_path %>" class="govuk-link">How it looks</a>
81
+ <small class="govuk-!-font-size-16">(<a href="<%= @preview_path %>" class="govuk-link">preview</a>)</small>
82
+ <small class="govuk-!-font-size-16">(<a href="<%= @preview_all_path %>" class="govuk-link">preview all</a>)</small>
83
+ </h3>
84
+ <%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: @component_doc.example %>
85
+ <% end %>
81
86
 
82
- <h3 class="govuk-heading-m govuk-!-margin-top-4" id="how-to-call-this-component">How to call this component</h3>
87
+ <% if @component_doc.type == "component" %>
88
+ <h3 class="govuk-heading-m govuk-!-margin-top-4" id="how-to-call-this-component">How to call this component</h3>
89
+ <% else %>
90
+ <h3 class="govuk-heading-m govuk-!-margin-top-4" id="how-to-call-this-component">Passing data to this flexible section</h3>
91
+ <div class="component-markdown component-markdown--no-margin">
92
+ <p>Flexible sections are not called in the way shown below, however this information serves as a reference for the data required by this flexible section.</p>
93
+ </div>
94
+ <% end %>
83
95
  <%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, example: @component_doc.example %>
84
96
 
85
97
  <% if @component_doc.govuk_frontend_components.any? %>
@@ -127,8 +139,17 @@
127
139
  <% @component_doc.other_examples.each do |example| %>
128
140
  <div class="component-example" id="<%= example.id %>">
129
141
  <h3 class="govuk-heading-m">
130
- <a href="<%= component_example_path(@component_doc.id, example.id) %>" class="govuk-link"><%= example.name %></a>
131
- <small>(<a href="<%= component_preview_path(@component_doc.id, example.id) %>" class="govuk-link">preview</a>)</small>
142
+ <%
143
+ if @component_doc.type == "component"
144
+ example_path = component_example_path(@component_doc.id, example.id)
145
+ preview_path = component_preview_path(@component_doc.id, example.id)
146
+ else
147
+ example_path = flexible_section_example_path(@component_doc.id, example.id)
148
+ preview_path = flexible_section_preview_path(@component_doc.id, example.id)
149
+ end
150
+ %>
151
+ <a href="<%= example_path %>" class="govuk-link"><%= example.name %></a>
152
+ <small>(<a href="<%= preview_path %>" class="govuk-link">preview</a>)</small>
132
153
  </h3>
133
154
  <% if example.html_description %>
134
155
  <div class="component-markdown component-markdown--no-margin">
data/config/routes.rb CHANGED
@@ -1,9 +1,17 @@
1
1
  GovukPublishingComponents::Engine.routes.draw do
2
2
  get "/audit" => "audit#show", as: :audit
3
3
  get "/applications" => "applications_page#show", as: :apps
4
+
5
+ scope "/flexible-sections/" do
6
+ get ":flexible_section" => "component_guide#show", as: :flexible_section_doc
7
+ get ":flexible_section/preview" => "component_guide#preview", as: :flexible_section_preview_all
8
+ get ":flexible_section/:example" => "component_guide#example", as: :flexible_section_example
9
+ get ":flexible_section/:example/preview" => "component_guide#preview", as: :flexible_section_preview
10
+ end
11
+
4
12
  root to: "component_guide#index", as: :component_guide
5
- get ":component/preview" => "component_guide#preview", as: :component_preview_all
6
- get ":component/:example/preview" => "component_guide#preview", as: :component_preview
7
13
  get ":component" => "component_guide#show", as: :component_doc
14
+ get ":component/preview" => "component_guide#preview", as: :component_preview_all
8
15
  get ":component/:example" => "component_guide#example", as: :component_example
16
+ get ":component/:example/preview" => "component_guide#preview", as: :component_preview
9
17
  end
@@ -25,6 +25,10 @@ module GovukPublishingComponents
25
25
  APP_COMPONENT_DIRECTORY
26
26
  end
27
27
 
28
+ def self.flexible_sections_directory_name
29
+ "flexible_page/flexible_sections"
30
+ end
31
+
28
32
  def self.gem_directory
29
33
  Gem::Specification.find_by_name("govuk_publishing_components").gem_dir
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "66.4.1".freeze
2
+ VERSION = "66.4.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 66.4.1
4
+ version: 66.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev