digdir / designsystemet

Designsystemet
https://designsystemet.no
MIT License
80 stars 37 forks source link

Accordion naming convention? #2364

Open eirikbacker opened 2 months ago

eirikbacker commented 2 months ago

Description

Feedback from @Thunear :

Response from @eirikbacker:

Agree - then think that Expandable is perhaps a better naming convention, as Accordion gives the expectation of grouping and one open at a time. I also think that Expandable can be used without any wrapper around it - it is entirely possible to get rounded edges etc. with pure CSS that looks for the previous and next element, so that:

<p>Some text before</p>
<Expandable>...<Expandable>
<Expandable>...<Expandable>
<p>Some text after</p>

will "connect with each other" and run as a group, while

<p>Some text before</p>
<Expandable>...<Expandable>
<p>Some text between</p>
<Expandable>...<Expandable>
<p>Some text after</p>

rendered separately. The only annoying thing is that you then have to color each Expandable:

<p>Some text before</p>
<Expandable color="brand1">...<Expandable>
<Expandable color="brand1">...<Expandable>
<p>Some text after</p>

Alternatively, we can offer an Expandable.Group to have a quick way to wrap everyone, but that it is optional. It can be nice, but also a little assessment of how much we should do for people, because they will anyway often loop over content when they generate such groupings, and then they can put props there immediately (a bit the same as we landed on in ToggleGroup).

Regarding one open Expandable at a time; If we implement on top of native <details>, we can offer name="..." to group - when several Expandables have the same name, they are automatically linked together - in exactly the same way as input type="radio" works :relaxed :

eirikbacker commented 2 months ago

Related to https://github.com/digdir/designsystemet/pull/2363

mrosvik commented 2 months ago

ARIA skiller mellom "Accordion" og "Disclosure": https://www.w3.org/WAI/ARIA/apg/patterns/

eirikbacker commented 2 months ago

...og HTML kaller det details - "the details disclosure element" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details Se også første notis fra W3C spesifikasjonen: https://html.spec.whatwg.org/multipage/interactive-elements.html#the-details-element:the-details-element-2