-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Use <details> element for collapsible sections instead of JS #677
Comments
I'm personally leaning towards using |
According to https://caniuse.com/#search=details , some polyfills exist for browser that don't support this html tag. In particular https://github.com/javan/details-element-polyfill |
This is implemented in #708 You can see an example ZIM file here: I've tested it on KiwixJS and Kiwix Mac. It seems to be working properly. |
@ISNIT0 There's no support for However, do we really want to introduce new HTML into the document? One thing is providing custom CSS or JS files, but another is changing the HTML. Changing all H1 or all H2 (and H3?) headings to I wonder why Wikimedia's own solution doesn't work for us? It would be so much easier than injecting CSS or JS or altering the HTML quite so radically. |
@Jaifroid Sorry, I forgot to update here, I've implemented the polyfill here: #708 You can download the updated ZIM file from there :) @Jaifroid Your comment about removing the |
Thanks! I'll test. I've noticed one issue (testing on Chromium) with the framadrop ZIM linked in this thread, which is that clicking on a footnote doesn't open the "Notes" section (if it's closed), and therefore there is no jump to the relevant note. Tested in Kiwix JS in Service Worker mode. I understand this is more a proof-of-concept for testing (?) so that part of course isn't implemented yet, but I presume that would still require custom JavaScript? |
Fixed in latest ZIM :) |
@ISNIT0 So far I can see:
|
I quickly tested the framadrop file of @ISNIT0 last comment. |
@ISNIT0 For reasons of compatibility with code that creates a Table of Contents dynamically, would it be possible to attach the id of each heading to the In this example, we would move the Other things may depend on the ID being in the |
As a followup to the above, here is an example of the same code from the same article in a "legacy" ZIM ( In short, it would be great if the change merely substituted |
@kelson42 What do you mean by "cursor on paragraph title is wrong"? Thanks for your feedback everyone, these are the tasks I think I need to do:
|
@ISNIT0 The mouse pointer is wrong, should be the "hand", but is the "cursor". |
@ISNIT0 Looks good to me |
Looks good to me - both on desktop and smartphone! |
Hi @ISNIT0, with this new method, the following line in
The exception is "Unable to get property 'classList' of undefined or null reference". Maybe do something like this:
Maybe related to the removal of some classes in this type of ZIM? |
It works much better, indeed. I'm also wondering if it's good to close the subsections by default. For example, in article "Beaune Altarpiece" where there are many sections and subsections, I find it difficult to see in which subsection we are, and to open everything if I'd like to read the whole article. |
@mossroy Interesting, the sections seem to automatically open for me on desktop ( @Jaifroid I've updated You can see the generated ZIM here: https://framadrop.org/r/D1EE0C6YxL#SwJO6719lYGfukNN1i71HHy1glAK4MaJTdKiifDHBlo= |
@ISNIT0 Confirm it works on macOS (10.14) here too. Pretty neat. |
@ISNIT0 Below is what I'm seeing by default on Chromium (Kiwix JS, Desktop, Service Worker mode [i.e. with JavaScript fully supported]). As you can see, the |
Qualification to above: if I restrict the width of the screen <720 before I open the article, then all sections are closed. However, changing the width of the browser window while the article is open does not trigger closing of the sections (which was the previous behaviour). That may not be important. |
@Jaifroid I don't think it has ever responded to resizes in this way. |
@ISNIT0 The behaviour with previous ZIMs (e.g. any previous WikiMed from 2018) is that the sections are closed by the stylesheet rules if the screen is less than 720px, therefore changing the window size changes the behaviour dynamically. It's probably not important. The only case where it might be important is if the user changes the orientation of their screen in mobile. Old behaviour was that in portrait mode, sections are closed, in landscape mode, sections are open. Anyway, it's not a big deal. Thank you for your hard work with this change and for the creative solution! |
@ISNIT0 I don't see it in https://download.kiwix.org/zim/other/rationalwiki_en_all_novid_2019-05.zim for example (no small arrow on the left of each paragraph title). And this ZIM file has been done with 1.8.6. |
@kelson42 Perhaps this is the same issue I had with my UATs when I had to reinstall it again. |
@ISNIT0 All of this is Docker... it is anyway reset. |
Hmmm, I'll look into it. |
@kelson42 |
Caused by #722 |
For context: #633
If we are to re-visit the collapsible headings, it may make more sense to re-write the open/close logic to not depend on JavaScript at all using something like:
<details>
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details@cm8 @mossroy @Jaifroid
The text was updated successfully, but these errors were encountered: