@swarmclawai/swarmclaw 1.9.35 → 1.9.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,10 @@
1
1
  'use client'
2
2
 
3
3
  import { useState } from 'react'
4
+ import { Monitor, Moon, Sun } from 'lucide-react'
5
+ import { useTheme } from 'next-themes'
4
6
  import { toast } from 'sonner'
7
+ import { normalizeThemeMode, type ThemeMode } from '@/lib/theme-mode'
5
8
  import type { SettingsSectionProps } from './types'
6
9
 
7
10
  const PRESETS = [
@@ -13,12 +16,26 @@ const PRESETS = [
13
16
  { label: 'Rose', color: '#2e1a24' },
14
17
  ]
15
18
 
19
+ const THEME_MODES: Array<{ id: ThemeMode; label: string; Icon: typeof Sun }> = [
20
+ { id: 'light', label: 'Light', Icon: Sun },
21
+ { id: 'dark', label: 'Dark', Icon: Moon },
22
+ { id: 'system', label: 'System', Icon: Monitor },
23
+ ]
24
+
16
25
  export function ThemeSection({ appSettings, patchSettings, inputClass }: SettingsSectionProps) {
26
+ const { setTheme } = useTheme()
17
27
  const currentHue = appSettings.themeHue || PRESETS[0].color
28
+ const currentMode = normalizeThemeMode(appSettings.themeMode)
18
29
  const [customHex, setCustomHex] = useState(
19
30
  PRESETS.some((p) => p.color === currentHue) ? '' : currentHue,
20
31
  )
21
32
 
33
+ const applyMode = (mode: ThemeMode) => {
34
+ setTheme(mode)
35
+ patchSettings({ themeMode: mode })
36
+ toast.success('Theme updated')
37
+ }
38
+
22
39
  const applyHue = (color: string) => {
23
40
  patchSettings({ themeHue: color })
24
41
  document.documentElement.style.setProperty('--neutral-tint', color)
@@ -38,9 +55,32 @@ export function ThemeSection({ appSettings, patchSettings, inputClass }: Setting
38
55
  Theme
39
56
  </h3>
40
57
  <p className="text-[12px] text-text-3 mb-5">
41
- Shift the UI color palette. Pick a preset or enter a custom hex color.
58
+ Choose a color scheme and shift the UI palette with a preset or custom hex color.
42
59
  </p>
43
60
 
61
+ <div className="inline-grid grid-cols-3 rounded-[8px] border border-white/[0.08] bg-white/[0.03] p-1 mb-5">
62
+ {THEME_MODES.map(({ id, label, Icon }) => {
63
+ const isActive = currentMode === id
64
+ return (
65
+ <button
66
+ key={id}
67
+ type="button"
68
+ onClick={() => applyMode(id)}
69
+ aria-pressed={isActive}
70
+ className={`h-9 px-3 rounded-[6px] flex items-center justify-center gap-2 text-[12px] font-600 transition-colors ${
71
+ isActive
72
+ ? 'bg-accent text-white'
73
+ : 'text-text-3 hover:text-text hover:bg-white/[0.05]'
74
+ }`}
75
+ title={label}
76
+ >
77
+ <Icon className="w-4 h-4" aria-hidden="true" />
78
+ <span>{label}</span>
79
+ </button>
80
+ )
81
+ })}
82
+ </div>
83
+
44
84
  {/* Preset swatches */}
45
85
  <div className="flex flex-wrap gap-3 mb-4">
46
86
  {PRESETS.map((preset) => {