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 +4 -4
- data/README.md +7 -4
- data/app/assets/stylesheets/govuk_publishing_components/component_guide.scss +20 -17
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +1 -1
- data/app/models/govuk_publishing_components/component_doc.rb +33 -6
- data/app/views/govuk_publishing_components/component_guide/fixture.html.erb +2 -2
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +29 -11
- data/lib/govuk_publishing_components/engine.rb +1 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3efca617e49332732b085542512ded6a4570968
|
4
|
+
data.tar.gz: ba6a107353480ed2ebc197d6fc099050b5a93ac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
66
|
-
description:
|
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
|
-
|
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 *
|
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
|
-
|
33
|
-
|
34
|
-
|
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 *
|
111
|
+
margin: 0 0 $gutter * 1.5;
|
109
112
|
|
110
113
|
.fixture-title {
|
111
114
|
@include bold-24;
|
@@ -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
|
-
|
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],
|
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
|
30
|
-
|
31
|
-
|
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
|
-
<
|
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
|
-
<
|
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
|
-
<
|
11
|
-
<%= render
|
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
|
-
<
|
22
|
+
<h2 class="component-doc-h2">How it looks</h2>
|
14
23
|
</div>
|
15
24
|
|
16
|
-
<%= render
|
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="
|
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
|
27
|
-
<%= render
|
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>
|
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.
|
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-
|
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
|