You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/src/pages/components/interest-invokers.explainer.mdx
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,6 @@ There is another category of devices which also falls into the "Other" category:
106
106
When the HID is a mouse, where hover/de-hover is the method for showing and losing interest, delays are important for a number of reasons:
107
107
108
108
1. Simply hovering an element should not be enough to show interest in that element, since the user might just be moving the mouse from one place to another on the screen. It would be highly distracting to the user if such a move caused many popovers to show up. For this reason, showing interest needs to be done by hovering an element **for a period of time**.
109
-
110
109
2. For a similar reason, losing interest cannot be provided by *just* de-hovering the element. For example, in the common case of a link that has a hovercard, it is very common for the hovercard to be separated from the element by some padding space. And it is also common for the user to want to move their mouse *from* the link *to* the hovercard, e.g. to select and copy some text. However, since there's a gap between the elements, moving the mouse across that gap constitutes a de-hover of both the element and its target. For this reason, losing interest needs to be done by de-hovering the element (and its target) **for a period of time**.
111
110
112
111
Both of these time periods need to be CSS-configurable, because different use cases can require different delays. For example, a responsive gaming site might want very short delays, including potentially zero-delay. On the other hand, information-rich sites such as Wikipedia might want longer delays to ensure their content is easily accessible to all. To achieve this, two properties, `interest-target-show-delay` and `interest-target-hide-delay`, will control the corresponding delays. Because, as described above, both of these delays are fairly critical to proper operation of the interest mechanism, both properties will default to a non-zero value, 0.5 seconds. A shorthand `interest-target-delay` property will control both.
@@ -123,6 +122,30 @@ The same is not true for `interesttarget`. When the target is a popover, the onl
123
122
124
123
See https://github.com/openui/open-ui/issues/1064#issuecomment-2581511411 (particularly [this comment](https://github.com/openui/open-ui/issues/1064#issuecomment-2581511411)) for more discussion of this section.
125
124
125
+
## The `:has-interest` Pseudo Class
126
+
127
+
It is handy to be able to select elements that both a) have the `interesttarget` attribute, and b) are *currently* being shown interest. The `:has-interest` pseudo class matches elements in exactly this state. Two common use cases arise:
128
+
129
+
1. Styling the trigger element to indicate that it's showing interest:
130
+
131
+
```
132
+
:has-interest {
133
+
background-color: lightgreen;
134
+
border: 2px solid green;
135
+
}
136
+
```
137
+
138
+
2. "Speeding up" the `interest-target-show-delay` when another element already has interest. This is a common request: for example, the first popover hovercard takes ~1 second to show up. But then if you quickly hover another element that also triggers a hovercard, that one shows up much more quickly:
139
+
140
+
```
141
+
[interesttarget] {
142
+
interest-target-delay: 1s;
143
+
}
144
+
container:has(:has-interest) [interesttarget] {
145
+
interest-target-show-delay: 0s;
146
+
}
147
+
```
148
+
126
149
## Implementation Details
127
150
128
151
In the style of `commandfor`, we propose to add a global attribute called `interesttarget`, which can be used on `<button>`, `<a>`, and `<area>` elements:
0 commit comments