From ec0d5a30f92ccca57180f8ffe4c5a95d942b0f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 14 Mar 2026 12:28:17 +0400 Subject: [PATCH] Extract icon imports to separate util So icons can be used from anywhere, e.g. map component JS --- app/components/icon.gjs | 59 +----------------- app/components/place-details.gjs | 6 +- app/services/storage.js | 10 +++ app/styles/app.css | 2 +- app/utils/icons.js | 61 +++++++++++++++++++ .../components/place-details-test.gjs | 8 +-- 6 files changed, 79 insertions(+), 67 deletions(-) create mode 100644 app/utils/icons.js diff --git a/app/components/icon.gjs b/app/components/icon.gjs index 6b5c90f..22175f0 100644 --- a/app/components/icon.gjs +++ b/app/components/icon.gjs @@ -1,65 +1,10 @@ import Component from '@glimmer/component'; import { htmlSafe } from '@ember/template'; - -import arrowLeft from 'feather-icons/dist/icons/arrow-left.svg?raw'; -import activity from 'feather-icons/dist/icons/activity.svg?raw'; -import bookmark from 'feather-icons/dist/icons/bookmark.svg?raw'; -import clock from 'feather-icons/dist/icons/clock.svg?raw'; -import edit from 'feather-icons/dist/icons/edit.svg?raw'; -import facebook from 'feather-icons/dist/icons/facebook.svg?raw'; -import globe from 'feather-icons/dist/icons/globe.svg?raw'; -import home from 'feather-icons/dist/icons/home.svg?raw'; -import instagram from 'feather-icons/dist/icons/instagram.svg?raw'; -import logIn from 'feather-icons/dist/icons/log-in.svg?raw'; -import logOut from 'feather-icons/dist/icons/log-out.svg?raw'; -import mail from 'feather-icons/dist/icons/mail.svg?raw'; -import map from 'feather-icons/dist/icons/map.svg?raw'; -import mapPin from 'feather-icons/dist/icons/map-pin.svg?raw'; -import menu from 'feather-icons/dist/icons/menu.svg?raw'; -import navigation from 'feather-icons/dist/icons/navigation.svg?raw'; -import phone from 'feather-icons/dist/icons/phone.svg?raw'; -import plus from 'feather-icons/dist/icons/plus.svg?raw'; -import server from 'feather-icons/dist/icons/server.svg?raw'; -import search from 'feather-icons/dist/icons/search.svg?raw'; -import settings from 'feather-icons/dist/icons/settings.svg?raw'; -import target from 'feather-icons/dist/icons/target.svg?raw'; -import user from 'feather-icons/dist/icons/user.svg?raw'; -import x from 'feather-icons/dist/icons/x.svg?raw'; -import zap from 'feather-icons/dist/icons/zap.svg?raw'; -import wikipedia from '../icons/wikipedia.svg?raw'; - -const ICONS = { - 'arrow-left': arrowLeft, - activity, - bookmark, - clock, - edit, - facebook, - globe, - home, - instagram, - 'log-in': logIn, - 'log-out': logOut, - mail, - map, - 'map-pin': mapPin, - menu, - navigation, - phone, - plus, - server, - search, - settings, - target, - user, - wikipedia, - x, - zap, -}; +import { getIcon } from '../utils/icons'; export default class IconComponent extends Component { get svg() { - return ICONS[this.args.name]; + return getIcon(this.args.name); } get size() { diff --git a/app/components/place-details.gjs b/app/components/place-details.gjs index 3738fb1..732b7b2 100644 --- a/app/components/place-details.gjs +++ b/app/components/place-details.gjs @@ -281,11 +281,7 @@ export default class PlaceDetails extends Component {