UI: единый Switch для булевых опций вместо смеси чекбоксов и свитчей
Новый компонент Switch (разметка .switch из global.css). Применён: - создание группы: дополнения теперь свитчи, как в настройках группы; - настройки группы: базовые дополнения показываются, как при создании (включены, заблокированы, подпись «всегда включено»), а не скрываются; - админка: «Группировать по группам» и флаг «выбыл» в правке партии. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
|
||||
import { ApiError } from "../api/client";
|
||||
import { PlayerLink } from "../components/PlayerLink";
|
||||
import { Spinner } from "../components/Spinner";
|
||||
import { Switch } from "../components/Switch";
|
||||
import { MAX_GROUP_SIZE } from "../domain/constants";
|
||||
import { useToast } from "../context/ToastContext";
|
||||
import { useMe } from "../hooks/auth";
|
||||
@@ -73,24 +74,20 @@ export function GroupSettingsPage() {
|
||||
<div className="card">
|
||||
<h3>Дополнения</h3>
|
||||
<div className="stack">
|
||||
{(expansions ?? [])
|
||||
.filter((e) => !e.is_base)
|
||||
.map((e) => (
|
||||
<label key={e.id} className="row" style={{ justifyContent: "space-between" }}>
|
||||
<span>{e.name_ru}</span>
|
||||
<span className="switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
disabled={!isOwner}
|
||||
checked={selected.has(e.id)}
|
||||
onChange={() => toggle(e.id)}
|
||||
/>
|
||||
<span className="switch-track">
|
||||
<span className="switch-thumb" />
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
))}
|
||||
{/* Базовые дополнения показываем, как и при создании группы: включены и заблокированы. */}
|
||||
{(expansions ?? []).map((e) => (
|
||||
<label key={e.id} className="row" style={{ justifyContent: "space-between" }}>
|
||||
<span>
|
||||
{e.name_ru}
|
||||
{e.is_base && <span className="muted small"> (всегда включено)</span>}
|
||||
</span>
|
||||
<Switch
|
||||
disabled={e.is_base || !isOwner}
|
||||
checked={e.is_base || selected.has(e.id)}
|
||||
onChange={() => toggle(e.id)}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
{isOwner && (
|
||||
<button className="btn btn-primary" style={{ marginTop: 10 }} onClick={saveExpansions}>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
|
||||
import { ApiError } from "../../api/client";
|
||||
import { MatchMedia } from "../../components/MatchMedia";
|
||||
import { Spinner } from "../../components/Spinner";
|
||||
import { Switch } from "../../components/Switch";
|
||||
import { WIN_REASONS, type WinReason } from "../../domain/winReasons";
|
||||
import { useToast } from "../../context/ToastContext";
|
||||
import {
|
||||
@@ -141,12 +142,7 @@ export function AdminMatchEdit({ matchId, onClose }: { matchId: number; onClose:
|
||||
/>
|
||||
</div>
|
||||
<label className="row small" style={{ flex: "0 0 auto", gap: 4 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
style={{ width: "auto" }}
|
||||
checked={r.eliminated}
|
||||
onChange={(e) => upd(i, { eliminated: e.target.checked })}
|
||||
/>
|
||||
<Switch checked={r.eliminated} onChange={(v) => upd(i, { eliminated: v })} />
|
||||
выбыл
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Pencil, Trash2 } from "lucide-react";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import { Spinner } from "../../components/Spinner";
|
||||
import { Switch } from "../../components/Switch";
|
||||
import { useToast } from "../../context/ToastContext";
|
||||
import {
|
||||
useAdminDeleteMatch,
|
||||
@@ -112,12 +113,7 @@ export function AdminRecordsPage() {
|
||||
))}
|
||||
</select>
|
||||
<label className="row" style={{ gap: 8 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
style={{ width: "auto" }}
|
||||
checked={grouped}
|
||||
onChange={(e) => setGrouped(e.target.checked)}
|
||||
/>
|
||||
<Switch checked={grouped} onChange={setGrouped} />
|
||||
Группировать по группам
|
||||
</label>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user