Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

777 B
Raw Blame
'use client'

import type { ResolvedTheme, ThemePreference } from './theme'
import { useTheme } from 'next-themes'
import { useCallback } from 'react'
import { isThemePreference } from './theme'

type ThemePreferenceState = {
  preference: ThemePreference
  setPreference: (preference: ThemePreference) => void
}

export function useThemePreference(): ThemePreferenceState {
  const { theme, setTheme } = useTheme()
  const setPreference = useCallback(
    (preference: ThemePreference) => setTheme(preference),
    [setTheme],
  )

  return {
    preference: isThemePreference(theme) ? theme : 'system',
    setPreference,
  }
}

export function useResolvedTheme(): ResolvedTheme {
  const { resolvedTheme } = useTheme()
  return resolvedTheme === 'dark' ? 'dark' : 'light'
}