Centrally define filled icons

So we don't have to manually pass the option everywhere
This commit is contained in:
2026-03-20 16:55:19 +04:00
parent f2a2d910a0
commit 5fd4ebe184
3 changed files with 14 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
import Component from '@glimmer/component'; import Component from '@glimmer/component';
import { htmlSafe } from '@ember/template'; import { htmlSafe } from '@ember/template';
import { getIcon } from '../utils/icons'; import { getIcon, isIconFilled } from '../utils/icons';
export default class IconComponent extends Component { export default class IconComponent extends Component {
get svg() { get svg() {
@@ -25,10 +25,14 @@ export default class IconComponent extends Component {
return this.args.title || ''; return this.args.title || '';
} }
get isFilled() {
return this.args.filled || isIconFilled(this.args.name);
}
<template> <template>
{{#if this.svg}} {{#if this.svg}}
<span <span
class="icon {{if @filled 'icon-filled'}}" class="icon {{if this.isFilled 'icon-filled'}}"
style={{this.style}} style={{this.style}}
title={{this.title}} title={{this.title}}
> >

View File

@@ -318,7 +318,7 @@ export default class PlaceDetails extends Component {
{{#if this.cuisine}} {{#if this.cuisine}}
<p class="content-with-icon"> <p class="content-with-icon">
<Icon @name="fork-and-knife" @title="Cuisine" @filled={{true}} /> <Icon @name="fork-and-knife" @title="Cuisine" />
<span> <span>
{{this.cuisine}} {{this.cuisine}}
</span> </span>
@@ -393,7 +393,7 @@ export default class PlaceDetails extends Component {
{{#if this.wikipedia}} {{#if this.wikipedia}}
<p class="content-with-icon"> <p class="content-with-icon">
<Icon @name="wikipedia" @title="Wikipedia" @filled={{true}} /> <Icon @name="wikipedia" @title="Wikipedia" />
<span> <span>
<a <a
href="https://wikipedia.org/wiki/{{this.wikipedia}}" href="https://wikipedia.org/wiki/{{this.wikipedia}}"

View File

@@ -64,6 +64,12 @@ const ICONS = {
zap, zap,
}; };
const FILLED_ICONS = ['fork-and-knife', 'wikipedia'];
export function getIcon(name) { export function getIcon(name) {
return ICONS[name]; return ICONS[name];
} }
export function isIconFilled(name) {
return FILLED_ICONS.includes(name);
}