govuk_publishing_components 8.1.0 → 8.2.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/component_guide/application.scss +10 -0
  3. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +9 -5
  4. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +3 -2
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +12 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_phase-banner.scss +7 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +77 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +46 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss +2 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/print/_title.scss +7 -0
  11. data/app/controllers/govuk_publishing_components/component_guide_controller.rb +9 -9
  12. data/app/models/govuk_publishing_components/component_doc.rb +32 -20
  13. data/app/models/govuk_publishing_components/{component_doc_resolver.rb → component_docs.rb} +2 -27
  14. data/app/models/govuk_publishing_components/component_example.rb +4 -4
  15. data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb +1 -8
  16. data/app/views/govuk_publishing_components/component_guide/component_doc/_component_output.html.erb +7 -0
  17. data/app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb +7 -0
  18. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  19. data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -1
  20. data/app/views/govuk_publishing_components/component_guide/show.html.erb +2 -2
  21. data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +53 -0
  22. data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +13 -0
  23. data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +21 -1
  24. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +22 -0
  25. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +58 -0
  26. data/app/views/govuk_publishing_components/components/_title.html.erb +23 -0
  27. data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +1 -0
  28. data/app/views/govuk_publishing_components/components/docs/government_navigation.yml +18 -0
  29. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +10 -10
  30. data/app/views/govuk_publishing_components/components/docs/lead_paragraph.yml +22 -0
  31. data/app/views/govuk_publishing_components/components/docs/meta_tags.yml +1 -0
  32. data/app/views/govuk_publishing_components/components/docs/phase_banner.yml +21 -0
  33. data/app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml +64 -0
  34. data/app/views/govuk_publishing_components/components/docs/title.yml +63 -0
  35. data/lib/govuk_publishing_components.rb +1 -0
  36. data/lib/govuk_publishing_components/presenters/machine_readable/article_schema.rb +72 -0
  37. data/lib/govuk_publishing_components/presenters/machine_readable/news_article_schema.rb +16 -0
  38. data/lib/govuk_publishing_components/presenters/machine_readable/page.rb +47 -0
  39. data/lib/govuk_publishing_components/presenters/sanitisation.rb +13 -0
  40. data/lib/govuk_publishing_components/presenters/schema_org.rb +13 -101
  41. data/lib/govuk_publishing_components/version.rb +1 -1
  42. metadata +23 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 575de4ef4fef97453f60afc3d3ab388997efd80f10d76c9b7ee5860ca6423278
4
- data.tar.gz: 2a418743b25fa77ef0d553025f0d757642d4d2cf69ad6817402e77087f638894
3
+ metadata.gz: e88c86057a77da6fc577ecf2b7c95a5c37fdc6627335d6798838390be5e74658
4
+ data.tar.gz: 63dd6a60c53f6c03538e33a3880c88336a48978a92673d19e9e1f5db9a5b81ab
5
5
  SHA512:
6
- metadata.gz: 619fc4f95918f3f296d8981e9cbbb7ed3bccc7b56faa402e5b844c3b1057044ca5274b6ca7b5e684adc091e86f8a5a416eb50a4d86cb90e52f48b7f554b49f4b
7
- data.tar.gz: a46ec8e3951691469c222b91047967ee2c2822367ba04aae67dea3b68b34fe7d6b0cb65f0b6f3ce91db50c77cd1266eee94624e36b429f480c7fe82c7ee3392d
6
+ metadata.gz: 2df4fc9c44e66544eb54b8ccfab24989833888d9b82fca80f620cac81799a1ce8522ba9f1a59bb937469a876fa1005d4fde54c942fe563629ec447a491500162
7
+ data.tar.gz: 8c1dd8ccdebf70b01f695bad66b8f07532bf69d6c4914c7cc516cbaddcd169f5903015b39c41ed024dd7fd0b1363f97f972159d1a2bf6b6930d943dcfcdc03a7
@@ -106,6 +106,12 @@ $border-color: #ccc;
106
106
  }
107
107
  }
108
108
 
109
+ .component-output {
110
+ > pre {
111
+ max-height: 200px;
112
+ }
113
+ }
114
+
109
115
  .component-guide-preview {
110
116
  &.direction-rtl {
111
117
  direction: rtl;
@@ -116,6 +122,10 @@ $border-color: #ccc;
116
122
  background-color: $govuk-blue;
117
123
  }
118
124
 
125
+ &.component-output {
126
+ padding: 0;
127
+ }
128
+
119
129
  padding: ($gutter * 1.5) $gutter $gutter;
120
130
  border: 1px solid $border-colour;
121
131
  position: relative;
@@ -14,20 +14,24 @@
14
14
  @import "components/button";
15
15
  @import "components/document-list";
16
16
  @import "components/error-summary";
17
+ @import "components/feedback";
17
18
  @import "components/fieldset";
18
19
  @import "components/heading";
19
20
  @import "components/input";
21
+ @import "components/inverse-header";
20
22
  @import "components/label";
23
+ @import "components/lead-paragraph";
24
+ @import "components/phase-banner";
25
+ @import "components/previous-and-next-navigation";
21
26
  @import "components/radio";
22
27
  @import "components/related-navigation";
23
28
  @import "components/search";
24
- @import "components/step-by-step-nav";
29
+ @import "components/share-links";
25
30
  @import "components/step-by-step-nav-header";
26
31
  @import "components/step-by-step-nav-related";
32
+ @import "components/step-by-step-nav";
27
33
  @import "components/subscription-links";
28
- @import "components/translation-nav";
29
- @import "components/feedback";
30
- @import "components/inverse-header";
31
34
  @import "components/success-alert";
32
- @import "components/share-links";
33
35
  @import "components/taxonomy-navigation";
36
+ @import "components/title";
37
+ @import "components/translation-nav";
@@ -7,6 +7,7 @@
7
7
  @import "typography";
8
8
  @import "colours";
9
9
 
10
- @import "components/print/step-by-step-nav";
11
- @import "components/print/step-by-step-nav-header";
12
10
  @import "components/print/feedback";
11
+ @import "components/print/step-by-step-nav-header";
12
+ @import "components/print/step-by-step-nav";
13
+ @import "components/print/title";
@@ -0,0 +1,12 @@
1
+ @import "mixins/margins";
2
+
3
+ .gem-c-lead-paragraph {
4
+ @include core-24;
5
+ @include responsive-bottom-margin;
6
+ // Ensure the text has a line-length of around 60 characters
7
+ max-width: 30em;
8
+ }
9
+
10
+ .gem-c-lead-paragraph--inverse {
11
+ color: $white;
12
+ }
@@ -0,0 +1,7 @@
1
+ @import "mixins/touch-friendly-links";
2
+ @import "design-patterns/alpha-beta";
3
+
4
+ .gem-c-phase-banner {
5
+ @include phase-banner;
6
+ @include touch-friendly-links;
7
+ }
@@ -0,0 +1,77 @@
1
+ .gem-c-pagination {
2
+ display: block;
3
+ margin-top: $gutter;
4
+ margin-bottom: $gutter;
5
+ margin-left: -$gutter-half;
6
+ margin-right: -$gutter-half;
7
+ }
8
+
9
+ .gem-c-pagination__list {
10
+ margin: 0;
11
+ padding: 0;
12
+
13
+ &:after {
14
+ content: "";
15
+ display: block;
16
+ clear: both;
17
+ }
18
+ }
19
+
20
+ .gem-c-pagination__item {
21
+ @include core-16($line-height: (20 / 16));
22
+ list-style: none;
23
+ text-align: right;
24
+ margin: 0;
25
+ padding: 0;
26
+ }
27
+
28
+ .gem-c-pagination__link {
29
+ display: block;
30
+ padding: $gutter-half;
31
+ text-decoration: none;
32
+
33
+ &:visited {
34
+ color: $link-colour;
35
+ }
36
+
37
+ &:hover,
38
+ &:active {
39
+ background-color: $canvas-colour;
40
+ }
41
+ }
42
+
43
+ .gem-c-pagination__link-title {
44
+ @include core-27($line-height: (33.75 / 27));
45
+ display: block;
46
+ }
47
+
48
+ .gem-c-pagination__item--previous {
49
+ text-align: left;
50
+
51
+ @include media(tablet) {
52
+ float: left;
53
+ width: 50%;
54
+ }
55
+ }
56
+
57
+ .gem-c-pagination__item--next {
58
+ text-align: right;
59
+
60
+ @include media(tablet) {
61
+ float: right;
62
+ width: 50%;
63
+ }
64
+ }
65
+
66
+ .gem-c-pagination__link-icon {
67
+ display: inline-block;
68
+ margin-bottom: 1px;
69
+ height: .482em;
70
+ width: .63em;
71
+ }
72
+
73
+ .gem-c-pagination__link-label {
74
+ display: inline-block;
75
+ margin-top: 0.1em;
76
+ text-decoration: underline;
77
+ }
@@ -0,0 +1,46 @@
1
+ .gem-c-title {
2
+ @include responsive-top-margin;
3
+ }
4
+
5
+ .gem-c-title--bottom-margin {
6
+ @include responsive-bottom-margin;
7
+ }
8
+
9
+ .gem-c-title--inverse {
10
+ color: $white;
11
+
12
+ .gem-c-title__context {
13
+ color: inherit;
14
+ }
15
+ }
16
+
17
+ .gem-c-title__context {
18
+ @include core-24;
19
+ color: $secondary-text-colour;
20
+ }
21
+
22
+ .gem-c-title__context-link {
23
+ text-decoration: none;
24
+
25
+ &:link,
26
+ &:visited {
27
+ color: inherit;
28
+
29
+ &:focus {
30
+ color: $black;
31
+ }
32
+ }
33
+
34
+ &:hover,
35
+ &:focus {
36
+ text-decoration: underline;
37
+ }
38
+ }
39
+
40
+ .gem-c-title__text {
41
+ @include bold-48;
42
+ }
43
+
44
+ .gem-c-title__text--long {
45
+ @include bold-36;
46
+ }
@@ -1,3 +1,5 @@
1
+ @import "mixins/margins";
2
+
1
3
  .gem-c-translation-nav {
2
4
  @include responsive-top-margin;
3
5
  @include core-16;
@@ -0,0 +1,7 @@
1
+ .gem-c-title__context {
2
+ margin: 0;
3
+ }
4
+
5
+ .gem-c-title__text {
6
+ margin-top: 0;
7
+ }
@@ -3,17 +3,17 @@ module GovukPublishingComponents
3
3
  append_view_path File.join(Rails.root, "app", "views", GovukPublishingComponents::Config.component_directory_name)
4
4
 
5
5
  def index
6
- @component_docs = component_documentation_resolver.all
7
- @gem_component_docs = gem_component_documentation_resolver.all
6
+ @component_docs = component_docs.all
7
+ @gem_component_docs = gem_component_docs.all
8
8
  end
9
9
 
10
10
  def show
11
- @component_doc = component_documentation_resolver.get(params[:component])
11
+ @component_doc = component_docs.get(params[:component])
12
12
  @guide_breadcrumbs = [index_breadcrumb, component_breadcrumb(@component_doc)]
13
13
  end
14
14
 
15
15
  def example
16
- @component_doc = component_documentation_resolver.get(params[:component])
16
+ @component_doc = component_docs.get(params[:component])
17
17
  @component_example = @component_doc.examples.find { |f| f.id == params[:example] }
18
18
  @guide_breadcrumbs = [
19
19
  index_breadcrumb,
@@ -26,7 +26,7 @@ module GovukPublishingComponents
26
26
 
27
27
  def preview
28
28
  @component_examples = []
29
- @component_doc = component_documentation_resolver.get(params[:component])
29
+ @component_doc = component_docs.get(params[:component])
30
30
  @preview = true
31
31
 
32
32
  if params[:example].present?
@@ -38,12 +38,12 @@ module GovukPublishingComponents
38
38
 
39
39
  private
40
40
 
41
- def component_documentation_resolver
42
- @component_documentation_resolver ||= ComponentDocResolver.new
41
+ def component_docs
42
+ @component_docs ||= ComponentDocs.new
43
43
  end
44
44
 
45
- def gem_component_documentation_resolver
46
- @gem_component_documentation_resolver ||= ComponentDocResolver.new(gem_components: true)
45
+ def gem_component_docs
46
+ @gem_component_docs ||= ComponentDocs.new(gem_components: true)
47
47
  end
48
48
 
49
49
  def index_breadcrumb
@@ -4,29 +4,30 @@ module GovukPublishingComponents
4
4
  :name,
5
5
  :description,
6
6
  :body,
7
- :accessibility_criteria,
7
+ :component,
8
8
  :accessibility_excluded_rules,
9
- :examples,
10
9
  :source
11
10
 
12
- def initialize(
13
- id,
14
- name,
15
- description,
16
- body,
17
- accessibility_criteria,
18
- accessibility_excluded_rules,
19
- examples,
20
- source
21
- )
22
- @id = id
23
- @name = name
24
- @description = description
25
- @body = body
26
- @accessibility_criteria = accessibility_criteria
27
- @accessibility_excluded_rules = accessibility_excluded_rules
28
- @examples = examples
29
- @source = source
11
+ def initialize(component)
12
+ @component = component
13
+ @id = component[:id]
14
+ @name = component[:name]
15
+ @description = component[:description]
16
+ @body = component[:body]
17
+ @accessibility_excluded_rules = component[:accessibility_excluded_rules]
18
+ @source = component[:source]
19
+ end
20
+
21
+ def accessibility_criteria
22
+ shared_accessibility_criteria = []
23
+
24
+ if component[:shared_accessibility_criteria].present?
25
+ component[:shared_accessibility_criteria].each do |criteria|
26
+ shared_accessibility_criteria << SharedAccessibilityCriteria.send(criteria) if SharedAccessibilityCriteria.respond_to? criteria
27
+ end
28
+ end
29
+
30
+ "#{component[:accessibility_criteria]}\n#{shared_accessibility_criteria.join("\n")}"
30
31
  end
31
32
 
32
33
  def example
@@ -37,6 +38,10 @@ module GovukPublishingComponents
37
38
  examples.slice(1..-1)
38
39
  end
39
40
 
41
+ def display_html?
42
+ component[:display_html]
43
+ end
44
+
40
45
  def html_body
41
46
  govspeak_to_html(body) if body.present?
42
47
  end
@@ -58,6 +63,13 @@ module GovukPublishingComponents
58
63
  "https://github.com/search?#{params.to_query}"
59
64
  end
60
65
 
66
+ def examples
67
+ @examples ||= component[:examples].map do |id, example_data|
68
+ example_data = example_data || {}
69
+ ComponentExample.new(id.to_s, example_data)
70
+ end
71
+ end
72
+
61
73
  private
62
74
 
63
75
  def govspeak_to_html(govspeak)
@@ -1,6 +1,6 @@
1
1
  module GovukPublishingComponents
2
2
  # @private
3
- class ComponentDocResolver
3
+ class ComponentDocs
4
4
  def initialize(gem_components: false)
5
5
  @documentation_directory = gem_components ? gem_documentation_directory : app_documentation_directory
6
6
  end
@@ -17,32 +17,7 @@ module GovukPublishingComponents
17
17
  private
18
18
 
19
19
  def build(component)
20
- examples = component[:examples].map { |id, example|
21
- example = example || {}
22
- ComponentExample.new(id.to_s, example["data"], example["context"], example["description"])
23
- }
24
-
25
- ComponentDoc.new(
26
- component[:id],
27
- component[:name],
28
- component[:description],
29
- component[:body],
30
- combined_accessibility_criteria(component),
31
- component[:accessibility_excluded_rules],
32
- examples,
33
- component[:source],
34
- )
35
- end
36
-
37
- def combined_accessibility_criteria(component)
38
- shared_accessibility_criteria = []
39
-
40
- if component[:shared_accessibility_criteria].present?
41
- component[:shared_accessibility_criteria].each do |criteria|
42
- shared_accessibility_criteria << SharedAccessibilityCriteria.send(criteria) if SharedAccessibilityCriteria.respond_to? criteria
43
- end
44
- end
45
- "#{component[:accessibility_criteria]}\n#{shared_accessibility_criteria.join("\n")}"
20
+ ComponentDoc.new(component)
46
21
  end
47
22
 
48
23
  def fetch_component_docs
@@ -8,11 +8,11 @@ module GovukPublishingComponents
8
8
  :description,
9
9
  :block
10
10
 
11
- def initialize(id, data, context, description)
11
+ def initialize(id, example)
12
12
  @id = id
13
- @data = data || {}
14
- @context = context || {}
15
- @description = description || false
13
+ @data = example["data"] || {}
14
+ @context = example["context"] || {}
15
+ @description = example["description"] || false
16
16
  @block = @data.delete(:block) || false
17
17
  end
18
18
 
@@ -2,12 +2,5 @@
2
2
  <% if example.right_to_left? %>direction-rtl<% end %>
3
3
  <% if example.dark_background? %>dark-background<% end %>
4
4
  <% if preview_page %>component-guide-preview--simple<% end %>" data-content="EXAMPLE">
5
-
6
- <% if example.has_block? %>
7
- <%= render component_doc.partial_path, example.html_safe_data do %>
8
- <%= example.block.html_safe %>
9
- <% end %>
10
- <% else %>
11
- <%= render component_doc.partial_path, example.html_safe_data %>
12
- <% end %>
5
+ <%= render "govuk_publishing_components/component_guide/component_doc/component_output", example: example, component_doc: component_doc %>
13
6
  </div>
@@ -0,0 +1,7 @@
1
+ <% if example.has_block? %>
2
+ <%= render component_doc.partial_path, example.html_safe_data do %>
3
+ <%= example.block.html_safe %>
4
+ <% end %>
5
+ <% else %>
6
+ <%= render component_doc.partial_path, example.html_safe_data %>
7
+ <% end %>