Giter Site home page Giter Site logo

play-ui's Introduction

Deprecation

🚨 play-ui has been deprecated in favour of play-frontend-hmrc. 🚨

This library is no longer supported, and teams need to be aware of the vulnerabilities via the dependency on assets-frontend. There are also known accessibility issues with play-ui which will cause delays with going live. As of 13th October 2021, we won't be making updates to play-ui so we recommend moving over to the latest play-frontend-hmrc

play-ui

Deprecated micro-library containing core for HMRC's Play UI:

Formatters

  • Dates provides various human-readable date formats
  • Money formats pounds and pence
  • Strings changes the case of phrases and hyphenates

Form Mappers & Validators

  • DateTuple maps year, month, day fields to a LocalDate
  • StopOnFirstFail applies constraints in order and fails fast
  • Validators contains multiple small validation functions such as addressTuple, positiveInteger & nonEmptySmallText

Helper Templates

Has many standard snippets for form fields, such as: address, dateFields, dropdown, fieldGroup. Each helper correctly adds labels, error messages and CSS classes.

Layout Templates

Contains templates for components used across frontend applications such as: header, footer, sidebar, betaBanner.

Accessibility Statements

The FooterLinks component generates the standard list of links for passing into Gov.UK template.

To configure this component to link to the new Accessibility Statement service, provide the key accessibility-statement.service-path in your application.conf. This key is the path to your accessibility statement under https://www.tax.service.gov.uk/accessibility-statement.

For example, if your accessibility statement is https://www.tax.service.gov.uk/accessibility-statement/discounted-icecreams, this property must be set to /discounted-icecreams as follows:

accessibility-statement.service-path = "/discounted-icecreams"

Integrating with Tracking Consent

If you intend to use Google Analytics to measure usage of your service, you will need to integrate with tracking consent. The HeadWithTrackingConsent component is a replacement to the existing Head component and generates the HTML SCRIPT tags necessary to integrate with tracking-consent-frontend

Before integrating, it is important to remove any existing snippets relating to GTM or Optimizely, for example, through use of the Head or GTMSnippet components. Tracking consent manages the enabling of these third-party solutions based on the user's tracking preferences. If they are not removed there is a risk the user's tracking preferences will not be honoured.

Configure your service's GTM container in conf/application.conf. For example, if you have been instructed to use GTM container a, the configuration would appear as:

tracking-consent-frontend {
  gtm.container = "a"
}

gtm.container can be one of: a, b, c, d, e, f or sdes. Consult with the CIPSAGA team to understand which GTM container you should be using in your service.

If you are already using the Head template, simply replace with HeadWithTrackingConsent.

If you are not using Head, locate in your frontend code the location where common Javascripts and stylesheets are added to the HTML HEAD element. Add TrackingConsentSnippet above the other assets in the HEAD tag. For example,

@this(trackingConsentSnippet: TrackingConsentSnippet)

...

@trackingConsentSnippet()

<link href='path-to-asset.css' media="all" rel="stylesheet" type="text/css" />
...

If using Play 2.7 and CSPFilter, the nonce can be passed to tracking consent as follows:

@import views.html.helper.CSPNonce
...
@trackingConsentSnippet(nonce = CSPNonce.get)
...

Adding to your service

Add the library to the project dependencies:

libraryDependencies += "uk.gov.hmrc" %% "play-language" % "[INSERT VERSION]"

Ensure to add the resolvers to your plugins.sbt:

resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2")
resolvers += Resolver.url("HMRC-open-artefacts-ivy", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "[INSERT VERSION 3.0.0 OR HIGHER]")

If you require either Head or Footer you'll also need to add some config to your application.conf file in order to build the complete urls for assets:

assets {
  version = "x.x.x"
  url = ""
}

Play Framework and Scala compatibility notes

This library is currently compatible with:

  • Scala 2.12
  • Play 2.6, Play 2.7, Play 2.8

And with the addition of support for Play 2.8 we have had to remove compatibility with Scala 2.11.

Additionally, the deprecated static helpers for components available in versions targeting up to Play 2.7 have been excluded from versions targeting Play 2.8. When upgrading your service to Play 2.8 you will now need to include components via Dependency Injection within templates instead.

How to test changes locally

Publish the library locally with

sbt clean compile publishLocal

This will build and install the library into your local Ivy cache. The final lines of the output will contain the version number.

Then update the configuration of your frontend application to use this version number. This is in different files depending on the application. In business-tax-account, it is in FrontendBuild.scala. In one-time-password-frontend, it is in MicroServiceBuild.scala. The line will look like "uk.gov.hmrc" %% "play-ui" % "4.10"

now restart your frontend application, and you will see your local changes.

n.b. you will need to run the sbt command to publish locally each time you make a change.

License

This code is open source software licensed under the Apache 2.0 License.

play-ui's People

Contributors

adamliversidge avatar alexanderjamesking avatar andynewton avatar anshulbajpai avatar benaveryee avatar benjaminparker avatar bennetimo avatar beyond-code-github avatar callumcodes avatar dabd avatar duncancrawford avatar feedmypixel avatar gordonmcmullan avatar howyp avatar iteratoruk avatar jopintopaul avatar kerrzinga avatar konradwudkowski avatar kyle-bowden avatar matthewmascord avatar oscarduignan avatar philsherry avatar rbangay avatar rpowis avatar silasl avatar steve-e avatar timsb avatar tomasz-rosiek avatar ufuoma-daniel avatar wolfendale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

play-ui's Issues

Input Id should not contain dot characters, should use Play Framework's method field.id.

Input Id should not contain dot characters and should use Play Framework's inbuilt method field.id rather than using field.name. field.id essentially replaces . characters with _

. characters cause problems with Javascript/Jquery as anything after the dot is incorrectly treated as a class.

I have fixed the issues for my use case, however there are more places in Play-UI where id=field.name instead of field.id

Please see my forked commit linked below:
https://github.com/LukeDeighton/play-ui/commit/806023bfec292d71781d088fd053cf6d1fc0d019

Add support for Welsh language

Welsh language support is a common business requirement that many teams have to implement. This has lead to different teams creating different ways to achieve the same result. I propose moving the logic into play-ui so that it is common across all teams and can be easily implemented. Alternatively, would this be better within its own 'play-language-support' project?

validDateTuple references a non existent message

When entering all letters for a date using validDateTuple (eg a bb cccc) the validation message seen on screen is "error.enter_numbers".
This is because in messages.en, there is a typo where an extra underscore is included at the end - "error.enter_numbers_"

Footer missing an h2 for meta links

An internal accessibility review found that our footer was missing an h2.
"Check that you are using the most recent code to generate the footer. The H2 text ‘Support links’ looks to be missing - h2 class="govuk-visually-hidden"/>Support links h2/>
See GOV.UK design system https://design-system.service.gov.uk/components/footer/ the section ‘Footer with links to meta information’ seems to match the layout you have."

<legend> ending up beneath <label>

Hi, I'm not sure if this is due to the way our team used it but we were experiencing a problem with the elements when rendered. The issue was two fold.
clkuhup
The Yes on the first label, or any first element was dropping to the next line when rendered and the legend was being covered by the . I attempted a couple of workarounds using CSS and Z-Index and all failed. In the end I took the out of the Helper and put it directly in front of the helper so it rendered then the helper. This solved both problems.
Using firebug I think the issue is with the Clear:none; on the block-label

Whitespace padding on <option> display values

The dropdown helper adds whitespace padding to the option display values. This is more noticeable when used in conjunction with the accessible-autocomplete component (https://github.com/alphagov/accessible-autocomplete)

Currently it looks like:-
image

After the code change:-
image

I created a unit test which failed and then the dropdown helper was modified to remove the whitespace

[info] @helpers.dropDown
[info] - should render element options *** FAILED ***
[info] "...ntry-AU" value="AU">[ Australia ]" was not equal to "...ntry-AU" value="AU">[Australia]" (DropDownSpec.scala:45)

The PR for this is #77

Question on Feildset

Hi is there anyway I can stop the fieldset getting written as I've already got a

before so I end up with fieldet -> legend -> feildset.
Any help appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.