Add shared horizontal and vertical checkbox groups
This commit is contained in:
1 parent
aece8e59cd
commit
36f526aa02
12 files changed
+135
-1
No files matched your search
@@ -16,6 +16,24 @@
|
||||
|
||||
Choice pill: подписанные checkbox/radio помещаются внутрь label.choice-pill со span текста. Вся капсула кликабельна; native input сохраняет поведение и клавиатуру. Контрол и подпись центрированы, checked меняет фон/рамку/цвет, focus-visible обводит капсулу; минимальная высота 40px, на мобильном 44px. Табличные checkbox остаются компактными.
|
||||
|
||||
Choice group: общая капсула для нескольких связанных checkbox. Fieldset/legend задают название группы, div.choice-group — одну внешнюю поверхность, label.choice-group-option — пункты без отдельных пузырьков. По умолчанию расположение горизонтальное; choice-group--vertical ставит пункты столбцом. Нативные checkbox сохраняют независимый множественный выбор, клики по подписям и Space. Разделители нарисованы псевдоэлементами и не смещают центры контролов. Focus-visible меняет фон пункта без прямоугольной рамки. Минимальная высота пункта — 44px.
|
||||
|
||||
```html
|
||||
<fieldset class="choice-fieldset">
|
||||
<legend>Каналы уведомлений</legend>
|
||||
<div class="choice-group choice-group--vertical">
|
||||
<label class="choice-group-option">
|
||||
<input type="checkbox" name="channels" value="email" checked />
|
||||
<span>Email</span>
|
||||
</label>
|
||||
<label class="choice-group-option">
|
||||
<input type="checkbox" name="channels" value="push" />
|
||||
<span>Push</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
```
|
||||
|
||||
Тосты: createNotifier из toast.js, типы success/info/warning/error. Иконка, заголовок, текст, семантический акцент и закрытие. Таймеры: 4/5/8 секунд, ошибка без автоматического скрытия. Hover и фокус приостанавливают таймер. Повторный вызов заменяет активное уведомление. Error использует role=alert/assertive; остальные status/polite. Текст вставляется через textContent. Тост помещается в активный dialog и показывается в верхнем слое: затемнение не перекрывает его, закрытие доступно мышью и клавиатурой, фокус возвращается инициатору.
|
||||
|
||||
```js
|
||||
|
||||
@@ -2842,3 +2842,89 @@ body[data-concept="dock"].dock-open
|
||||
.choice-pill:has(input:disabled) > input {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* One shared surface for related choices; inner options have no individual bubbles. */
|
||||
.choice-fieldset {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 20px 0 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.choice-fieldset legend {
|
||||
padding: 0;
|
||||
margin-bottom: 10px;
|
||||
font-size: 13px;
|
||||
color: var(--color-muted);
|
||||
}
|
||||
.choice-group {
|
||||
display: inline-flex;
|
||||
align-items: stretch;
|
||||
max-width: 100%;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 999px;
|
||||
background: var(--color-surface);
|
||||
overflow: hidden;
|
||||
vertical-align: top;
|
||||
}
|
||||
.choice-group-option {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
min-height: 44px;
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.choice-group-option + .choice-group-option::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
border-left: 1px solid var(--color-border);
|
||||
pointer-events: none;
|
||||
}
|
||||
.choice-group-option > :is(input[type="checkbox"], input[type="radio"]) {
|
||||
display: block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.choice-group-option > span {
|
||||
min-width: 0;
|
||||
line-height: 20px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.choice-group-option:hover {
|
||||
background: var(--color-row-hover);
|
||||
}
|
||||
.choice-group-option:has(input:checked) {
|
||||
background: var(--color-row-active);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
.choice-group-option:has(input:focus-visible) {
|
||||
background: var(--color-row-hover);
|
||||
}
|
||||
.choice-group-option > input:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
.choice-group-option:has(input:disabled),
|
||||
.choice-group-option > input:disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.choice-group-option:has(input:disabled) {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.choice-group--vertical {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(280px, 100%);
|
||||
border-radius: 18px;
|
||||
}
|
||||
.choice-group--vertical > .choice-group-option + .choice-group-option::before {
|
||||
inset: 0 0 auto;
|
||||
border-left: 0;
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
Reference in new issue
Block a user