Add activation toggle pattern with inline an/aus chip
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
<li><a href="./patterns/card-gruppe-mit-tastennavigation.html">Card Gruppe mit Tastennavigation</a></li>
|
<li><a href="./patterns/card-gruppe-mit-tastennavigation.html">Card Gruppe mit Tastennavigation</a></li>
|
||||||
<li><a href="./patterns/formular-mit-abschnitten.html">Formular mit Abschnitten</a></li>
|
<li><a href="./patterns/formular-mit-abschnitten.html">Formular mit Abschnitten</a></li>
|
||||||
<li><a href="./patterns/multiselektions-pulldown.html">Multiselektions-Pulldown</a></li>
|
<li><a href="./patterns/multiselektions-pulldown.html">Multiselektions-Pulldown</a></li>
|
||||||
|
<li><a href="./patterns/aktivierungs-schalter.html">Aktivierungs-Schalter (an/aus)</a></li>
|
||||||
<li><a href="./patterns/text-layouts.html">Text Layouts</a></li>
|
<li><a href="./patterns/text-layouts.html">Text Layouts</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Styleguide – Pattern Aktivierungs-Schalter</title>
|
||||||
|
<link rel="stylesheet" href="../styleguide.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1 class="sg-main-heading">Pattern – Aktivierungs-Schalter</h1>
|
||||||
|
<section id="pattern-aktivierungs-schalter">
|
||||||
|
<p class="sg-preview-label">Pattern: Aktivierungs-Schalter (an/aus)</p>
|
||||||
|
|
||||||
|
<div class="sg-form-preview-area">
|
||||||
|
<div class="sg-state-example">
|
||||||
|
<p class="sg-state-example__label sg-table-label">Pattern Demo</p>
|
||||||
|
<div class="sg-activation-toggle-pattern" data-pattern="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>
|
||||||
|
</button>
|
||||||
|
<span class="sg-activation-toggle-pattern__label sg-body" data-pattern-part="activation-toggle-state">Status: aus</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.querySelectorAll('.sg-activation-toggle-chip').forEach((toggle) => {
|
||||||
|
toggle.addEventListener('click', () => {
|
||||||
|
const nextState = toggle.dataset.active === 'an' ? 'aus' : 'an';
|
||||||
|
const statusLabel = toggle.closest('[data-pattern="activation-toggle"]')?.querySelector('[data-pattern-part="activation-toggle-state"]');
|
||||||
|
|
||||||
|
toggle.dataset.active = nextState;
|
||||||
|
toggle.setAttribute('aria-pressed', String(nextState === 'an'));
|
||||||
|
toggle.setAttribute('aria-label', `Aktivierung ${nextState}`);
|
||||||
|
|
||||||
|
if (statusLabel) {
|
||||||
|
statusLabel.textContent = `Status: ${nextState}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1769,6 +1769,70 @@ section + section {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================= */
|
||||||
|
/* Patterns: Aktivierungs-Schalter */
|
||||||
|
/* ========================================================= */
|
||||||
|
|
||||||
|
.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 {
|
||||||
|
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(--border-width-thin);
|
||||||
|
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(--border-width-thin);
|
||||||
|
left: var(--border-width-thin);
|
||||||
|
width: calc(50% - var(--border-width-thin));
|
||||||
|
height: calc(100% - (var(--border-width-thin) * 2));
|
||||||
|
border-radius: calc(var(--radius-interaction) - var(--border-width-thin));
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sg-activation-toggle-chip:focus,
|
||||||
|
.sg-activation-toggle-chip:focus-visible {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* ========================================================= */
|
/* ========================================================= */
|
||||||
/* Patterns: Object Card */
|
/* Patterns: Object Card */
|
||||||
/* ========================================================= */
|
/* ========================================================= */
|
||||||
|
|||||||
Reference in New Issue
Block a user