@djangocfg/ui-nextjs 2.1.18 → 2.1.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ui-nextjs",
3
- "version": "2.1.18",
3
+ "version": "2.1.19",
4
4
  "description": "Next.js UI component library with Radix UI primitives, Tailwind CSS styling, charts, and form components",
5
5
  "keywords": [
6
6
  "ui-components",
@@ -58,8 +58,8 @@
58
58
  "check": "tsc --noEmit"
59
59
  },
60
60
  "peerDependencies": {
61
- "@djangocfg/api": "^2.1.18",
62
- "@djangocfg/ui-core": "^2.1.18",
61
+ "@djangocfg/api": "^2.1.19",
62
+ "@djangocfg/ui-core": "^2.1.19",
63
63
  "@types/react": "^19.1.0",
64
64
  "@types/react-dom": "^19.1.0",
65
65
  "consola": "^3.4.2",
@@ -104,7 +104,7 @@
104
104
  "vidstack": "next"
105
105
  },
106
106
  "devDependencies": {
107
- "@djangocfg/typescript-config": "^2.1.18",
107
+ "@djangocfg/typescript-config": "^2.1.19",
108
108
  "@types/node": "^24.7.2",
109
109
  "eslint": "^9.37.0",
110
110
  "tailwindcss-animate": "1.0.7",
@@ -8,7 +8,14 @@
8
8
  * ```tsx
9
9
  * import { ThemeToggle } from '@djangocfg/ui-nextjs';
10
10
  *
11
+ * // Default
11
12
  * <ThemeToggle />
13
+ *
14
+ * // Compact (for mobile/tight spaces)
15
+ * <ThemeToggle size="compact" />
16
+ *
17
+ * // Custom className
18
+ * <ThemeToggle className="ml-auto" />
12
19
  * ```
13
20
  */
14
21
 
@@ -17,21 +24,41 @@
17
24
  import { useEffect, useState } from 'react';
18
25
  import { Moon, Sun } from 'lucide-react';
19
26
  import { Button } from '@djangocfg/ui-core/components';
27
+ import { cn } from '@djangocfg/ui-core/lib';
20
28
  import { useThemeContext } from './ThemeProvider';
29
+ import { useIsMobile } from '../hooks';
21
30
 
22
- export function ThemeToggle() {
31
+ export interface ThemeToggleProps {
32
+ /** Custom className */
33
+ className?: string;
34
+ /** Size variant (auto-detects mobile if not specified) */
35
+ size?: 'default' | 'compact' | 'auto';
36
+ }
37
+
38
+ export function ThemeToggle({ className, size = 'auto' }: ThemeToggleProps) {
23
39
  const { resolvedTheme, toggleTheme } = useThemeContext();
24
40
  const [mounted, setMounted] = useState(false);
41
+ const isMobile = useIsMobile();
25
42
 
26
43
  // Prevent hydration mismatch
27
44
  useEffect(() => {
28
45
  setMounted(true);
29
46
  }, []);
30
47
 
48
+ // Determine actual size based on prop and screen size
49
+ const actualSize = size === 'auto' ? (isMobile ? 'compact' : 'default') : size;
50
+ const buttonSize = actualSize === 'compact' ? 'h-8 w-8' : 'h-9 w-9';
51
+ const iconSize = actualSize === 'compact' ? 'h-3.5 w-3.5' : 'h-4 w-4';
52
+
31
53
  if (!mounted) {
32
54
  return (
33
- <Button variant="ghost" size="icon" className="h-9 w-9" disabled>
34
- <Sun className="h-4 w-4" />
55
+ <Button
56
+ variant="ghost"
57
+ size="icon"
58
+ className={cn(buttonSize, className)}
59
+ disabled
60
+ >
61
+ <Sun className={iconSize} />
35
62
  <span className="sr-only">Toggle theme</span>
36
63
  </Button>
37
64
  );
@@ -42,13 +69,13 @@ export function ThemeToggle() {
42
69
  variant="ghost"
43
70
  size="icon"
44
71
  onClick={toggleTheme}
45
- className="h-9 w-9"
72
+ className={cn(buttonSize, className)}
46
73
  title={`Switch to ${resolvedTheme === 'light' ? 'dark' : 'light'} theme`}
47
74
  >
48
75
  {resolvedTheme === 'light' ? (
49
- <Sun className="h-4 w-4" />
76
+ <Sun className={iconSize} />
50
77
  ) : (
51
- <Moon className="h-4 w-4" />
78
+ <Moon className={iconSize} />
52
79
  )}
53
80
  <span className="sr-only">Toggle theme</span>
54
81
  </Button>