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

Add notifications banner template macro and tests #1977

Merged
merged 5 commits into from
Oct 22, 2020

Conversation

hannalaakso
Copy link
Member

This PR adds

  • a template macro for the notification banner component
  • tests for the template logic
  • examples of the component

Please don't review the stylesheets for now, they are from the demo version and need to be worked on separately; this could be done as part of #1934.

Addresses parts of #1935

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 6, 2020 17:22 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 6, 2020 17:53 Inactive
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.

Looking really good so far 👍🏻

src/govuk/components/notification-banner/template.njk Outdated Show resolved Hide resolved
src/govuk/components/notification-banner/template.njk Outdated Show resolved Hide resolved
src/govuk/components/notification-banner/template.njk Outdated Show resolved Hide resolved
src/govuk/components/notification-banner/template.njk Outdated Show resolved Hide resolved
src/govuk/components/notification-banner/template.test.js Outdated Show resolved Hide resolved
src/govuk/components/notification-banner/README.md Outdated Show resolved Hide resolved

## Installation

See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably update these to point to the Frontend docs at some point…

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 13, 2020 09:26 Inactive
@hannalaakso
Copy link
Member Author

Thanks for the reviews @36degrees and @vanitabarrett 🙌 I think I've now resolved most of the comments, mainly apart from #1977 (comment) where it'd be good to decide how we name space boolean data attributes. I've left 2 TO DO's in the template code pending a decision.

I'm going to do a review of the documentation side of things with Eoin next.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 13, 2020 10:23 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 15, 2020 18:02 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 15, 2020 18:06 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 20, 2020 08:43 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 20, 2020 08:54 Inactive
- name: text
type: string
required: true
description: If `html` is set, this is not required. Text to use within the notification banner. If `html` is provided, the `text` argument will be ignored.
Copy link
Contributor

@EoinShaughnessy EoinShaughnessy Oct 21, 2020

Choose a reason for hiding this comment

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

Does "text to use" suggest that users do something with the text once it's inside the notification banner? Suggested tweak: "The text to display within the notification banner."

Also, should this info display at the start of the description, i.e., after Required? This would inform the user what the text option is before they learn about the effect html has on it.

Re first and last sentences — could personalise and phrase in active voice. So, "If you set 'html', this..." and "If you provide 'html', this..."

Copy link
Member Author

@hannalaakso hannalaakso Oct 22, 2020

Choose a reason for hiding this comment

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

We're going to do a separate wider review of the template options docs as this comment touches on most of the components.

- name: html
type: string
required: true
description: If `text` is set, this is not required. HTML to use within the notification banner. If `html` is provided, the `text` argument will be ignored.
Copy link
Contributor

@EoinShaughnessy EoinShaughnessy Oct 21, 2020

Choose a reason for hiding this comment

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

Could personalise first and last sentences and phrase them in the active voice: "If you set 'text', this..." and "If you provide 'html', this..."

Do we say 'parameter' instead of 'argument'?

Should "HTML to use within the notification banner" display at the start of the description, i.e., after Required? This would inform the user what the option is before they learn anything else about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we say 'parameter' instead of 'argument'?

We actually say 'option' 😅 but this might not always be consistent throughout the rest of the tech docs.

type: string
required: true
description: If `html` is set, this is not required. Text to use within the notification banner. If `html` is provided, the `text` argument will be ignored.
- name: html
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the table options display in order of importance? If not, then is there a case for displaying them alphabetically? (I understand, though, if we wouldn't want to change the order because it would make this doc inconsistent with other docs.)

Copy link
Member Author

Choose a reason for hiding this comment

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

We have a loose order of importance (very loose in fact) and we seem to have settled on a bit of a hierarchy where text/html come first and the classes option is always last. We could definitely review that though.

type: string
required: true
description: If `text` is set, this is not required. HTML to use within the notification banner. If `html` is provided, the `text` argument will be ignored.
- name: title
Copy link
Contributor

Choose a reason for hiding this comment

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

So this option is for the title text in the banner, and the text option (above) is for non-title text in the banner? In the table, should this option display above the text option, to reflect their order in the banner?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. We've tended to have the text/html options first as those could be considered to be the main content. In this particular case, title text is also not required (a placeholder text is used if you don't supply one) whereas text/html are.

- name: title
type: string
required: false
description: Title text to use within the notification banner. Defaults to 'Important' ('Success' for success type and 'Error' for error type). If `titleHtml` is supplied, the `title` argument will be ignored.
Copy link
Contributor

Choose a reason for hiding this comment

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

Re first sentence — could just say "The title of the notification banner" (if that sounds ok).

What do we mean by “Defaults to ‘Important’” and ‘“‘Success’ for success type and ‘Error’ for error type’”? Also, is “‘Success’ for success type and ‘Error’ for error type’” self-evident (success for success, error for error)?

I think we can delete the parentheses as the style guide says not to use them.

Re last sentence — we could personalise this and make it active, for example, "If you provide 'titleHTML,' the 'title' argument..." (The options above this say "provide" instead of "supply," so I'd use the same wording here.)

Copy link
Member Author

Choose a reason for hiding this comment

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

What do we mean by “Defaults to ‘Important’” and ‘“‘Success’ for success type and ‘Error’ for error type’”?

I agree, this is definitely not clear, will be good to chat about it next week.

- name: titleHtml
type: string
required: false
description: Title HTML to use within the notification banner. If `titleHtml` is provided, the `title` argument will be ignored.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we personalise and replace the passive? So: “If you provide 'titleHtml',…”

- name: titleHeadingLevel
type: string
required: false
description: Heading level, from 1 to 6. Default is `2`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Mark's suggestion: "Sets the heading level of the title. The minimum is 1 and the maximum is 6. The default is 2."

How do we feel about beginning each description with a verb, like in Mark's suggestion? Would it be a good way to communicate the purpose of each option?

- name: type
type: string
required: false
description: If `type` is set to `success` or `error`, the notification banner sets `role` to `alert` and `tabindex` to `-1`, and JavaScript moves the keyboard focus moves to the notification banner when the page loads. If `type` is not set, the notification banner defaults to setting `role` to `region` and using `aria-labelledby` to provide information for users of assistive technologies.
Copy link
Contributor

Choose a reason for hiding this comment

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

The description states what happens when you set type. Do we need to specify what type actually is, though?

Is this option to denote whether the notification banner is purely informational or else an alert box which the screen reader picks up on immediately?

Typo to remove: second "moves" in "Javascript moves the keyboard focus moves to the notification banner..."

Could personalise and make active the second last and last sentences. So, "If you set type to success..." and "If you do not set type..."

I'd also suggest changing "using aria-labelledby" to "uses aria-labelledby." This would be to parallel the active voice used in the previous clause ("...the notification banner defaults...").

- name: role
type: string
required: false
description: Overrides the value of the `role` attribute for the notification banner. Defaults to `region`. If `type` is set to `success` or `error`, defaults to `alert`.
Copy link
Contributor

Choose a reason for hiding this comment

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

The description for the type option (above) mentions the role attribute, but doesn’t explain it. Would it help users if this role description displayed before they read about the type option?

“If type is set to success or error, defaults to alert.” It’s the role that defaults (and not the type), is that right? If so, should we explicitly call that out?

Replace passive in last sentence? So: “If you set type to…”

- name: role
type: string
required: false
description: Overrides the value of the `role` attribute for the notification banner. Defaults to `region`. If `type` is set to `success` or `error`, defaults to `alert`.
Copy link
Contributor

Choose a reason for hiding this comment

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

The description for the type option (above) mentions the role attribute, but doesn’t explain it. Would it help users if this role description displayed before they read about the type option?

“If type is set to success or error, defaults to alert.” It’s the role that defaults (and not the type), is that right? If so, should we explicitly call that out?

Replace passive in last sentence? So: “If you set type to…”

- name: tabindex
type: string/boolean
required: false
description: Overrides the value of the `tabindex` attribute for the notification banner. Not set by default. If `type` is set to `success` or `error`, defaults to `-1`; the attribute can be removed by setting `tabindex` to `false`;
Copy link
Contributor

@EoinShaughnessy EoinShaughnessy Oct 21, 2020

Choose a reason for hiding this comment

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

The description for the type option above mentions the tabindex attribute, but doesn’t explain it. Would it help users if this tabindex description displayed before they read about the type option?

Are options set by default unless we state otherwise? If so, do we need to call this out somewhere?

Instead of "Not set by default," could we reword the first sentence to "Overrides the value that the browser sets for the tabindex attribute" (or similar)?

“If type is set to success or error, defaults to alert.” Is it the tabindex or the type that defaults?

Suggested tweak for last sentence: “If you set type to success or error, tabindex defaults to -1. To remove the attribute, set tabindex to false.”

- name: titleId
type: string
required: false
description: Overrides the value of the `id` attribute for the title. `id` used by the `aria-labelledby` attribute on the notification banner to provide information to users of assistive technologies. `id` defaults to `govuk-notification-banner-title` if `role` is set to `region`. If `type` is set to `success` or `error`, `id` is not rendered by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could break up the second sentence. So: “...on the notification banner. This provides information…”

Should this display first? “id used by the aria-labelledby attribute on the notification banner.” It defines the option, which might be the first info a user wants to know.

Replace passive? So, “if you set role to region” instead of “if role is set to region” and “If you set type…" instead of "If type is set..."

- name: initialFocus
type: boolean
required: false
description: Moves keyboard focus to the notification banner when the page loads. Defaults to `false`. If `type` is set to `success` or `error`, defaults to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to say "Defaults to false"? Maybe we could emphasise what setting it to true does. So, "If you set initialFocus to true, the keyboard focus moves to the notification banner when the page loads" (or similar).

Could make last sentence active: "If you set type,…"

- name: classes
type: string
required: false
description: Classes to add to the notification banner.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder could we personalise this (e.g. "Classes you want to add to the notification banner").

- name: attributes
type: object
required: false
description: HTML attributes (for example data attributes) to add to the notification banner.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could edit this to remove parentheses (as per style guide advice) and personalise it. So, "HTML attributes that you want to add to the notification banner, for example, data attributes."

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1977 October 22, 2020 13:13 Inactive
@hannalaakso hannalaakso changed the base branch from master to feature/notification-banner October 22, 2020 15:26
@hannalaakso
Copy link
Member Author

Thanks @EoinShaughnessy for the super useful comments! 🙏 As discussed, we're going to incorporate your changes in a new pull request in order to unblock this PR as this is now blocking another PR from being merged.

@hannalaakso hannalaakso merged commit eccd105 into feature/notification-banner Oct 22, 2020
@hannalaakso hannalaakso deleted the add-notifications-banner branch October 22, 2020 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

5 participants