<div class="dso-accordion dso-accordion-compact">
<div class="dso-accordion-section dso-open">
<h3 class="dso-section-handle"><button type="button">Sectie titel (active)</button>
</h3>
<div class="dso-section-body">
<div class="dso-rich-content">
<p>Dit is de inhoud van <strong>Sectie titel (active)</strong></p>
<p>Semantisch klopt deze pagina niet, maar om de styling voor de verschillende <code>.dso-accordion.handle</code>s te waarborgen staan alle varianten in het DOM (<code>div</code>, <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>)</p>
</div>
</div>
</div>
<div class="dso-accordion-section">
<h3 class="dso-section-handle"><button type="button">Sectie titel</button>
</h3>
</div>
<div class="dso-accordion-section">
<h3 class="dso-section-handle"><button type="button">Sectie titel</button>
</h3>
</div>
<div class="dso-accordion-section">
<h3 class="dso-section-handle"><button type="button">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vehicula, ipsum eu porttitor cursus, metus ante ultricies quam, quis egestas urna justo a quam.</button>
</h3>
</div>
</div>
{{#accordion}}
{{#each sections }}
{{#accordionSection title header=header }}
<div class="dso-rich-content">
<p>Dit is de inhoud van <strong>{{ title }}</strong></p>
<p>Semantisch klopt deze pagina niet, maar om de styling voor de verschillende <code>.dso-accordion.handle</code>s te waarborgen staan alle varianten in het DOM (<code>div</code>, <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>)</p>
</div>
{{#if sections }}
{{#accordion}}
{{#each sections }}
{{#accordionSection title header=header }}
<div class="dso-rich-content">
<p>Dit is een geneste accordion. De inhoud is van <strong>{{ title }}</strong>. Zie de <em>Notes</em> van dit component.</p>
</div>
{{/accordionSection}}
{{/each}}
{{/accordion}}
{{/if}}
{{/accordionSection}}
{{/each}}
{{/accordion}}
sections:
- title: Sectie titel (active)
id: panel1
header: h3
type: button
open: true
- title: Sectie titel
id: panel2
header: h3
type: button
- title: Sectie titel
id: panel3
header: h3
type: button
- title: >-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
vehicula, ipsum eu porttitor cursus, metus ante ultricies quam, quis
egestas urna justo a quam.
id: panel4
header: h3
type: button
modifiers: dso-accordion-compact
// Notes:
// ------
// * Each change to this file needs a restart of the fractal instance
// * Exported methods are merged as helpers in fractal.js
module.exports = function () {
return {
accordion(options) {
const classNames = ['dso-accordion', this.modifiers].filter(c => c).join(' ');
return `
<div class="${classNames}">
${options.fn(this)}
</div>
`.trim();
},
accordionSection(title, options) {
const self = this;
const header = options.hash.header || 'div';
const handleType = self.type;
const termMap = {
success: 'succes',
warning: 'waarschuwing',
info: 'info',
danger: 'gevaar'
};
let html = (
`<div class="dso-accordion-section${(self.state ? ' dso-' + self.state : '') + (self.open ? ' dso-open' : '') + (self.sections ? ' dso-nested-accordion' : '') }">
<${header} class="dso-section-handle">`);
html += handleType === 'button' ? (`<button type="button">`) : (`<a href="#">`);
const term = self.state;
if (termMap[term]) {
html += (`<span class="sr-only">${termMap[term]}: </span>`);
}
html += title;
const status = self.status;
if (status) {
html += (`<span class="dso-status">${status}</span>`);
}
const attachments = self.attachments;
if (typeof attachments === 'number') {
html += (`<span class="dso-attachments">${attachments} <span class="sr-only">bijlage${attachments === 1 ? '' : 'n'}</span></span>`)
}
html += handleType === 'button' ? (`</button>\n</${header}>`) : (`</a>\n</${header}>`);
if (self.open) {
html += (
`<div class="dso-section-body">
${options.fn(self)}
</div>`
);
}
html += `</div>`;
return html.trim();
}
};
};
Een accordion (.dso-accordion
) bestaat uit secties (.dso-accordion-section
). Een sectie heeft een handle (.dso-section-handle
) en body (.dso-section-body
).
Een accordion section in de state “open” moet een .dso-open
class op .dso-accordion-section
krijgen. Dit zorgt het “chevron-up”-icoon. Ook als het .dso-accordion-section
element niet in het DOM staat, moet een open accordion altijd .dso-open
krijgen.
Er zijn 4 modifiers: .dso-succes
, .dso-warning
, .dso-info
en .dso-danger
die op de .dso-accordion-section
kunnen.
Het is mogelijk om een accordion in een accordion te plaatsen. Er moet dan wel .dso-nested-accordion
op de .dso-accordion-section
worden gezet.