govuk_publishing_components 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/component_guide.scss +8 -3
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +10 -10
- data/app/models/govuk_publishing_components/component_doc.rb +7 -7
- data/app/models/govuk_publishing_components/component_doc_resolver.rb +4 -3
- data/app/models/govuk_publishing_components/{component_fixture.rb → component_example.rb} +10 -4
- data/app/views/govuk_publishing_components/component_guide/component_doc/_call.html.erb +1 -1
- data/app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb +2 -2
- data/app/views/govuk_publishing_components/component_guide/{fixture.html.erb → example.html.erb} +4 -4
- data/app/views/govuk_publishing_components/component_guide/preview.html.erb +4 -6
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +11 -11
- data/app/views/layouts/govuk_publishing_components/application.html.erb +2 -2
- data/config/routes.rb +2 -2
- data/lib/generators/govuk_publishing_components/templates/component.yml.erb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 964f3e0359c0d4bc49f3bd8e40c6735569a492c2
|
4
|
+
data.tar.gz: f4ff341d71b97c332a0b642ee27e43f1367bc8e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69201660752e0a7a58a565563ff83b1f8632d99df40cae14fefa81a0cd67d17022007e0377f04b9f7879f1cee03dc40b38fa480046afa2fb4d09e7458da55d89
|
7
|
+
data.tar.gz: 3d961bc24e02413fbc21087588cc21adfcfcf51efe550194c4e86bfa1b21bf4cdbc894a7299b27c1689c870bfe6636901f03d5156d03ffc5d9c31d9a7c952272
|
@@ -99,6 +99,11 @@ $border-color: #ccc;
|
|
99
99
|
}
|
100
100
|
|
101
101
|
.component-guide-preview {
|
102
|
+
&.direction-rtl {
|
103
|
+
direction: rtl;
|
104
|
+
text-align: start;
|
105
|
+
}
|
106
|
+
|
102
107
|
padding: ($gutter * 1.5) $gutter $gutter;
|
103
108
|
border: 1px solid $border-colour;
|
104
109
|
position: relative;
|
@@ -122,11 +127,11 @@ $border-color: #ccc;
|
|
122
127
|
}
|
123
128
|
}
|
124
129
|
|
125
|
-
.
|
126
|
-
.component-
|
130
|
+
.examples {
|
131
|
+
.component-example {
|
127
132
|
margin: 0 0 $gutter * 1.5;
|
128
133
|
|
129
|
-
.
|
134
|
+
.example-title {
|
130
135
|
@include bold-24;
|
131
136
|
margin: $gutter-half 0;
|
132
137
|
|
@@ -11,27 +11,27 @@ module GovukPublishingComponents
|
|
11
11
|
@guide_breadcrumbs = [index_breadcrumb, component_breadcrumb(@component_doc)]
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def example
|
15
15
|
@component_doc = component_documentation_resolver.get(params[:component])
|
16
|
-
@
|
16
|
+
@component_example = @component_doc.examples.find { |f| f.id == params[:example] }
|
17
17
|
@guide_breadcrumbs = [
|
18
18
|
index_breadcrumb,
|
19
|
-
component_breadcrumb(@component_doc, @
|
19
|
+
component_breadcrumb(@component_doc, @component_example),
|
20
20
|
{
|
21
|
-
title: @
|
21
|
+
title: @component_example.name
|
22
22
|
}
|
23
23
|
]
|
24
24
|
end
|
25
25
|
|
26
26
|
def preview
|
27
|
-
@
|
27
|
+
@component_examples = []
|
28
28
|
@component_doc = component_documentation_resolver.get(params[:component])
|
29
29
|
@preview = true
|
30
30
|
|
31
|
-
if params[:
|
32
|
-
@
|
31
|
+
if params[:example].present?
|
32
|
+
@component_examples.push(@component_doc.examples.find { |f| f.id == params[:example] })
|
33
33
|
else
|
34
|
-
@
|
34
|
+
@component_examples = @component_doc.examples
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -48,10 +48,10 @@ module GovukPublishingComponents
|
|
48
48
|
}
|
49
49
|
end
|
50
50
|
|
51
|
-
def component_breadcrumb(component_doc,
|
51
|
+
def component_breadcrumb(component_doc, component_example = nil)
|
52
52
|
Hash.new.tap do |h|
|
53
53
|
h[:title] = component_doc.name
|
54
|
-
h[:url] = component_doc_path(component_doc.id) if
|
54
|
+
h[:url] = component_doc_path(component_doc.id) if component_example
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -5,23 +5,23 @@ module GovukPublishingComponents
|
|
5
5
|
:description,
|
6
6
|
:body,
|
7
7
|
:accessibility_criteria,
|
8
|
-
:
|
8
|
+
:examples
|
9
9
|
|
10
|
-
def initialize(id, name, description, body, accessibility_criteria,
|
10
|
+
def initialize(id, name, description, body, accessibility_criteria, examples)
|
11
11
|
@id = id
|
12
12
|
@name = name
|
13
13
|
@description = description
|
14
14
|
@body = body
|
15
15
|
@accessibility_criteria = accessibility_criteria
|
16
|
-
@
|
16
|
+
@examples = examples
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
19
|
+
def example
|
20
|
+
examples.first
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def other_examples
|
24
|
+
examples.slice(1..-1)
|
25
25
|
end
|
26
26
|
|
27
27
|
def html_body
|
@@ -12,8 +12,9 @@ module GovukPublishingComponents
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def build(component)
|
15
|
-
|
16
|
-
|
15
|
+
examples = component[:examples].map { |id, example|
|
16
|
+
example = example || {}
|
17
|
+
ComponentExample.new(id.to_s, example["data"], example["context"])
|
17
18
|
}
|
18
19
|
|
19
20
|
ComponentDoc.new(component[:id],
|
@@ -21,7 +22,7 @@ module GovukPublishingComponents
|
|
21
22
|
component[:description],
|
22
23
|
component[:body],
|
23
24
|
component[:accessibility_criteria],
|
24
|
-
|
25
|
+
examples)
|
25
26
|
end
|
26
27
|
|
27
28
|
def fetch_component_docs
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module GovukPublishingComponents
|
2
|
-
class
|
2
|
+
class ComponentExample
|
3
3
|
attr_reader :id,
|
4
|
-
:data
|
4
|
+
:data,
|
5
|
+
:context
|
5
6
|
|
6
|
-
def initialize(id, data)
|
7
|
+
def initialize(id, data, context)
|
7
8
|
@id = id
|
8
|
-
@data = data
|
9
|
+
@data = data || {}
|
10
|
+
@context = context || {}
|
9
11
|
end
|
10
12
|
|
11
13
|
def name
|
@@ -42,5 +44,9 @@ module GovukPublishingComponents
|
|
42
44
|
obj
|
43
45
|
end
|
44
46
|
end
|
47
|
+
|
48
|
+
def right_to_left?
|
49
|
+
!!context['right_to_left']
|
50
|
+
end
|
45
51
|
end
|
46
52
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<div class="component-call code-block" contenteditable>
|
2
|
-
<pre class="language-ruby"><code><%= render '<%= @component_doc.partial_path %>'<% if
|
2
|
+
<pre class="language-ruby"><code><%= render '<%= @component_doc.partial_path %>'<% if example.data? %>, <%= example.pretty_data %><% end %> %></code></pre>
|
3
3
|
</div>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<div data-module="test-a11y" class="component-guide-preview">
|
2
|
-
<%= render
|
1
|
+
<div data-module="test-a11y" class="component-guide-preview <% if example.right_to_left? %>direction-rtl<% end %>">
|
2
|
+
<%= render component_doc.partial_path, example.html_safe_data %>
|
3
3
|
</div>
|
data/app/views/govuk_publishing_components/component_guide/{fixture.html.erb → example.html.erb}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
|
-
<% content_for :title, "#{@
|
2
|
-
<%= render 'govuk_component/title', title: @
|
1
|
+
<% content_for :title, "#{@component_example.name} example - #{@component_doc.name} component" %>
|
2
|
+
<%= render 'govuk_component/title', title: @component_example.name, context: "#{@component_doc.name} example" %>
|
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
|
-
<%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc,
|
7
|
+
<%= render partial: "govuk_publishing_components/component_guide/component_doc/call", locals: { component_doc: @component_doc, example: @component_example } %>
|
8
8
|
|
9
9
|
<h2 class="component-doc-h2">How it looks</h2>
|
10
|
-
<%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc,
|
10
|
+
<%= render partial: "govuk_publishing_components/component_guide/component_doc/preview", locals: { component_doc: @component_doc, example: @component_example } %>
|
11
11
|
</div>
|
12
12
|
</div>
|
@@ -1,10 +1,8 @@
|
|
1
|
-
<% @
|
1
|
+
<% @component_examples.each do |example| %>
|
2
2
|
<div class="component-guide-preview-page">
|
3
|
-
<% if @
|
4
|
-
<h2 class="preview-title"><a href="<%=
|
3
|
+
<% if @component_examples.length > 1 %>
|
4
|
+
<h2 class="preview-title"><a href="<%= component_example_path(@component_doc.id, example.id) %>"><%= example.name %></a></h2>
|
5
5
|
<% end %>
|
6
|
-
|
7
|
-
<%= render @component_doc.partial_path, fixture.html_safe_data %>
|
8
|
-
</div>
|
6
|
+
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: example %>
|
9
7
|
</div>
|
10
8
|
<% end %>
|
@@ -17,12 +17,12 @@
|
|
17
17
|
|
18
18
|
<div class="component-doc">
|
19
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,
|
20
|
+
<%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, example: @component_doc.example %>
|
21
21
|
|
22
22
|
<h2 class="component-doc-h2">How it looks</h2>
|
23
23
|
</div>
|
24
24
|
|
25
|
-
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc,
|
25
|
+
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: @component_doc.example %>
|
26
26
|
|
27
27
|
<% if @component_doc.accessibility_criteria.present? %>
|
28
28
|
<div class="grid-row component-accessibility-criteria">
|
@@ -33,19 +33,19 @@
|
|
33
33
|
</div>
|
34
34
|
<% end %>
|
35
35
|
|
36
|
-
<% if @component_doc.
|
37
|
-
<div class="
|
36
|
+
<% if @component_doc.other_examples.any? %>
|
37
|
+
<div class="examples">
|
38
38
|
<h2 class="component-doc-h2">Other examples
|
39
39
|
<small>(<a href="<%= component_preview_all_path(@component_doc.id) %>">preview all</a>)</small>
|
40
40
|
</h2>
|
41
|
-
<% @component_doc.
|
42
|
-
<div class="component-
|
43
|
-
<h3 class="
|
44
|
-
<a href="<%=
|
45
|
-
<small>(<a href="<%= component_preview_path(@component_doc.id,
|
41
|
+
<% @component_doc.other_examples.each do |example| %>
|
42
|
+
<div class="component-example">
|
43
|
+
<h3 class="example-title">
|
44
|
+
<a href="<%= component_example_path(@component_doc.id, example.id) %>"><%= example.name %></a>
|
45
|
+
<small>(<a href="<%= component_preview_path(@component_doc.id, example.id) %>">preview</a>)</small>
|
46
46
|
</h3>
|
47
|
-
<%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc,
|
48
|
-
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc,
|
47
|
+
<%= render "govuk_publishing_components/component_guide/component_doc/call", component_doc: @component_doc, example: example %>
|
48
|
+
<%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, example: example %>
|
49
49
|
</div>
|
50
50
|
<% end %>
|
51
51
|
</div>
|
@@ -3,8 +3,8 @@
|
|
3
3
|
<head>
|
4
4
|
<title>
|
5
5
|
<% if @preview %>
|
6
|
-
<%= @component_doc.name %><% if @
|
7
|
-
<%= @
|
6
|
+
<%= @component_doc.name %><% if @component_examples.length == 1 %>:
|
7
|
+
<%= @component_examples.first.name %>
|
8
8
|
<% end %>
|
9
9
|
preview -
|
10
10
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GovukPublishingComponents::Engine.routes.draw do
|
2
2
|
root :to => 'component_guide#index', as: :component_guide
|
3
3
|
get ':component/preview' => 'component_guide#preview', as: :component_preview_all
|
4
|
-
get ':component/:
|
4
|
+
get ':component/:example/preview' => 'component_guide#preview', as: :component_preview
|
5
5
|
get ':component' => 'component_guide#show', as: :component_doc
|
6
|
-
get ':component/:
|
6
|
+
get ':component/:example' => 'component_guide#example', as: :component_example
|
7
7
|
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.
|
4
|
+
version: 1.0.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-08-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -186,10 +186,10 @@ files:
|
|
186
186
|
- app/helpers/govuk_publishing_components/application_helper.rb
|
187
187
|
- app/models/govuk_publishing_components/component_doc.rb
|
188
188
|
- app/models/govuk_publishing_components/component_doc_resolver.rb
|
189
|
-
- app/models/govuk_publishing_components/
|
189
|
+
- app/models/govuk_publishing_components/component_example.rb
|
190
190
|
- app/views/govuk_publishing_components/component_guide/component_doc/_call.html.erb
|
191
191
|
- app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb
|
192
|
-
- app/views/govuk_publishing_components/component_guide/
|
192
|
+
- app/views/govuk_publishing_components/component_guide/example.html.erb
|
193
193
|
- app/views/govuk_publishing_components/component_guide/index.html.erb
|
194
194
|
- app/views/govuk_publishing_components/component_guide/preview.html.erb
|
195
195
|
- app/views/govuk_publishing_components/component_guide/show.html.erb
|