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