Сглаживающая линия #28

Merged
NBizyaev merged 9 commits from dev into main 2026-07-08 10:50:54 +00:00
5 changed files with 33 additions and 20 deletions
Showing only changes of commit 5d0408c533 - Show all commits

View File

@@ -96,6 +96,7 @@ export function ArchiveView({
onToggleTag, onToggleTag,
}: ArchiveViewProps) { }: ArchiveViewProps) {
const [avgLineMode, setAvgLineMode] = useState<AvgLineMode>('auto'); const [avgLineMode, setAvgLineMode] = useState<AvgLineMode>('auto');
const [selectedRangePresetId, setSelectedRangePresetId] = useState<string>('24h');
const [selectorOpen, setSelectorOpen] = useState(false); const [selectorOpen, setSelectorOpen] = useState(false);
const selectedPreview = selectedTags.slice(0, 10); const selectedPreview = selectedTags.slice(0, 10);
const hiddenSelectedCount = Math.max(0, selectedTags.length - selectedPreview.length); const hiddenSelectedCount = Math.max(0, selectedTags.length - selectedPreview.length);
@@ -106,6 +107,7 @@ export function ArchiveView({
const fromIso = toIsoFromInput(range.from) as string; const fromIso = toIsoFromInput(range.from) as string;
const toIso = toIsoFromInput(range.to) as string; const toIso = toIsoFromInput(range.to) as string;
const updateRangePart = (rangePart: RangePart, inputPart: RangeInputPart, value: string) => { const updateRangePart = (rangePart: RangePart, inputPart: RangeInputPart, value: string) => {
setSelectedRangePresetId('');
onRangeChange({ onRangeChange({
...range, ...range,
[rangePart]: updateRangeInputPart(range[rangePart], inputPart, value), [rangePart]: updateRangeInputPart(range[rangePart], inputPart, value),
@@ -152,14 +154,14 @@ export function ArchiveView({
<input value={search} onChange={(event) => onSearchChange(event.target.value)} placeholder="Поиск" /> <input value={search} onChange={(event) => onSearchChange(event.target.value)} placeholder="Поиск" />
</label> </label>
<div className="tag-selector__tools"> <div className="tag-selector__tools">
<button type="button" onClick={onSelectFirstTags}> {/* <button type="button" onClick={onSelectFirstTags}>
Первый Первый
</button> </button> */}
<button type="button" onClick={onSelectVisibleTags}> <button type="button" onClick={onSelectVisibleTags}>
Выбрать найденный Выбрать все
</button> </button>
<button type="button" onClick={onClearVisibleTags}> <button type="button" onClick={onClearVisibleTags}>
Снять найденные Снять все
</button> </button>
<button type="button" onClick={onClearTags}> <button type="button" onClick={onClearTags}>
Сбросить все Сбросить все
@@ -212,12 +214,22 @@ export function ArchiveView({
onPointerEnter={() => setSelectorOpen(false)} onPointerEnter={() => setSelectorOpen(false)}
> >
<div className="toolbar"> <div className="toolbar">
<div className="segmented segmented--range-preset"> <div className="archive-toolbar-segmented-control">
{RANGE_PRESETS.map((preset) => ( <div className="segmented segmented--range-preset">
<button key={preset.id} type="button" onClick={() => onRangeChange(createRange(preset.hours))}> {RANGE_PRESETS.map((preset) => (
{preset.label} <button
</button> key={preset.id}
))} type="button"
className={preset.id === selectedRangePresetId ? 'segmented__button--active' : undefined}
onClick={() => {
setSelectedRangePresetId(preset.id);
onRangeChange(createRange(preset.hours));
}}
>
{preset.label}
</button>
))}
</div>
</div> </div>
<div className="archive-date-range"> <div className="archive-date-range">
<span>С</span> <span>С</span>

View File

@@ -8,19 +8,19 @@ type HistoryChartAvgLineModeControlProps = {
const AVG_LINE_MODES: Array<{ value: AvgLineMode; label: string }> = [ const AVG_LINE_MODES: Array<{ value: AvgLineMode; label: string }> = [
{ value: 'auto', label: 'Авто' }, { value: 'auto', label: 'Авто' },
{ value: 'show', label: 'Рисовать' }, { value: 'show', label: 'Рисовать' },
{ value: 'hide', label: 'Не рисовать' }, { value: 'hide', label: 'Скрывать' },
]; ];
export function HistoryChartAvgLineModeControl({ value, onChange }: HistoryChartAvgLineModeControlProps) { export function HistoryChartAvgLineModeControl({ value, onChange }: HistoryChartAvgLineModeControlProps) {
return ( return (
<div className="archive-avgline-mode-control" aria-label="Режим соединительной линии avg"> <div className="archive-toolbar-segmented-control archive-avgline-mode-control" aria-label="Режим соединительной линии avg">
<span>Линия avg</span> <span>Соединительная линия</span>
<div className="segmented history-chart-line-mode"> <div className="segmented history-chart-line-mode">
{AVG_LINE_MODES.map((mode) => ( {AVG_LINE_MODES.map((mode) => (
<button <button
key={mode.value} key={mode.value}
type="button" type="button"
className={mode.value === value ? 'history-chart-line-mode__button--active' : undefined} className={mode.value === value ? 'segmented__button--active' : undefined}
onClick={() => onChange(mode.value)} onClick={() => onChange(mode.value)}
aria-pressed={mode.value === value} aria-pressed={mode.value === value}
> >

View File

@@ -60,11 +60,6 @@
font-size: inherit; font-size: inherit;
} }
.history-chart-line-mode__button--active {
border-color: var(--line-strong);
background: rgba(201, 122, 61, 0.18);
}
.chart-section--archive .history-chart-shell, .chart-section--archive .history-chart-shell,
.chart-section--archive .history-chart { .chart-section--archive .history-chart {
flex: 1; flex: 1;

View File

@@ -73,6 +73,12 @@
background: rgba(201, 122, 61, 0.18); background: rgba(201, 122, 61, 0.18);
} }
.segmented__button--active {
border-color: rgba(212, 165, 116, 0.34);
background: rgba(201, 122, 61, 0.14);
color: #f8fafc;
}
.source-chip, .source-chip,
.status-pill, .status-pill,
.metric-card__state { .metric-card__state {

View File

@@ -216,7 +216,7 @@
font-size: 0.84rem; font-size: 0.84rem;
} }
.archive-avgline-mode-control { .archive-toolbar-segmented-control {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;