mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
- Fix gray/zinc alias confusion (gray→neutral, zinc→zen) - Consolidate duplicate gray color definition - Add finance components to ui/ directory - Clean up documentation structure - Remove test artifacts and backup files The color aliases were incorrectly mapped: Before: gray→zen, zinc→neutral (wrong) After: gray→neutral, zinc→zen (correct) This ensures Hanzo's branded 'zen' color properly maps to zinc while gray correctly references the standard neutral palette. Verified: - Production build: 544 pages ✓ - All tests passing: 219/219 ✓ - Visual verification: /colors page working ✓ - Code review: Approved ✓ Ready for deployment to ui.hanzo.ai
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
"use client"
|
|
|
|
import { memo, useEffect, useRef } from "react"
|
|
|
|
function AdvancedChart({ symbol = "NASDAQ:AAPL" }: { symbol?: string }) {
|
|
const container = useRef<HTMLDivElement>(null)
|
|
|
|
useEffect(() => {
|
|
if (!container.current) return
|
|
|
|
// Check if widget is already initialized using data attribute
|
|
if (container.current.dataset.initialized === "true") {
|
|
return // Widget already initialized, skip
|
|
}
|
|
|
|
// Mark as initialized before adding script
|
|
container.current.dataset.initialized = "true"
|
|
|
|
const script = document.createElement("script")
|
|
script.src =
|
|
"https://s3.tradingview.com/external-embedding/embed-widget-advanced-chart.js"
|
|
script.type = "text/javascript"
|
|
script.async = true
|
|
script.innerHTML = JSON.stringify({
|
|
width: "100%",
|
|
height: "600",
|
|
symbol,
|
|
interval: "D",
|
|
timezone: "Etc/UTC",
|
|
theme: "dark",
|
|
style: "1",
|
|
locale: "en",
|
|
allow_symbol_change: true,
|
|
calendar: false,
|
|
support_host: "https://www.tradingview.com",
|
|
})
|
|
|
|
container.current.appendChild(script)
|
|
|
|
// Cleanup function
|
|
return () => {
|
|
if (container.current) {
|
|
// Remove initialization flag on unmount
|
|
delete container.current.dataset.initialized
|
|
// Remove all scripts
|
|
const scripts = container.current.querySelectorAll("script")
|
|
scripts.forEach((s) => s.remove())
|
|
}
|
|
}
|
|
}, [symbol])
|
|
|
|
return (
|
|
<div
|
|
className="tradingview-widget-container w-full h-[600px]"
|
|
ref={container}
|
|
>
|
|
<div className="tradingview-widget-container__widget h-full"></div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default memo(AdvancedChart)
|