mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
feat(copy-svg): add functionality to copy SVG as a fully functional Angular standalone component
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
export function generateAngularComponent(svgContent: string, componentName: string): string {
|
||||
const updatedSvgContent = svgContent.replace(
|
||||
/<svg([^>]*)>/,
|
||||
`<svg$1 [attr.width]="size.width" [attr.height]="size.height">`
|
||||
);
|
||||
|
||||
return `
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* This Angular standalone component was generated by svgl.app
|
||||
* 🧩 A beautiful library with SVG logos
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'svg-${componentName}',
|
||||
standalone: true,
|
||||
template: \`
|
||||
${updatedSvgContent.trim()}
|
||||
\`,
|
||||
})
|
||||
export class ${componentName}Component {
|
||||
@Input({ required: true }) size: { width: number; height: number };
|
||||
}
|
||||
`;
|
||||
}
|
||||
Reference in New Issue
Block a user