refactor: Move drawing tools to TradingView-style left toolbar

- Move drawing tools from right-side popup to left sidebar
- Add toggle button for desktop (right sidebar) and mobile (bottom nav)
- Implement collapsible toolbar with 6 drawing tools
- Add visual hover effects matching TradingView style
This commit is contained in:
DiTus
2026-03-21 09:46:32 +01:00
parent a34f80f841
commit 39df199c7f
2 changed files with 95 additions and 59 deletions

View File

@ -105,38 +105,57 @@
<section class="relative w-full bg-[#0d1421] h-[60vh] md:h-[70vh]" data-purpose="chart-container" id="chartWrapper"> <section class="relative w-full bg-[#0d1421] h-[60vh] md:h-[70vh]" data-purpose="chart-container" id="chartWrapper">
<div id="chart" class="w-full h-full"></div> <div id="chart" class="w-full h-full"></div>
<!-- Overlay Controls --> <!-- TradingView-style Left Toolbar -->
<div class="absolute bottom-4 right-4 flex gap-2 z-10 opacity-0 hover:opacity-100 transition-opacity" id="priceScaleControls"> <div class="absolute left-0 top-0 bottom-0 flex flex-col justify-center bg-[#0d1421]/90 border-r border-[#1b1f2b] backdrop-blur-sm z-20 px-2 py-4 gap-3" style="display: none;" id="chartToolbar">
<!-- Drawing Tools Button --> <!-- Trend Line Tool -->
<button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] transition-colors shadow-lg" id="btnDrawingTools" title="Drawing Tools"> <button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] hover:text-white transition-colors shadow-lg group" onclick="window.activateDrawingTool('trend_line')" title="Trend Line">
<span class="material-symbols-outlined text-sm">draw</span> <span class="material-symbols-outlined text-sm group-hover:text-[#2962ff]">call_split</span>
</button> </button>
<!-- Drawing Tools Popup --> <!-- Horizontal Line Tool -->
<div class="hidden absolute bottom-10 right-0 bg-[#1a2333] border border-[#2d3a4f] rounded-lg py-2 z-50 w-64 shadow-xl text-sm" id="drawingToolsPopup"> <button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] hover:text-white transition-colors shadow-lg group" onclick="window.activateDrawingTool('horizontal_line')" title="Horizontal Line">
<div class="px-4 py-2 hover:bg-[#252f3f] cursor-pointer flex items-center gap-3" onclick="window.activateDrawingTool('trend_line')"> <span class="material-symbols-outlined text-sm group-hover:text-[#2962ff]">swap_horizontal_circle</span>
<span class="material-symbols-outlined text-sm">call_split</span> Trend Line </button>
</div>
<div class="px-4 py-2 hover:bg-[#252f3f] cursor-pointer flex items-center gap-3" onclick="window.activateDrawingTool('horizontal_line')"> <!-- Vertical Line Tool -->
<span class="material-symbols-outlined text-sm">swap_horizontal_circle</span> Horizontal Line <button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] hover:text-white transition-colors shadow-lg group" onclick="window.activateDrawingTool('vertical_line')" title="Vertical Line">
</div> <span class="material-symbols-outlined text-sm group-hover:text-[#2962ff]">swap_vert</span>
<div class="px-4 py-2 hover:bg-[#252f3f] cursor-pointer flex items-center gap-3" onclick="window.activateDrawingTool('vertical_line')"> </button>
<span class="material-symbols-outlined text-sm">swap_vert</span> Vertical Line
</div> <!-- Text Label Tool -->
<div class="px-4 py-2 hover:bg-[#252f3f] cursor-pointer flex items-center gap-3" onclick="window.activateDrawingTool('text')"> <button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] hover:text-white transition-colors shadow-lg group" onclick="window.activateDrawingTool('text')" title="Text Label">
<span class="material-symbols-outlined text-sm">text_fields</span> Text Label <span class="material-symbols-outlined text-sm group-hover:text-[#2962ff]">text_fields</span>
</div> </button>
<div class="px-4 py-2 hover:bg-[#252f3f] cursor-pointer flex items-center gap-3" onclick="window.activateDrawingTool('arrow_up')">
<span class="material-symbols-outlined text-sm">arrow_upward</span> Arrow Up <!-- Arrow Up Tool -->
</div> <button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] hover:text-white transition-colors shadow-lg group" onclick="window.activateDrawingTool('arrow_up')" title="Arrow Up">
<div class="px-4 py-2 hover:bg-[#252f3f] cursor-pointer flex items-center gap-3" onclick="window.activateDrawingTool('arrow_down')"> <span class="material-symbols-outlined text-sm group-hover:text-[#2962ff]">arrow_upward</span>
<span class="material-symbols-outlined text-sm">arrow_downward</span> Arrow Down </button>
</div>
<div class="px-4 py-2 hover:bg-[#252f3f] cursor-pointer flex items-center gap-3" onclick="window.activateDrawingTool('clear')"> <!-- Arrow Down Tool -->
<span class="material-symbols-outlined text-sm">clear_all</span> Clear All <button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] hover:text-white transition-colors shadow-lg group" onclick="window.activateDrawingTool('arrow_down')" title="Arrow Down">
</div> <span class="material-symbols-outlined text-sm group-hover:text-[#2962ff]">arrow_downward</span>
</button>
<!-- Divider -->
<div class="w-8 h-px bg-[#2d3a4f] my-1"></div>
<!-- Clear All -->
<button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] hover:text-[#ef5350] transition-colors shadow-lg" onclick="window.activateDrawingTool('clear')" title="Clear All">
<span class="material-symbols-outlined text-sm">clear_all</span>
</button>
<!-- Divider -->
<div class="w-8 h-px bg-[#2d3a4f] my-1"></div>
<!-- Toggle Toolbar -->
<button class="w-8 h-8 bg-[#2d3a4f] border border-[#2d3a4f] text-[#2962ff] flex items-center justify-center rounded hover:bg-[#2962ff]/20 transition-colors shadow-lg" id="toggleChartToolbar" title="Toggle Toolbar">
<span class="material-symbols-outlined text-sm">more_vert</span>
</button>
</div> </div>
<!-- Settings & Price Scale Controls - Bottom Right -->
<div class="absolute bottom-4 right-4 flex gap-2 z-10 opacity-0 hover:opacity-100 transition-opacity" id="priceScaleControls">
<button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] transition-colors shadow-lg" id="btnSettings" title="Settings"> <button class="w-8 h-8 bg-[#1e222d] border border-[#2d3a4f] text-gray-300 flex items-center justify-center rounded hover:bg-[#2d3a4f] transition-colors shadow-lg" id="btnSettings" title="Settings">
<span class="material-symbols-outlined text-sm">settings</span> <span class="material-symbols-outlined text-sm">settings</span>
</button> </button>
@ -254,6 +273,10 @@
<span class="material-symbols-outlined group-hover:text-blue-400">fullscreen</span> <span class="material-symbols-outlined group-hover:text-blue-400">fullscreen</span>
<span class="text-[10px] font-medium mt-1 opacity-70 group-hover:opacity-100">Full</span> <span class="text-[10px] font-medium mt-1 opacity-70 group-hover:opacity-100">Full</span>
</div> </div>
<div class="flex flex-col items-center justify-center w-full py-4 text-[#2962ff] bg-[#2962ff]/10 border-r-2 border-[#2962ff] cursor-pointer" onclick="document.getElementById('chartToolbar').style.display === 'none' || !document.getElementById('chartToolbar') ? document.getElementById('chartToolbar').style.display = 'flex' : document.getElementById('chartToolbar').style.display = 'none'">
<span class="material-symbols-outlined">draw</span>
<span class="text-[10px] font-medium mt-1">Draw</span>
</div>
<div class="mt-auto flex flex-col items-center justify-center w-full py-4 text-[#c3c5d8] hover:text-[#dfe2f2] cursor-pointer transition-colors group"> <div class="mt-auto flex flex-col items-center justify-center w-full py-4 text-[#c3c5d8] hover:text-[#dfe2f2] cursor-pointer transition-colors group">
<span class="material-symbols-outlined group-hover:text-blue-400">more_horiz</span> <span class="material-symbols-outlined group-hover:text-blue-400">more_horiz</span>
<span class="text-[10px] font-medium mt-1 opacity-70 group-hover:opacity-100">More</span> <span class="text-[10px] font-medium mt-1 opacity-70 group-hover:opacity-100">More</span>
@ -283,6 +306,10 @@
<span class="material-symbols-outlined group-hover:text-blue-400">fullscreen</span> <span class="material-symbols-outlined group-hover:text-blue-400">fullscreen</span>
<span class="text-[10px] font-medium mt-1">Full</span> <span class="text-[10px] font-medium mt-1">Full</span>
</div> </div>
<div class="flex flex-col items-center justify-center min-w-[70px] flex-shrink-0 text-[#2962ff] bg-[#2962ff]/10 rounded-xl px-4 py-1.5 transition-transform duration-200 cursor-pointer border border-[#2962ff]/20" onclick="document.getElementById('chartToolbar').style.display === 'none' || !document.getElementById('chartToolbar') ? document.getElementById('chartToolbar').style.display = 'flex' : document.getElementById('chartToolbar').style.display = 'none'">
<span class="material-symbols-outlined">draw</span>
<span class="text-[10px] font-bold mt-1">Draw</span>
</div>
<div class="flex flex-col items-center justify-center min-w-[70px] flex-shrink-0 text-[#c3c5d8] hover:text-[#dfe2f2] hover:scale-105 transition-all duration-200 cursor-pointer group"> <div class="flex flex-col items-center justify-center min-w-[70px] flex-shrink-0 text-[#c3c5d8] hover:text-[#dfe2f2] hover:scale-105 transition-all duration-200 cursor-pointer group">
<span class="material-symbols-outlined group-hover:text-blue-400">more_horiz</span> <span class="material-symbols-outlined group-hover:text-blue-400">more_horiz</span>
<span class="text-[10px] font-medium mt-1">More</span> <span class="text-[10px] font-medium mt-1">More</span>

View File

@ -502,6 +502,8 @@ constructor() {
initPriceScaleControls() { initPriceScaleControls() {
const btnSettings = document.getElementById('btnSettings'); const btnSettings = document.getElementById('btnSettings');
const settingsPopup = document.getElementById('settingsPopup'); const settingsPopup = document.getElementById('settingsPopup');
const toggleToolbarBtn = document.getElementById('toggleChartToolbar');
const chartToolbar = document.getElementById('chartToolbar');
// Settings Popup Toggle and Outside Click // Settings Popup Toggle and Outside Click
if (btnSettings && settingsPopup) { if (btnSettings && settingsPopup) {
@ -523,6 +525,13 @@ constructor() {
} }
} }
// Toggle Chart Toolbar
if (toggleToolbarBtn && chartToolbar) {
toggleToolbarBtn.addEventListener('click', () => {
chartToolbar.style.display = chartToolbar.style.display === 'flex' ? 'none' : 'flex';
});
}
// Drawing Tools // Drawing Tools
this.initDrawingTools(); this.initDrawingTools();