antfu / vscode-iconify

🙂 Iconify IntelliSense for VS Code
https://marketplace.visualstudio.com/items?itemName=antfu.iconify
MIT License
453 stars 33 forks source link

Support for aliases #58

Closed RebeccaStevens closed 3 months ago

RebeccaStevens commented 10 months ago

Clear and concise description of the problem

Icons aren't shown for aliased icon names. It would be great if they could be.

Suggested solution

Ability to read a json file like this to get the aliases.

{
  aliases: {
    "chevron-left": "ri:arrow-left-s-line",
    "chevron-up": "ri:arrow-up-s-line",
    "chevron-right": "ri:arrow-right-s-line",
    "chevron-down": "ri:arrow-down-s-line",
    // ...
  }
}

Alternative

No response

Additional context

I'm using nuxt icon which allows for declaring aliases for icons. Config details

Validations

arthur-leclerc commented 8 months ago

Hi, I would add that it would be nice to be able to also put an alias on an entire collection.

For example, simple-icons is defined with the alias si on a project I use.

antfu commented 8 months ago

Sure, PR welcome :)

RebeccaStevens commented 5 months ago

@arthur-leclerc There's already an option for that: https://github.com/antfu/vscode-iconify/blob/d295384d5f642791f52d36432b58369e4fac1603/package.json#L526-L530

lumosminima commented 3 months ago

@RebeccaStevens How is this supposed to be used? I have:

// settings.json
...
 "iconify.customCollectionIdsMap": {
    "ms": "material-symbols",
    "logo": "logos",
    "spinners": "svg-spinners",
  },
  "iconify.customCollectionJsonPaths": [
    "./.vscode/iconsMap.json"
  ],
...

And:

// iconsMap.json

{
    "i-add": "i-ms-add",
    "i-check": "i-ms-check-small",
    "i-avatar": "i-ms-account-circle-outline",
    "i-delete": "i-ms-delete-outline",
    "i-signout": "i-ms-logout",
}

I have same mapping as above inside another iconShortcuts.ts to actually match the aliases but they don't display any icon also customCollectionIdsMap stops working whereas previously i-ms-check would display a ✔️. If I remove customCollectionJsonPaths then it starts working again. So docs on proper usage would be awesome!

RebeccaStevens commented 3 months ago

@lumosminima You'll want to use customAliasesJsonPaths instead of customCollectionJsonPaths. customCollectionJsonPaths is for providing your own custom icon set.

lumosminima commented 3 months ago

@RebeccaStevens 🤦‍♂️ got it! though for some reason they only work if I don't have the i- prefix in both shortcuts and map so icon-check works but not i-check. Thanks for this eye candy 🤩

Update: I have a monorepo and was duplicating the iconMap.json but only one is needed and also it looks like I have to use:

// presetIconShortcuts.ts
'i-overview': 'i-ms-table-chart-view-outline',

And

// iconMap.json
'i-overview': 'ms:table-chart-view-outline',

For i-overview to work.