Files
marco/app/components/icon.gjs
Râu Cao 5fd4ebe184 Centrally define filled icons
So we don't have to manually pass the option everywhere
2026-03-20 16:55:19 +04:00

44 lines
870 B
Plaintext

import Component from '@glimmer/component';
import { htmlSafe } from '@ember/template';
import { getIcon, isIconFilled } 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 || '';
}
get isFilled() {
return this.args.filled || isIconFilled(this.args.name);
}
<template>
{{#if this.svg}}
<span
class="icon {{if this.isFilled 'icon-filled'}}"
style={{this.style}}
title={{this.title}}
>
{{htmlSafe this.svg}}
</span>
{{/if}}
</template>
}