diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f3b903c..ab5daaab5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/). For compatibility information see `govukFrontendVersion` and `hmrcFrontendVersion` in [LibDependencies](project/LibDependencies.scala) + +## [9.3.0] - 2024-03-25 + +### Changed + +- Updated `HmrcHeader` template to align with `GovukHeader`, and to take in optional `menuButtonText`, `menuButtonLabel` + and `navigationLabel` parameters +- Removed `hmrc-header__service-name` and `hmrc-header__service-name--linked` classes from `HmrcHeader` +- Added Welsh translation for `Choose a language` + +### Compatible with + +- [hmrc/hmrc-frontend v6.11.0](https://github.com/hmrc/hmrc-frontend/releases/tag/v6.11.0) +- [alphagov/govuk-frontend v5.2.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.2.0) + ## [9.2.0] - 2024-03-22 ### Changed diff --git a/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/controllers/Assets.scala b/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/controllers/Assets.scala index aa04827e8..ce86bdd2d 100644 --- a/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/controllers/Assets.scala +++ b/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/controllers/Assets.scala @@ -17,7 +17,6 @@ package uk.gov.hmrc.hmrcfrontend.controllers import controllers.{AssetsBuilder, AssetsMetadata} -import play.api.Environment import javax.inject.{Inject, Singleton} import play.api.http.HttpErrorHandler diff --git a/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/views/viewmodels/header/Header.scala b/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/views/viewmodels/header/Header.scala index 3b1aa8b2f..2339cd87f 100644 --- a/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/views/viewmodels/header/Header.scala +++ b/play-frontend-hmrc-play-30/src/main/scala/uk/gov/hmrc/hmrcfrontend/views/viewmodels/header/Header.scala @@ -45,7 +45,9 @@ case class Header( userResearchBanner: Option[UserResearchBanner] = None, phaseBanner: Option[PhaseBanner] = None, additionalBannersBlock: Option[Html] = None, - menuButtonLabel: Option[String] = None + menuButtonLabel: Option[String] = None, + menuButtonText: Option[String] = None, + navigationLabel: Option[String] = None ) { // We use this method instead of using the input language toggle directly @@ -85,7 +87,9 @@ object Header { (__ \ "userResearchBanner").readNullable[UserResearchBanner] and (__ \ "phaseBanner").readNullable[PhaseBanner] and (__ \ "additionalBannersBlock").readNullable[Html] and - (__ \ "menuButtonLabel").readNullable[String] + (__ \ "menuButtonLabel").readNullable[String] and + (__ \ "menuButtonText").readNullable[String] and + (__ \ "navigationLabel").readNullable[String] )(Header.apply _) implicit def jsonWrites: OWrites[Header] = @@ -108,6 +112,8 @@ object Header { (__ \ "userResearchBanner").writeNullable[UserResearchBanner] and (__ \ "phaseBanner").writeNullable[PhaseBanner] and (__ \ "additionalBannersBlock").writeNullable[Html] and - (__ \ "menuButtonLabel").writeNullable[String] + (__ \ "menuButtonLabel").writeNullable[String] and + (__ \ "menuButtonText").writeNullable[String] and + (__ \ "navigationLabel").writeNullable[String] )(header => unlift(Header.unapply)(header.copy(inputLanguageToggle = header.languageToggle))) } diff --git a/play-frontend-hmrc-play-30/src/main/twirl/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeader.scala.html b/play-frontend-hmrc-play-30/src/main/twirl/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeader.scala.html index d1a0090d2..662fd313c 100644 --- a/play-frontend-hmrc-play-30/src/main/twirl/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeader.scala.html +++ b/play-frontend-hmrc-play-30/src/main/twirl/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeader.scala.html @@ -89,7 +89,7 @@
@serviceNameLinkOrSpan(serviceName, serviceUrl) @if(navigation.getOrElse(Seq.empty).nonEmpty) { -
- + Service Name
- + Service Name
- + Service Name
- + Gwasanaeth enghreifftiol
- + Example Service
- + Service with HMRC Banner and an additional one
diff --git a/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/component.json b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/component.json new file mode 100644 index 000000000..7cd43b887 --- /dev/null +++ b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/component.json @@ -0,0 +1,3 @@ +{ + "name" : "hmrcHeader" +} \ No newline at end of file diff --git a/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/input.json b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/input.json new file mode 100644 index 000000000..2e07cdbb4 --- /dev/null +++ b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/input.json @@ -0,0 +1,19 @@ +{ + "navigation" : [ { + "href" : "#1", + "text" : "Navigation item 1", + "active" : true + }, { + "href" : "#2", + "text" : "Navigation item 2" + }, { + "href" : "#3", + "text" : "Navigation item 3" + }, { + "href" : "#4", + "text" : "Navigation item 4" + } ], + "menuButtonText" : "Custom button text", + "menuButtonLabel" : "Custom button label", + "navigationLabel" : "Custom navigation label" +} \ No newline at end of file diff --git a/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/output.txt b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/output.txt new file mode 100644 index 000000000..26ee168b4 --- /dev/null +++ b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-custom-navigation-text-and-labels/output.txt @@ -0,0 +1,54 @@ + +
+
+ +
+
diff --git a/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-hmrc-banner-english/output.txt b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-hmrc-banner-english/output.txt index 1cac3e198..39b7ba4a1 100644 --- a/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-hmrc-banner-english/output.txt +++ b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-hmrc-banner-english/output.txt @@ -20,11 +20,11 @@
- + Service with HMRC Banner -
- + Gwasanaeth gyda Banner CThEF -
- + Example Service -
- + Gwasanaeth enghreifftiol -
- + Gwasanaeth ar gyfer gwasanaeth gydag enw hir iawn yn Gymraeg
- + Service name
- + Service Name
- + Service Name
diff --git a/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-service-name/output.txt b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-service-name/output.txt index d43062171..007235f7b 100644 --- a/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-service-name/output.txt +++ b/play-frontend-hmrc-play-30/src/test/resources/fixtures/hmrc-frontend/test-fixtures/header-with-service-name/output.txt @@ -20,7 +20,7 @@
- + Service Name
diff --git a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeaderSpec.scala b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeaderSpec.scala index 4e5ed5d4d..aba305b5f 100644 --- a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeaderSpec.scala +++ b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/components/HmrcHeaderSpec.scala @@ -36,7 +36,7 @@ class HmrcHeaderSpec extends TemplateUnitSpec[Header, HmrcHeader]("hmrcHeader") Header(serviceName = Some(""), containerClasses = "govuk-width-container", signOutHref = Some("/sign-out")) val componentTry = Try(component(params)) - componentTry should be a 'success + componentTry.isSuccess shouldBe true } """display Tudor crown logo set by config""" in { @@ -49,8 +49,8 @@ class HmrcHeaderSpec extends TemplateUnitSpec[Header, HmrcHeader]("hmrcHeader") val componentTry = Try(hmrcHeader(Header())) - componentTry should be a 'success - componentTry.get.body should include("M22.6 10.4c-1") + componentTry.isSuccess shouldBe true + componentTry.get.body should include("M22.6 10.4c-1") } """display St Edwards crown logo when set by config""" in { @@ -63,8 +63,8 @@ class HmrcHeaderSpec extends TemplateUnitSpec[Header, HmrcHeader]("hmrcHeader") val componentTry = Try(hmrcHeader(Header())) - componentTry should be a 'success - componentTry.get.body should include("M6.7 12.2c1") + componentTry.isSuccess shouldBe true + componentTry.get.body should include("M6.7 12.2c1") } """display Tudor crown when no config is found""" in { @@ -73,8 +73,8 @@ class HmrcHeaderSpec extends TemplateUnitSpec[Header, HmrcHeader]("hmrcHeader") val componentTry = Try(hmrcHeader(Header())) - componentTry should be a 'success - componentTry.get.body should include("M22.6 10.4c-1") + componentTry.isSuccess shouldBe true + componentTry.get.body should include("M22.6 10.4c-1") } } } diff --git a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/HmrcStandardPageSpec.scala b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/HmrcStandardPageSpec.scala index ad2c6ca36..eecebebc5 100644 --- a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/HmrcStandardPageSpec.scala +++ b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/HmrcStandardPageSpec.scala @@ -89,7 +89,7 @@ class HmrcStandardPageSpec "not bind a service title by default" in { val document = Jsoup.parse(contentAsString(defaultHmrcStandardPage)) - val serviceNameLink = document.select(".hmrc-header__service-name") + val serviceNameLink = document.select(".govuk-header__service-name") serviceNameLink should have size 0 } @@ -101,7 +101,7 @@ class HmrcStandardPageSpec ) val document = Jsoup.parse(content) - val serviceNameLink = document.select(".hmrc-header__service-name") + val serviceNameLink = document.select(".govuk-header__service-name") serviceNameLink should have size 1 serviceNameLink.text() shouldBe "My Service Name" } @@ -181,7 +181,7 @@ class HmrcStandardPageSpec "not include a service url by default" in { val document = Jsoup.parse(contentAsString(defaultHmrcStandardPage)) - val homepageLink = document.select(".hmrc-header__service-name") + val homepageLink = document.select(".govuk-header__service-name") homepageLink should have size 0 } @@ -189,7 +189,7 @@ class HmrcStandardPageSpec val page = hmrcStandardPage(HmrcStandardPageParams(serviceName = Some("My Service")))(Html("")) val document = Jsoup.parse(contentAsString(page)) - val homepageLink = document.select(".hmrc-header__service-name") + val homepageLink = document.select(".govuk-header__service-name") homepageLink should have size 1 homepageLink.attr("href") shouldBe "" } @@ -205,7 +205,7 @@ class HmrcStandardPageSpec )(Html("")) val document = Jsoup.parse(contentAsString(page)) - val homepageLink = document.select(".hmrc-header__service-name") + val homepageLink = document.select(".govuk-header__service-name") homepageLink should have size 1 homepageLink.attr("href") shouldBe "my-homepage-route" homepageLink.text() shouldBe "My Service" diff --git a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcLayoutSpec.scala b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcLayoutSpec.scala index 427f10694..524611a88 100644 --- a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcLayoutSpec.scala +++ b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcLayoutSpec.scala @@ -88,7 +88,7 @@ class hmrcLayoutSpec "not bind a service title by default" in { val document = Jsoup.parse(contentAsString(defaultHmrcLayout)) - val serviceNameLink = document.select(".hmrc-header__service-name") + val serviceNameLink = document.select(".govuk-header__service-name") serviceNameLink should have size 0 } @@ -99,7 +99,7 @@ class hmrcLayoutSpec contentAsString(hmrcLayout(serviceName = Some("My Service Name"))(Html(""))(fakeRequest, messages)) val document = Jsoup.parse(content) - val serviceNameLink = document.select(".hmrc-header__service-name") + val serviceNameLink = document.select(".govuk-header__service-name") serviceNameLink should have size 1 serviceNameLink.text() shouldBe "My Service Name" } @@ -187,7 +187,7 @@ class hmrcLayoutSpec "not include a service url by default" in { val document = Jsoup.parse(contentAsString(defaultHmrcLayout)) - val homepageLink = document.select(".hmrc-header__service-name") + val homepageLink = document.select(".govuk-header__service-name") homepageLink should have size 0 } @@ -197,7 +197,7 @@ class hmrcLayoutSpec val layout = hmrcLayout(serviceName = Some("My Service"))(Html(""))(fakeRequest, messages) val document = Jsoup.parse(contentAsString(layout)) - val homepageLink = document.select(".hmrc-header__service-name") + val homepageLink = document.select(".govuk-header__service-name") homepageLink should have size 1 homepageLink.attr("href") shouldBe "" } @@ -211,7 +211,7 @@ class hmrcLayoutSpec )(Html(""))(fakeRequest, messages) val document = Jsoup.parse(contentAsString(layout)) - val homepageLink = document.select(".hmrc-header__service-name") + val homepageLink = document.select(".govuk-header__service-name") homepageLink should have size 1 homepageLink.attr("href") shouldBe "my-homepage-route" homepageLink.text() shouldBe "My Service" diff --git a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcStandardHeaderSpec.scala b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcStandardHeaderSpec.scala index 42e624766..a8ca71ea9 100644 --- a/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcStandardHeaderSpec.scala +++ b/play-frontend-hmrc-play-30/src/test/scala/uk/gov/hmrc/hmrcfrontend/views/helpers/hmrcStandardHeaderSpec.scala @@ -75,7 +75,7 @@ class HmrcStandardHeaderSpec extends AnyWordSpecLike with Matchers with JsoupHel val messages = getMessages(Map("en" -> Map("service.name" -> "Foo Service"))) val content = contentAsString(hmrcStandardHeader(serviceUrl = Some("/foo"))(messages, fakeRequest)) val document = Jsoup.parse(content) - val links = document.select(".hmrc-header__service-name") + val links = document.select(".govuk-header__service-name") links should have size 1 links.first.attr("href") should be("/foo") @@ -90,7 +90,7 @@ class HmrcStandardHeaderSpec extends AnyWordSpecLike with Matchers with JsoupHel hmrcStandardHeader(serviceUrl = Some("/foo"), serviceName = Some("Bam Service"))(messages, fakeRequest) ) val document = Jsoup.parse(content) - val links = document.select(".hmrc-header__service-name") + val links = document.select(".govuk-header__service-name") links should have size 1 links.first.text should be("Bam Service") @@ -104,7 +104,7 @@ class HmrcStandardHeaderSpec extends AnyWordSpecLike with Matchers with JsoupHel hmrcStandardHeader(serviceUrl = Some("/foo"), serviceName = Some("Bar Service"))(messages, fakeRequest) ) val document = Jsoup.parse(content) - val links = document.select(".hmrc-header__service-name") + val links = document.select(".govuk-header__service-name") links should have size 1 links.first.text should be("Bar Service") @@ -116,7 +116,7 @@ class HmrcStandardHeaderSpec extends AnyWordSpecLike with Matchers with JsoupHel val messages = getMessages(Map("cy" -> Map("service.name" -> "Welsh Service")), Lang("cy")) val content = contentAsString(hmrcStandardHeader()(messages, fakeRequest)) val document = Jsoup.parse(content) - val links = document.select(".hmrc-header__service-name") + val links = document.select(".govuk-header__service-name") links should have size 1 links.first.text should be("Welsh Service") diff --git a/project/LibDependencies.scala b/project/LibDependencies.scala index 8ab2979eb..dea977fc5 100644 --- a/project/LibDependencies.scala +++ b/project/LibDependencies.scala @@ -2,7 +2,7 @@ import sbt._ object LibDependencies { val govukFrontendVersion: String = "5.2.0" - val hmrcFrontendVersion: String = "6.4.0" + val hmrcFrontendVersion: String = "6.11.0" val playLanguageVersion: String = "7.0.0" val play28Version = "2.8.20"