-
Notifications
You must be signed in to change notification settings - Fork 59
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
Custom icons must be in kebab case #265
Comments
Stumbled upon this quirk too. It seems that only lowercase letters, digits and dash ( I was hoping to be able to use uppercase letters and underscores... I wonder why this naming convention is never mentioned in the docs. |
I'll work on it when i have some free time |
Same here, tortured me for an hour |
Would it also be possible to consider supporting dots ( |
/cc @cyberalien, do you see this possibly being supported by Iconify, or what do you suggest we do with a custom solution for it? Thanks a lot! |
Duplicated as #257 |
Naming convention is used in all parts of Iconify ecosystem, so changing it would be tricky. It would require way too many code changes. I recommend changing it internally in Nuxt Icon. Convert names when loading and when passing icon name parameter. It should be as simple as changing icon name to lower case. |
I added automatical convention and warnings upon loading to make this more transparent - as a temporary workaround. (c09fdc7, v0.6.1) In the long term, I do wish to support more relaxed conversion (at least |
I think support for any icon names can be added in future versions. Current convention will remain for icons loaded from API, but can be ignored for custom icons. |
It is not simple. Icons are not loaded one by one, they are loaded in bulk from API, otherwise loading could take a while. So API end point is not easily customisable. I think a simple solution would be to allow custom loaded based on prefix and/or provider. Then current API logic won't need to change, but it would allow custom solutions, which could be used to load icons from Nuxt. Then naming convention would apply only to icons loaded with default loader. |
Oh yeah, I think that would be great to serve our needs! |
I'm thinking of making 3 ways to handle loading:
Types for callbacks to make it clearer how callbacks could be implemented: type IconSetLoaderCallback = (prefix: string, provider: string) => Promise<IconifyJSON | null>;
type IconsLoaderCallback = (names: string[], prefix: string, provider: string) => Promise<IconifyJSON | null>;
type IconLoaderCallback = (name: string, prefix: string, provider: string) => Promise<IconifyIcon | null>; Idea is to set at least one method, icon component will use whatever is available:
Parameters in function and callback are ordered from most useful first to least useful last. All loaders are async functions that return What do you think? |
Personally, I think that Even if, in this case, the user endpoint only supports loading a single icon, on the loader side, the user could still dispatch multiple requests and merge the results into one. Having only one API would also be made it easy on the Iconify side, I think. |
Working on solution: iconify/iconify#348 |
Added 2 loaders:
You can use one or both. If both are set, loader for one icon is called when loading only one icon, otherwise loader for multiple icons is called. Loaders have same signature, but different callbacks: setCustomIconsLoader(callback, prefix, provider = '')
setCustomIconLoader(callback, prefix, provider = '') where Data is Callback can be asynchronous or synchronous. Types for callbacks: /**
* Custom icons loader
*/
export type IconifyCustomIconsLoader = (
icons: string[],
prefix: string,
provider: string
) => Promise<IconifyJSON | null> | IconifyJSON | null;
/**
* Custom loader for one icon
*/
export type IconifyCustomIconLoader = (
name: string,
prefix: string,
provider: string
) => Promise<IconifyIcon | null> | IconifyIcon | null; Icon or list of icons is first parameter because other parameters are most likely will not be used, unless you are reusing same loader for multiple prefixes. Why 2 loaders? Loader for one icon can be used as solution for customising icons: set loader for a custom prefix, use it to load icon from another icon set (possibly from API) using setCustomIconLoader(async (name) => {
const data = await loadIcon(`tabler:${name}`);
return data
? {
...data,
body: data.body.replaceAll(
'stroke-width="1.5"',
'stroke-width="3"'
),
}
: null;
}, 'tabler-fat'); For now implemented in core, I'll add it to all components later today. Loaders work with custom prefixes and icon names that have only one requirement: not being empty strings. So you can use whatever you want, even filenames (though |
Published |
Notes about naming requirements. Icon still must have a prefix and name parts, separated with Names like Entities and unicode are not parsed. Everything is kept as is. So be careful when using non-latin characters that might end up being encoded differently. |
Description
iconify's
getIcon
usesvalidateIconName
which enforce some validation for an icon's name.One validation is that a name must be split with
-
which is often not the case with users custom iconsReproduction
https://stackblitz.com/edit/nuxt-starter-qlykyd?file=icons%2FEuro.svg,nuxt.config.ts,app.vue
in this reproduction, we can't see
my-icons:Euro
because Euro is in PascalCaseSolution
Either a documentation fix about naming convention or fix it in iconify or we could also merge prefix with the name ?
The text was updated successfully, but these errors were encountered: