govuk_publishing_components 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbb83256986e4545e64248565b7cba15736e7a32
4
- data.tar.gz: 1ff9fb3cacb3adb715aa8af6e6d16330ddacf5f2
3
+ metadata.gz: e3efca617e49332732b085542512ded6a4570968
4
+ data.tar.gz: ba6a107353480ed2ebc197d6fc099050b5a93ac3
5
5
  SHA512:
6
- metadata.gz: 8405daba61f51141903fcae33350c808b136dec08e85e4ad4ad8c03c6ba006d13ed2cf328adbfbf5a89064f8bfd6e2f54cd430420025f61135ad3c7c5104a720
7
- data.tar.gz: 87809be46cbb2ba31c581d7e01c408632dc4951c3086c975f7ce909cee5282b46403d8714c4c80c2e24ed6a85049af5213a7d097948d84022ea02f5a931020c2
6
+ metadata.gz: 7fc02fd56242e42a451d4c87cc4e1c1bb98e14e9a18a82b7fb406896e3ce7ba262b4e1eb3f28aa3fa374210dd23deb7ba750d859972c4b36d6661a7467a5b642
7
+ data.tar.gz: 634be50179e617b3b64090ab9d4c5700f45693978641959cad04327e8c5f7eeb775cd850128c5b4d4ecd3d552d000ae2156603043c25f13d6bf7292caa3fffe0
data/README.md CHANGED
@@ -62,12 +62,15 @@ The `.yml` file must have:
62
62
  #### Example documentation
63
63
 
64
64
  ```yaml
65
- name: Withdrawal notice
66
- description: A banner that displays when content is withdrawn
65
+ name: Name of component
66
+ description: Short description of component
67
+ body: |
68
+ Optional markdown providing further detail about the component
69
+ acceptance_criteria: |
70
+ Markdown listing what this component must do to be accessible
67
71
  fixtures:
68
72
  default:
69
- title: 'This consultation was withdrawn on 20 April 2017'
70
- explanation_html: '<p>A supporting paragraph</p>'
73
+ some_parameter: 'The parameter value'
71
74
  ```
72
75
 
73
76
  ### Configuration
@@ -2,7 +2,7 @@ $prism-background: #f5f2f0;
2
2
  $border-color: #ccc;
3
3
 
4
4
  .govuk-component-guide-wrapper {
5
- padding-bottom: $gutter * 2;
5
+ padding-bottom: $gutter * 1.5;
6
6
  }
7
7
 
8
8
  .component-list {
@@ -15,11 +15,20 @@ $border-color: #ccc;
15
15
  .component-description {
16
16
  @include core-24;
17
17
  max-width: 30em;
18
+ margin-bottom: $gutter * 1.5;
19
+ }
20
+
21
+ .component-body {
22
+ margin-bottom: $gutter * 1.5;
18
23
  }
19
24
 
20
25
  .component-doc {
21
26
  @include core-16;
22
27
 
28
+ .component-doc-h2:first-child {
29
+ margin-top: 0;
30
+ }
31
+
23
32
  p {
24
33
  margin: $gutter-half 0;
25
34
  }
@@ -28,11 +37,16 @@ $border-color: #ccc;
28
37
  ul {
29
38
  margin: 0 0 0 $gutter;
30
39
  }
40
+ }
31
41
 
32
- h3 {
33
- margin: $gutter 0 $gutter-half;
34
- @include bold-19;
35
- }
42
+ .component-doc-h2 {
43
+ @include bold-27;
44
+ margin: ($gutter * 1.5) 0 $gutter;
45
+ }
46
+
47
+ .component-doc-h3 {
48
+ margin: $gutter 0 $gutter-half;
49
+ @include bold-19;
36
50
  }
37
51
 
38
52
  .component-guide-preview {
@@ -93,19 +107,8 @@ $border-color: #ccc;
93
107
  }
94
108
 
95
109
  .fixtures {
96
- margin-top: $gutter * 2;
97
-
98
- .fixtures-title {
99
- @include bold-27;
100
- margin: $gutter 0;
101
-
102
- small {
103
- @include bold-16;
104
- }
105
- }
106
-
107
110
  .component-fixture {
108
- margin: 0 0 $gutter * 2;
111
+ margin: 0 0 $gutter * 1.5;
109
112
 
110
113
  .fixture-title {
111
114
  @include bold-24;
@@ -1,5 +1,5 @@
1
1
  module GovukPublishingComponents
2
- class ComponentGuideController < ApplicationController
2
+ class ComponentGuideController < GovukPublishingComponents::ApplicationController
3
3
  append_view_path File.join(Rails.root, "app", "views", "components")
4
4
 
5
5
  def index
@@ -1,7 +1,8 @@
1
1
  module GovukPublishingComponents
2
- ComponentDoc = Struct.new(:id, :name, :description, :body, :fixtures) do
2
+ ComponentDoc = Struct.new(:id, :name, :description, :body, :accessibility_criteria, :fixtures) do
3
3
  def self.get(id)
4
- all.find { |component| component.id == id }
4
+ component = fetch_component_doc(id)
5
+ self.build(component)
5
6
  end
6
7
 
7
8
  def self.all
@@ -13,7 +14,12 @@ module GovukPublishingComponents
13
14
  GovukPublishingComponents::ComponentFixture.new(id.to_s, data)
14
15
  }
15
16
 
16
- self.new(component[:id], component[:name], component[:description], component[:body], fixtures)
17
+ self.new(component[:id],
18
+ component[:name],
19
+ component[:description],
20
+ component[:body],
21
+ component[:accessibility_criteria],
22
+ fixtures)
17
23
  end
18
24
 
19
25
  def fixture
@@ -26,9 +32,30 @@ module GovukPublishingComponents
26
32
 
27
33
  def self.fetch_component_docs
28
34
  doc_files = Rails.root.join("app", "views", "components", "docs", "*.yml")
29
- Dir[doc_files].sort.map do |file|
30
- { id: File.basename(file, ".yml") }.merge(YAML::load_file(file)).with_indifferent_access
31
- end
35
+ Dir[doc_files].sort.map { |file| parse_documentation(file) }
36
+ end
37
+
38
+ def self.fetch_component_doc(id)
39
+ file = Rails.root.join("app", "views", "components", "docs", "#{id}.yml")
40
+ parse_documentation(file)
41
+ end
42
+
43
+ def self.parse_documentation(file)
44
+ { id: File.basename(file, ".yml") }.merge(YAML::load_file(file)).with_indifferent_access
45
+ end
46
+
47
+ def html_body
48
+ govspeak_to_html(body) if body.present?
49
+ end
50
+
51
+ def html_accessibility_criteria
52
+ govspeak_to_html(accessibility_criteria) if accessibility_criteria.present?
53
+ end
54
+
55
+ private
56
+
57
+ def govspeak_to_html(govspeak)
58
+ Govspeak::Document.new(govspeak).to_html
32
59
  end
33
60
  end
34
61
  end
@@ -3,10 +3,10 @@
3
3
 
4
4
  <div class="component-show">
5
5
  <div class="component-doc">
6
- <h3>How to call this example</h3>
6
+ <h2 class="component-doc-h2">How to call this example</h2>
7
7
  <%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc, fixture: @component_fixture } %>
8
8
 
9
- <h3>How it looks</h3>
9
+ <h2 class="component-doc-h2">How it looks</h2>
10
10
  <%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc, fixture: @component_fixture } %>
11
11
  </div>
12
12
  </div>
@@ -1,30 +1,48 @@
1
1
  <% content_for :title, "#{@component_doc.name} component" %>
2
2
  <%= render 'govuk_component/title', title: @component_doc.name, context: 'Component' %>
3
3
 
4
- <p class="component-description">
5
- <%= @component_doc.description %>
6
- </p>
7
-
8
4
  <div class="component-show">
5
+ <div class="grid-row">
6
+ <div class="column-two-thirds">
7
+ <p class="component-description">
8
+ <%= @component_doc.description %>
9
+ </p>
10
+ <% if @component_doc.body.present? %>
11
+ <div class="component-body">
12
+ <%= render 'govuk_component/govspeak', content: @component_doc.html_body %>
13
+ </div>
14
+ <% end %>
15
+ </div>
16
+ </div>
17
+
9
18
  <div class="component-doc">
10
- <h3>How to call this component</h3>
11
- <%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc, fixture: @component_doc.fixture } %>
19
+ <h2 class="component-doc-h2">How to call this component</h2>
20
+ <%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, fixture: @component_doc.fixture %>
12
21
 
13
- <h3>How it looks</h3>
22
+ <h2 class="component-doc-h2">How it looks</h2>
14
23
  </div>
15
24
 
16
- <%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc, fixture: @component_doc.fixture } %>
25
+ <%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, fixture: @component_doc.fixture %>
26
+
27
+ <% if @component_doc.accessibility_criteria.present? %>
28
+ <div class="grid-row component-accessibility-criteria">
29
+ <div class="column-two-thirds">
30
+ <h2 class="component-doc-h2">Accessibility acceptance criteria</h2>
31
+ <%= render 'govuk_component/govspeak', content: @component_doc.html_accessibility_criteria %>
32
+ </div>
33
+ </div>
34
+ <% end %>
17
35
 
18
36
  <% if @component_doc.other_fixtures.any? %>
19
37
  <div class="fixtures">
20
- <h2 class="fixtures-title">Other examples</h2>
38
+ <h2 class="component-doc-h2">Other examples</h2>
21
39
  <% @component_doc.other_fixtures.each do |fixture| %>
22
40
  <div class="component-fixture">
23
41
  <h3 class="fixture-title">
24
42
  <a href="<%= component_fixture_path(@component_doc.id, fixture.id) %>"><%= fixture.name %></a>
25
43
  </h3>
26
- <%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc, fixture: fixture } %>
27
- <%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc, fixture: fixture } %>
44
+ <%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, fixture: fixture %>
45
+ <%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, fixture: fixture %>
28
46
  </div>
29
47
  <% end %>
30
48
  </div>
@@ -2,5 +2,6 @@ module GovukPublishingComponents
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace GovukPublishingComponents
4
4
  require 'govuk_frontend_toolkit'
5
+ require 'govspeak'
5
6
  end
6
7
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2017-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: govspeak
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 5.0.3
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 5.0.3
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: govuk-lint
77
91
  requirement: !ruby/object:Gem::Requirement