
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
angular2-svg-icons
Advanced tools
Easily use icons in your Angular app with this component. It uses the `` element to duplicate SVG's without manipulating the DOM (the browser does all the work).
Easily use icons in your Angular app with this component. It uses the <use>
element to duplicate SVG's without manipulating the DOM (the browser does all the work).
$ npm install angular2-svg-icons --save
Then add it to the modules that require it:
import { IconModule } from 'angular2-svg-icons';
@NgModule({
imports: [IconModule]
})
export class SomeModule {}
<icon i="search"></icon>
The i
attribute is the name (id) of the icon. The above code generates the following:
<svg class="icon"
x="0" y="0"
xmlns="http://www.w3.org/2000/svg"
width="24px"
height="24px"
preserveAspectRatio="xMidYMin">
<use xlink:href="baseUrl/#search" />
</svg>
You must add all your symbols to your page prior to using this component. For example, you can create a svg-symbols.ts
file that has all your symbols with the appropriate id
as the name:
export const svgSymbols = `
<svg style="display: none">
<symbol id="search" d="path-stuff"></symbol>
</svg>`;
Then add this to your application. For example, you can add it to your root component:
import { Component } from '@angular/core';
import { svgSymbols } from './components/icons/svg-symbols';
@Component({
selector: 'app',
template: `
${svgSymbols}
<rest-of-your-app></rest-of-your-app>`,
})
export class RootComponent { }
NOTE: It's recommended to hide the <svg>
or else the entire sheet will be displayed when added to your app.
I built a Gulp task that takes in an icon json file and then produces an svg-symbols.ts
file for you. The repo houses all the svg icons, so all you have to do is specify the list of icons you want in your json file: ["search","home","person"]
.
This is pretty specific to my needs (and uses material icons), but you can fork it to create your own.
I purposefully left out styles -- the generated icons have an icon
class so you can style them however you want. Just be aware of the limitations of the <use>
element (A guide to SVG elements)
// example of changing color and size
// remember to style the <icon> element as well
icon {
width: 24px;
height: 24px;
display: inline-block;
svg {
fill: #404040;
width: 24px;
height: 24px;
}
}
FAQs
Easily use icons in your Angular app with this component. It uses the `` element to duplicate SVG's without manipulating the DOM (the browser does all the work).
We found that angular2-svg-icons demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.