-
Notifications
You must be signed in to change notification settings - Fork 213
Description
Here's a new idea (thanks @chrishtr!) to meet the same use case as ::interest-hint
(see explainer and CSSWG issue):
<a href=# interestfor=popover id=link>Some link with a hovercard</a>
<button id=interest-hint commandfor=link command="toggle-interest"> (i) </button>
<div popover id=popover>The hovercard</div>
Essentially, add a command
called "toggle-interest"
which (when targeted at an element with interestfor
) shows interest in that target element when the button is activated (and loses interest if the popover is already showing). This achieves roughly the same developer experience and capabilities as the ::interest-hint
proposal, and side-steps a lot of questions such as accessibility (buttons inside buttons), focusability, arbitrary content, etc.
Because one of the use cases is to only show this extra button on touchscreen devices, here's how that would be done, in a very similar way to ::interest-hint
:
#interest-hint {
display:none;
}
@media (any-pointer: coarse) {
/* On touch devices, show the extra button */
#interest-hint {
display:inline-block;
}
}
One question is about the name: I chose "toggle-interest" here because I think tapping the button twice should lose interest. We could call it "show-interest" but it might be a little less clear that this will actually toggle. Or I guess you could only show interest, and use other things like tapping elsewhere on the page to lose interest. But it feels nice to have the button toggle, right?
Thoughts? Things you can't do with this version?