I'm trying to factor out some of the disparate functionality in my app.
This one seemed to peel out rather nicely, only I'm somehow not able
to successfully send it a custom "redraw" event. In my application I'm having to trigger a redraw by peeking into the shadow dom and calling .click() twice on the toggle.
A <more-panel></more-panel> works like a div that can be in either
of two states: a 'more' state where the clickable word says "(less)"
and the panel hides contents with the class of "less" and shows
contents with the class of "more; and a 'less' state where the clickable word says "(more)" and the panel hides contents with the class of
"more" and shows contents with the class of "less". Contents without
either of these classes is simply passed through unmolested.
Contents with both classes will be shown in both states.
The more-panel itself can be instantiated with or without the "more"
class to specify its initial state.
Any critiques or comments welcome.
[...]
On Thursday, July 6, 2023 at 10:34:49 AM UTC-5, luserdroog wrote:
I'm trying to factor out some of the disparate functionality in my app. This one seemed to peel out rather nicely, only I'm somehow not able
to successfully send it a custom "redraw" event. In my application I'm having to trigger a redraw by peeking into the shadow dom and calling .click() twice on the toggle.
A <more-panel></more-panel> works like a div that can be in either
of two states: a 'more' state where the clickable word says "(less)"
and the panel hides contents with the class of "less" and shows
contents with the class of "more; and a 'less' state where the clickable word says "(more)" and the panel hides contents with the class of
"more" and shows contents with the class of "less". Contents without either of these classes is simply passed through unmolested.
Contents with both classes will be shown in both states.
The more-panel itself can be instantiated with or without the "more"
class to specify its initial state.
Any critiques or comments welcome.
[...]
There is a native <details /> tag you can use now:
<https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details>
Just style it as appropriate
Just style it as appropriateWell, dang. I wish I'd noticed that earlier. Thanks. That does 90% of what
I wanted. Ultimately, I found the extra flexibility very useful. Being able to
toggle the "more" and "less" classes separately on the contents means
I can pop up an important control into the abbreviated state by just
adding "less" to it. I suppose I could accomplish similar with some js gymnastics upon a <details />.
Anyway, good to know. I like mine better.
On Monday, July 10, 2023 at 9:12:05 PM UTC-5, luserdroog wrote:
Just style it as appropriateWell, dang. I wish I'd noticed that earlier. Thanks. That does 90% of what I wanted. Ultimately, I found the extra flexibility very useful. Being able to
toggle the "more" and "less" classes separately on the contents means
I can pop up an important control into the abbreviated state by just adding "less" to it. I suppose I could accomplish similar with some js gymnastics upon a <details />.
Anyway, good to know. I like mine better.Well, the open state of <details /> can be styled with: details[open].
The JavaScript event is simply:
details.addEventListener("toggle", (event) => {
if (details.open) {
/* the element was toggled open */
} else {
/* the element was toggled closed */
}
});
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 469 |
Nodes: | 16 (2 / 14) |
Uptime: | 42:20:32 |
Calls: | 9,449 |
Calls today: | 6 |
Files: | 13,596 |
Messages: | 6,111,762 |
Posted today: | 1 |