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

Combining icon style into items #26

Open
xakiy opened this issue Jun 4, 2018 · 8 comments
Open

Combining icon style into items #26

xakiy opened this issue Jun 4, 2018 · 8 comments
Assignees

Comments

@xakiy
Copy link

xakiy commented Jun 4, 2018

Hi, I wonder is there a simple way to add icon styling into these items links. I use vue-awesome but didn't know how to combine them, any suggestion to make the links look prettier, thanks.

@MisRob
Copy link
Collaborator

MisRob commented Jun 10, 2018

Hi,

I checked some options and I don't think there is a simple way right now. You could add icons to all links with something like

.NavigationItem::before {
  font-family: "Font Awesome 5 Brands";  content: "\f099";
}

but this is totally useless - I don't suppose anyone would like to use the same icon for everything :)

I was thinking about it more and I am considering the idea of adding new fields to source items: id and class.

Example of enhanced component API:

items: [
    { name: 'Products', children: [
        { name: 'Shoes', route: 'shoes', id: 'my-id' } 
    ]},
    { name: 'About', route: 'about', class: 'my-class', children: [
        { name: 'Contact', route: 'contact', children: [
            { name: 'E-mail', element: 'email' },
            { name: 'Phone', element: 'phone' }
        ]},
    ]},
    { name: 'Github', class: 'my-class', external: 'https://github.com' },
],

I think this could be usefull in general for adding some extra style only to a few selected links, right? Also you could add your icons with #my-id::before or .my-class::before.

Could this help you?

@MisRob MisRob added the task label Jun 21, 2018
@xakiy
Copy link
Author

xakiy commented Aug 4, 2018

Thanks for the reply. Yes, I think it's quite more work if we need to add manual id and class for the items.
Why not provide generated id and class for every item in the tree and by adding them special prefix in in them so that it won't clash with other elements in the page.

Like, say:
items: [ { name: 'Products', children: [ { name: 'Shoes', route: 'shoes' } ]}, { name: 'About', route: 'about', children: [ { name: 'Contact', route: 'contact', children: [ { name: 'E-mail', element: 'email' }, { name: 'Phone', element: 'phone' } ]}, ]}, { name: 'Github', external: 'https://github.com' }, ],
will produce
id="vue-tree-product" for "product"
id="vue-tree-shoes" for "shoes", or id="vue-tree-product-shoes" for hierachical purpose (maybe)?
based on their route names.
So people can predict ids of their route links.

I think that what I can conceive.

@MisRob
Copy link
Collaborator

MisRob commented Aug 4, 2018

Hi, thank you.

Why not provide generated id and class for every item in the tree and by adding them special prefix in in them so that it won't clash with other elements in the page.

I get automatically assigned ids. But I am not sure about classes. Purpose of class in some use cases could be to provide a way how to simply style some custom group of menu items and we cannot predict which group it will be - this is something which library users will need to choose themselves sometimes.

So I suppose we could combine both solutions actually. There are already some automatically assigned classes (described here https://vue-tree-navigation.misrob.cz/#/styling) so I think we could assign these hierarchical classes too - something like TreeNavigation__product, TreeNavigation__product-shoes (not 100% sure about naming yet, just would like to stay consistent with what is there already- BEM). So these classes could be used instead of ids and users could guess their names easily how you propose.

And then there would be an option to add a custom class or custom id (optional, not required) to any menu item as proposed in a first comment so there would be a possibility to use id for some overrides or to use some custom classes.

Does it make sense?

@xakiy
Copy link
Author

xakiy commented Aug 26, 2018

Yes, it does, and I couldn't agree more, that would be nice to be able to override the generated ids for more customizing purpose.
And about classes having them generated automatically and overrideable is awesome.
Can't wait when you implement it.

Sorry for my late reply..

@MisRob
Copy link
Collaborator

MisRob commented Aug 28, 2018

Ok, thanks.

I'm planning to release v4 so this will be probably included. Didn't have much time through holidays but will be back open-sourcing since the second half of September.

@MisRob
Copy link
Collaborator

MisRob commented Nov 3, 2018

I've decided to release v4.0.0 without this feature since 4.0.0 contains some updates which could be quite useful so I don't want to wait longer than needed for the new release. Will add this feature to 4.1.0.

@HamishMcDougall
Copy link

This would be a very useful feature

@MisRob
Copy link
Collaborator

MisRob commented Jan 18, 2019

It's first item on my to-do list :) Contributions are welcome!

@chellem chellem self-assigned this Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants