Use admonitions to style collapsible cells :)#656
Use admonitions to style collapsible cells :)#656bsipocz merged 4 commits intoexecutablebooks:masterfrom
Conversation
|
I don't think these test failures are related to this PR? some pyarrow bug? also sorry this is i think the second time i have raised a PR without an issue discussion first, i just saw a sort of low-hanging fruit option and took it. but obvi open to closing this and pursuing any other strategy |
|
@sneakers-the-rat - thanks for the contribution! Re CI: -Yes, we started seeing some CI issues in the scheduled runs, too. I haven't had the time to look into those. As for your PR, this will need a review from someone who is more familiar with the frontend parts of the package. |
bsipocz
left a comment
There was a problem hiding this comment.
Since this clearly improves the behaviour for the bug that many downstream already patched over, I would go ahead and merge it.
If anyone runs into problems because of it, do feel free to open an issue.
Fix: #523
Collapsible cells currently look like this:
sphinx_book_themefuropydata_sphinx_themealabastersphinx_rtd_themesphinx_immaterialbiggest problem here is that they don't handle dark mode. secondary is that they don't adapt to the theme. this means that myst-nb is not really usable out of the box for all the modern themes that have a dark mode! I've been copy/pasting the same dark mode overrides for
myst-nbsphinx projects for years and i figure i might as well try to help out with the problem.challenge: there isn't a standard way to declare colors as css vars or things we could otherwise anticipate and use when rendering a notebook - we can't reliably ship opinionated css for rendering collapsibles (and it's arguably not our job, but the job of the theme).
proposal: use admonition classes! Very simple change to the html rendering process to add classes and switch a
spanto ap, and then clearing out the css rules that set colors, add some rules that unset values commonly used withdetailsandadmonitiontags so they take on the appearance of the theme.sphinx_book_themefuropydata_sphinx_themealabastersphinx_rtd_themesphinx_immaterialso not 100% perfect, but imo an improvement. only breaking change to existing use will be to swap out
span->pin css overrides, but this should also give us a more stable selector to target in the future rather than needing to override by being relative to a.cellelement (we could add a more unique class just for the sake of overriding, but didn't want to do too much)edit: a more foolproof version of this would be to not use
detailsbut directly mimic the structure of admonitions and use javascript to open/close the container. i could also do that if maintainers prefer, i just figured start with this since it was easier and more semantic html5 compliant, but it does miss the styles a bit in some of these themes.