Banner github location npm version

Informs visitors about important changes or persistent conditions. Use this component if you need to communicate to visitors in a prominent way. Banners are placed at the top of the page or section they apply to, and below the page or section header.


Variants


Usage

note: The vf-banner--alert variants include the option to dismiss the banner. This is currently a 'bring your own JavaScript' button. To include a close button in the markup you need to make sure you have the variable banner__dismissable set to true:

banner__dismissable: true

JS Documentation for --modal variant

Like all JS-enabled components in the Visual Framework, if you wish to use the bundled JS, you need to include JS data attributes, here is an overview of what the options are for the vf-banner--modal variant.

Here is some very, very important information

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__info": true,
  "banner__dismissable": true,
  "banner__message": "Here is some very, <em>very</em> <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">important information</a>"
}
 %}
{% include "../path_to/vf-banner/vf-banner.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.

{% render '@vf-banner', {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__info": true,
  "banner__dismissable": true,
  "banner__message": "Here is some very, <em>very</em> <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">important information</a>"
} %}
                
HTML
<div class="vf-banner vf-banner--alert vf-banner--info">

  <div class="vf-banner__content">

    <p class="vf-banner__text">Here is some very, <em>very</em> <a class="vf-banner__link" href="JavaScript:Void(0);">important information</a></p>

    <button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <title>dismiss banner</title>
        <path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
      </svg>
    </button>

  </div>

</div>
              

Easy now, easy does it.

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__warning": true,
  "banner__dismissable": true,
  "banner__message": "Easy now, easy does it."
}
 %}
{% include "../path_to/vf-banner/vf-banner.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.

{% render '@vf-banner', {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__warning": true,
  "banner__dismissable": true,
  "banner__message": "Easy now, easy does it."
} %}
                
HTML
<div class="vf-banner vf-banner--alert vf-banner--warning">

  <div class="vf-banner__content">

    <p class="vf-banner__text">Easy now, easy does it.</p>

    <button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <title>dismiss banner</title>
        <path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
      </svg>
    </button>

  </div>

</div>
              

Oh dear, what have you done?

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__danger": true,
  "banner__dismissable": true,
  "banner__message": "Oh dear, what have you done?"
}
 %}
{% include "../path_to/vf-banner/vf-banner.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.

{% render '@vf-banner', {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__danger": true,
  "banner__dismissable": true,
  "banner__message": "Oh dear, what have you done?"
} %}
                
HTML
<div class="vf-banner vf-banner--alert vf-banner--danger">

  <div class="vf-banner__content">

    <p class="vf-banner__text">Oh dear, what have you done?</p>

    <button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <title>dismiss banner</title>
        <path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
      </svg>
    </button>

  </div>

</div>
              

Congratulations! You have made something awesome!

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__success": true,
  "banner__dismissable": true,
  "banner__message": "Congratulations! You have made something <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">awesome</a>!"
}
 %}
{% include "../path_to/vf-banner/vf-banner.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.

{% render '@vf-banner', {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss",
  "banner__success": true,
  "banner__dismissable": true,
  "banner__message": "Congratulations! You have made something <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">awesome</a>!"
} %}
                
HTML
<div class="vf-banner vf-banner--alert vf-banner--success">

  <div class="vf-banner__content">

    <p class="vf-banner__text">Congratulations! You have made something <a class="vf-banner__link" href="JavaScript:Void(0);">awesome</a>!</p>

    <button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
        <title>dismiss banner</title>
        <path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
      </svg>
    </button>

  </div>

</div>
              

This website uses cookies, and the limiting processing of your personal data to function. By using the site you are agreeing to this as outlined in our Privacy Notice and Terms Of Use.

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss"
}
 %}
{% include "../path_to/vf-banner/vf-banner.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.

{% render '@vf-banner', {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss"
} %}
                
HTML
<!-- dismissible banner -->
<div class="vf-banner vf-banner--fixed vf-banner--bottom vf-banner--notice" data-vf-js-banner data-vf-js-banner-state="dismissible" data-vf-js-banner-button-text="NaN" data-vf-js-banner-cookie-name="NaN" data-vf-js-banner-cookie-version="NaN" data-vf-js-banner-extra-button="<a href='#'>Optional button</a><a target='_blank' href='#'>New tab button</a>" data-vf-js-banner-auto-accept="false">
  <div class="vf-banner__content | vf-grid" data-vf-js-banner-text>
    <p class="vf-banner__text vf-banner__text--lg">
      This website uses cookies, and the limiting processing of your personal data to function. By using the site you are agreeing to this as outlined in our <a class="vf-banner__link" href="JavaScript:Void(0);">Privacy Notice</a> and <a class="vf-banner__link" href="JavaScript:Void(0);">Terms Of Use</a>.
    </p>
  </div>
</div>

<!-- persistent banner -->
<!-- <div class="vf-banner vf-banner--fixed vf-banner--bottom vf-banner--notice"
data-vf-js-banner
data-vf-js-banner-state="persistent"
data-vf-js-banner-extra-button="<a href='#'>Optional button</a><a target='_blank' href='#'>New tab button</a>">
  <div class="vf-banner__content | vf-grid" data-vf-js-banner-notice-text>
    <p class="vf-text vf-text-body--2">
      A persistent banner <a class="vf-link" href="JavaScript:Void(0);">Privacy Notice</a> and <a class="vf-link" href="JavaScript:Void(0);">Terms Of Use</a>.
    </p>
  </div>
</div> -->

<!-- Blocking, dismissible banner -->
<!-- <div class="vf-banner vf-banner--blocking vf-banner--notice"
data-vf-js-banner
data-vf-js-banner-state="blocking" data-vf-js-banner-esc-close="y"
data-vf-js-banner-cookie-name="NaN"
data-vf-js-banner-cookie-version="NaN">
  <div class="vf-banner__content | vf-grid" data-vf-js-banner-notice-text>

    <div class="vf-box">
        <h2 class="vf-text vf-text-heading-2">A blocking banner</h2>
        <p class="vf-text vf-text-body--3">This might have a richer layout. Note, this implementation is not yet feature complete.</p>
    </div>

  </div>
</div> -->

<!-- programatic banner -->
<!-- <div class="vf-banner vf-banner--fixed vf-banner--bottom vf-banner--notice"
      data-vf-js-banner-id="32423"
></div> -->
              
BETA

This is the new EMBL.org Complete our quick survey to help us make it better.

Nunjucks syntax

Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.

Using include

You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.


{% set context fromYourYamlFile %}
- or -
{% set context = {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss"
}
 %}
{% include "../path_to/vf-banner/vf-banner.njk" %}
                

Using render

This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.

{% render '@vf-banner', {
  "component-type": "container",
  "data-service-id": "MyService",
  "data-protection-version": 0.1,
  "vf-data-protection-banner__text": "I agree, dismiss this banner",
  "vf-data-protection-banner__link": null,
  "vf-banner--inline_href": "JavaScript:Void(0);",
  "alert_icon_text": "dismiss"
} %}
                
HTML
<div class="vf-banner vf-banner--fixed vf-banner--top vf-banner--phase" data-vf-js-banner data-vf-js-banner-state="dismissible" data-vf-js-banner-button-text="Close notice" data-vf-js-banner-button-theme="primary">
  <div class="vf-banner__content" data-vf-js-banner-text>
    <span class="vf-badge vf-badge--primary">BETA</span>
    <p class="vf-banner__text">This is the new EMBL.org <a href="NaN" class="vf-banner__link">Complete our quick survey</a> to help us make it better.</p>
  </div>
</div>
              
Installation info

This repository is distributed with npm. After installing npm, you can install primer-buttons with this command.

$ yarn add --dev @visual-framework/vf-banner

Sass/CSS

The style files included are written in Sass. If you're using a VF-core project, you can import it like this:

@import "@visual-framework/vf-banner/index.scss";

Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter

Changelog

Changelog

1.1.2

  • Implements updated vf-search markup.
  • Changes a few pages on how it works with nunjucks and markdown.

1.1.0

  • updates Design Tokens homepage.
  • adds neutral colour tokens
  • adds 'status banners' for components in the documentation page.
  • Adds the form options as their own set of components in the list.
  • https://github.com/visual-framework/vf-core/pull/1390/files
  • Updates to use 11ty 0.12.1
  • https://github.com/visual-framework/vf-core/pull/1435

1.0.24

  • changes the vf-intro so it's a white background, removes the padding.
  • changes the links in vf-intro to be the 'correct' buttons.

1.0.23

  • small change to cards on homepage

1.0.18

  • dependency bump

1.0.17

  • dependency bump

1.0.16

  • dependency bump

1.0.13

  • dependency bump
  • adds roamap and consultation docs

1.0.12

  • design token documenation now lives in the component libary

1.0.7

  • adds updates blog

1.0.6

  • begin to make more pattern/boilerplate guidance
  • minor templating updates

1.0.5

  • dependency bump

1.0.4

  • uses vf-favicon
  • adds meta attributes

1.0.3

  • run vf-component-assets:everything on local dev
  • remove reference to removed /css/app.css

1.0.2

  • Add 404
  • Fix component CSS generation

1.0.1

  • Also generate per-component CSS with vf-css:generate-component-css

1.0.0

  • Initial release to be used with vf-core 2.2.0

Assets



File system location: components/vf-banner

Find an issue on this page? Propose a change or discuss it.