design_system 0.13.1 → 0.14.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: 6ddbf824c3c04882aad8ea47ae6ca5d5dcc1798d6d44d5cc82afbb4503830794
4
- data.tar.gz: 0ec5ac5539c5fd885a8b4f48f5095733a177a6d3cee37fafe2a46b9ba3fac192
3
+ metadata.gz: e985fe0cfcfbfc619222a57c2501acff5e4172e0eb8b3767069c0f1f66f8541d
4
+ data.tar.gz: 72436a314d93ae0f3f35089969cb0e2a1524c156373dedbd059112e11340a1be
5
5
  SHA512:
6
- metadata.gz: 4091c2841ce407790524424a4cdeaee68a1f4fe25aadc5f9a4c4124f1c83d35f0ec3b07c92803a7e5181396098ddf432a3d30dfea0252513d4ba4382156ed216
7
- data.tar.gz: df2bee72498df8b22f065fa5ca799b0ca9ff4625596a99aa4e2ec4e411f8d8dc7f9d0d0ecf8e837fa77b5b273da408f85cb109f82c5dc4161ef173e6580426e0
6
+ metadata.gz: e9eeff12697761fdf1542041c31b4b85acdfc29bd01682da6cb06a3a711482ed532271837328faf7ee2f2cd552349a73d481e7a6f5717a2207d267584e6ddc14
7
+ data.tar.gz: 7c19fed7bbfee92c6e585615bfb8d956d1ac8ff38c2938b32d634dac0125084a3756b43d5cc81c143491c5eeae62f7320705bfab6d283ae88fb791099315691b
data/README.md CHANGED
@@ -80,7 +80,40 @@ bundle exec rake js:build
80
80
 
81
81
  ## Contributing
82
82
 
83
- Contribution directions go here.
83
+ ### Setting up
84
+
85
+ This project uses [mise](https://mise.jdx.dev/) to manage Ruby. With mise installed, run `mise install` from the project root to install the Ruby version pinned in `.ruby-version`. Then install the gems:
86
+
87
+ ```bash
88
+ bundle install
89
+ ```
90
+
91
+ To run the dummy app or the accessibility workflows locally, also install the dummy app's Node packages:
92
+
93
+ ```bash
94
+ cd test/dummy && npm install
95
+ ```
96
+
97
+ ### Running the tests
98
+
99
+ ```bash
100
+ bin/rails test
101
+ ```
102
+
103
+ The suite runs against the dummy app at `test/dummy`. On a fresh checkout the test helper compiles Dart Sass automatically on the first run; subsequent runs are fast.
104
+
105
+ ### Running the dummy app
106
+
107
+ ```bash
108
+ cd test/dummy
109
+ bin/dev
110
+ ```
111
+
112
+ This starts the Rails server alongside `dartsass:watch`, so styles rebuild as you edit.
113
+
114
+ ### CI
115
+
116
+ `bin/rails test` runs on every push and pull request via the `Test` workflow. Accessibility (`wcag2aa`, `wcag2aaa`) and inclusive-language checks run separately.
84
117
 
85
118
  Created using:
86
119
 
@@ -78,8 +78,8 @@ module DesignSystemHelper
78
78
  DesignSystem::Registry.builder(brand, 'notification', self).render_alert(message, &)
79
79
  end
80
80
 
81
- def ds_notice(message = nil, header: nil, type: :information, &)
82
- DesignSystem::Registry.builder(brand, 'notification', self).render_notice(message, header:, type:, &)
81
+ def ds_notice(message = nil, type: :information, content_heading: { text: nil, tag: :h3 }, &)
82
+ DesignSystem::Registry.builder(brand, 'notification', self).render_notice(message, type:, content_heading:, &)
83
83
  end
84
84
 
85
85
  def ds_heading(text, level: 2, **options)
@@ -5,6 +5,7 @@ module DesignSystem
5
5
  module Builders
6
6
  # This class provides generic methods to display notifications.
7
7
  class Notification < Base
8
+ include ActionView::Helpers::OutputSafetyHelper
8
9
  include ActionView::Helpers::SanitizeHelper
9
10
 
10
11
  def render_alert(msg = nil, &)
@@ -16,19 +17,22 @@ module DesignSystem
16
17
  end
17
18
  end
18
19
 
19
- def render_notice(msg = nil, header: nil, type: :information, &)
20
+ def render_notice(msg = nil, type: :information, content_heading: { text: nil, tag: :h3 }, &)
20
21
  @context.instance_variable_set(:@link_context, :notification_banner)
21
22
 
22
- raise ArgumentError,
23
- "Invalid notification type: #{type}. Must be one of: #{notification_type_hash.keys.join(', ')}" unless notification_type_hash.key?(type)
23
+ unless notification_type_hash.key?(type)
24
+ raise ArgumentError,
25
+ "Invalid notification type: #{type}. Must be one of: #{notification_type_hash.keys.join(', ')}"
26
+ end
24
27
 
25
- header ||= notification_type_hash.dig(type, :header)
28
+ header = notification_type_hash.dig(type, :header)
29
+
30
+ content_body = block_given? ? capture(&) : msg
26
31
 
27
- content_to_display = block_given? ? capture(&) : msg
28
32
  content_tag(:div, class: notification_type_hash.dig(type, :class), role: notification_type_hash.dig(type, :role),
29
33
  'aria-labelledby': "#{brand}-notification-banner-title",
30
34
  'data-module': "#{brand}-notification-banner") do
31
- banner_tile(header) + banner_content(content_to_display)
35
+ banner_tile(header) + banner_content(content_body, content_heading:)
32
36
  end
33
37
  end
34
38
 
@@ -41,10 +45,19 @@ module DesignSystem
41
45
  end
42
46
  end
43
47
 
44
- def banner_content(content)
48
+ def banner_content(content_body, content_heading: {})
45
49
  content_tag(:div, class: "#{brand}-notification-banner__content") do
46
- content_tag(:p, content,
47
- class: "#{brand}-notification-banner__heading")
50
+ content = []
51
+
52
+ if content_heading.present? && content_heading[:text].present?
53
+ tag = content_heading[:tag] || :h3
54
+ raise ArgumentError, "Invalid content_heading tag: #{tag}.}" unless tag.in?(%i[h3 p])
55
+
56
+ content << content_tag(tag, content_heading[:text], class: "#{brand}-notification-banner__heading")
57
+ end
58
+ content << content_body if content_body.present?
59
+
60
+ safe_join(content)
48
61
  end
49
62
  end
50
63
 
@@ -1,3 +1,3 @@
1
1
  module DesignSystem
2
- VERSION = '0.13.1'.freeze
2
+ VERSION = '0.14.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: design_system
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filis Liu
@@ -462,7 +462,6 @@ files:
462
462
  - lib/design_system/nhsuk/builders/elements/breadcrumbs.rb
463
463
  - lib/design_system/nhsuk/builders/fixed_elements.rb
464
464
  - lib/design_system/nhsuk/builders/grid.rb
465
- - lib/design_system/nhsuk/builders/grid_test.rb
466
465
  - lib/design_system/nhsuk/builders/heading.rb
467
466
  - lib/design_system/nhsuk/builders/inset_text.rb
468
467
  - lib/design_system/nhsuk/builders/link.rb
@@ -480,7 +479,7 @@ files:
480
479
  - lib/tasks/design_system_tasks.rake
481
480
  - lib/tasks/govuk.rake
482
481
  - lib/tasks/nhsuk.rake
483
- - public/design_system/static/design_system-0.13.1/design_system.js
482
+ - public/design_system/static/design_system-0.14.0/design_system.js
484
483
  - public/design_system/static/govuk-frontend-5.11.1/fonts/bold-affa96571d-v2.woff
485
484
  - public/design_system/static/govuk-frontend-5.11.1/fonts/bold-b542beb274-v2.woff2
486
485
  - public/design_system/static/govuk-frontend-5.11.1/fonts/light-94a07e06a1-v2.woff2
@@ -1,109 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DesignSystem
4
- module Nhsuk
5
- module Builders
6
- # This tests the nhsuk grid builder
7
- class GridTest < ActionView::TestCase
8
- include DesignSystemHelper
9
-
10
- setup do
11
- @brand = 'nhsuk'
12
- @controller.stubs(:brand).returns(@brand)
13
- end
14
-
15
- test 'should fail if width is specified' do
16
- assert_raises(ArgumentError) do
17
- ds_grid do |grid|
18
- grid.add_column do
19
- 'Test content'
20
- end
21
- end
22
- end
23
- end
24
-
25
- test 'should fail if given width is not supported' do
26
- error = assert_raises(ArgumentError) do
27
- ds_grid do |grid|
28
- grid.add_column(:nonsense_width) do
29
- 'Test content'
30
- end
31
- end
32
- end
33
- assert_equal 'Unknown grid width: nonsense_width', error.message
34
- end
35
-
36
- test 'should render block of content' do
37
- @output_buffer = ds_grid do |grid|
38
- grid.add_column(:two_thirds) do
39
- content_tag(:p, 'Test content')
40
- end
41
- end
42
-
43
- assert_select "div.#{brand}-grid-row" do
44
- assert_select "div.#{brand}-grid-column-two-thirds" do
45
- assert_select 'p', text: 'Test content'
46
- end
47
- end
48
- end
49
-
50
- test 'should render multiple columns' do
51
- @output_buffer = ds_grid do |grid|
52
- grid.add_column(:two_thirds) do
53
- content_tag(:p, 'Two thirds content')
54
- end
55
- grid.add_column(:one_third) do
56
- content_tag(:p, 'One third content')
57
- end
58
- end
59
- assert_select "div.#{brand}-grid-row" do
60
- assert_select "div.#{brand}-grid-column-two-thirds" do
61
- assert_select 'p', text: 'Two thirds content'
62
- end
63
- assert_select "div.#{brand}-grid-column-one-third" do
64
- assert_select 'p', text: 'One third content'
65
- end
66
- end
67
- end
68
-
69
- test 'should raise an error if total width exceeds 100%' do
70
- error = assert_raises(ArgumentError) do
71
- ds_grid do |grid|
72
- grid.add_column(:two_thirds) do
73
- content_tag(:p, 'Two thirds content')
74
- end
75
- grid.add_column(:two_thirds) do
76
- content_tag(:p, 'Two thirds content')
77
- end
78
- end
79
- end
80
- assert_equal 'Total grid width exceeds 100%', error.message
81
- end
82
-
83
- test 'should render nested grid' do
84
- @output_buffer = ds_grid do |row|
85
- row.add_column(:two_thirds) do
86
- content_tag(:p, 'Outer two thirds content') +
87
- ds_grid do |inner_row|
88
- inner_row.add_column(:two_thirds) do
89
- content_tag(:p, 'Inner two thirds content')
90
- end
91
- end
92
- end
93
- end
94
-
95
- assert_select "div.#{brand}-grid-row" do
96
- assert_select "div.#{brand}-grid-column-two-thirds" do
97
- assert_select 'p', text: 'Outer two thirds content'
98
- assert_select "div.#{brand}-grid-row" do
99
- assert_select "div.#{brand}-grid-column-two-thirds" do
100
- assert_select 'p', text: 'Inner two thirds content'
101
- end
102
- end
103
- end
104
- end
105
- end
106
- end
107
- end
108
- end
109
- end