govuk_publishing_components 16.15.0 → 16.16.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/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss +45 -0
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +47 -0
- data/app/views/govuk_publishing_components/components/docs/attachment.yml +57 -0
- data/config/locales/en.yml +2 -0
- data/lib/govuk_publishing_components/presenters/attachment.rb +20 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/package.json +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7256193228c60f02e42966c635d3d54ec138cc0e42bc2d46a918ef44246e9bd
|
4
|
+
data.tar.gz: 99232181ca29fbed66fe26d756b577401a1eadf45ff84dcb8fb4107614cca542
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e7b54f5790debc09afc83f58da7c5cccb8960262fbdbec154de6bb020f03126ce14f2f95fcad74e78c396f9d7d324ab71583429f21887f640bc2c121b5eb200
|
7
|
+
data.tar.gz: d48dd0e873de4dca0796f53c13acd478dc7c11fcb7646f0487878b64aaf5f2db08b243501707cf85c2bee4e146c6d813b85039364973bb75e6d6d8ed175eb6b5
|
@@ -0,0 +1,45 @@
|
|
1
|
+
$thumbnail-width: 99px;
|
2
|
+
$thumbnail-height: 140px;
|
3
|
+
$thumbnail-border: 5px;
|
4
|
+
$thumbnail-border-colour: rgba(11, 12, 12, .1);
|
5
|
+
$thumbnail-shadow-colour: rgba(11, 12, 12, .4);
|
6
|
+
$thumbnail-shadow-width: 0 2px 2px;
|
7
|
+
|
8
|
+
.gem-c-attachment {
|
9
|
+
@include govuk-font(19);
|
10
|
+
@include govuk-clearfix;
|
11
|
+
}
|
12
|
+
|
13
|
+
.gem-c-attachment__thumbnail {
|
14
|
+
float: left;
|
15
|
+
margin-bottom: govuk-spacing(3);
|
16
|
+
margin-right: govuk-spacing(5);
|
17
|
+
padding: $thumbnail-border;
|
18
|
+
position: relative;
|
19
|
+
}
|
20
|
+
|
21
|
+
.gem-c-attachment__thumbnail-image {
|
22
|
+
display: block;
|
23
|
+
width: auto; // for IE8
|
24
|
+
max-width: $thumbnail-width;
|
25
|
+
height: $thumbnail-height;
|
26
|
+
outline: $thumbnail-border solid $thumbnail-border-colour;
|
27
|
+
border: $thumbnail-border-colour; // for IE9 & IE10
|
28
|
+
background: govuk-colour("white");
|
29
|
+
box-shadow: $thumbnail-shadow-width $thumbnail-shadow-colour;
|
30
|
+
}
|
31
|
+
|
32
|
+
.gem-c-attachment__title {
|
33
|
+
@include govuk-font($size: 27);
|
34
|
+
margin: 0 0 govuk-spacing(3);
|
35
|
+
}
|
36
|
+
|
37
|
+
.gem-c-attachment__metadata {
|
38
|
+
@include govuk-font($size: 14);
|
39
|
+
margin: 0 0 govuk-spacing(3);
|
40
|
+
}
|
41
|
+
|
42
|
+
.gem-c-attachment__abbr {
|
43
|
+
cursor: help;
|
44
|
+
text-decoration: none;
|
45
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<%
|
2
|
+
attachment = GovukPublishingComponents::Presenters::Attachment.new(attachment)
|
3
|
+
target ||= "_self"
|
4
|
+
hide_help_text ||= false
|
5
|
+
attributes = []
|
6
|
+
|
7
|
+
if attachment.content_type_abbr
|
8
|
+
content = tag.abbr(attachment.content_type_abbr,
|
9
|
+
class: "gem-c-attachment__abbr",
|
10
|
+
title: attachment.readable_content_type)
|
11
|
+
attributes << tag.span(content, class: "gem-c-attachment__attribute")
|
12
|
+
end
|
13
|
+
|
14
|
+
if attachment.readable_file_size
|
15
|
+
attributes << tag.span(attachment.readable_file_size, class: "gem-c-attachment__attribute")
|
16
|
+
end
|
17
|
+
|
18
|
+
if attachment.readable_number_of_pages
|
19
|
+
attributes << tag.span(attachment.readable_number_of_pages, class: "gem-c-attachment__attribute")
|
20
|
+
end
|
21
|
+
%>
|
22
|
+
<%= tag.section class: "gem-c-attachment" do %>
|
23
|
+
<%= tag.div class: "gem-c-attachment__thumbnail" do %>
|
24
|
+
<%= link_to attachment.url, target: target, tabindex: "-1", "aria-hidden": true do %>
|
25
|
+
<%= tag.img class: "gem-c-attachment__thumbnail-image",
|
26
|
+
src: attachment.thumbnail
|
27
|
+
%>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
<%= tag.h2 class: "gem-c-attachment__title" do %>
|
32
|
+
<%= link_to attachment.title, attachment.url,
|
33
|
+
class: "govuk-link",
|
34
|
+
target: target %>
|
35
|
+
<% end %>
|
36
|
+
<%= tag.p class: "gem-c-attachment__metadata" do %>
|
37
|
+
<%= raw(attributes.join(', ')) if attributes.any? %>
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
<% unless hide_help_text %>
|
41
|
+
<% if attachment.opendocument? %>
|
42
|
+
<%= tag.p class: "gem-c-attachment__metadata" do %>
|
43
|
+
<%= t("components.attachment.opendocument_html", target: target) %>
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
46
|
+
<% end %>
|
47
|
+
<% end %>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
name: Attachment (experimental)
|
2
|
+
description: Displays a link to download an attachment and metadata about the file
|
3
|
+
body: |
|
4
|
+
This component is marked as experimental as it is part of a drive to provide
|
5
|
+
a consistent place for attachment presentation logic (currently this logic is
|
6
|
+
within [Govspeak][] and [Whitehall][]). The API for this
|
7
|
+
component may change during this process.
|
8
|
+
|
9
|
+
It shows a link to a document that is attached to GOV.UK content along with a
|
10
|
+
thumbnail and relevant file data.
|
11
|
+
|
12
|
+
It is intended to be rendered in Govspeak and as an attachment 'preview' in
|
13
|
+
Content Publisher.
|
14
|
+
|
15
|
+
[Govspeak]: https://github.com/alphagov/govspeak/blob/c3a0742c87537a371108d097cea23688efa90a14/lib/govspeak/presenters/attachment_presenter.rb
|
16
|
+
[Whitehall]: https://github.com/alphagov/whitehall/blob/5c760eea912320c5a80ef59791df47161d889f2f/app/helpers/document_helper.rb
|
17
|
+
shared_accessibility_criteria:
|
18
|
+
- link
|
19
|
+
accessibility_criteria: |
|
20
|
+
The thumbnail image has no `alt` attribute, which causes the link which wraps
|
21
|
+
the thumbnail to contain no content. Since screen readers will have nothing to
|
22
|
+
read in this case, we set `aria-hidden=true` on the thumbail so that it's hidden.
|
23
|
+
examples:
|
24
|
+
default:
|
25
|
+
data:
|
26
|
+
attachment:
|
27
|
+
title: "Department for Transport information asset register"
|
28
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/747661/department-for-transport-information-asset-register.csv
|
29
|
+
filename: department-for-transport-information-asset-register.csv
|
30
|
+
content_type: text/csv
|
31
|
+
file_size: 20000
|
32
|
+
with_number_of_pages:
|
33
|
+
data:
|
34
|
+
attachment:
|
35
|
+
title: "Temporary snow ploughs: guidance note"
|
36
|
+
url: https://assets.publishing.service.gov.uk/government/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: 7
|
41
|
+
opendocument:
|
42
|
+
data:
|
43
|
+
attachment:
|
44
|
+
title: "BEIS Information Asset Register"
|
45
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/744083/BEIS_Information_Asset_Register_.ods
|
46
|
+
filename: BEIS_Information_Asset_Register_.ods
|
47
|
+
content_type: application/vnd.oasis.opendocument.spreadsheet
|
48
|
+
file_size: 20000
|
49
|
+
help_text_disabled:
|
50
|
+
data:
|
51
|
+
attachment:
|
52
|
+
title: "BEIS Information Asset Register"
|
53
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/744083/BEIS_Information_Asset_Register_.ods
|
54
|
+
filename: BEIS_Information_Asset_Register_.ods
|
55
|
+
content_type: application/vnd.oasis.opendocument.spreadsheet
|
56
|
+
file_size: 20000
|
57
|
+
hide_help_text: true
|
data/config/locales/en.yml
CHANGED
@@ -23,6 +23,8 @@ en:
|
|
23
23
|
common:
|
24
24
|
translations: "Translations"
|
25
25
|
components:
|
26
|
+
attachment:
|
27
|
+
opendocument_html: "This file is in an <a href='https://www.gov.uk/guidance/open-document-format-odf-guidance-for-uk-government/overview-of-productivity-software' target=%{target} class='govuk-link'>OpenDocument</a> format"
|
26
28
|
autocomplete:
|
27
29
|
multiselect: "To select multiple items in a list, hold down Ctrl (PC) or Cmd (Mac) key."
|
28
30
|
back_link:
|
@@ -48,6 +48,14 @@ module GovukPublishingComponents
|
|
48
48
|
pluralize(attachment_data[:number_of_pages], "page")
|
49
49
|
end
|
50
50
|
|
51
|
+
def thumbnail
|
52
|
+
"https://www.gov.uk/government/assets/pub-cover-doc-afe3b0a8a9511beeca890340170aee8b5649413f948e512c9b8ce432d8513d32.png"
|
53
|
+
end
|
54
|
+
|
55
|
+
def opendocument?
|
56
|
+
content_type.opendocument?
|
57
|
+
end
|
58
|
+
|
51
59
|
class SupportedContentType
|
52
60
|
attr_reader :content_type, :name, :abbr
|
53
61
|
|
@@ -77,6 +85,10 @@ module GovukPublishingComponents
|
|
77
85
|
{ content_type: "text/xml", extension: ".xsd", abbr: "XSD", name: "XML Schema" }.freeze,
|
78
86
|
].freeze
|
79
87
|
|
88
|
+
OPENDOCUMENT_CONTENT_TYPES = %w(application/vnd.oasis.opendocument.presentation
|
89
|
+
application/vnd.oasis.opendocument.spreadsheet
|
90
|
+
application/vnd.oasis.opendocument.text).freeze
|
91
|
+
|
80
92
|
def self.find(content_type, extension = nil)
|
81
93
|
matching_types = TYPES.select { |type| type[:content_type] == content_type }
|
82
94
|
|
@@ -96,6 +108,10 @@ module GovukPublishingComponents
|
|
96
108
|
@name = content_type[:name]
|
97
109
|
@abbr = content_type[:abbr]
|
98
110
|
end
|
111
|
+
|
112
|
+
def opendocument?
|
113
|
+
OPENDOCUMENT_CONTENT_TYPES.include?(content_type)
|
114
|
+
end
|
99
115
|
end
|
100
116
|
|
101
117
|
class UnsupportedContentType
|
@@ -108,6 +124,10 @@ module GovukPublishingComponents
|
|
108
124
|
def name; end
|
109
125
|
|
110
126
|
def abbr; end
|
127
|
+
|
128
|
+
def opendocument?
|
129
|
+
false
|
130
|
+
end
|
111
131
|
end
|
112
132
|
end
|
113
133
|
end
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"/"
|
50
50
|
],
|
51
51
|
"_resolved": "git://github.com/alphagov/accessible-autocomplete.git#0c518b4fa79b9a95b544410858486ed9e6403c84",
|
52
|
-
"_shasum": "
|
52
|
+
"_shasum": "72a16e16cbdbe5b44ca47631d9c8bc47063c5a74",
|
53
53
|
"_shrinkwrap": null,
|
54
54
|
"_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
|
55
55
|
"_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 16.
|
4
|
+
version: 16.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -369,6 +369,7 @@ files:
|
|
369
369
|
- app/assets/stylesheets/govuk_publishing_components/components/_accessible-autocomplete.scss
|
370
370
|
- app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss
|
371
371
|
- app/assets/stylesheets/govuk_publishing_components/components/_attachment-link.scss
|
372
|
+
- app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss
|
372
373
|
- app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss
|
373
374
|
- app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss
|
374
375
|
- app/assets/stylesheets/govuk_publishing_components/components/_button.scss
|
@@ -485,6 +486,7 @@ files:
|
|
485
486
|
- app/views/govuk_publishing_components/components/_accessible_autocomplete.html.erb
|
486
487
|
- app/views/govuk_publishing_components/components/_accordion.html.erb
|
487
488
|
- app/views/govuk_publishing_components/components/_admin_analytics.html.erb
|
489
|
+
- app/views/govuk_publishing_components/components/_attachment.html.erb
|
488
490
|
- app/views/govuk_publishing_components/components/_attachment_link.html.erb
|
489
491
|
- app/views/govuk_publishing_components/components/_back_link.html.erb
|
490
492
|
- app/views/govuk_publishing_components/components/_breadcrumbs.html.erb
|
@@ -552,6 +554,7 @@ files:
|
|
552
554
|
- app/views/govuk_publishing_components/components/docs/accessible_autocomplete.yml
|
553
555
|
- app/views/govuk_publishing_components/components/docs/accordion.yml
|
554
556
|
- app/views/govuk_publishing_components/components/docs/admin_analytics.yml
|
557
|
+
- app/views/govuk_publishing_components/components/docs/attachment.yml
|
555
558
|
- app/views/govuk_publishing_components/components/docs/attachment_link.yml
|
556
559
|
- app/views/govuk_publishing_components/components/docs/back_link.yml
|
557
560
|
- app/views/govuk_publishing_components/components/docs/breadcrumbs.yml
|