UNPKG

@bimdos/icon

Version:

跨框架图标库,支持 React、Vue、Angular、AngularJS、小程序等多种使用方式

45 lines (40 loc) 2.2 kB
import { Component, Input } from '@angular/core'; /** * Bimdos 图标组件 - Angular 版本 */ @Component({ selector: 'bimdos-icon', template: ` <svg [attr.class]="'bimdos-icon ' + className" [attr.width]="size" [attr.height]="size" viewBox="0 0 24 24" [attr.fill]="color" [style]="style" > <path [attr.d]="iconData?.path" *ngIf="iconData"></path> </svg> ` }) export class BimdosIconComponent { @Input() name!: string; @Input() size: number | string = 16; @Input() color: string = 'currentColor'; @Input() className: string = ''; @Input() style: any = {}; get iconData() { const data = iconMap[this.name]; if (!data) { console.warn(`Icon "${this.name}" not found`); } return data; } } // 图标数据映射 const iconMap: Record<string, { path: string }> = { 'up': { path: 'M489.373 361.373C501.744 349 521.726 348.877 534.25 361l.377.372 256 256c12.497 12.496 12.497 32.758 0 45.254-12.371 12.372-32.353 12.496-44.877.372l-.377-.372L512 429.255 278.627 662.627C266.256 675 246.274 675.123 233.75 663l-.377-.372C221 650.256 220.877 630.274 233 617.75l.372-.377z' }, 'right': { path: 'M361.373 233.373C373.744 221 393.726 220.877 406.25 233l.377.372 256 256c12.372 12.371 12.496 32.353.372 44.877l-.372.377-256 256c-12.496 12.497-32.758 12.497-45.254 0-12.373-12.37-12.496-32.352-.373-44.876l.372-.377L594.745 512 361.373 278.627C349 266.256 348.877 246.274 361 233.75z' }, 'left': { path: 'M617.373 233.373c12.496-12.497 32.758-12.497 45.254 0 12.372 12.371 12.496 32.353.372 44.877l-.372.377L429.255 512l233.372 233.373c12.372 12.371 12.496 32.353.372 44.877l-.372.377C650.256 803 630.274 803.123 617.75 791l-.377-.372-256-256C349 522.256 348.877 502.274 361 489.75l.372-.377z' }, 'down': { path: 'M745.373 361.373c12.496-12.497 32.758-12.497 45.254 0 12.372 12.371 12.496 32.353.372 44.877l-.372.377-256 256C522.256 675 502.274 675.123 489.75 663l-.377-.372-256-256c-12.497-12.496-12.497-32.758 0-45.254C245.744 349 265.726 348.877 278.25 361l.377.372L512 594.745z' } };