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

Different class on trigger and target? #88

Closed
jenstornell opened this issue Sep 4, 2020 · 10 comments
Closed

Different class on trigger and target? #88

jenstornell opened this issue Sep 4, 2020 · 10 comments
Labels
enhancement New feature or request

Comments

@jenstornell
Copy link

Let's say I have the below:

<div data-toggle-class="active" data-toggle-target="#target">Trigger</div>
<div id="target">Target</div>

Then active will be added as a class to both the trigger and the target elements.

I can use data-toggle-target-only which disable the class on the target. However, that is not what I want in this case.

I would like one toggle class on the trigger element and another on the target.

Is that possible?

@Twikito Twikito added the question Further information is requested label Sep 14, 2020
@Twikito
Copy link
Owner

Twikito commented Sep 14, 2020

Hi @jenstornell!
Thanks for taking time to add this comment.

No, for now it is not possible. By the way, I don't see why you would like to have differents class names. is-active is a generic name that should work for any context, and I have added the possibility to change it, so why are you asking for having two different class names. Shouldn't this be handle in you CSS?
Can you explain me more?

@jenstornell
Copy link
Author

@Twikito I use https://tailwindcss.com/. With that library you add and remove utility classes for whatever you need. Nothing goes into the css file.

@Twikito
Copy link
Owner

Twikito commented Sep 14, 2020

@jenstornell Ok, I see. Let me investigate on what could be possible.

@Twikito
Copy link
Owner

Twikito commented Sep 15, 2020

@jenstornell Ok, tell me, what do you think if I add two new attibutes to be able to seperate behaviour?

  • data-toggle-class="class-name" would still toggle the class on trigger and target•s
  • data-toggle-class-trigger="class-name" would toggle the class only on the trigger
  • data-toggle-class-target="class-name" would toggle the class only on target•s

And obviously, I would need to remove data-toggle-target-only attribute because data-toggle-class-target would actually replace it.

What do you think?

@jenstornell
Copy link
Author

@Twikito Yes, I think the new approach would be great, except for it being a breaking change of cause.

This change alone would make it Tailwind compatible.

@Twikito
Copy link
Owner

Twikito commented Sep 16, 2020

@jenstornell Ok, great. I'll try to do that asap.

@jenstornell
Copy link
Author

A workaround I use for this at the moment is the toggleAfter hook to add or remove classes programmatically.

@Twikito
Copy link
Owner

Twikito commented Sep 25, 2020

@jenstornell Almost done. Need to test a little bit more, and update documentation.

@Twikito Twikito added enhancement New feature or request and removed question Further information is requested labels Sep 29, 2020
@Twikito
Copy link
Owner

Twikito commented Sep 29, 2020

@jenstornell Hey! It's done: these options are now availables!

Documentation is updated: https://twikito.github.io/easy-toggle-state/#toggling

@Twikito Twikito closed this as completed Sep 29, 2020
@jenstornell
Copy link
Author

@Twikito Sorry for my late reply. Finally I've got some time to get back to this.

I can confirm that it works. I tested it with the simple tabs example.

A note for others reading this issue, the data attributes has changed from this discussion to include an on.

data-toggle-class-on-trigger
data-toggle-class-on-target

Thank you for keeping this repo around, it's great!

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

No branches or pull requests

2 participants