Closed nicetransition closed 4 years ago
Hello Kevin,
Thank you very much for taking the time to contribute to a11y-toggle. Unfortunately, I’m not entirely sure what kind of use case you’re trying to solve here… Would you mind explaining?
Yup. This is to allow for development to use CSS selectors to identify the target in your plugin. When using the new [data-target]
it will select the target, check to see if it has an [id]
defined – if it does, it uses that applies it to your generated aria tags - if not, it creates an unique if then applies it. In addition, their a next functionality which is helpful when having a generated grid and multiple contextual toggles in an interface.
See these examples:
Basically, allows you to use CSS selectors besides id
to be used.... making this plugin a little more dynamic :)
Good morning Kevin.
Thank you for taking the time to explain your intention. I see how that would be an interesting feature for a11y-toggle
, however I am not too keen into merging it as this seems like quite some overhead for most use cases. What we could do is updating the documentation with a link to this pull-request to help people who have a similar need maybe. What do you think?
Sounds like a cool idea to me as a fork. It would be great if maybe Hugo could link to the fork in the readme maybe.
@HugoGiraudel that works and sounds cool to me.
Cool! Feel free to open a PR to mention your use case and fork/PR in the docs so it serves other people. :)
Class-based toggles
This pull request (PR) supports CSS-based selectors to generate ID's for targeted element.
The
[data-target]
attribute looks at the target and identifies if element has anid
or not. If it does not have anid
, it generates one and updates the[data-a11y-toggle]
with the generatedid
.Add
data-a11y-toggle
(with no value) anddata-target
with the value equal to the selector you are targeting in your toggle button.Next Item Target toggles
This PR supports dynamically generated queries to "next siblings" in the DOM Structure.
The [data-target] equal to "next" looks at the next element in the DOM structure and identifies if element has an
id
or not. If it does not have anid
, it then generates one and updates the[data-a11y-toggle]
with the generatedid
.Add
data-a11y-toggle
(with no value) anddata-target="next"
What shall we do!?