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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3dc010098e20d7c3f41d718c0f35fcfca619bd3
4
- data.tar.gz: d29bd6f7f3822e2d327e73f614db8ace63128235
3
+ metadata.gz: 964f3e0359c0d4bc49f3bd8e40c6735569a492c2
4
+ data.tar.gz: f4ff341d71b97c332a0b642ee27e43f1367bc8e8
5
5
  SHA512:
6
- metadata.gz: 31d55fa0966460daa1476332d765c43e19e83c3acff69b558474165f63158674da3080349dc8d2a7e512f6e0113b4a57236415d27cafeacfa3b6bcc8d39491ea
7
- data.tar.gz: f87f4b14640ba594300a97e65e616236e2f2048d6abbd86537c7b02bf7e89bc919c468b7852e679b279aab074e16e698a4e87c4c6fdb613afd2086d02295c5a6
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
- .fixtures {
126
- .component-fixture {
130
+ .examples {
131
+ .component-example {
127
132
  margin: 0 0 $gutter * 1.5;
128
133
 
129
- .fixture-title {
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 fixture
14
+ def example
15
15
  @component_doc = component_documentation_resolver.get(params[:component])
16
- @component_fixture = @component_doc.fixtures.find { |f| f.id == params[:fixture] }
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, @component_fixture),
19
+ component_breadcrumb(@component_doc, @component_example),
20
20
  {
21
- title: @component_fixture.name
21
+ title: @component_example.name
22
22
  }
23
23
  ]
24
24
  end
25
25
 
26
26
  def preview
27
- @component_fixtures = []
27
+ @component_examples = []
28
28
  @component_doc = component_documentation_resolver.get(params[:component])
29
29
  @preview = true
30
30
 
31
- if params[:fixture].present?
32
- @component_fixtures.push(@component_doc.fixtures.find { |f| f.id == params[:fixture] })
31
+ if params[:example].present?
32
+ @component_examples.push(@component_doc.examples.find { |f| f.id == params[:example] })
33
33
  else
34
- @component_fixtures = @component_doc.fixtures
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, component_fixture = nil)
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 component_fixture
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
- :fixtures
8
+ :examples
9
9
 
10
- def initialize(id, name, description, body, accessibility_criteria, fixtures)
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
- @fixtures = fixtures
16
+ @examples = examples
17
17
  end
18
18
 
19
- def fixture
20
- fixtures.first
19
+ def example
20
+ examples.first
21
21
  end
22
22
 
23
- def other_fixtures
24
- fixtures.slice(1..-1)
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
- fixtures = component[:fixtures].map { |id, data|
16
- ComponentFixture.new(id.to_s, data)
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
- fixtures)
25
+ examples)
25
26
  end
26
27
 
27
28
  def fetch_component_docs
@@ -1,11 +1,13 @@
1
1
  module GovukPublishingComponents
2
- class ComponentFixture
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>&lt;%= render '<%= @component_doc.partial_path %>'<% if fixture.data? %>, <%= fixture.pretty_data %><% end %> %&gt;</code></pre>
2
+ <pre class="language-ruby"><code>&lt;%= render '<%= @component_doc.partial_path %>'<% if example.data? %>, <%= example.pretty_data %><% end %> %&gt;</code></pre>
3
3
  </div>
@@ -1,3 +1,3 @@
1
- <div data-module="test-a11y" class="component-guide-preview">
2
- <%= render @component_doc.partial_path, fixture.html_safe_data %>
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>
@@ -1,12 +1,12 @@
1
- <% content_for :title, "#{@component_fixture.name} example - #{@component_doc.name} component" %>
2
- <%= render 'govuk_component/title', title: @component_fixture.name, context: "#{@component_doc.name} example" %>
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, fixture: @component_fixture } %>
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, fixture: @component_fixture } %>
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
- <% @component_fixtures.each do |fixture| %>
1
+ <% @component_examples.each do |example| %>
2
2
  <div class="component-guide-preview-page">
3
- <% if @component_fixtures.length > 1 %>
4
- <h2 class="preview-title"><a href="<%= component_fixture_path(@component_doc.id, fixture.id) %>"><%= fixture.name %></a></h2>
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
- <div data-module="test-a11y">
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, fixture: @component_doc.fixture %>
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, fixture: @component_doc.fixture %>
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.other_fixtures.any? %>
37
- <div class="fixtures">
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.other_fixtures.each do |fixture| %>
42
- <div class="component-fixture">
43
- <h3 class="fixture-title">
44
- <a href="<%= component_fixture_path(@component_doc.id, fixture.id) %>"><%= fixture.name %></a>
45
- <small>(<a href="<%= component_preview_path(@component_doc.id, fixture.id) %>">preview</a>)</small>
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, fixture: fixture %>
48
- <%= render "govuk_publishing_components/component_guide/component_doc/preview", component_doc: @component_doc, fixture: fixture %>
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 @component_fixtures.length == 1 %>:
7
- <%= @component_fixtures.first.name %>
6
+ <%= @component_doc.name %><% if @component_examples.length == 1 %>:
7
+ <%= @component_examples.first.name %>
8
8
  <% end %>
9
9
  preview -
10
10
  <% end %>
@@ -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/:fixture/preview' => 'component_guide#preview', as: :component_preview
4
+ get ':component/:example/preview' => 'component_guide#preview', as: :component_preview
5
5
  get ':component' => 'component_guide#show', as: :component_doc
6
- get ':component/:fixture' => 'component_guide#fixture', as: :component_fixture
6
+ get ':component/:example' => 'component_guide#example', as: :component_example
7
7
  end
@@ -8,5 +8,5 @@ accessibility_criteria: |
8
8
  The link must:
9
9
 
10
10
  * be keyboard focusable
11
- fixtures:
11
+ examples:
12
12
  default: {}
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '0.9.0'.freeze
2
+ VERSION = '1.0.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.9.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-25 00:00:00.000000000 Z
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/component_fixture.rb
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/fixture.html.erb
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