탭 지표 자동추가

This commit is contained in:
Macbook
2026-05-27 13:24:05 +09:00
parent f22abbdc19
commit f7aac535d8
7 changed files with 182 additions and 11 deletions
+6
View File
@@ -1,6 +1,7 @@
import React from 'react';
import type { Timeframe } from '../types';
import TimezonePicker from './TimezonePicker';
import IndicatorTabQuickButtons from './IndicatorTabQuickButtons';
interface BottomBarProps {
timeframe: Timeframe;
@@ -16,6 +17,8 @@ interface BottomBarProps {
onAutoScale: () => void;
onFitContent: () => void;
onToggleGrid: () => void;
onAddIndicators?: (types: string[]) => void;
onAddIndicator?: (type: string) => void;
}
const PERIODS: { label: string; tf: Timeframe }[] = [
@@ -55,6 +58,7 @@ const BottomBar: React.FC<BottomBarProps> = ({
timeframe, logScale, percentScale, showGrid, lastTime,
displayTimezone, onTimezoneChange,
onTimeframe, onLogScale, onPercentScale, onAutoScale, onFitContent, onToggleGrid,
onAddIndicators, onAddIndicator,
}) => {
return (
<div className="tv-bottom-bar">
@@ -72,6 +76,8 @@ const BottomBar: React.FC<BottomBarProps> = ({
<IcCalendar />
</button>
<IndicatorTabQuickButtons onAddMany={onAddIndicators} onAdd={onAddIndicator} />
<div className="tv-bottom-spacer" />
<TimezonePicker
@@ -0,0 +1,69 @@
import React, { useCallback, useEffect, useState } from 'react';
import { loadCustomTabs, type IndicatorCustomTab } from '../utils/indicatorCustomTabsStorage';
import { applyIndicatorTab } from '../utils/indicatorTabApply';
const IcApplyTab = () => (
<svg width="12" height="12" viewBox="0 0 14 14" fill="none" stroke="currentColor" strokeWidth="1.8">
<line x1="7" y1="2" x2="7" y2="12" />
<line x1="2" y1="7" x2="12" y2="7" />
</svg>
);
interface Props {
onAddMany?: (types: string[]) => void;
onAdd?: (type: string) => void;
}
const IndicatorTabQuickButtons: React.FC<Props> = ({ onAddMany, onAdd }) => {
const [customTabs, setCustomTabs] = useState<IndicatorCustomTab[]>(() => loadCustomTabs());
const refreshTabs = useCallback(() => {
setCustomTabs(loadCustomTabs());
}, []);
useEffect(() => {
refreshTabs();
window.addEventListener('gc-indicator-custom-tabs-changed', refreshTabs);
return () => window.removeEventListener('gc-indicator-custom-tabs-changed', refreshTabs);
}, [refreshTabs]);
if (!onAddMany && !onAdd) return null;
const applyMain = () => {
applyIndicatorTab({ kind: 'main' }, onAddMany, onAdd);
};
const applyCustom = (tab: IndicatorCustomTab) => {
applyIndicatorTab({ kind: 'custom', tab }, onAddMany, onAdd);
};
return (
<div className="tv-ind-tab-quick" role="group" aria-label="지표 탭 빠른 적용">
<button
type="button"
className="tv-ind-tab-quick-btn"
title="주요지표 탭 — 차트 보조지표 일괄 교체"
aria-label="주요지표 탭 일괄 적용"
onClick={applyMain}
>
<IcApplyTab />
<span className="tv-ind-tab-quick-label"></span>
</button>
{customTabs.map(tab => (
<button
key={tab.id}
type="button"
className="tv-ind-tab-quick-btn"
title={`${tab.name} 탭 — 차트 보조지표 일괄 교체`}
aria-label={`${tab.name} 탭 일괄 적용`}
onClick={() => applyCustom(tab)}
>
<IcApplyTab />
<span className="tv-ind-tab-quick-label">{tab.name}</span>
</button>
))}
</div>
);
};
export default IndicatorTabQuickButtons;
+7 -11
View File
@@ -10,6 +10,9 @@ import {
parseCustomTabKey,
type IndicatorTabKey,
} from '../utils/indicatorMainTab';
import {
confirmAndApplyIndicatorTab,
} from '../utils/indicatorTabApply';
import {
loadCustomTabs,
createCustomTab,
@@ -379,19 +382,12 @@ const IndDropdown: React.FC<IndDropdownProps> = ({
const handleAddAllInTab = () => {
if (!addAllContext || addAllContext.types.length === 0) return;
const validTypes = addAllContext.types.filter(
type => INDICATOR_REGISTRY.some(d => d.type === type),
);
if (validTypes.length === 0) {
window.alert('추가할 지표가 없습니다.');
if (category === 'Main') {
confirmAndApplyIndicatorTab({ kind: 'main' }, onAddMany, onAdd);
return;
}
const msg = `기존 보조지표를 모두 제거하고 ${addAllContext.label} 탭의 지표 ${validTypes.length}개로 교체하시겠습니까?`;
if (!window.confirm(msg)) return;
if (onAddMany) {
onAddMany(validTypes);
} else {
validTypes.forEach(type => onAdd(type));
if (isCustomTabKey(category) && selectedCustomTab) {
confirmAndApplyIndicatorTab({ kind: 'custom', tab: selectedCustomTab }, onAddMany, onAdd);
}
};