
Security News
Feross on Risky Business Weekly Podcast: npm’s Ongoing Supply Chain Attacks
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
@ewc-lib/ewc-banner
Advanced tools
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.
npm install @ewc-lib/ewc-banner
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>
Property | Attribute | Type | Default | Description |
---|---|---|---|---|
showButton | show-button | Boolean | false | Whether to display the call-to-action button |
maintitle | maintitle | String | "" | The main title text for the banner |
subtitle | subtitle | String | "" | The subtitle text for the banner |
buttonText | button-text | String | "" | The text to display on the button |
Event Name | Description |
---|---|
button-click | Fired when the button is clicked. The embedding application can listen for this event and handle it as needed |
When a user clicks the button in the EWC Banner, the component dispatches a custom event named button-click
. This event:
bubbles: true
)composed: true
)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
});
<ewc-banner
maintitle="Population Statistics"
subtitle="Explore demographic data across Europe">
</ewc-banner>
<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>
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);
The EWC Banner component is designed with accessibility in mind:
European Union Public License (EUPL)
FAQs
Did you know?
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.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.