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

Design Nunjucks API for notification banner component #1933

Closed
36degrees opened this issue Sep 1, 2020 · 2 comments
Closed

Design Nunjucks API for notification banner component #1933

36degrees opened this issue Sep 1, 2020 · 2 comments

Comments

@36degrees
Copy link
Contributor

What

Work out what the API for the notification banner component should look like.

Where possible, it should be consistent with the APIs for our existing components.

There are a few things we need to consider:

  • Do we want a single option to set the 'type' of alert? For example, setting type: 'error' which then adds the modifier class for the style and also sets the role? Or do we just set both explicitly in every example in the Design System?
  • If we do have a single option to set the 'type', do we also allow users to override the role?
  • Should we make it callable?

Depends on

  • Making a decision about whether the notification banner is a single component.

Why

By designing and agreeing the API for the component upfront we can ensure that it behaves consistently with our other components.

@36degrees 36degrees added this to Upcoming sprints in Design System Sprint Board via automation Sep 1, 2020
@kellylee-gds kellylee-gds moved this from Upcoming sprints to Sprint Backlog in Design System Sprint Board Sep 2, 2020
@hannalaakso hannalaakso self-assigned this Sep 16, 2020
@hannalaakso hannalaakso moved this from Sprint Backlog to In progress in Design System Sprint Board Sep 16, 2020
@hannalaakso
Copy link
Member

hannalaakso commented Sep 16, 2020

I picked this up but then saw that there's another meeting booked to firm up the final details. The below is where I got to in case it's helpful when this is picked up:

Different options for Nunjucks API

1. Require team to set attributes/styles etc. manually

This is more flexible but increases the risk of team making a mistake by missing an attribute etc. However it also means that they would hopefully spend some time trying to understand what attributes etc. are most appropriate for their use case.

{{ govukNotification({
  style: "red/green/blue", //could also be "error/success/information"
  role: "region/alert",
  tabindex: "-1",
  initialfocus: true/false,
  
  titleText: "",
  titleHtml: "",
  headingLevel: "", // or this could be handled by titleHtml	
  text: "",
  html: "",
  classes: "", // we could also remove the above 'style' attribute and require team to set class directly here
  attributes: {}
}) }}

2. Set all attributes/styles etc. based on one option

Macro sets appropriate role, tabindex, initialFocus based on type.

{{ govukNotification({
  type: "red/green/blue", 
  
  titleText: "",
  titleHtml: "",
  text: "",
  html: "",
  classes: "",
  attributes: {}
}) }}

3. Set all attributes/styles etc. based on one option but allow them to be overridden

Would make it easy to use a variant but is more flexible than 2.

{{ govukNotification({
  type: "red/green/blue", 
  role: "region/alert", // to override default
  tabindex: "-1", // to override default
  initialfocus: true/false, // to override default
  
  titleText: "",
  titleHtml: "",
  text: "",
  html: "",
  classes: "",
  attributes: {}
}) }}

@hannalaakso hannalaakso moved this from In progress to Sprint Backlog in Design System Sprint Board Sep 16, 2020
@hannalaakso hannalaakso removed their assignment Sep 16, 2020
@vanitabarrett
Copy link
Contributor

Discussed in a meeting, I think we settled on Option 3 as the preferred option. It might need some tweaking if we change the design of the banner to this:

screenshot_2020-09-17_at_12 10 24

@hannalaakso hannalaakso moved this from Sprint Backlog to In progress in Design System Sprint Board Sep 23, 2020
@hannalaakso hannalaakso moved this from In progress to Done in Design System Sprint Board Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants