Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@ngaox/icons
Advanced tools
Easily inline SVG icons into your angular app with a ready to import and use set of icons
Easily inline SVG icons into your angular app with a ready to import and use set of icons.
The library provides a registry (IconsService
) that loads, caches and adds SVG by a unique name,
It also provides a component (<ngaox-icon>
) for displaying (Inlining) a registered SVG using its name.
To install this library run:
ng add @ngaox/icons
Integrate @ngaox/icons
with your app, just by import both the HttpClientModule
& IconsModule
in the root module (AppModule
).
as follows:
@NgModule({
imports: [HttpClientModule, IconsModule.forRoot()]
})
class AppModule {}
you can pass IconsModule.forRoot
three params:
icons
an array of icons to be registered globally with a unique namefallbackHtml
a string represent the SVG element to fallback to when the icon not existAnd for other child modules that need access to <ngaox-icon>
you only will need to import IconsModule
.
@NgModule({
imports: [IconsModule]
})
class MyNgModule {}
To inject an public (accessible via browser) SVG file to a component template:
<svg-icon name="my-icon-name" url="assets/my-icon.svg" width="100px"></svg-icon>
By default, the icon has no width set so It may not appear!
Or if the icon was previously registered with a name you can use it like:
<svg-icon name="my-icon" width="100px"></svg-icon>
All icons specified in the module import are registered and ready to use.
However you can use IconsService
to add, remove and get icons from the registry, all you need to do is just to inject it wherever you need to:
import { IconsService } from '@ngaox/icons';
constructor(icons: IconsService) {
icons.add('my-icon-name', {
url: 'assets/my-icon.svg',
lazy: true
}, 'my-icon');
icons.remove('ugly-icon');
icons.add(
'linkedIn-icon',
`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 48\"><path d=\"M8.421,14h0.052l0,0C11.263,14,13,12,13,9.5C12.948,6.945,11.263,5,8.526,5S4,6.945,4,9.5C4,12,5.736,14,8.421,14z M4,17h9v26H4V17z M44,26.5c0-5.247-4.253-9.5-9.5-9.5c-3.053,0-5.762,1.446-7.5,3.684V17h-9v26h9V28l0,0c0-2.209,1.791-4,4-4s4,1.791,4,4v15h9C44,43,44,27.955,44,26.5z\"/></svg>`
);
icons.get('linkedIn-icon')?.subscribe(svg => {
console.log(svg);
});
}
Made with ❤️ by Rabyâ Raghib
FAQs
Inline SVG icons from (src | files | your favorite icons library | ...)!
We found that @ngaox/icons demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.