govuk-components 0.4.0 → 1.0.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 +4 -4
- data/README.md +17 -16
- data/app/components/govuk_component/footer.rb +1 -1
- data/app/components/govuk_component/notification_banner.html.erb +20 -0
- data/app/components/govuk_component/notification_banner.rb +59 -0
- data/app/helpers/govuk_components_helper.rb +1 -0
- data/app/helpers/govuk_link_helper.rb +17 -5
- data/lib/govuk/components/version.rb +1 -1
- metadata +9 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3416a15e9cff8a8ed1f34bd5936d00abef53d308b8ceda1fb1a473cf0d6b6ad
|
4
|
+
data.tar.gz: 6af9343561c9eb003c16d0cceea38aa131e1b43afe0429c6af01fecf6d5ffe24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f700f825eaefe7f69808e06f27613a030aea3a86aa027d17cecbbaec08cad205344c888c1a8c97e2f6b34b0b3f9c4a0f460d1cd0fd5358782c271744ea6291cf
|
7
|
+
data.tar.gz: d9a149d4b223807c8135af07c3edaf27a94fa93dc5ab028b4e7212d6decd986bc8ff73f466e23bca8381445c4c0c7cd3c380c1b63a35bb9b1f529c05270932d4
|
data/README.md
CHANGED
@@ -8,22 +8,23 @@ This gem provides a suite of reusable components for the [GOV.UK Design System](
|
|
8
8
|
|
9
9
|
## What's included
|
10
10
|
|
11
|
-
| Component name
|
12
|
-
| --------------
|
13
|
-
| [Accordion](app/components/govuk_component/accordion.rb)
|
14
|
-
| [Back link](app/components/govuk_component/back_link.rb)
|
15
|
-
| [Breadcrumbs](app/components/govuk_component/breadcrumbs.rb)
|
16
|
-
| [Details](app/components/govuk_component/details.rb)
|
17
|
-
| [Footer](app/components/govuk_component/footer.rb)
|
18
|
-
| [Header](app/components/govuk_component/header.rb)
|
19
|
-
| [Inset text](app/components/govuk_component/inset_text.rb)
|
20
|
-
| [
|
21
|
-
| [
|
22
|
-
| [
|
23
|
-
| [
|
24
|
-
| [
|
25
|
-
| [
|
26
|
-
| [
|
11
|
+
| Component name | Helper |
|
12
|
+
| -------------- | ------ |
|
13
|
+
| [Accordion](app/components/govuk_component/accordion.rb) | `govuk_accordion` |
|
14
|
+
| [Back link](app/components/govuk_component/back_link.rb) | `govuk_back_link` |
|
15
|
+
| [Breadcrumbs](app/components/govuk_component/breadcrumbs.rb) | `govuk_breadcrumbs` |
|
16
|
+
| [Details](app/components/govuk_component/details.rb) | `govuk_details` |
|
17
|
+
| [Footer](app/components/govuk_component/footer.rb) | `govuk_footer` |
|
18
|
+
| [Header](app/components/govuk_component/header.rb) | `govuk_header` |
|
19
|
+
| [Inset text](app/components/govuk_component/inset_text.rb) | `govuk_inset_text` |
|
20
|
+
| [Notification banner](app/components/govuk_component/notification_banner.rb) | `govuk_notification_banner` |
|
21
|
+
| [Panel](app/components/govuk_component/panel.rb) | `govuk_panel` |
|
22
|
+
| [Phase banner](app/components/govuk_component/phase_banner.rb) | `govuk_phase_banner` |
|
23
|
+
| [Start now button](app/components/govuk_component/start_now_button.rb) | `govuk_start_now_button` |
|
24
|
+
| [Summary list](app/components/govuk_component/summary_list.rb) | `govuk_summary_list` |
|
25
|
+
| [Tabs](app/components/govuk_component/tabs.rb) | `govuk_tabs` |
|
26
|
+
| [Tag](app/components/govuk_component/tag.rb) | `govuk_tag` |
|
27
|
+
| [Warning text](app/components/govuk_component/warning.rb) | `govuk_warning` |
|
27
28
|
|
28
29
|
### Helpers
|
29
30
|
|
@@ -29,7 +29,7 @@ private
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def default_licence
|
32
|
-
link = link_to("Open Government Licence v3.0", "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/")
|
32
|
+
link = link_to("Open Government Licence v3.0", "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/", class: %w(govuk-footer__link))
|
33
33
|
|
34
34
|
raw(%(All content is available under the #{link}, except where otherwise stated))
|
35
35
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%= tag.div(class: classes.append(success_class).compact, **html_attributes, role: "region", aria: { labelledby: title_id }, data: data_params) do %>
|
2
|
+
<div class="govuk-notification-banner__header">
|
3
|
+
<%= content_tag(title_tag, class: "govuk-notification-banner__title", id: title_id) do %>
|
4
|
+
<%= title %>
|
5
|
+
<% end %>
|
6
|
+
</div>
|
7
|
+
<div class="govuk-notification-banner__content">
|
8
|
+
<% headings.each do |heading| %>
|
9
|
+
<p class="govuk-notification-banner__heading">
|
10
|
+
|
11
|
+
<%= heading.text %>.
|
12
|
+
<% if heading.link_target && heading.link_text %>
|
13
|
+
<%= link_to(heading.link_text, heading.link_target, class: "govuk-notification-banner__link") %>.
|
14
|
+
<% end %>
|
15
|
+
</p>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<%= content %>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class GovukComponent::NotificationBanner < GovukComponent::Base
|
2
|
+
attr_reader :title, :title_id, :success, :title_heading_level, :disable_auto_focus
|
3
|
+
|
4
|
+
include ViewComponent::Slotable
|
5
|
+
with_slot :heading, collection: true, class_name: 'Heading'
|
6
|
+
wrap_slot(:heading)
|
7
|
+
|
8
|
+
def initialize(title:, success: false, title_heading_level: 2, title_id: "govuk-notification-banner-title", disable_auto_focus: nil, classes: [], html_attributes: {})
|
9
|
+
super(classes: classes, html_attributes: html_attributes)
|
10
|
+
|
11
|
+
@title = title
|
12
|
+
@title_id = title_id
|
13
|
+
@success = success
|
14
|
+
@title_heading_level = title_heading_level
|
15
|
+
@disable_auto_focus = disable_auto_focus
|
16
|
+
end
|
17
|
+
|
18
|
+
def success_class
|
19
|
+
%(govuk-notification-banner--success) if success?
|
20
|
+
end
|
21
|
+
|
22
|
+
def success?
|
23
|
+
@success
|
24
|
+
end
|
25
|
+
|
26
|
+
def render?
|
27
|
+
headings.any?
|
28
|
+
end
|
29
|
+
|
30
|
+
def title_tag
|
31
|
+
fail "title_heading_level must be a number between 1 and 6" unless title_heading_level.is_a?(Integer) && title_heading_level.in?(1..6)
|
32
|
+
|
33
|
+
"h#{title_heading_level}"
|
34
|
+
end
|
35
|
+
|
36
|
+
class Heading < ViewComponent::Slot
|
37
|
+
attr_accessor :text, :link_target, :link_text
|
38
|
+
|
39
|
+
def initialize(text:, link_text: nil, link_target: nil)
|
40
|
+
@text = text
|
41
|
+
@link_text = link_text
|
42
|
+
@link_target = link_target
|
43
|
+
end
|
44
|
+
|
45
|
+
def default_classes
|
46
|
+
%w(govuk-notification-banner__heading)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def default_classes
|
53
|
+
%w(govuk-notification-banner)
|
54
|
+
end
|
55
|
+
|
56
|
+
def data_params
|
57
|
+
{ "module" => "govuk-notification-banner", "disable-auto-focus" => disable_auto_focus }.compact
|
58
|
+
end
|
59
|
+
end
|
@@ -7,6 +7,7 @@ module GovukComponentsHelper
|
|
7
7
|
govuk_footer: 'GovukComponent::Footer',
|
8
8
|
govuk_header: 'GovukComponent::Header',
|
9
9
|
govuk_inset_text: 'GovukComponent::InsetText',
|
10
|
+
govuk_notification_banner: 'GovukComponent::NotificationBanner',
|
10
11
|
govuk_panel: 'GovukComponent::Panel',
|
11
12
|
govuk_phase_banner: 'GovukComponent::PhaseBanner',
|
12
13
|
govuk_start_now_button: 'GovukComponent::StartNowButton',
|
@@ -1,14 +1,26 @@
|
|
1
1
|
module GovukLinkHelper
|
2
|
-
def govuk_link_to(*args, **kwargs)
|
3
|
-
link_to(*args, **
|
2
|
+
def govuk_link_to(*args, button: false, **kwargs, &block)
|
3
|
+
link_to(*args, **inject_class(kwargs, class_name: link_class(button)), &block)
|
4
4
|
end
|
5
5
|
|
6
|
-
def govuk_mail_to(*args, **kwargs)
|
7
|
-
mail_to(*args, **
|
6
|
+
def govuk_mail_to(*args, button: false, **kwargs, &block)
|
7
|
+
mail_to(*args, **inject_class(kwargs, class_name: link_class(button)), &block)
|
8
8
|
end
|
9
9
|
|
10
10
|
def govuk_button_to(*args, **kwargs)
|
11
|
-
button_to(*args, **
|
11
|
+
button_to(*args, **inject_class(kwargs, class_name: 'govuk-button'))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def inject_class(attributes, class_name:)
|
17
|
+
attributes.with_indifferent_access.tap do |attrs|
|
18
|
+
attrs[:class] = Array.wrap(attrs[:class]).prepend(class_name)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def link_class(button)
|
23
|
+
button ? 'govuk-button' : 'govuk-link'
|
12
24
|
end
|
13
25
|
end
|
14
26
|
|
metadata
CHANGED
@@ -1,49 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-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
|
- DfE developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0.3
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 6.0
|
19
|
+
version: '6.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 6.0.3
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 6.0
|
26
|
+
version: '6.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: view_component
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: 2.
|
33
|
+
version: 2.22.1
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.
|
40
|
+
version: 2.22.1
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: sqlite3
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +133,8 @@ files:
|
|
139
133
|
- app/components/govuk_component/header.html.erb
|
140
134
|
- app/components/govuk_component/header.rb
|
141
135
|
- app/components/govuk_component/inset_text.rb
|
136
|
+
- app/components/govuk_component/notification_banner.html.erb
|
137
|
+
- app/components/govuk_component/notification_banner.rb
|
142
138
|
- app/components/govuk_component/panel.html.erb
|
143
139
|
- app/components/govuk_component/panel.rb
|
144
140
|
- app/components/govuk_component/phase_banner.html.erb
|
@@ -164,7 +160,7 @@ files:
|
|
164
160
|
- lib/govuk/components/engine.rb
|
165
161
|
- lib/govuk/components/version.rb
|
166
162
|
- lib/tasks/govuk/components_tasks.rake
|
167
|
-
homepage: https://
|
163
|
+
homepage: https://github.com/DFE-Digital/govuk-components
|
168
164
|
licenses:
|
169
165
|
- MIT
|
170
166
|
metadata: {}
|