design_system 0.13.2 → 0.15.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 +36 -3
- data/app/assets/stylesheets/design_system/_hljs.scss +131 -0
- data/app/assets/stylesheets/design_system/govuk.scss +43 -0
- data/app/assets/stylesheets/design_system/nhsuk.scss +55 -0
- data/app/components/design_system/base_component.rb +21 -0
- data/app/components/design_system/generic/action_link_component.rb +17 -0
- data/app/components/design_system/generic/alert_component.rb +25 -0
- data/app/components/design_system/generic/breadcrumbs_component.rb +18 -0
- data/app/components/design_system/generic/button_component.rb +51 -0
- data/app/components/design_system/generic/callout_component.html.erb +8 -0
- data/app/components/design_system/generic/callout_component.rb +15 -0
- data/app/components/design_system/generic/details_component.html.erb +4 -0
- data/app/components/design_system/generic/details_component.rb +13 -0
- data/app/components/design_system/generic/grid_component.html.erb +5 -0
- data/app/components/design_system/generic/grid_component.rb +31 -0
- data/app/components/design_system/generic/heading_component.rb +41 -0
- data/app/components/design_system/generic/inset_text_component.html.erb +1 -0
- data/app/components/design_system/generic/inset_text_component.rb +24 -0
- data/app/components/design_system/generic/link_component.rb +51 -0
- data/app/components/design_system/generic/list_component.html.erb +7 -0
- data/app/components/design_system/generic/list_component.rb +26 -0
- data/app/components/design_system/generic/notification_component.html.erb +15 -0
- data/app/components/design_system/generic/notification_component.rb +39 -0
- data/app/components/design_system/generic/panel_component.html.erb +4 -0
- data/app/components/design_system/generic/panel_component.rb +18 -0
- data/app/components/design_system/generic/paragraph_component.rb +46 -0
- data/app/components/design_system/generic/start_button_component.html.erb +4 -0
- data/app/components/design_system/generic/start_button_component.rb +17 -0
- data/app/components/design_system/generic/summary_card_component.html.erb +15 -0
- data/app/components/design_system/generic/summary_card_component.rb +40 -0
- data/app/components/design_system/generic/summary_list_component.html.erb +21 -0
- data/app/components/design_system/generic/summary_list_component.rb +59 -0
- data/app/components/design_system/generic/tab_component.html.erb +21 -0
- data/app/components/design_system/generic/tab_component.rb +14 -0
- data/app/components/design_system/generic/table_component.rb +46 -0
- data/app/components/design_system/govuk/action_link_component.html.erb +1 -0
- data/app/components/design_system/govuk/action_link_component.rb +8 -0
- data/app/components/design_system/govuk/alert_component.rb +6 -0
- data/app/components/design_system/govuk/breadcrumbs_component.html.erb +11 -0
- data/app/components/design_system/govuk/breadcrumbs_component.rb +7 -0
- data/app/components/design_system/govuk/button_component.rb +6 -0
- data/app/components/design_system/govuk/callout_component.html.erb +6 -0
- data/app/components/design_system/govuk/callout_component.rb +6 -0
- data/app/components/design_system/govuk/details_component.rb +6 -0
- data/app/components/design_system/govuk/grid_component.rb +6 -0
- data/app/components/design_system/govuk/heading_component.rb +6 -0
- data/app/components/design_system/govuk/inset_text_component.rb +6 -0
- data/app/components/design_system/govuk/link_component.rb +17 -0
- data/app/components/design_system/govuk/list_component.rb +6 -0
- data/app/components/design_system/govuk/notification_component.rb +6 -0
- data/app/components/design_system/govuk/panel_component.rb +10 -0
- data/app/components/design_system/govuk/paragraph_component.rb +6 -0
- data/app/components/design_system/govuk/start_button_component.rb +6 -0
- data/app/components/design_system/govuk/summary_card_component.html.erb +15 -0
- data/app/components/design_system/govuk/summary_card_component.rb +13 -0
- data/app/components/design_system/govuk/summary_list_component.rb +6 -0
- data/app/components/design_system/govuk/tab_component.rb +6 -0
- data/app/components/design_system/govuk/table_component.html.erb +30 -0
- data/app/components/design_system/govuk/table_component.rb +6 -0
- data/app/components/design_system/nhsuk/action_link_component.html.erb +7 -0
- data/app/components/design_system/nhsuk/action_link_component.rb +7 -0
- data/app/components/design_system/nhsuk/alert_component.rb +6 -0
- data/app/components/design_system/nhsuk/breadcrumbs_component.html.erb +16 -0
- data/app/components/design_system/nhsuk/breadcrumbs_component.rb +7 -0
- data/app/components/design_system/nhsuk/button_component.rb +6 -0
- data/app/components/design_system/nhsuk/callout_component.rb +6 -0
- data/app/components/design_system/nhsuk/details_component.rb +6 -0
- data/app/components/design_system/nhsuk/grid_component.rb +6 -0
- data/app/components/design_system/nhsuk/heading_component.rb +6 -0
- data/app/components/design_system/nhsuk/inset_text_component.html.erb +4 -0
- data/app/components/design_system/nhsuk/inset_text_component.rb +6 -0
- data/app/components/design_system/nhsuk/link_component.rb +17 -0
- data/app/components/design_system/nhsuk/list_component.rb +6 -0
- data/app/components/design_system/nhsuk/notification_component.rb +6 -0
- data/app/components/design_system/nhsuk/panel_component.rb +6 -0
- data/app/components/design_system/nhsuk/paragraph_component.rb +6 -0
- data/app/components/design_system/nhsuk/start_button_component.rb +6 -0
- data/app/components/design_system/nhsuk/summary_card_component.rb +6 -0
- data/app/components/design_system/nhsuk/summary_list_component.rb +19 -0
- data/app/components/design_system/nhsuk/tab_component.rb +6 -0
- data/app/components/design_system/nhsuk/table_component.html.erb +43 -0
- data/app/components/design_system/nhsuk/table_component.rb +6 -0
- data/app/controllers/concerns/design_system/branded.rb +6 -0
- data/app/helpers/design_system_helper.rb +65 -27
- data/app/javascript/design_system/controllers/clipboard_controller.js +41 -0
- data/app/javascript/design_system/controllers/code_highlight_controller.js +9 -0
- data/app/javascript/design_system/controllers/hello_world_controller.js +6 -0
- data/app/javascript/design_system/index.js +4 -0
- data/app/views/layouts/govuk/application.html.erb +20 -7
- data/app/views/layouts/nhsuk/application.html.erb +10 -7
- data/lib/design_system/brand_derivable.rb +9 -0
- data/lib/design_system/engine.rb +1 -0
- data/lib/design_system/generic/builders/base.rb +1 -1
- data/lib/design_system/generic/builders/code.rb +23 -0
- data/lib/design_system/generic/builders/elements/breadcrumbs.rb +4 -24
- data/lib/design_system/generic/builders/elements/headings.rb +3 -2
- data/lib/design_system/generic/builders/pagination_renderer.rb +5 -4
- data/lib/design_system/generic.rb +1 -14
- data/lib/design_system/govuk/builders/code.rb +11 -0
- data/lib/design_system/govuk/builders/fixed_elements.rb +0 -1
- data/lib/design_system/govuk.rb +1 -12
- data/lib/design_system/nhsuk/builders/code.rb +11 -0
- data/lib/design_system/nhsuk/builders/fixed_elements.rb +0 -1
- data/lib/design_system/nhsuk.rb +1 -12
- data/lib/design_system/registry.rb +19 -1
- data/lib/design_system/version.rb +1 -1
- data/public/design_system/static/design_system-0.15.0/design_system.js +53150 -0
- metadata +101 -50
- data/lib/design_system/generic/builders/action_link.rb +0 -17
- data/lib/design_system/generic/builders/button.rb +0 -33
- data/lib/design_system/generic/builders/callout.rb +0 -28
- data/lib/design_system/generic/builders/concerns/brand_derivable.rb +0 -14
- data/lib/design_system/generic/builders/details.rb +0 -30
- data/lib/design_system/generic/builders/grid.rb +0 -44
- data/lib/design_system/generic/builders/heading.rb +0 -38
- data/lib/design_system/generic/builders/inset_text.rb +0 -18
- data/lib/design_system/generic/builders/link.rb +0 -44
- data/lib/design_system/generic/builders/list.rb +0 -41
- data/lib/design_system/generic/builders/notification.rb +0 -68
- data/lib/design_system/generic/builders/panel.rb +0 -18
- data/lib/design_system/generic/builders/paragraph.rb +0 -28
- data/lib/design_system/generic/builders/summary_list.rb +0 -89
- data/lib/design_system/generic/builders/tab.rb +0 -14
- data/lib/design_system/generic/builders/table.rb +0 -73
- data/lib/design_system/govuk/builders/action_link.rb +0 -17
- data/lib/design_system/govuk/builders/button.rb +0 -55
- data/lib/design_system/govuk/builders/callout.rb +0 -26
- data/lib/design_system/govuk/builders/details.rb +0 -10
- data/lib/design_system/govuk/builders/elements/breadcrumbs.rb +0 -33
- data/lib/design_system/govuk/builders/grid.rb +0 -12
- data/lib/design_system/govuk/builders/heading.rb +0 -11
- data/lib/design_system/govuk/builders/inset_text.rb +0 -11
- data/lib/design_system/govuk/builders/link.rb +0 -21
- data/lib/design_system/govuk/builders/list.rb +0 -11
- data/lib/design_system/govuk/builders/notification.rb +0 -11
- data/lib/design_system/govuk/builders/panel.rb +0 -18
- data/lib/design_system/govuk/builders/paragraph.rb +0 -11
- data/lib/design_system/govuk/builders/summary_list.rb +0 -32
- data/lib/design_system/govuk/builders/tab.rb +0 -54
- data/lib/design_system/govuk/builders/table.rb +0 -77
- data/lib/design_system/nhsuk/builders/action_link.rb +0 -30
- data/lib/design_system/nhsuk/builders/button.rb +0 -11
- data/lib/design_system/nhsuk/builders/callout.rb +0 -11
- data/lib/design_system/nhsuk/builders/details.rb +0 -10
- data/lib/design_system/nhsuk/builders/elements/breadcrumbs.rb +0 -43
- data/lib/design_system/nhsuk/builders/grid.rb +0 -12
- data/lib/design_system/nhsuk/builders/heading.rb +0 -11
- data/lib/design_system/nhsuk/builders/inset_text.rb +0 -23
- data/lib/design_system/nhsuk/builders/link.rb +0 -21
- data/lib/design_system/nhsuk/builders/list.rb +0 -11
- data/lib/design_system/nhsuk/builders/notification.rb +0 -11
- data/lib/design_system/nhsuk/builders/panel.rb +0 -11
- data/lib/design_system/nhsuk/builders/paragraph.rb +0 -11
- data/lib/design_system/nhsuk/builders/summary_list.rb +0 -18
- data/lib/design_system/nhsuk/builders/tab.rb +0 -11
- data/lib/design_system/nhsuk/builders/table.rb +0 -68
- data/public/design_system/static/design_system-0.13.2/design_system.js +0 -1309
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Generic
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides generic summary list.
|
|
7
|
-
class SummaryList < Base
|
|
8
|
-
include ActionView::Helpers::OutputSafetyHelper
|
|
9
|
-
|
|
10
|
-
def render_summary_list
|
|
11
|
-
@summary_list = ::DesignSystem::Components::SummaryList.new
|
|
12
|
-
yield @summary_list
|
|
13
|
-
|
|
14
|
-
safe_buffer = ActiveSupport::SafeBuffer.new
|
|
15
|
-
safe_buffer.concat(render_rows)
|
|
16
|
-
|
|
17
|
-
safe_buffer
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
def render_rows
|
|
23
|
-
content_tag(:dl, class: "#{brand}-summary-list") do
|
|
24
|
-
@summary_list.rows.map { |row| render_row(row) }.join.html_safe
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def render_row(row)
|
|
29
|
-
row_classes = ["#{brand}-summary-list__row"]
|
|
30
|
-
row_classes << "#{brand}-summary-list__row--no-actions" if row[:actions].blank?
|
|
31
|
-
|
|
32
|
-
content_tag(:div, class: row_classes.join(' ')) do
|
|
33
|
-
[render_key(row),
|
|
34
|
-
render_value(row),
|
|
35
|
-
render_actions(row)].compact.join.html_safe
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def render_key(row)
|
|
40
|
-
content_tag(:dt, row[:key][:content], class: "#{brand}-summary-list__key")
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def render_value(row)
|
|
44
|
-
content_tag(:dd, class: "#{brand}-summary-list__value") do
|
|
45
|
-
if row[:values].blank?
|
|
46
|
-
''
|
|
47
|
-
elsif row[:values].length == 1
|
|
48
|
-
row[:values].first[:content]
|
|
49
|
-
else
|
|
50
|
-
row[:values].map { |value| content_tag(:p, value[:content], class: "#{brand}-body") }.join.html_safe
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def render_actions(row)
|
|
56
|
-
return if row[:actions].blank?
|
|
57
|
-
|
|
58
|
-
content_tag(:dd, class: "#{brand}-summary-list__actions") do
|
|
59
|
-
if row[:actions].length == 1
|
|
60
|
-
render_action(row[:actions].first)
|
|
61
|
-
else
|
|
62
|
-
content_tag(:ul, class: "#{brand}-summary-list__actions-list") do
|
|
63
|
-
row[:actions].map do |action|
|
|
64
|
-
content_tag(:li, render_action(action), class: "#{brand}-summary-list__actions-list-item")
|
|
65
|
-
end.join.html_safe
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def render_action(action)
|
|
72
|
-
options = action[:options].dup
|
|
73
|
-
path = options.delete(:path) || '#'
|
|
74
|
-
hidden_text = options.delete(:hidden_text)
|
|
75
|
-
|
|
76
|
-
link_to(path, { class: "#{brand}-link" }.merge(options)) do
|
|
77
|
-
safe_join([action[:content], render_hidden_text(hidden_text)])
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def render_hidden_text(hidden_text)
|
|
82
|
-
return '' if hidden_text.blank?
|
|
83
|
-
|
|
84
|
-
content_tag(:span, hidden_text, class: "#{brand}-visually-hidden")
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Generic
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides generic methods to display tab on html.
|
|
7
|
-
class Tab < Base
|
|
8
|
-
def render_tabs
|
|
9
|
-
raise 'Subclass needs to implement brand specific render_tabs'
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Generic
|
|
5
|
-
module Builders
|
|
6
|
-
# This class is used to provide table builder.
|
|
7
|
-
class Table < Base
|
|
8
|
-
def render_table(options = {})
|
|
9
|
-
@table = ::DesignSystem::Components::Table.new
|
|
10
|
-
yield @table
|
|
11
|
-
|
|
12
|
-
content_tag(:div, **options) do
|
|
13
|
-
safe_buffer = ActiveSupport::SafeBuffer.new
|
|
14
|
-
safe_buffer.concat(table_content)
|
|
15
|
-
|
|
16
|
-
safe_buffer
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
def table_content
|
|
23
|
-
content_tag :table do
|
|
24
|
-
safe_buffer = ActiveSupport::SafeBuffer.new
|
|
25
|
-
safe_buffer.concat(content_tag(:caption, @table.caption)) if @table.caption
|
|
26
|
-
safe_buffer.concat(render_headers)
|
|
27
|
-
safe_buffer.concat(render_rows)
|
|
28
|
-
safe_buffer
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def render_headers
|
|
33
|
-
content_tag :thead do
|
|
34
|
-
content_tag :tr do
|
|
35
|
-
@table.columns.each_with_object(ActiveSupport::SafeBuffer.new) do |header, header_buffer|
|
|
36
|
-
options = cell_numeric?(header) ? header[:options].merge(align: 'right') : header[:options]
|
|
37
|
-
header_buffer.concat(content_tag(:th, header[:content], options))
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def render_rows
|
|
44
|
-
content_tag :tbody do
|
|
45
|
-
@table.rows.each_with_object(ActiveSupport::SafeBuffer.new) do |row, rows_buffer|
|
|
46
|
-
rows_buffer.concat(content_tag(:tr) do
|
|
47
|
-
row.each_with_object(ActiveSupport::SafeBuffer.new) do |cell, cell_buffer|
|
|
48
|
-
options = cell_numeric?(cell) ? cell[:options].merge(align: 'right') : cell[:options]
|
|
49
|
-
cell_buffer.concat(content_tag(:td, cell_content(cell), options))
|
|
50
|
-
end
|
|
51
|
-
end)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def cell_content(cell)
|
|
57
|
-
if cell[:content].is_a?(Numeric)
|
|
58
|
-
cell[:content].to_s
|
|
59
|
-
elsif cell[:content].is_a?(Proc)
|
|
60
|
-
capture(&cell[:content])
|
|
61
|
-
else
|
|
62
|
-
cell[:content]
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# This method is for table component to identify if cell is numeric type
|
|
67
|
-
def cell_numeric?(cell)
|
|
68
|
-
cell[:options][:type] == 'numeric'
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides GOVUK Action Link. GOVUK doesn't have a specific action link component, so we use the button styled link component.
|
|
7
|
-
class ActionLink < ::DesignSystem::Generic::Builders::ActionLink
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def prep_style(name, options, html_options)
|
|
11
|
-
html_options[:class] = "#{brand}-button"
|
|
12
|
-
link_to(name, options, html_options)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides GOVUK Button.
|
|
7
|
-
class Button < ::DesignSystem::Generic::Builders::Button
|
|
8
|
-
def render_button(content_or_options = nil, options = nil, &)
|
|
9
|
-
options = prep_button_options(content_or_options, options)
|
|
10
|
-
options[:class] = "#{brand}-button"
|
|
11
|
-
|
|
12
|
-
options = css_class_options_merge(options) do |button_classes|
|
|
13
|
-
button_classes << style_class_hash[options['style']]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
if block_given?
|
|
17
|
-
button_tag(options = nil, &)
|
|
18
|
-
else
|
|
19
|
-
button_tag(content_or_options, options)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def render_start_button(text, href, options)
|
|
24
|
-
render_start_tag(text, href, options)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
def render_start_tag(text, href, options)
|
|
30
|
-
merged_options = options.merge('data-module': "#{brand}-button")
|
|
31
|
-
buffer = ActiveSupport::SafeBuffer.new
|
|
32
|
-
content_tag(:a, href:, class: "#{brand}-button #{brand}-button--start",
|
|
33
|
-
role: 'button', draggable: 'false', **merged_options) do
|
|
34
|
-
buffer.concat(content_tag(:span, text, class: "#{brand}-button-text"))
|
|
35
|
-
buffer.concat(
|
|
36
|
-
content_tag(:svg, '', class: "#{brand}-button__start-icon", xmlns: 'http://www.w3.org/2000/svg',
|
|
37
|
-
width: '17.5', height: '19', viewBox: '0 0 33 40', aria: { hidden: 'true' },
|
|
38
|
-
focusable: 'false') do
|
|
39
|
-
content_tag(:path, '', fill: 'currentColor', d: 'M0 0h13l20 20-20 20H0l20-20z')
|
|
40
|
-
end
|
|
41
|
-
)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def style_class_hash
|
|
46
|
-
{
|
|
47
|
-
'secondary' => "#{brand}-button--secondary",
|
|
48
|
-
'warning' => "#{brand}-button--warning",
|
|
49
|
-
'reverse' => "#{brand}-button--inverse"
|
|
50
|
-
}
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This generates html for rendering warning callout for Govuk
|
|
7
|
-
class Callout < ::DesignSystem::Generic::Builders::Callout
|
|
8
|
-
def render_callout(label, body)
|
|
9
|
-
safe_buffer = ActiveSupport::SafeBuffer.new
|
|
10
|
-
content_tag(:div, class: "#{brand}-warning-text") do
|
|
11
|
-
safe_buffer.concat(content_tag(:span, '!', class: "#{brand}-warning-text__icon", 'aria-hidden': 'true'))
|
|
12
|
-
safe_buffer.concat(render_body(label, body))
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def render_body(label, body)
|
|
19
|
-
content_tag(:strong, class: "#{brand}-warning-text__text") do
|
|
20
|
-
content_tag(:span, 'Warning', class: "#{brand}-visually-hidden") + label + ' ' + body
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module DesignSystem
|
|
2
|
-
module Govuk
|
|
3
|
-
module Builders
|
|
4
|
-
module Elements
|
|
5
|
-
# This mixin module is used to provide GOVUK breadcrumbs.
|
|
6
|
-
module Breadcrumbs
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
def content_for_breadcrumbs
|
|
10
|
-
content_for(:breadcrumbs) do
|
|
11
|
-
content_tag(:div, class: "#{brand}-breadcrumbs") do
|
|
12
|
-
content_tag(:ol, class: "#{brand}-breadcrumbs__list") do
|
|
13
|
-
@breadcrumbs.each_with_object(ActiveSupport::SafeBuffer.new) do |breadcrumb, safe_buffer|
|
|
14
|
-
safe_buffer.concat(render_breadcrumb(breadcrumb))
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def render_breadcrumb(breadcrumb)
|
|
22
|
-
content_tag(:li, class: "#{brand}-breadcrumbs__list-item") do
|
|
23
|
-
link_to(breadcrumb[:label],
|
|
24
|
-
breadcrumb[:path],
|
|
25
|
-
class: "#{brand}-breadcrumbs__link",
|
|
26
|
-
'aria-current': @context.current_page?(breadcrumb[:path]) ? 'page' : nil)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# GOV UK specific grid implementation
|
|
7
|
-
# Inherits all functionality from generic builder
|
|
8
|
-
class Grid < ::DesignSystem::Generic::Builders::Grid
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides GOVUK Link.
|
|
7
|
-
class Link < ::DesignSystem::Generic::Builders::Link
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def button_type_class_hash
|
|
11
|
-
{
|
|
12
|
-
button: "#{brand}-button",
|
|
13
|
-
secondary_button: "#{brand}-button #{brand}-button--secondary",
|
|
14
|
-
warning_button: "#{brand}-button #{brand}-button--warning",
|
|
15
|
-
reverse_button: "#{brand}-button #{brand}-button--inverse"
|
|
16
|
-
}
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This generates html for rendering panel for Govuk
|
|
7
|
-
class Panel < ::DesignSystem::Generic::Builders::Panel
|
|
8
|
-
def render_panel(title, body)
|
|
9
|
-
safe_buffer = ActiveSupport::SafeBuffer.new
|
|
10
|
-
content_tag(:div, class: "#{brand}-panel #{brand}-panel--confirmation") do
|
|
11
|
-
safe_buffer.concat(content_tag(:h1, title, class: "#{brand}-panel__title"))
|
|
12
|
-
safe_buffer.concat(content_tag(:div, body, class: "#{brand}-panel__body"))
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides GOVUK Summary List.
|
|
7
|
-
class SummaryList < ::DesignSystem::Generic::Builders::SummaryList
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def render_value(row)
|
|
11
|
-
content_tag(:dd, class: 'govuk-summary-list__value') do
|
|
12
|
-
if row[:values].blank?
|
|
13
|
-
''
|
|
14
|
-
elsif row[:values].length == 1
|
|
15
|
-
wrap_value(row[:values].first)
|
|
16
|
-
else
|
|
17
|
-
row[:values].map { |value| wrap_value(value) }.join.html_safe
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def wrap_value(value)
|
|
23
|
-
if value[:options]&.dig(:path)
|
|
24
|
-
link_to(value[:content], value[:options][:path] || '#', class: 'govuk-link')
|
|
25
|
-
else
|
|
26
|
-
content_tag(:p, value[:content], class: 'govuk-body')
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides GOVUK Tab.
|
|
7
|
-
class Tab < ::DesignSystem::Generic::Builders::Tab
|
|
8
|
-
def render_tabs
|
|
9
|
-
@tab = ::DesignSystem::Components::Tab.new(self)
|
|
10
|
-
|
|
11
|
-
yield @tab
|
|
12
|
-
content_tag(:div, class: "#{brand}-tabs", 'data-module': "#{brand}-tabs") do
|
|
13
|
-
safe_buffer = ActiveSupport::SafeBuffer.new
|
|
14
|
-
|
|
15
|
-
safe_buffer.concat(content_tag(:h2, @tab.title, class: "#{brand}-tabs__title")) if @tab.title
|
|
16
|
-
safe_buffer.concat(tabs_list_content) if @tab.tabs.present?
|
|
17
|
-
safe_buffer.concat(tabs_body_content) if @tab.tabs.present?
|
|
18
|
-
safe_buffer
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def tabs_list_content
|
|
25
|
-
content_tag(:ul, class: "#{brand}-tabs__list") do
|
|
26
|
-
@tab.tabs.each_with_object(ActiveSupport::SafeBuffer.new) do |(name, _content, id, sel), link_buffer|
|
|
27
|
-
style = if sel
|
|
28
|
-
"#{brand}-tabs__list-item #{brand}-tabs__list-item--selected"
|
|
29
|
-
else
|
|
30
|
-
"#{brand}-tabs__list-item"
|
|
31
|
-
end
|
|
32
|
-
link_buffer.concat(
|
|
33
|
-
content_tag(:li, class: style) do
|
|
34
|
-
content_tag(:a, name, class: "#{brand}-tabs__tab", href: "##{id}")
|
|
35
|
-
end
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def tabs_body_content
|
|
42
|
-
@tab.tabs.each_with_object(ActiveSupport::SafeBuffer.new) do |(_name, content, id, sel), body_buffer|
|
|
43
|
-
style = if sel
|
|
44
|
-
"#{brand}-tabs__panel"
|
|
45
|
-
else
|
|
46
|
-
"#{brand}-tabs__panel #{brand}-tabs__panel--hidden"
|
|
47
|
-
end
|
|
48
|
-
body_buffer.concat(content_tag(:div, content, class: style, id:))
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Govuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This concern is used to provide GOVUK Table.
|
|
7
|
-
class Table < ::DesignSystem::Generic::Builders::Table
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def table_content
|
|
11
|
-
content_tag(:table, nil, class: "#{brand}-table #{brand}-table--small-text-until-tablet") do
|
|
12
|
-
safe_buffer = ActiveSupport::SafeBuffer.new
|
|
13
|
-
|
|
14
|
-
if @table.caption
|
|
15
|
-
safe_buffer.concat(content_tag(:caption, @table.caption,
|
|
16
|
-
class: "#{brand}-table__caption #{brand}-table__caption--m"))
|
|
17
|
-
end
|
|
18
|
-
safe_buffer.concat(render_headers)
|
|
19
|
-
safe_buffer.concat(render_rows)
|
|
20
|
-
|
|
21
|
-
safe_buffer
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# brand specific <th>
|
|
26
|
-
def render_headers
|
|
27
|
-
content_tag(:thead, class: "#{brand}-table__head") do
|
|
28
|
-
content_tag(:tr, class: "#{brand}-table__row") do
|
|
29
|
-
@table.columns.each_with_object(ActiveSupport::SafeBuffer.new) do |column, header_buffer|
|
|
30
|
-
header_buffer.concat(render_header_cell(column, 'col'))
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def render_header_cell(cell, scope)
|
|
37
|
-
classes = "#{brand}-table__header"
|
|
38
|
-
classes += " #{brand}-table__header--numeric" if cell_numeric?(cell)
|
|
39
|
-
|
|
40
|
-
content_tag(:th, cell_content(cell), cell[:options].merge(scope:, class: classes))
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# brand specific <tr>
|
|
44
|
-
def render_rows
|
|
45
|
-
content_tag(:tbody, class: "#{brand}-table__body") do
|
|
46
|
-
@table.rows.each_with_object(ActiveSupport::SafeBuffer.new) do |row, rows_buffer|
|
|
47
|
-
rows_buffer.concat(render_row(row))
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def render_row(row)
|
|
53
|
-
content_tag(:tr, class: "#{brand}-table__row") do
|
|
54
|
-
row.each_with_object(ActiveSupport::SafeBuffer.new).with_index do |(cell, cell_buffer), index|
|
|
55
|
-
cell_buffer.concat(render_cell(cell, index, 'row'))
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def render_cell(cell, index, scope)
|
|
61
|
-
if index.zero?
|
|
62
|
-
render_header_cell(cell, scope)
|
|
63
|
-
else
|
|
64
|
-
render_data_cell(cell)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def render_data_cell(cell)
|
|
69
|
-
classes = "#{brand}-table__cell"
|
|
70
|
-
classes += " #{brand}-table__cell--numeric" if cell_numeric?(cell)
|
|
71
|
-
|
|
72
|
-
content_tag(:td, cell_content(cell), cell[:options].merge(class: classes))
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DesignSystem
|
|
4
|
-
module Nhsuk
|
|
5
|
-
module Builders
|
|
6
|
-
# This class provides NHSUK Action Link.
|
|
7
|
-
class ActionLink < ::DesignSystem::Generic::Builders::ActionLink
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def prep_style(name, options, html_options)
|
|
11
|
-
html_options[:class] = "#{brand}-action-link"
|
|
12
|
-
|
|
13
|
-
link_to(options, html_options) do
|
|
14
|
-
arrow_right_circle_icon +
|
|
15
|
-
content_tag(:span, name, class: "#{brand}-action-link__text")
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def arrow_right_circle_icon
|
|
20
|
-
%(
|
|
21
|
-
<svg class="nhsuk-icon nhsuk-icon__arrow-right-circle" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="36" height="36">
|
|
22
|
-
<path d="M0 0h24v24H0z" fill="none"></path>
|
|
23
|
-
<path d="M12 2a10 10 0 0 0-9.95 9h11.64L9.74 7.05a1 1 0 0 1 1.41-1.41l5.66 5.65a1 1 0 0 1 0 1.42l-5.66 5.65a1 1 0 0 1-1.41 0 1 1 0 0 1 0-1.41L13.69 13H2.05A10 10 0 1 0 12 2z"></path>
|
|
24
|
-
</svg>
|
|
25
|
-
).html_safe
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|