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'}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1
-62
@@ -1776,68 +1776,7 @@ section + section {
|
||||
.sg-activation-toggle-pattern {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-small);
|
||||
}
|
||||
|
||||
.sg-activation-toggle-pattern__label {
|
||||
margin: 0;
|
||||
color: var(--text-control-default);
|
||||
}
|
||||
|
||||
.sg-activation-toggle-chip {
|
||||
--sg-activation-toggle-inset: 0px;
|
||||
position: relative;
|
||||
display: inline-grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
align-items: center;
|
||||
min-width: calc(var(--layout-mode-toggle-local-height) * 3);
|
||||
height: var(--layout-mode-toggle-local-height);
|
||||
padding: var(--sg-activation-toggle-inset);
|
||||
border: var(--border-none);
|
||||
border-radius: var(--radius-interaction);
|
||||
background: var(--surface-toggle-track);
|
||||
color: var(--text-control-default);
|
||||
font-family: var(--font-family-base);
|
||||
font-size: var(--font-size-small);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.sg-activation-toggle-chip::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: var(--sg-activation-toggle-inset);
|
||||
left: var(--sg-activation-toggle-inset);
|
||||
width: calc(50% - var(--sg-activation-toggle-inset));
|
||||
height: calc(100% - (var(--sg-activation-toggle-inset) * 2));
|
||||
border-radius: var(--radius-interaction);
|
||||
background: var(--surface-toggle-handle);
|
||||
transition: transform 160ms ease;
|
||||
}
|
||||
|
||||
.sg-activation-toggle-chip[data-active="an"]::before {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
|
||||
.sg-activation-toggle-chip__text {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
text-transform: lowercase;
|
||||
color: var(--text-control-default);
|
||||
}
|
||||
|
||||
.sg-activation-toggle-chip[data-active="aus"] .sg-activation-toggle-chip__text:first-child,
|
||||
.sg-activation-toggle-chip[data-active="an"] .sg-activation-toggle-chip__text:last-child {
|
||||
color: var(--color-font-light);
|
||||
}
|
||||
|
||||
.sg-activation-toggle-chip:focus,
|
||||
.sg-activation-toggle-chip:focus-visible {
|
||||
outline: none;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
/* ========================================================= */
|
||||
|
||||
Reference in New Issue
Block a user