Toggle & Accordions with ARIA sausage by @williamrembert

While working on a project, tried to update the way of coding a Toggle panel and an accordion. Inspired by this excellent tutorial in French from Accede Web initiative Accordéons (plier/déplier) by @societe_atalan , but need some improvements for my project. Here is the compiled result.

The challenge

Accordion demo

For my example, will use The universal declaration of human rights ! Though it could be usefull to remind it. Accordion must to close the active panels when opening a new one.

Article 1

All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.

Article 2

Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. Furthermore, no distinction shall be made on the basis of the political, jurisdictional or international status of the country or territory to which a person belongs, whether it be independent, trust, non-self-governing or under any other limitation of sovereignty. A link to test the focus order

Try with a second accordion to prevent conflict, can be setup in the JS see Options on line 42 & 46

Article 3 & 4

Everyone has the right to life, liberty and security of person.

No one shall be held in slavery or servitude; slavery and the slave trade shall be prohibited in all their forms.

Article 5

No one shall be subjected to torture or to cruel, inhuman or degrading treatment or punishment.

Toggles demo

Difference between Accordion is that opening a panel won't close the others

Article 6

Everyone has the right to recognition everywhere as a person before the law.

Article 7

All are equal before the law and are entitled without any discrimination to equal protection of the law. All are entitled to equal protection against any discrimination in violation of this Declaration and against any incitement to such discrimination. A link to test the focus order

How to use ?

Setup an accordion

  1. Copy the content of JS Panel in your script.js files
  2. Copy the content of CSS Panel in your styles.css. You'll need only since line 62.
  3. Wrap the content you want to affect with a container with class 'accordion'
  4. Add class panel-title to each panel title. Obvious no ?
  5. Wrap you panel content in a container with class 'panel-content'

Setup a toggle

  1. Copy the content of JS Panel in your script.js files
  2. Copy the content of CSS Panel in your styles.css. You'll need only since line 62.
  3. Add class panel-title to each panel title. Obvious no ?
  4. Wrap you panel content in a container with class 'panel-content'