diff --git a/app/assets/stylesheets/govuk-component/_title-print.scss b/app/assets/stylesheets/govuk-component/_title-print.scss index 25ac74ca7..206531997 100644 --- a/app/assets/stylesheets/govuk-component/_title-print.scss +++ b/app/assets/stylesheets/govuk-component/_title-print.scss @@ -1,3 +1,14 @@ +// scss-lint:disable SelectorFormat +.pub-c-title__context { + margin: 0; +} + +.pub-c-title__text { + margin-top: 0; +} +// scss-lint:enable SelectorFormat + +// To Be Deleted: Old Styling .govuk-title { .context { margin: 0; diff --git a/app/assets/stylesheets/govuk-component/_title.scss b/app/assets/stylesheets/govuk-component/_title.scss index 4f729b03f..26163410f 100644 --- a/app/assets/stylesheets/govuk-component/_title.scss +++ b/app/assets/stylesheets/govuk-component/_title.scss @@ -1,3 +1,23 @@ +// scss-lint:disable SelectorFormat +.pub-c-title { + @include responsive-vertical-margins; +} + +.pub-c-title__context { + @include core-24; + color: $secondary-text-colour; +} + +.pub-c-title__text { + @include bold-48; +} + +.pub-c-title__text--long { + @include bold-36; +} +// scss-lint:enable SelectorFormat + +// To Be Deleted: Old Styling .govuk-title { @include responsive-vertical-margins; diff --git a/app/views/govuk_component/docs/title.yml b/app/views/govuk_component/docs/title.yml index ae5aba5d0..93eba785c 100644 --- a/app/views/govuk_component/docs/title.yml +++ b/app/views/govuk_component/docs/title.yml @@ -8,6 +8,12 @@ body: | On average the titles on government bits of content are 50 characters. The average for bits of general guidance are nearer 27 characters long. +accessibility_criteria: + The page title must: + + - be part of a correct heading structure for a page + - be semantically represented as a heading + - convey the heading level fixtures: default: title: My page title diff --git a/app/views/govuk_component/title.raw.html.erb b/app/views/govuk_component/title.raw.html.erb index d220c64fa..500c84e0b 100644 --- a/app/views/govuk_component/title.raw.html.erb +++ b/app/views/govuk_component/title.raw.html.erb @@ -1,10 +1,12 @@ <% - average_title_length ||= :average + average_title_length ||= false context ||= false %> -
+
<% if context %> -

<%= context %>

+

<%= context %>

<% end %> -

<%= title %>

+

+ <%= title %> +

diff --git a/test/govuk_component/title_test.rb b/test/govuk_component/title_test.rb index fe410bf2f..df97ca137 100644 --- a/test/govuk_component/title_test.rb +++ b/test/govuk_component/title_test.rb @@ -13,11 +13,16 @@ def component_name test "title text appears" do render_component(title: "Hello World") - assert_select ".govuk-title", text: "Hello World" + assert_select ".pub-c-title__text", text: "Hello World" end test "title context appears" do render_component(title: "Hello World", context: "Format") - assert_select ".govuk-title .context", text: "Format" + assert_select ".pub-c-title__context", text: "Format" + end + + test "applies title length if supplied" do + render_component(title: "Hello World", context: "format", average_title_length: 'long') + assert_select ".pub-c-title .pub-c-title__text--long", text: "Hello World" end end