diff --git a/src/components/Page/Dashboard/TrafficChart.tsx b/src/components/Page/Dashboard/TrafficChart.tsx index d9dc41a..012f303 100644 --- a/src/components/Page/Dashboard/TrafficChart.tsx +++ b/src/components/Page/Dashboard/TrafficChart.tsx @@ -13,6 +13,7 @@ import { Tooltip, } from 'chart.js' import useDictionary from '@/locales/dictionary-hook' +import useComputedStyle from '@/hooks/use-computed-style' Chart.register(CategoryScale, LinearScale, PointElement, LineElement, BarElement, Tooltip, Filler) @@ -20,17 +21,8 @@ const random = (min: number, max: number) => Math.floor(Math.random() * (max - m export default function TrafficChart() { const dict = useDictionary() - - const getStyle = (property: string) => { - if (typeof window === 'undefined') { - return '' - } - if (typeof document === 'undefined') { - return '' - } - const element = document.body - return window.getComputedStyle(element, null).getPropertyValue(property).replace(/^\s/, '') - } + const borderColor = useComputedStyle('--bs-border-color') + const bodyColor = useComputedStyle('--bs-body-color') return ( { + if (typeof window !== 'undefined' && typeof document !== 'undefined') { + const element = document.body + const computedStyle = window.getComputedStyle(element, null).getPropertyValue(property).replace(/^\s/, '') + setStyle(computedStyle) + } + }, [property, theme]) + + return style +}