From 8be8b4c9a0ef9692f7591ac96f1169bbce1e65a8 Mon Sep 17 00:00:00 2001 From: Mahen Date: Mon, 13 Apr 2026 12:05:17 +0700 Subject: [PATCH] refactor: use theme context state to child component --- src/components/dashboards/AnalysisClient.tsx | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/dashboards/AnalysisClient.tsx b/src/components/dashboards/AnalysisClient.tsx index f37167d..ba91ae4 100644 --- a/src/components/dashboards/AnalysisClient.tsx +++ b/src/components/dashboards/AnalysisClient.tsx @@ -6,8 +6,9 @@ import { Input } from "../ui/input"; import { Button } from "../ui/button"; import ResultSection from "./ResultSection"; import UrlInputList from "./UrlInputList"; +import { useTheme } from "@/src/context/ThemeContext"; -export default function AnalysisClient({ isDark }: { isDark: boolean }) { +export default function AnalysisClient() { const { isValid, errors, @@ -23,19 +24,20 @@ export default function AnalysisClient({ isDark }: { isDark: boolean }) { handleCancel, setVisibleFields, } = useAnalyseText(); + const { darkMode } = useTheme(); return (

Analisis Sentimen Real-time

@@ -45,14 +47,14 @@ export default function AnalysisClient({ isDark }: { isDark: boolean }) {
{errors.url1 && ( @@ -64,14 +66,14 @@ export default function AnalysisClient({ isDark }: { isDark: boolean }) {
{errors.url2 && ( @@ -87,7 +89,7 @@ export default function AnalysisClient({ isDark }: { isDark: boolean }) { urlDatas={urlDatas} visibleFields={visibleFields} setVisibleFields={setVisibleFields} - isDark={isDark} + isDark={darkMode} /> {visibleFields < 2 && ( @@ -105,7 +107,7 @@ export default function AnalysisClient({ isDark }: { isDark: boolean }) { border-dashed border border-primary/20 shadow-xs transition-all duration-500 animate-in fade-in zoom-in-95 ${visibleFields === 0 ? "w-full md:w-1/2" : "w-full"} - ${isDark ? "bg-gray-800 text-white hover:bg-gray-900 border-dashed border border-white" : "text-black hover:bg-[#F8FBFF] "} + ${darkMode ? "bg-gray-800 text-white hover:bg-gray-900 border-dashed border border-white" : "text-black hover:bg-[#F8FBFF] "} `} > {visibleFields === 0 @@ -125,7 +127,7 @@ export default function AnalysisClient({ isDark }: { isDark: boolean }) {
@@ -148,7 +150,7 @@ export default function AnalysisClient({ isDark }: { isDark: boolean }) { type="submit" hidden={loading} disabled={!isValid} - className={`w-full md:w-max ${isDark ? "bg-gray-900 hover:bg-card hover:text-black" : "bg-primary text-white"} px-6 py-3 mt-6 rounded-md transition-colors disabled:bg-gray-400`} + className={`w-full md:w-max ${darkMode ? "bg-gray-900 hover:bg-card hover:text-black" : "bg-primary text-white"} px-6 py-3 mt-6 rounded-md transition-colors disabled:bg-gray-400`} > {loading ? "Menganalisis..." : "Analisis Sekarang"}