Socket
Book a DemoInstallSign in
Socket

@ewc-lib/ewc-banner

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ewc-lib/ewc-banner

A banner component built with LitElement based on ECL styles.

latest
npmnpm
Version
2.0.6
Version published
Maintainers
4
Created
Source

EWC Banner Component

Overview

The EWC Banner component provides a standardized banner for Eurostat web applications. It offers a consistent visual identity across Eurostat digital products while allowing for customization to meet specific application needs.

Features

  • Responsive design that adapts to different screen sizes
  • Customizable title and subtitle
  • Optional call-to-action button with custom event
  • Eurostat branding with official logos
  • Accessibility compliant

Installation

npm install @ewc-lib/ewc-banner

Usage

Import the component in your application:

// Using ES modules
import '@ewc-lib/ewc-banner';

// Or using CommonJS
require('@ewc-lib/ewc-banner');

Then use it in your HTML:

<ewc-banner 
  maintitle="Your Main Title" 
  subtitle="Your Subtitle" 
  button-text="Button Text" 
  show-button>
</ewc-banner>

Properties

PropertyAttributeTypeDefaultDescription
showButtonshow-buttonBooleanfalseWhether to display the call-to-action button
maintitlemaintitleString""The main title text for the banner
subtitlesubtitleString""The subtitle text for the banner
buttonTextbutton-textString""The text to display on the button

Events

Event NameDescription
button-clickFired when the button is clicked. The embedding application can listen for this event and handle it as needed

Working with the button-click Event

When a user clicks the button in the EWC Banner, the component dispatches a custom event named button-click. This event:

  • Bubbles up through the DOM tree (bubbles: true)
  • Crosses shadow DOM boundaries (composed: true)
  • Contains no additional data

Direct Event Listener

The most straightforward approach is to add an event listener directly to the banner element:

// Get a reference to the banner element
const banner = document.querySelector('ewc-banner');

// Add an event listener for the button-click event
banner.addEventListener('button-click', () => {
  console.log('Button was clicked!');
  // Your code to handle the click goes here
});

Examples

Basic Banner

<ewc-banner 
  maintitle="Population Statistics" 
  subtitle="Explore demographic data across Europe">
</ewc-banner>

Banner with Button

<ewc-banner 
  maintitle="Economic Indicators" 
  subtitle="Latest economic data and analysis" 
  button-text="View Dashboard" 
  show-button>
</ewc-banner>

<script>
  // Add event listener to handle button click
  document.querySelector('ewc-banner').addEventListener('button-click', () => {
    console.log('Button clicked');
    // Handle the button click, e.g., show a modal or navigate to another page
  });
</script>

Programmatically Created Banner

You can also create and configure the banner programmatically:

// Import the component (if not already imported)
import '@ewc-lib/ewc-banner';

// Create a new banner element
const banner = document.createElement('ewc-banner');

// Set properties
banner.maintitle = "Programmatically Created Banner";
banner.subtitle = "This banner was created using JavaScript";
banner.buttonText = "Learn More";
banner.showButton = true;

// Add event listener for button click
banner.addEventListener('button-click', () => {
  console.log('Button clicked');
  // Handle the button click as needed
});

// Add the banner to the DOM
document.body.prepend(banner);

// You can also update properties dynamically
setTimeout(() => {
  banner.maintitle = "Updated Title";
  banner.subtitle = "Properties can be changed at runtime";
}, 5000);

Accessibility

The EWC Banner component is designed with accessibility in mind:

  • Proper semantic HTML structure with header element
  • Keyboard navigable elements
  • Sufficient color contrast
  • Screen reader friendly with appropriate ARIA attributes

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

European Union Public License (EUPL)

FAQs

Package last updated on 22 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.