publishing_platform_publishing_components 0.1.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd01d35952a87cf92b3a809b7628e56626ece151e2d565e50a01b3f2b9f2e061
4
- data.tar.gz: ba093a8a4bdaf481ee512f9591b1e8c5c1ac07e7c47b282d67d6e6040b6d4b65
3
+ metadata.gz: 121be41623e1a6fcce5729c8ab46a2de53cd72df59cf9db2b5e1c10f45392145
4
+ data.tar.gz: 524450f95947aae19261304a6301ce9a58ecd11279eb68447e14c1486a96ec40
5
5
  SHA512:
6
- metadata.gz: 3d2483aaec570385b5ccb72fa91d69f6a823e4759f89bcca713ad1581611a7ddf7e2dda58ceb02f6443bfb25467039828530f78d25e84baf9fd5987768eb334c
7
- data.tar.gz: 0eec104aef8ff7d932dbffc0b218707c8ba0c7032d9d89c62b4c025baea141693ed3a7886f813499717ffc4add6eaf82b5407e3da1d7be8369263767d3660a33
6
+ metadata.gz: d7509f2fc53b6fd6ce9c265418027256614ba9ed5b014b660cb51f79c3e21967c4defa2be3189fc4621902211f7e6b8f4a084620fa63d45e5b55a217ba2f221b
7
+ data.tar.gz: 264583c82dece2d71a0018148848ca1d31661845e2a96d0de8796f18474f95e0f1f015fe8fe6bd6f97b3f6454e4748619f38fe1ac650f72f62ccc23ab141b7bc
@@ -1,3 +1,4 @@
1
1
  @import "bootstrap";
2
2
  @import "components/attachment";
3
+ @import "components/attachment-link";
3
4
  @import "components/summary-list";
@@ -0,0 +1,21 @@
1
+ @import 'functions';
2
+ @import 'variables';
3
+ @import 'mixins';
4
+
5
+ .gem-c-attachment-link__abbr {
6
+ text-decoration: none !important;
7
+ cursor: help;
8
+ }
9
+
10
+ // stylelint-disable declaration-no-important
11
+ @media print {
12
+ .gem-c-attachment-link .govuk-link {
13
+ color: $black!important;
14
+
15
+ &::after {
16
+ font-size: inherit;
17
+ color: inherit;
18
+ }
19
+ }
20
+ }
21
+ // stylelint-enable declaration-no-important
@@ -0,0 +1,38 @@
1
+ <%
2
+ attachment = PublishingPlatformPublishingComponents::Presenters::AttachmentHelper.new(attachment)
3
+ target ||= nil
4
+ attributes = []
5
+ if attachment.content_type_name
6
+ content = if attachment.content_type_abbr
7
+ raw tag.abbr(attachment.content_type.abbr,
8
+ title: attachment.content_type_name,
9
+ class: "gem-c-attachment-link__abbr")
10
+ else
11
+ attachment.content_type_name
12
+ end
13
+
14
+ attributes << tag.span(content, class: "gem-c-attachment-link__attribute")
15
+ end
16
+
17
+ if attachment.file_size
18
+ attributes << tag.span(
19
+ number_to_human_size(attachment.file_size),
20
+ class: "gem-c-attachment-link__attribute",
21
+ )
22
+ end
23
+
24
+ if attachment.number_of_pages
25
+ attributes << tag.span(
26
+ "#{attachment.number_of_pages} pages",
27
+ class: "gem-c-attachment-link__attribute",
28
+ )
29
+ end
30
+
31
+ component_helper = PublishingPlatformPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
32
+ component_helper.add_class("gem-c-attachment-link")
33
+ %>
34
+ <%= tag.span(**component_helper.all_attributes) do %>
35
+ <%= link_to(attachment.title, attachment.url,
36
+ target: target) -%>
37
+ <%= raw("(#{attributes.join(', ')})") if attributes.any? -%>
38
+ <% end %>
@@ -0,0 +1,61 @@
1
+ name: Attachment link
2
+ description: A link to a file with metadata of the file contents
3
+ body: |
4
+ This component provides a means to show a link to an attachment with some
5
+ relevant file data.
6
+
7
+ It is expected to be embedded inside an element that provides text styles
8
+ so does not provide its own text styling.
9
+ accessibility_criteria: |
10
+ All touch targets (e.g the attachment link) must be 24px large, or leave sufficient space (target-size). See [Understanding Success Criterion 2.5.8: Target Size (Minimum))](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html).
11
+
12
+ To achieve this, you can embed the attachment link within another element that maintains sufficient space above and below the target. For instance, you can place individual links inside a paragraph element, or as a list item.
13
+
14
+ Attachment links within paragraphs of text do not need to meet the 24 by 24 CSS pixels requirements.
15
+ shared_accessibility_criteria:
16
+ - link
17
+ uses_component_wrapper_helper: true
18
+ examples:
19
+ default:
20
+ data:
21
+ attachment:
22
+ title: "Temporary snow ploughs: guidance note"
23
+ url: https://assets.publishing.service.publishing-platform.co.uk/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
24
+ filename: temporary-snow-ploughs.pdf
25
+ content_type: application/pdf
26
+ file_size: 20000
27
+ number_of_pages: 1
28
+ embedded_in_paragraph:
29
+ embed: |
30
+ <p>
31
+ <%= component %>
32
+ </p>
33
+ data:
34
+ attachment:
35
+ title: "Temporary snow ploughs: guidance note"
36
+ url: https://assets.publishing.service.publishing-platform.co.uk/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
37
+ filename: temporary-snow-ploughs.pdf
38
+ content_type: application/pdf
39
+ file_size: 20000
40
+ number_of_pages: 1
41
+ embedded_in_markdown:
42
+ description: |
43
+ This component can be embedded in markdown with the `[AttachmentLink:]` code.
44
+ embed: |
45
+ <%= render "publishing_platform_publishing_components/components/publishing_platform_markdown" do %>
46
+ <p>Some introductory information about <%= component %>.</p>
47
+ <% end %>
48
+ data:
49
+ attachment:
50
+ title: "Temporary snow ploughs: guidance note"
51
+ url: https://assets.publishing.service.publishing-platform.co.uk/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
52
+ filename: temporary-snow-ploughs.pdf
53
+ content_type: application/pdf
54
+ file_size: 20000
55
+ number_of_pages: 1
56
+ with_target_blank:
57
+ data:
58
+ attachment:
59
+ title: "Temporary snow ploughs: guidance note"
60
+ url: https://assets.publishing.service.publishing-platform.co.uk/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
61
+ target: _blank
@@ -1,3 +1,3 @@
1
1
  module PublishingPlatformPublishingComponents
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publishing_platform_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Publishing Platform
@@ -175,6 +175,7 @@ files:
175
175
  - app/assets/config/publishing_platform_publishing_components_manifest.js
176
176
  - app/assets/images/publishing_platform_publishing_components/gemkeep
177
177
  - app/assets/stylesheets/publishing_platform_publishing_components/_all_components.scss
178
+ - app/assets/stylesheets/publishing_platform_publishing_components/components/_attachment-link.scss
178
179
  - app/assets/stylesheets/publishing_platform_publishing_components/components/_attachment.scss
179
180
  - app/assets/stylesheets/publishing_platform_publishing_components/components/_summary-list.scss
180
181
  - app/controllers/publishing_platform_publishing_components/application_controller.rb
@@ -185,6 +186,7 @@ files:
185
186
  - app/models/publishing_platform_publishing_components/shared_accessibility_criteria.rb
186
187
  - app/views/publishing_platform_publishing_components/component_doc/_component_output.html.erb
187
188
  - app/views/publishing_platform_publishing_components/components/_attachment.html.erb
189
+ - app/views/publishing_platform_publishing_components/components/_attachment_link.html.erb
188
190
  - app/views/publishing_platform_publishing_components/components/_error_summary.html.erb
189
191
  - app/views/publishing_platform_publishing_components/components/_summary_list.html.erb
190
192
  - app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_document.html.erb
@@ -194,6 +196,7 @@ files:
194
196
  - app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_pdf.html.erb
195
197
  - app/views/publishing_platform_publishing_components/components/attachment/_thumbnail_spreadsheet.html.erb
196
198
  - app/views/publishing_platform_publishing_components/components/docs/attachment.yml
199
+ - app/views/publishing_platform_publishing_components/components/docs/attachment_link.yml
197
200
  - app/views/publishing_platform_publishing_components/components/docs/error_summary.yml
198
201
  - app/views/publishing_platform_publishing_components/components/docs/summary_list.yml
199
202
  - config/initializers/assets.rb