nhsuk / nhsuk-prototype-kit

NHS.UK prototype kit enables you to make interactive prototypes that will look like pages on NHS.UK. The prototypes you make are a great way to show ideas to others and for conducting user research.
http://nhsuk-prototype-kit.azurewebsites.net/docs
MIT License
49 stars 40 forks source link

Month (3) to word (March) Nunjucks filter #227

Open chrimesdev opened 2 years ago

chrimesdev commented 2 years ago

Description

For the formatting of dates on the check your answers page in a prototype, I came across this this useful Nunjucks filter to change a number, like 1 "12" or 04, to a month in words: https://github.com/nhsuk/permission-to-contact-prototype/blob/master/app/filters.js#L12

I think this would be useful adding to main prototype kit?

henocookie commented 2 years ago

This would help prototypes (and therefore services) meet the Dates guidance:

As far as possible, spell out months in full. Screen readers read out shortened months (Jan, Feb and so on) in inconsistent and sometimes confusing ways.

Good idea @chrimesdev 👏🏻

GrilloPress commented 2 years ago

That code looks like something I wrote up for the app prototype ages ago. So I am sure there's a smarter way of writing it. The reason we wrote it was we were redesigning the appointment booking service.

We constantly needed to convert what was inputted into dates and reflected back to the user. So we needed the filter. It saved a load of code in each template file.

https://github.com/GrilloPress/contact-preference/blob/master/app/filters.js#L165