-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add dropdown
directive
#14
Comments
Way ahead of yah 😉 Basically I am going to copy https://github.com/tk0miya/sphinxcontrib-details-directive/blob/master/sphinxcontrib/details/directive/__init__.py, but adapt it with some bootstrap (cards) + custom CSS, as exampled below. <style>
details.sphinx .summary-title {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
padding-right: 3em!important;
}
details.sphinx:hover {
cursor: pointer;
}
details.sphinx .summary-content {
cursor: default;
}
details.sphinx summary {
padding: 1em;
list-style: none;
}
/* chrome doesn't yet support list-style */
details.sphinx summary::-webkit-details-marker {
display: none;
}
details.sphinx summary:focus {
outline: none;
}
details.sphinx summary:hover .summary-chevron-up svg {
opacity: 1;
}
details.sphinx .summary-chevron-up svg {
opacity: 0.5;
}
details.sphinx .summary-chevron-up,
details.sphinx .summary-chevron-down {
pointer-events: none;
position: absolute;
top: 0.75em;
right: 1em;
}
details.sphinx .summary-chevron-up svg,
details.sphinx .summary-chevron-down svg {
display: block;
}
details.sphinx[open] .summary-chevron-up{
visibility: hidden;
}
</style>
<details class="sphinx card">
<summary class="summary-title card-header bg-danger text-white">
Details element with custom arrow!
<div class="summary-chevron-up">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
</div>
</summary>
<div class="summary-content card-body">
<p class="card-text">paragraph 1</p>
<p class="card-text">paragraph 2</p>
</div>
<div class="summary-chevron-down">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"></polyline></svg>
</div>
</details> |
Give it a go and let me know what you think |
oh nice! when you say "give it a go", do you mean this: https://github.com/tk0miya/sphinxcontrib-details-directive/blob/master/sphinxcontrib/details/directive/__init__.py ? So basically, you're suggesting "use the HTML details element with styling so that it doesn't look crappy"? If that's it, then I think it's a great idea :-) |
nice - looks good to me (though the extra "button" styling is missing in my demo). I suppose that themes etc could also control some styling. The toggle-buttons in sphinx togglebutton are also pure CSS (even though toggling the actual content uses js) |
What does it look like to you? Do you have e.g. |
ah I just missed your point about "that has bootstrap css loaded" haha, I literally copypasted into a local html file and opened it in chrome. It looks great in a page built with jupyter book ✨ |
so you're imagining that with things like cells, we just wrap their content in a |
another note - perhaps we could allow users to specify Sphinx admonition styles rather than using the bootstrap-specific class names. E.g. to let people do:
and that would adopt the styling of the sphinx |
Yeh thats a bit more tricky. I think for |
yeah that makes sense - in the case of togglebutton, the element could just be the "+/-" or the "v ^" elements to the right |
We can talk about this more when I do the PR (soon).
|
yeah - I think it's a broader question for this repo (or our general "bootstrap support") whether we want users to use bootstrap-specific classes etc, or if we want to piggy-back on the Sphinx terminology. I think there are pros/cons to each. But happy to iterate in a PR! |
What do you mean by this? Just note, warning, attention, etc? |
yeah, like do we ask people to put FWIW there are a bunch of these translations here: https://github.com/pandas-dev/pydata-sphinx-theme/blob/master/pydata_sphinx_theme/bootstrap_html_translator.py |
That type of translation only really makes sense for single element constructs. Just use the bootstrap class names for setting specific classes; they are well named and well documented already. But then, as I mentioned, there could be "top-level" |
Also I'll probably create a |
that all makes sense to me 👍 |
We've discussed this in a few other spots, but figured it's worth making an issue about it.
Right now we're using custom JS/CSS in the sphinx-togglebutton extension, but we could probably use some combination of
for this, especially for the "toggle buttons with titles" parts of sphinx-togglebutton
If we implement that functionality here, then I am fine deprecating
sphinx-togglebutton
(though at that point we may wanna rename this tosphinx-bootstrap
or something).The only thing we need to make sure of is that we don't mess-up the CSS styling of togglebuttons...we don't want those elements to take up too much visual space IMO
The text was updated successfully, but these errors were encountered: