Files
marco/app/components/icon.gjs
Râu Cao ec0d5a30f9
All checks were successful
CI / Lint (pull_request) Successful in 28s
CI / Test (pull_request) Successful in 43s
Extract icon imports to separate util
So icons can be used from anywhere, e.g. map component JS
2026-03-14 12:28:17 +04:00

40 lines
765 B
Plaintext

import Component from '@glimmer/component';
import { htmlSafe } from '@ember/template';
import { getIcon } from '../utils/icons';
export default class IconComponent extends Component {
get svg() {
return getIcon(this.args.name);
}
get size() {
return this.args.size || 16;
}
get color() {
return this.args.color || '#898989';
}
get style() {
return htmlSafe(
`width:${this.size}px;height:${this.size}px;color:${this.color}`
);
}
get title() {
return this.args.title || '';
}
<template>
{{#if this.svg}}
<span
class="icon {{if @filled 'icon-filled'}}"
style={{this.style}}
title={{this.title}}
>
{{htmlSafe this.svg}}
</span>
{{/if}}
</template>
}