Align activation toggle with existing external-label slider style
This commit is contained in:
@@ -493,18 +493,16 @@
|
||||
<section id="component-activation-toggle">
|
||||
<p class="sg-preview-label">Component: Aktivierungs-Schalter (an/aus)</p>
|
||||
|
||||
<div class="sg-activation-toggle-pattern" data-component="activation-toggle">
|
||||
<button
|
||||
class="sg-activation-toggle-chip"
|
||||
type="button"
|
||||
data-active="aus"
|
||||
aria-pressed="false"
|
||||
aria-label="Aktivierung aus"
|
||||
>
|
||||
<span class="sg-activation-toggle-chip__text">aus</span>
|
||||
<span class="sg-activation-toggle-chip__text">an</span>
|
||||
<div class="sg-activation-toggle-pattern">
|
||||
<button class="sg-mode-toggle sg-mode-toggle--local sg-activation-mode-toggle" type="button" data-active="absolute" aria-label="Aktivierung: aus">
|
||||
<span class="sg-mode-toggle__label">aus</span>
|
||||
|
||||
<span class="sg-mode-toggle__switch" aria-hidden="true" data-component-part="toggle-track">
|
||||
<span class="sg-mode-toggle__handle" data-component-part="toggle-handle"></span>
|
||||
</span>
|
||||
|
||||
<span class="sg-mode-toggle__label">an</span>
|
||||
</button>
|
||||
<span class="sg-activation-toggle-pattern__label sg-body" data-component-part="activation-toggle-state">Status: aus</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -617,7 +615,7 @@
|
||||
</section>
|
||||
|
||||
<script>
|
||||
document.querySelectorAll('.sg-mode-toggle').forEach((toggle) => {
|
||||
document.querySelectorAll('.sg-mode-toggle:not(.sg-activation-mode-toggle)').forEach((toggle) => {
|
||||
toggle.addEventListener('click', () => {
|
||||
const nextState = toggle.dataset.active === 'relative' ? 'absolute' : 'relative';
|
||||
const modeLabel = toggle.dataset.modeLabel || 'Modus Schieber';
|
||||
@@ -629,18 +627,11 @@
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('.sg-activation-toggle-chip').forEach((toggle) => {
|
||||
document.querySelectorAll('.sg-activation-mode-toggle').forEach((toggle) => {
|
||||
toggle.addEventListener('click', () => {
|
||||
const nextState = toggle.dataset.active === 'an' ? 'aus' : 'an';
|
||||
const statusLabel = toggle.closest('[data-component="activation-toggle"]')?.querySelector('[data-component-part="activation-toggle-state"]');
|
||||
|
||||
const nextState = toggle.dataset.active === 'absolute' ? 'relative' : 'absolute';
|
||||
toggle.dataset.active = nextState;
|
||||
toggle.setAttribute('aria-pressed', String(nextState === 'an'));
|
||||
toggle.setAttribute('aria-label', `Aktivierung ${nextState}`);
|
||||
|
||||
if (statusLabel) {
|
||||
statusLabel.textContent = `Status: ${nextState}`;
|
||||
}
|
||||
toggle.setAttribute('aria-label', `Aktivierung: ${nextState === 'absolute' ? 'aus' : 'an'}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user