-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easier to set date values #994
Conversation
A similar change has been proposed for GOVUK frontend: alphagov/govuk-frontend#4932 |
To confirm - would this be a breaking change? |
Yes, I think so? It doesn’t change the visual output at all, but does change the default Incidentally, all of the examples on Date input specify the full items array, even though most of them don’t need to as they're outputting the default Day, Month, Year options. 🤔 |
This looks good. Just to check, does this still allow for items, for flexibility? Eg. day of week, week of year etc.
This means we'll also need a ticket to update the service manual examples separately? |
Yes, it didn't affect that at all, although @edwardhorsford's suggestion might also make it easier to set values once even if you're using custom items.
Yeah, probably? That could even be done now, as the first example on the page sets custom items even though they're the same as the default ones. Although perhaps there’s a good reason for this – consistency with the second examples where the error classes are added? Actually there could be a separate task to also make it easier to set the error classes on the default items, similar to what Joe has suggested - but that could be a follow-up, and feels a bit lower priority, given Nunjucks is rarely used in production here, and most prototypes don’t bother with error handling? |
@anandamaryon1 have updated the README for this component. This change would also need an update to the Nunjucks macro documentation in the NHS design system docs. I’ve tagged this as a breaking change, so it might need a bit of explanation in the release notes for the version of
|
…tend into add-task-list-component * 'add-task-list-component' of github.com:nhsuk/nhsuk-frontend: (34 commits) Fix encoding issue introduce in gulp v5.0 (#1013) Make it easier to set date values (#994) Update app/components/task-list/multiple-sections.njk Update packages/components/task-list/_task-list.scss Update packages/components/task-list/_task-list.scss Update app/components/task-list/multiple-sections.njk Add summary list row classes (#1007) Add summary list row condition (#1008) changelog backstop refs backstop refs change margins to padding still trying to fix linting error backstop refs remove testing markup from component examples backstop refs updated Use page template in examples update reference images tweak main wrapper margin reduce the padding on main wrapper on mobile ...
This updates the
dateInput
component to make it easier to set the values (for example, if going back to a page), without having to set the individual items.For example, currently if you do this:
There is no way to set the value for each of the day, month and year components. To do that, you need to specify the items manually, include their css classes and labels:
This PR proposed a shorter option, by doing this:
Additionally, the
name
attribute has changed fromnamePrefix-day
tonamePrefix[day]
. This is to aid in prototyping, as the NHS Prototype Kit uses the square brackets to save the data in a nested key withindata
. This means you can do this:You can also use top-level
values
object with a customitems
array as a shorthand, allowing you do this:Setting
value
within the items still works as well.