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

FR: current key as className #54

Open
Christilut opened this issue Jan 6, 2020 · 4 comments
Open

FR: current key as className #54

Christilut opened this issue Jan 6, 2020 · 4 comments

Comments

@Christilut
Copy link

I would like to be able to add specific css to certain nodes from a certain JSON key.

So for example, all text nodes are now vjs-value vjs-value__string but I'd like it when I use the following JSON:

stackTrace: 'trace here with lots of line endings and very unreadable if they are ignore'

That it would turn into vjs-value vjs-value__string stackTrace. Or maybe vjs-key-stackTrace to avoid existing CSS names.

In my case, I want to set white-space: pre-line to this specific strack trace string, otherwise it's quite unreadable.

@leezng
Copy link
Owner

leezng commented Jan 17, 2020

I think css isn't a good solution, maybe provide a custom render method?

@Christilut
Copy link
Author

Why isn't css a good solution?

I just want to style certain parts, using a custom render method seems like overkill

@leezng
Copy link
Owner

leezng commented Jan 19, 2020

There is such an example:

{
  "name": "aa",
  "children": {
    "name": "bb"
  }
}

If I add the vjs-key-name classname to the key, then there will be 2 classnames in the above json, but maybe the user only wants to use a different style on the first key. If I provide a method similar to renderKey (key, xxx, xxx), the user may be able to make a custom judgment based on the provided parameter xxx?

@Christilut
Copy link
Author

Hmm yeah I see your point. But I'm thinking of the added complexity of a custom renderer. I think if you add the key vjs-key-name and maybe a level vjs-level-0 of how deep the key is, then a user get a long way already. And implementation of something like that would be very simple.

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

No branches or pull requests

2 participants