Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Icons] Alias for icons #1767

Open
Xbirdfr opened this issue Apr 22, 2024 · 9 comments
Open

[Icons] Alias for icons #1767

Xbirdfr opened this issue Apr 22, 2024 · 9 comments
Labels
Feature New Feature Icons

Comments

@Xbirdfr
Copy link

Xbirdfr commented Apr 22, 2024

Hi !

I love the icon initiative, a very great ressource !

i'm comming with an idea, a thing that actually I use a lot in my custom projects:

an alias system for icons
Ex:

# config/packages/ux_icons.yaml
ux_icons:
    alias:
      - "home": "material-symbols:home"
# templates/base.html.twig
...
<a href="#">{{ ux_icon('home') }} Homepage </a>
...

this will ensure consistency of the icon throughout the project, and to be able to easily change / update it in one go

Or maybe a way to create a custom twig extension extending ux_icons already exist ?

@kbond
Copy link
Member

kbond commented Apr 22, 2024

Hey @Xbirdfr, thanks for the idea! This is a bit similar to #1596 where we've been discussing multiple icon registries and aliasing. That issue is more about including multiple directories of icons.

What you're thinking is using ux_icon('home') would lazy load (on-demand) material-symbols:home?

@Xbirdfr
Copy link
Author

Xbirdfr commented Apr 22, 2024

Hi @kbond ,

not necessarily this particular icon, but rather an alias:icon format

like today I want my alias "home" to refer to "material-symbols:home",
but tomorrow, I think the "solar:home-outline" will better fit my app, so I juste change the alias from :

# config/packages/ux_icons.yaml
ux_icons:
    alias:
      - "home": "material-symbols:home"

to

# config/packages/ux_icons.yaml
ux_icons:
    alias:
      - "home": "solar:home-outlinee"

refresh the cache and voila

@Kocal
Copy link
Contributor

Kocal commented Apr 22, 2024

What about using symbolinks instead? assets/icons/home.svg can refers to assets/icons/solar/home-outline.svg

@kbond
Copy link
Member

kbond commented Apr 22, 2024

What about using symbolinks instead?

That could work today for sure.

@Xbirdfr
Copy link
Author

Xbirdfr commented Apr 23, 2024

What about using symbolinks instead? assets/icons/home.svg can refers to assets/icons/solar/home-outline.svg

Yes, nice solution 👌

But I think a file based / config based way will ne more stable

@smnandre
Copy link
Collaborator

But I think a file based / config based way will ne more stable

We will add several configuration parameters and "namespace aliases" are one of my top priorities, as all icon sets are not equal currently on a DX perspective (typing bi:heart VS material-icon-foo-bar:heart is not fair)

We've been very busy with support / minor bugs / documentation recently but we're going to work on Icon very very soon :)

@smnandre smnandre added Feature New Feature Icons labels Apr 24, 2024
@kbond
Copy link
Member

kbond commented Apr 24, 2024

I think having aliases in config is valid. From a technical standpoint, we can decorate the current icon registry service with an AliasIconRegistry (that read the config).

As Simon said, we are going to be doing some work multiple icon sets/namespaces so let's keep this issue open as something to add after that.

@Xbirdfr
Copy link
Author

Xbirdfr commented Apr 24, 2024

I will keep an eye on that, and if I can propose a pr, I will 👌

@smnandre
Copy link
Collaborator

. From a technical standpoint, we can decorate the current icon registry service with an AliasIconRegistry (that read the config).

I'm not sure this will be necessary... i think we can resolve in the renderer

(and this is precisely why i'd like to add "name" and "set/namespace" in the Icon object..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Icons
Projects
None yet
Development

No branches or pull requests

4 participants