* feat: adding create bot functionality Signed-off-by: James <james@jan.ai> * update the temperature progress bar Signed-off-by: James <james@jan.ai> * WIP baselayout * Mapping plugins with available preferences * Added loader component * WIP working another screen * Cleanup types and avoid import one by one * Prepare bottom bar * Add css variables colors to enable user select the accent * Enable change accent color * Seperate css variable * Fix conflict * Add blank state of my model empty * Restyle explore models page * Enable user config left sidebar * Restyle my models page * WIP styling chat page * Restyling chat message * Fix conflict * Adde form preferences setting plugins * Fixed form bot info * Sidebar bot chat * Showing rightbar for both setting when user created bot * Fix style bot info * Using overflow auto intead of scroll * Remove script built UI from root package * Fix missig import * Resolve error linter * fix e2e tests Signed-off-by: James <james@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
'use client'
|
|
|
|
import * as React from 'react'
|
|
import { useTheme } from 'next-themes'
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
import { motion as m } from 'framer-motion'
|
|
|
|
const themeMenus = [
|
|
{
|
|
name: 'light',
|
|
},
|
|
{
|
|
name: 'dark',
|
|
},
|
|
{
|
|
name: 'system',
|
|
},
|
|
]
|
|
|
|
const ToggleTheme = () => {
|
|
const { theme: currentTheme, setTheme } = useTheme()
|
|
|
|
const handeleNativeTheme = async (val: string) => {
|
|
switch (val) {
|
|
case 'light':
|
|
return await window?.electronAPI.setNativeThemeLight()
|
|
case 'dark':
|
|
return await window?.electronAPI.setNativeThemeDark()
|
|
default:
|
|
return await window?.electronAPI.setNativeThemeSystem()
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex items-center space-x-1">
|
|
{themeMenus.map((theme, i) => {
|
|
const isActive = currentTheme === theme.name
|
|
return (
|
|
<div className="relative" key={i}>
|
|
<button
|
|
className={twMerge(
|
|
'px-2 py-1 font-semibold capitalize',
|
|
!isActive && 'opacity-50'
|
|
)}
|
|
onClick={async () => {
|
|
setTheme(theme.name)
|
|
handeleNativeTheme(theme.name)
|
|
}}
|
|
>
|
|
{theme.name}
|
|
</button>
|
|
{isActive ? (
|
|
<m.div
|
|
className="border-accent/50 bg-accent/20 absolute inset-0 h-full w-full rounded-md border"
|
|
layoutId="active-theme-menu"
|
|
/>
|
|
) : null}
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ToggleTheme
|