@mohammad-irfan/create-dashboard-kit 1.0.0

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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -0
  3. package/bin/create-dashboard.js +12 -0
  4. package/dist/cli.d.ts +7 -0
  5. package/dist/cli.js +223 -0
  6. package/dist/configBuilder.d.ts +8 -0
  7. package/dist/configBuilder.js +573 -0
  8. package/dist/generator.d.ts +9 -0
  9. package/dist/generator.js +223 -0
  10. package/dist/presets.d.ts +8 -0
  11. package/dist/presets.js +72 -0
  12. package/dist/prompts.d.ts +2 -0
  13. package/dist/prompts.js +121 -0
  14. package/dist/templateEngine.d.ts +3 -0
  15. package/dist/templateEngine.js +31 -0
  16. package/dist/types.d.ts +54 -0
  17. package/dist/types.js +1 -0
  18. package/dist/validation.d.ts +16 -0
  19. package/dist/validation.js +73 -0
  20. package/package.json +56 -0
  21. package/templates/source/components/controls/Button.tsx +69 -0
  22. package/templates/source/components/controls/Input.tsx +59 -0
  23. package/templates/source/components/controls/SearchBar.tsx +44 -0
  24. package/templates/source/components/controls/Select.tsx +61 -0
  25. package/templates/source/components/controls/ThemeToggle.tsx +23 -0
  26. package/templates/source/components/feedback/NotificationCenter.tsx +151 -0
  27. package/templates/source/components/feedback/Skeleton.tsx +22 -0
  28. package/templates/source/components/feedback/StatusBadge.tsx +35 -0
  29. package/templates/source/components/feedback/statusBadgeStyles.ts +28 -0
  30. package/templates/source/components/icons/IconSet.tsx +235 -0
  31. package/templates/source/components/layout/AppShell.tsx +70 -0
  32. package/templates/source/components/layout/Header.tsx +90 -0
  33. package/templates/source/components/layout/PageHeader.tsx +27 -0
  34. package/templates/source/components/layout/Sidebar.tsx +202 -0
  35. package/templates/source/components/metrics/MetricRow.tsx +61 -0
  36. package/templates/source/components/metrics/StatCard.tsx +49 -0
  37. package/templates/source/components/navigation/NavItem.tsx +75 -0
  38. package/templates/source/components/navigation/ShortcutPill.tsx +39 -0
  39. package/templates/source/components/surfaces/EmptyState.tsx +36 -0
  40. package/templates/source/components/surfaces/HeroSurface.tsx +64 -0
  41. package/templates/source/components/surfaces/Panel.tsx +43 -0
  42. package/templates/source/components/surfaces/PriorityCard.tsx +75 -0
  43. package/templates/source/components/surfaces/QuietListCard.tsx +146 -0
  44. package/templates/source/design-system/animations.css +25 -0
  45. package/templates/source/design-system/tokens.css +74 -0
  46. package/templates/source/design-system/typography.css +34 -0
  47. package/templates/source/theme/ThemeContext.tsx +82 -0
  48. package/templates/source/theme/useTheme.ts +10 -0
@@ -0,0 +1,82 @@
1
+ import { createContext, useEffect, useState, type ReactNode } from 'react'
2
+
3
+ export type Theme = 'light' | 'dark'
4
+
5
+ export interface ThemeContextValue {
6
+ theme: Theme
7
+ setTheme: (theme: Theme) => void
8
+ toggleTheme: () => void
9
+ isDark: boolean
10
+ }
11
+
12
+ export const ThemeContext = createContext<ThemeContextValue | null>(null)
13
+
14
+ export interface ThemeProviderProps {
15
+ children: ReactNode
16
+ defaultTheme?: Theme
17
+ storageKey?: string
18
+ }
19
+
20
+ const DEFAULT_STORAGE_KEY = 'starter_kit_theme'
21
+
22
+ function getInitialTheme(defaultTheme?: Theme, storageKey = DEFAULT_STORAGE_KEY): Theme {
23
+ if (typeof window === 'undefined') return defaultTheme || 'light'
24
+
25
+ try {
26
+ const stored = localStorage.getItem(storageKey)
27
+ if (stored === 'light' || stored === 'dark') return stored
28
+ } catch {
29
+ // Ignore localStorage failures
30
+ }
31
+
32
+ if (defaultTheme) return defaultTheme
33
+
34
+ try {
35
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
36
+ return 'dark'
37
+ }
38
+ } catch {
39
+ // Ignore media match failures
40
+ }
41
+
42
+ return 'light'
43
+ }
44
+
45
+ export function ThemeProvider({
46
+ children,
47
+ defaultTheme,
48
+ storageKey = DEFAULT_STORAGE_KEY,
49
+ }: ThemeProviderProps) {
50
+ const [theme, setThemeState] = useState<Theme>(() => getInitialTheme(defaultTheme, storageKey))
51
+
52
+ useEffect(() => {
53
+ if (typeof document === 'undefined') return
54
+ document.documentElement.setAttribute('data-theme', theme)
55
+ try {
56
+ localStorage.setItem(storageKey, theme)
57
+ } catch {
58
+ // Ignore quota errors
59
+ }
60
+ }, [theme, storageKey])
61
+
62
+ const setTheme = (nextTheme: Theme) => {
63
+ setThemeState(nextTheme)
64
+ }
65
+
66
+ const toggleTheme = () => {
67
+ setThemeState((prev) => (prev === 'dark' ? 'light' : 'dark'))
68
+ }
69
+
70
+ return (
71
+ <ThemeContext.Provider
72
+ value={{
73
+ theme,
74
+ setTheme,
75
+ toggleTheme,
76
+ isDark: theme === 'dark',
77
+ }}
78
+ >
79
+ {children}
80
+ </ThemeContext.Provider>
81
+ )
82
+ }
@@ -0,0 +1,10 @@
1
+ import { useContext } from 'react'
2
+ import { ThemeContext, type ThemeContextValue } from './ThemeContext.tsx'
3
+
4
+ export function useTheme(): ThemeContextValue {
5
+ const context = useContext(ThemeContext)
6
+ if (!context) {
7
+ throw new Error('useTheme must be used within a ThemeProvider')
8
+ }
9
+ return context
10
+ }