Skip to content
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 snippet to close a summary-element if a different detail element is opened #417

Closed
wants to merge 3 commits into from

Conversation

msbt
Copy link
Collaborator

@msbt msbt commented Aug 7, 2023

This should fix #413

@amotl
Copy link
Member

amotl commented Aug 7, 2023

About

Thanks a stack for providing this implementation. I've converged it to tech-writing/sphinx-design-elements#15 in a slightly more generic manner, calling it a "Dropdown Group", as inspired by using CSS toggle-group to group exclusive toggles.

Documentation and Demo

https://sphinx-design-elements.readthedocs.io/en/latest/dropdown-group.html

Code

Your code is now at sphinx-design-elements:addon.js.

Details

Effectively, it extends the CSS selector, now using document.querySelectorAll(".dropdown-group details") for selecting only relevant elements instead. With corresponding markup, it looks like this.

rST

.. div:: dropdown-group

    .. dropdown:: Dropdown A

        Dropdown content A

    .. dropdown:: Dropdown B

        Dropdown content B

MyST

::::{div} dropdown-group

:::{dropdown} Dropdown A
Dropdown content A
:::

:::{dropdown} Dropdown B
Dropdown content B
:::

::::

@amotl
Copy link
Member

amotl commented Aug 8, 2023

GH-419 has a corresponding patch, which brings in the dropdown-group CSS rule from sphinx-design-elements, and the JavaScript code from your pen, effectively superseding this patch. I hope you like it. Thank you again for submitting this fix.

@msbt
Copy link
Collaborator Author

msbt commented Aug 8, 2023

@amotl Appreciate it, thanks! Quick question about the chevrons you're using for up/down: Wouldn't it be nicer to have only one that turns 180° when you open it instead of two that show/hided depending on the status?

Like

details.sd-dropdown .sd-summary-down {
  transition: 180ms;
}

details.sd-dropdown[open] > .sd-summary-title .sd-summary-down {
  /* visibility: hidden; */
  transform: rotate(-180deg);
}

If so, do you want me to submit a PR over there?

@msbt msbt closed this Aug 8, 2023
@amotl amotl deleted the matthias/fix-version-feedback-details-summary branch August 8, 2023 10:15
@amotl
Copy link
Member

amotl commented Aug 8, 2023

Thanks. I've converged your suggestion into tech-writing/sphinx-design-elements#20, in order to track it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improving feedback and version choosers
2 participants