Skip to content
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

Update required options for components #1979

Merged
merged 13 commits into from
Oct 9, 2020

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented Oct 7, 2020

Part of #1965

What

  • Updates some component yaml files to mark certain options as required: false
  • Add any missing required attributes to options
  • Attempt to clarify option descriptions where certain options depend on/override the other

Not included:

  • Phase banner - tag is marked as required: false but failing to pass a tag means that a blank tag (with background colour) is rendered. See issue here.

Vanita Barrett added 6 commits October 7, 2020 16:24
The back-link text defaults to "Back". You can provide just a `href` to the component and it will render correctly.
Therefore, mark `text` and `html` as not required.
The character count threshold triggers the count message to be hidden by default. If not set, the count message is visible all the time.
Therefore, mark the count threshold as not required.
If checkbox item.name is not set, then the component global nameis used instead.
Therefore, mark the checkbox item.name as not required.
Match the description for the `item.name` option - when ommitted, the global option is applied instead
If the date input label is not provided, the name is used instead.
Therefore, mark the label as not required.
The visuallyHiddenText option was missing the required option. It has a default value of "Error" so is not required, but let's make that clear and keep things consistent.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1979 October 7, 2020 15:46 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1979 October 8, 2020 10:49 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1979 October 8, 2020 13:17 Inactive
@vanitabarrett vanitabarrett force-pushed the match-required-fields-examples branch from 5254cce to bc91cc5 Compare October 8, 2020 13:22
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1979 October 8, 2020 13:22 Inactive
Vanita Barrett added 6 commits October 8, 2020 15:50
The footer navigation title does not have a default.

If navigation is provided, but the title attribute is missed, you end up with an empty heading tag.
Therefore, mark the title as required.
Make it clearer that if items.id is not set, then `idPrefix` is required instead.
It is possible to pass navigation items without a `href` - you might want to do this if you're showing the current page.

However, passing a navigation item without one of `text` or `html` results in no text or link rendering at all.

Following the pattern we use for other components, we should mark `navigation.text` and `navigation.html` as required and use the description to explain that one overrides the other.

The description already explains the relationship between the two. Therefore, we should mark the navigation.text and navigation.html as required.
Both `text` and `href` attributes need to be present to create a link.

A navigation item with no href or text does not render - you end up with an empty <ul> element. We also instruct users that a navigation.title is required, so you also end up with a heading with an empty list underneath.

Therefore, mark navigation.items.text and navigation.items.href as required
Passing a href by itsef results in an invisible link (no visible text). Passing text by itself results in a link with no href.

Therefore, mark the footer meta.items.text and meta.items.href as required.
@vanitabarrett vanitabarrett force-pushed the match-required-fields-examples branch from bc91cc5 to bb983b7 Compare October 8, 2020 14:50
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1979 October 8, 2020 14:50 Inactive
@@ -13,7 +13,7 @@ params:
description: Type of input control to render. Defaults to "text".
- name: inputmode
type: string
require: false
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it when you improve your test coverage and it catches stuff like this! 👏🏻

Great job.

tasks/gulp/__tests__/after-build-package.test.js Outdated Show resolved Hide resolved
The way the previous tests were structured seemed to test for the presence of at least one single object within the component options with the required attributes, instead of all options having the correct attributes. The same was happening for the fixtures file.

This meant that one missing `required` attribute in a component yaml file would not cause the test to fail.

This commit tests for the presence of the required attributes by looping through each option/fixture. It also fixes one typo picked up by these new tests.
@vanitabarrett vanitabarrett force-pushed the match-required-fields-examples branch from bb983b7 to d52f62f Compare October 9, 2020 08:25
@vanitabarrett vanitabarrett changed the title [DRAFT] Update required options for components Update required options for components Oct 9, 2020
@vanitabarrett vanitabarrett marked this pull request as ready for review October 9, 2020 08:38
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thanks for putting the rationale in the commit messages – it made it really easy to review.

@vanitabarrett vanitabarrett merged commit 803da2c into master Oct 9, 2020
@vanitabarrett vanitabarrett deleted the match-required-fields-examples branch October 9, 2020 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants