-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from hmrc/PLATUI-441-add-currency-input
PLATUI-441: Add currency input component from hmrc-frontend
- Loading branch information
Showing
158 changed files
with
624 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...it/scala/uk/gov/hmrc/hmrcfrontend/views/components/hmrcCurrencyInputIntegrationSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2019 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.hmrc.hmrcfrontend.views.components | ||
|
||
import play.twirl.api.HtmlFormat | ||
import uk.gov.hmrc.hmrcfrontend.support.TemplateIntegrationSpec | ||
import uk.gov.hmrc.hmrcfrontend.views.html.components._ | ||
import uk.gov.hmrc.hmrcfrontend.views.viewmodels.currencyinput.Generators._ | ||
|
||
import scala.util.Try | ||
|
||
object hmrcCurrencyInputIntegrationSpec | ||
extends TemplateIntegrationSpec[CurrencyInput](hmrcComponentName = "hmrcCurrencyInput", seed = None) { | ||
|
||
override def render(currencyInput: CurrencyInput): Try[HtmlFormat.Appendable] = | ||
Try(HmrcCurrencyInput(currencyInput)) | ||
} |
93 changes: 93 additions & 0 deletions
93
...main/play-25/twirl/uk/gov/hmrc/hmrcfrontend/views/components/hmrcCurrencyInput.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
@* | ||
* Copyright 2020 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*@ | ||
|
||
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukErrorMessage | ||
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukHint | ||
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukLabel | ||
@import uk.gov.hmrc.govukfrontend.views.viewmodels.label.Label | ||
@import uk.gov.hmrc.govukfrontend.views.viewmodels.hint.Hint | ||
@import uk.gov.hmrc.govukfrontend.views.viewmodels.errormessage.ErrorMessage | ||
|
||
|
||
|
||
@(params: CurrencyInput) | ||
@import params._ | ||
@require(name.nonEmpty && id.nonEmpty, s"failed requirements for govukInput: name and id should not be empty. name=[$name], id=[$id]") | ||
|
||
@hintSnippet(describedBy: String) = @{ | ||
hint.fold((describedBy, HtmlFormat.empty)) { hint => | ||
val hintId = s"$id-hint" | ||
val describedBy1 = s"$describedBy $hintId".ltrim | ||
val hintHtml = | ||
GovukHint(Hint( | ||
id = Some(hintId), | ||
classes = hint.classes, | ||
attributes = hint.attributes, | ||
content = hint.content | ||
)) | ||
(describedBy1, hintHtml) | ||
} | ||
} | ||
|
||
@errorMessageSnippet(describedBy: String) = @{ | ||
errorMessage.fold((describedBy, HtmlFormat.empty)) { errorMessage => | ||
val errorId = s"$id-error" | ||
val describedBy1 = s"$describedBy $errorId".ltrim | ||
val errorMessageHtml = | ||
GovukErrorMessage(ErrorMessage( | ||
id = Some(errorId), | ||
classes = errorMessage.classes, | ||
attributes = errorMessage.attributes, | ||
visuallyHiddenText = errorMessage.visuallyHiddenText, | ||
content = errorMessage.content | ||
)) | ||
(describedBy1, errorMessageHtml) | ||
} | ||
} | ||
|
||
@inputSnippet(describedBy: String) = { | ||
<div class="hmrc-currency-input__wrapper"> | ||
<span class="hmrc-currency-input__unit" aria-hidden="true">£</span> | ||
<input | ||
class="@toClasses("govuk-input", classes, errorMessage.fold("")(_ => "govuk-input--error"))" | ||
id="@id" | ||
name="@name" | ||
type="text" | ||
@value.mapNonEmpty { value => value="@value" }@if(describedBy.nonEmpty) { aria-describedby="@describedBy"} | ||
@autocomplete.mapNonEmpty { autocomplete => autocomplete="@autocomplete"} | ||
inputmode="decimal" | ||
@toAttributes(attributes) | ||
/> | ||
</div> | ||
} | ||
|
||
@divSnippet = @{ | ||
val (describedBy1, hintHtml) = hintSnippet(describedBy.getOrElse("")) | ||
val (describedBy2, errorMessageHtml) = errorMessageSnippet(describedBy1) | ||
val inputHtml = inputSnippet(describedBy2) | ||
HtmlFormat.fill(collection.immutable.Seq(hintHtml, errorMessageHtml, inputHtml)) | ||
} | ||
|
||
<div class="@toClasses("govuk-form-group", errorMessage.fold("")(_ => "govuk-form-group--error"))"> | ||
@GovukLabel(Label( | ||
forAttr = Some(id), | ||
isPageHeading = label.isPageHeading, | ||
classes = label.classes, | ||
attributes = label.attributes, | ||
content = label.content | ||
)) | ||
@divSnippet | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...main/play-26/twirl/uk/gov/hmrc/hmrcfrontend/views/components/hmrcCurrencyInput.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
@* | ||
* Copyright 2020 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*@ | ||
|
||
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukErrorMessage | ||
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukHint | ||
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukLabel | ||
@import uk.gov.hmrc.govukfrontend.views.viewmodels.label.Label | ||
@import uk.gov.hmrc.govukfrontend.views.viewmodels.hint.Hint | ||
@import uk.gov.hmrc.govukfrontend.views.viewmodels.errormessage.ErrorMessage | ||
|
||
@this(GovukErrorMessage: GovukErrorMessage, GovukHint: GovukHint, GovukLabel: GovukLabel) | ||
|
||
@(params: CurrencyInput) | ||
@import params._ | ||
@require(name.nonEmpty && id.nonEmpty, s"failed requirements for govukInput: name and id should not be empty. name=[$name], id=[$id]") | ||
|
||
@hintSnippet(describedBy: String) = @{ | ||
hint.fold((describedBy, HtmlFormat.empty)) { hint => | ||
val hintId = s"$id-hint" | ||
val describedBy1 = s"$describedBy $hintId".ltrim | ||
val hintHtml = | ||
GovukHint(Hint( | ||
id = Some(hintId), | ||
classes = hint.classes, | ||
attributes = hint.attributes, | ||
content = hint.content | ||
)) | ||
(describedBy1, hintHtml) | ||
} | ||
} | ||
|
||
@errorMessageSnippet(describedBy: String) = @{ | ||
errorMessage.fold((describedBy, HtmlFormat.empty)) { errorMessage => | ||
val errorId = s"$id-error" | ||
val describedBy1 = s"$describedBy $errorId".ltrim | ||
val errorMessageHtml = | ||
GovukErrorMessage(ErrorMessage( | ||
id = Some(errorId), | ||
classes = errorMessage.classes, | ||
attributes = errorMessage.attributes, | ||
visuallyHiddenText = errorMessage.visuallyHiddenText, | ||
content = errorMessage.content | ||
)) | ||
(describedBy1, errorMessageHtml) | ||
} | ||
} | ||
|
||
@inputSnippet(describedBy: String) = { | ||
<div class="hmrc-currency-input__wrapper"> | ||
<span class="hmrc-currency-input__unit" aria-hidden="true">£</span> | ||
<input | ||
class="@toClasses("govuk-input", classes, errorMessage.fold("")(_ => "govuk-input--error"))" | ||
id="@id" | ||
name="@name" | ||
type="text" | ||
@value.mapNonEmpty { value => value="@value" }@if(describedBy.nonEmpty) { aria-describedby="@describedBy"} | ||
@autocomplete.mapNonEmpty { autocomplete => autocomplete="@autocomplete"} | ||
inputmode="decimal" | ||
@toAttributes(attributes) | ||
/> | ||
</div> | ||
} | ||
|
||
@divSnippet = @{ | ||
val (describedBy1, hintHtml) = hintSnippet(describedBy.getOrElse("")) | ||
val (describedBy2, errorMessageHtml) = errorMessageSnippet(describedBy1) | ||
val inputHtml = inputSnippet(describedBy2) | ||
HtmlFormat.fill(collection.immutable.Seq(hintHtml, errorMessageHtml, inputHtml)) | ||
} | ||
|
||
<div class="@toClasses("govuk-form-group", errorMessage.fold("")(_ => "govuk-form-group--error"))"> | ||
@GovukLabel(Label( | ||
forAttr = Some(id), | ||
isPageHeading = label.isPageHeading, | ||
classes = label.classes, | ||
attributes = label.attributes, | ||
content = label.content | ||
)) | ||
@divSnippet | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 0 additions & 87 deletions
87
src/main/scala/uk/gov/hmrc/hmrcfrontend/views/viewmodels/content/Content.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.