-
Notifications
You must be signed in to change notification settings - Fork 106
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
Replace all the javascript with html+css. #4
Comments
This is very cool! It actually started out without Javascript, but we ended up using bootstrap as a time saving measure. If I find the time for it, I'll see what I can do to remove Javascript. |
I spent some time investigating the effort needed to remove all javascript and I realized it is a lot. There are a lot of accordion examples without JS, but not really when there are sections within another. I was thinking of creating another template without the collapsible sections (everything expanded). It would also make it easier to search using the browser search function, and to add anchor links, something I have been wanting to do for a while. Users that don't want the Bootstrap/jQuery overhead could use that template instead. Thoughts? |
I think this alternative would be useful. Still, at least a "collapse/expand all" button could still be useful, if easily possible with CSS. Including the HTML in-line in a documentation would benefit from this simple overview. |
abc
|
@KOLANICH Thanks for the tip! I am more a Python developer than a Web developer, so please excuse my ignorance :) I started working on a "flat" version without JS, it's not very beautiful, but it generates and renders very quickly! It's in this branch: https://github.com/coveooss/json-schema-for-humans/tree/feature/flat-version. Just pass |
I have an attempt at it with the release on pypi: scikit-hep/pyhf@b615ea6 Just doing some modifications to the html. One could probably use beautifulsoup to pull out all the relevant pieces, but it would be much easier for all involved to put all the needed css/javascript at the bottom of the body, and then we can just extract the body into the html file as a post-processing step of sorts.. or just have a config for it. It's not perfect (missing some pieces) but the render does look nice-ish: https://pyhf.readthedocs.io/en/docs-jsonschema/schema.html |
@dblanchette, thank you. Sorry for the delay, I have planned to test it and answer after the test, but was busy enough to forget to test. It seems like in its current state the tool doesn't use |
@KOLANICH Do you know a way to make anchor links and the "expand" and "collapse" buttons work with details tag without javascript? The current implementation uses Javascript to iterate through the page and expand sections that need to be. I did not find any equivalent way without using some Javascript. @kratsg Thanks! I'll look into making an option as soon as I can get a schema that works. Right now, |
Unfortunately, if we want to expand by a link we have to fall-back to CSS solution. Here is one adapted from https://cdpn.io/cristina-silva/fullpage/pyXQrj and modified by me to expand by an URI fragment. <html>
<head></head>
<body>
<style>
.toggle-label {
cursor: pointer;
}
.toggle-label:before {
content: "+";
float: left;
}
.toggle-input:checked ~ .toggle-label:before {
content: "-";
}
.toggle-input:not(checked):target ~ .toggle-label {
display: none;
}
.close-href {
display: none;
}
.toggle-input:not(checked):target ~ .close-href {
display: inline;
}
.toggle-input {
display: none;
}
.toggle-input:not(checked) ~ .toggle-content {
display: none;
}
.toggle-input:checked ~ .toggle-content {
display: block;
}
.toggle-input:target ~ .toggle-content {
display: block;
}
</style>
<div class="toggle">
<!-- Checkbox toggle -->
<input type="checkbox" id="expand_aaaa" class="toggle-input"></input>
<a href="#" class="close-href">-aaaaa</a>
<label for="expand_aaaa" class="toggle-label">aaaaa</label>
<!-- Content to toggle -->
<div class="toggle-content">
bbbb
</div>
</div>
<a href="#expand_aaaa"> Expand aaaa </a>
</body>
</html> |
I have released the Just generate with The template uses no Javascript. It still uses Bootstrap for the CSS at the moment. There are no collapsible sections or tabbed sections, everything is rendered one after the other. I had to do it this way since I could not find a way to make anchor links work when a section is collapsed without using Javascript. This is far from perfect, but I figured it was better to release something rather than letting this nearly one year old issue pending while I try to find time and motivation to make something better :) I added a section in the README about how to add your own templates if this one does not suit you, it could be a way to have what you need. Contributions to the new |
Closed for inactivity and because a solution was implemented (even if not as good as I would wish). Feel free to build a better template if you still need this! |
https://github.com/you-dont-need/You-Dont-Need-JavaScript
The text was updated successfully, but these errors were encountered: