@hellboy/ds 0.1.2

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 (137) hide show
  1. package/README.md +111 -0
  2. package/dist/index.css +3699 -0
  3. package/dist/index.css.map +1 -0
  4. package/dist/index.d.mts +1087 -0
  5. package/dist/index.d.ts +1087 -0
  6. package/dist/index.js +3391 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/index.mjs +3287 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/theme.css +55 -0
  11. package/hellboy-ds-0.1.2.tgz +0 -0
  12. package/package.json +42 -0
  13. package/src/components/badge/Badge.tsx +29 -0
  14. package/src/components/badge/index.ts +1 -0
  15. package/src/components/banner/Banner.tsx +48 -0
  16. package/src/components/banner/banner.css +44 -0
  17. package/src/components/banner/index.ts +1 -0
  18. package/src/components/button/button.tsx +127 -0
  19. package/src/components/button/index.ts +1 -0
  20. package/src/components/card/card.tsx +57 -0
  21. package/src/components/card/index.ts +1 -0
  22. package/src/components/checkbox/Checkbox.tsx +98 -0
  23. package/src/components/checkbox/index.ts +1 -0
  24. package/src/components/code-block/code-block.tsx +44 -0
  25. package/src/components/code-block/index.ts +1 -0
  26. package/src/components/color-control/color-control.tsx +322 -0
  27. package/src/components/color-control/index.ts +1 -0
  28. package/src/components/drag-handle/DragHandle.tsx +78 -0
  29. package/src/components/drag-handle/index.ts +1 -0
  30. package/src/components/drawer/drawer.tsx +82 -0
  31. package/src/components/drawer/index.ts +1 -0
  32. package/src/components/floating-bar/floating-bar.tsx +52 -0
  33. package/src/components/floating-bar/index.ts +2 -0
  34. package/src/components/footer/footer.tsx +28 -0
  35. package/src/components/footer/index.ts +1 -0
  36. package/src/components/grid/Grid.tsx +53 -0
  37. package/src/components/grid/index.ts +1 -0
  38. package/src/components/header/header.tsx +57 -0
  39. package/src/components/header/index.ts +1 -0
  40. package/src/components/icons/icons.tsx +44 -0
  41. package/src/components/icons/index.ts +1 -0
  42. package/src/components/index.ts +29 -0
  43. package/src/components/input/DatePicker.tsx +133 -0
  44. package/src/components/input/Input.tsx +220 -0
  45. package/src/components/input/InputDate.tsx +10 -0
  46. package/src/components/input/InputDateTime.tsx +10 -0
  47. package/src/components/input/InputEmail.tsx +10 -0
  48. package/src/components/input/InputField.tsx +137 -0
  49. package/src/components/input/InputNumber.tsx +10 -0
  50. package/src/components/input/InputPassword.tsx +10 -0
  51. package/src/components/input/InputSearch.tsx +10 -0
  52. package/src/components/input/InputTel.tsx +10 -0
  53. package/src/components/input/InputText.tsx +10 -0
  54. package/src/components/input/InputTime.tsx +10 -0
  55. package/src/components/input/InputUrl.tsx +10 -0
  56. package/src/components/input/TimePicker.tsx +151 -0
  57. package/src/components/input/index.ts +11 -0
  58. package/src/components/layout/Layout.tsx +244 -0
  59. package/src/components/layout/index.ts +1 -0
  60. package/src/components/list/List.tsx +159 -0
  61. package/src/components/list/index.ts +1 -0
  62. package/src/components/navbar/MenuCategory.tsx +20 -0
  63. package/src/components/navbar/MenuGroup.tsx +288 -0
  64. package/src/components/navbar/MenuItem.tsx +65 -0
  65. package/src/components/navbar/Navbar.tsx +23 -0
  66. package/src/components/navbar/index.ts +4 -0
  67. package/src/components/page/index.ts +1 -0
  68. package/src/components/page/page.tsx +46 -0
  69. package/src/components/page-index/PageIndex.tsx +275 -0
  70. package/src/components/page-index/index.ts +1 -0
  71. package/src/components/popover/index.ts +1 -0
  72. package/src/components/popover/popover.tsx +199 -0
  73. package/src/components/radio/Radio.tsx +176 -0
  74. package/src/components/radio/index.ts +1 -0
  75. package/src/components/section/index.ts +1 -0
  76. package/src/components/section/section.tsx +66 -0
  77. package/src/components/select/Select.tsx +212 -0
  78. package/src/components/select/index.ts +1 -0
  79. package/src/components/slider/Slider.tsx +267 -0
  80. package/src/components/slider/index.ts +1 -0
  81. package/src/components/switch/index.ts +1 -0
  82. package/src/components/switch/switch.tsx +99 -0
  83. package/src/components/table/Table.tsx +147 -0
  84. package/src/components/table/index.ts +1 -0
  85. package/src/components/theme-control/index.ts +1 -0
  86. package/src/components/theme-control/theme-control.tsx +78 -0
  87. package/src/components/tooltip/index.ts +1 -0
  88. package/src/components/tooltip/tooltip.tsx +207 -0
  89. package/src/contexts/NavbarTooltipContext.tsx +48 -0
  90. package/src/contexts/index.ts +1 -0
  91. package/src/foundations/motion.md +136 -0
  92. package/src/index.ts +40 -0
  93. package/src/style/_shared/field.css +69 -0
  94. package/src/style/components/badge/badge.css +74 -0
  95. package/src/style/components/button/button.css +244 -0
  96. package/src/style/components/card/card.css +69 -0
  97. package/src/style/components/checkbox.css +142 -0
  98. package/src/style/components/code-block/code-block.css +34 -0
  99. package/src/style/components/color-control/color-control.css +126 -0
  100. package/src/style/components/drag-handle/drag-handle.css +68 -0
  101. package/src/style/components/drawer/drawer.css +210 -0
  102. package/src/style/components/floating-bar/floating-bar.css +39 -0
  103. package/src/style/components/footer/footer.css +108 -0
  104. package/src/style/components/grid/grid.css +33 -0
  105. package/src/style/components/header/header.css +44 -0
  106. package/src/style/components/icons/icons.css +44 -0
  107. package/src/style/components/input/input.css +393 -0
  108. package/src/style/components/layout/layout.css +205 -0
  109. package/src/style/components/list/list.css +140 -0
  110. package/src/style/components/navbar/navbar.css +342 -0
  111. package/src/style/components/page/page.css +46 -0
  112. package/src/style/components/page-index/page-index.css +158 -0
  113. package/src/style/components/popover/popover.css +44 -0
  114. package/src/style/components/radio.css +178 -0
  115. package/src/style/components/section/section.css +67 -0
  116. package/src/style/components/select/select.css +143 -0
  117. package/src/style/components/slider/slider.css +159 -0
  118. package/src/style/components/switch/switch.css +267 -0
  119. package/src/style/components/table/table.css +108 -0
  120. package/src/style/components/theme-control/theme-control.css +35 -0
  121. package/src/style/components/tooltip/tooltip.css +52 -0
  122. package/src/style/foundations/global.css +316 -0
  123. package/src/style/foundations/motion.css +164 -0
  124. package/src/style/foundations/spacing.css +51 -0
  125. package/src/style/foundations/typography.css +39 -0
  126. package/src/style/foundations/z-index.css +81 -0
  127. package/src/style/modes/dark.css +146 -0
  128. package/src/style/modes/light.css +147 -0
  129. package/src/style/semantic.css +52 -0
  130. package/src/style/styles.css +51 -0
  131. package/src/style/themes/theme.json +37 -0
  132. package/src/utils/README.md +305 -0
  133. package/src/utils/USER_PREFERENCES.md +558 -0
  134. package/src/utils/theme.ts +127 -0
  135. package/src/utils/user-preferences.ts +577 -0
  136. package/tsconfig.json +25 -0
  137. package/tsup.config.ts +52 -0
@@ -0,0 +1,305 @@
1
+ # Design System Utilities
2
+
3
+ This directory contains utility modules that provide practical, production-ready solutions for common application needs.
4
+
5
+ ## Philosophy
6
+
7
+ The Hellboy Design System utilities are designed to **accelerate development** by providing complete, opinionated solutions that go beyond basic component libraries. While we remain framework-agnostic where possible, we prioritize **developer productivity** and **real-world usability** over pure abstraction.
8
+
9
+ ## Available Utilities
10
+
11
+ ### 🎨 Theme Utilities (`theme.ts`)
12
+
13
+ Theme management with support for:
14
+ - Light/dark mode switching
15
+ - System preference detection
16
+ - Custom color configuration
17
+ - Persistent storage across sessions
18
+
19
+ **Key Features:**
20
+ - Automatic OS theme detection
21
+ - localStorage persistence (now using User Preferences system)
22
+ - CSS variable management
23
+ - TypeScript type safety
24
+
25
+ **Documentation:** See inline JSDoc comments in `theme.ts`
26
+
27
+ **Quick Start:**
28
+ ```typescript
29
+ import { getTheme, setTheme, toggleTheme } from '@hellboy/ds';
30
+
31
+ // Get current theme
32
+ const theme = getTheme(); // 'light' | 'dark'
33
+
34
+ // Set theme
35
+ setTheme('dark');
36
+
37
+ // Toggle theme
38
+ toggleTheme();
39
+ ```
40
+
41
+ ---
42
+
43
+ ### 💾 User Preferences (`user-preferences.ts`)
44
+
45
+ Comprehensive preference management system for storing user settings, configurations, and UI state.
46
+
47
+ **Key Features:**
48
+ - Type-safe preference storage
49
+ - localStorage with optional IndexedDB fallback
50
+ - Namespace support for organization
51
+ - Export/import functionality
52
+ - Framework-agnostic design
53
+ - Automatic migration from legacy storage
54
+
55
+ **Use Cases:**
56
+ - Theme preferences (light/dark, custom colors)
57
+ - Layout dimensions (sidebar widths, panel sizes)
58
+ - Component states (drawer positions, table settings)
59
+ - User-specific settings (language, timezone, etc.)
60
+
61
+ **Documentation:** See `USER_PREFERENCES.md` for comprehensive guide
62
+
63
+ **Quick Start:**
64
+ ```typescript
65
+ import { getPreference, setPreference } from '@hellboy/ds';
66
+
67
+ // Save a preference
68
+ setPreference('sidebarWidth', 300);
69
+
70
+ // Load a preference with default
71
+ const width = getPreference('sidebarWidth', 280);
72
+
73
+ // Use with namespaces
74
+ import { createPreferenceNamespace } from '@hellboy/ds';
75
+ const layoutPrefs = createPreferenceNamespace('layout');
76
+ layoutPrefs.set('collapsed', true);
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Integration Examples
82
+
83
+ ### Theme + User Preferences
84
+
85
+ The theme utilities now use the User Preferences system under the hood, providing automatic migration from legacy storage:
86
+
87
+ ```typescript
88
+ import { setTheme, getTheme } from '@hellboy/ds';
89
+
90
+ // Theme is automatically stored using the preference system
91
+ setTheme('dark'); // Saved to preferences as 'theme': 'dark'
92
+
93
+ // Retrieve theme (checks preferences, then legacy localStorage)
94
+ const theme = getTheme();
95
+ ```
96
+
97
+ ### Layout with Persistent Dimensions
98
+
99
+ The `Layout` component automatically saves sidebar widths:
100
+
101
+ ```tsx
102
+ import { Layout } from '@hellboy/ds';
103
+
104
+ // Sidebar widths are automatically saved and restored
105
+ <Layout
106
+ variant="sidebar-main-sidebar"
107
+ resizable
108
+ sidebarLeft={<Sidebar />}
109
+ sidebarRight={<RightPanel />}
110
+ >
111
+ <MainContent />
112
+ </Layout>
113
+ ```
114
+
115
+ Internally, the Layout component uses:
116
+ ```typescript
117
+ const leftWidth = getPreference('layout.leftSidebarWidth', 280);
118
+ // User resizes sidebar...
119
+ setPreference('layout.leftSidebarWidth', newWidth);
120
+ ```
121
+
122
+ ### React Hook Pattern
123
+
124
+ Create reusable hooks for your app:
125
+
126
+ ```typescript
127
+ // hooks/usePreference.ts
128
+ import { useState } from 'react';
129
+ import { getPreference, setPreference } from '@hellboy/ds';
130
+
131
+ export function usePreference<T>(key: string, defaultValue: T) {
132
+ const [value, setValue] = useState<T>(() =>
133
+ getPreference(key, defaultValue) ?? defaultValue
134
+ );
135
+
136
+ const updateValue = (newValue: T) => {
137
+ setValue(newValue);
138
+ setPreference(key, newValue);
139
+ };
140
+
141
+ return [value, updateValue] as const;
142
+ }
143
+
144
+ // Use in components
145
+ function MyComponent() {
146
+ const [theme, setTheme] = usePreference('theme', 'light');
147
+ const [sidebarWidth, setSidebarWidth] = usePreference('layout.sidebarWidth', 280);
148
+
149
+ return (
150
+ <div>
151
+ <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
152
+ Toggle Theme
153
+ </button>
154
+ </div>
155
+ );
156
+ }
157
+ ```
158
+
159
+ ## Design Decisions
160
+
161
+ ### Why User Preferences?
162
+
163
+ Many design systems stop at providing UI components. We believe that's only half the story. Real applications need:
164
+
165
+ 1. **State Persistence**: Users expect their preferences to be remembered
166
+ 2. **Type Safety**: TypeScript support prevents runtime errors
167
+ 3. **Organization**: Namespaces keep large apps maintainable
168
+ 4. **Portability**: Export/import allows users to backup settings
169
+ 5. **Migration**: Automatic legacy storage migration prevents breaking changes
170
+
171
+ ### Why localStorage by Default?
172
+
173
+ - ✅ **Synchronous**: No async complexity for simple use cases
174
+ - ✅ **Universal**: Supported in all browsers (even old ones)
175
+ - ✅ **Simple**: No setup required, works out of the box
176
+ - ✅ **Adequate**: 5-10MB is sufficient for most preferences
177
+
178
+ IndexedDB support is included for future expansion when dealing with larger datasets.
179
+
180
+ ### Integration with Components
181
+
182
+ Where appropriate, design system components integrate with the preference system automatically:
183
+
184
+ - **Layout**: Saves sidebar/panel dimensions
185
+ - **Theme**: Persists theme mode and custom colors
186
+ - **Future components**: Will leverage preferences for state persistence
187
+
188
+ This integration is **opt-in** via the `resizable` prop or similar, ensuring components remain flexible.
189
+
190
+ ## Best Practices
191
+
192
+ ### 1. Use Meaningful Key Names
193
+
194
+ Organize preferences with dot notation:
195
+
196
+ ```typescript
197
+ // Good
198
+ setPreference('layout.sidebar.width', 300);
199
+ setPreference('components.drawer.position', 'right');
200
+ setPreference('user.language', 'pt-BR');
201
+
202
+ // Avoid
203
+ setPreference('w', 300);
204
+ setPreference('pos', 'right');
205
+ ```
206
+
207
+ ### 2. Always Provide Defaults
208
+
209
+ Ensure your app works on first load:
210
+
211
+ ```typescript
212
+ // Good
213
+ const width = getPreference('sidebarWidth', 280);
214
+
215
+ // Avoid
216
+ const width = getPreference('sidebarWidth'); // Could be undefined
217
+ ```
218
+
219
+ ### 3. Use Namespaces for Related Preferences
220
+
221
+ Keep things organized:
222
+
223
+ ```typescript
224
+ const layoutPrefs = createPreferenceNamespace('layout');
225
+ const userPrefs = createPreferenceNamespace('user');
226
+
227
+ layoutPrefs.set('sidebarWidth', 300);
228
+ userPrefs.set('language', 'pt-BR');
229
+ ```
230
+
231
+ ### 4. Type Your Preferences
232
+
233
+ Leverage TypeScript:
234
+
235
+ ```typescript
236
+ type Theme = 'light' | 'dark';
237
+ const theme = getPreference<Theme>('theme', 'light');
238
+ ```
239
+
240
+ ### 5. Consider User Privacy
241
+
242
+ Allow users to export/clear their data:
243
+
244
+ ```typescript
245
+ import { exportPreferences, clearPreferences } from '@hellboy/ds';
246
+
247
+ // Export for backup
248
+ const json = exportPreferences();
249
+
250
+ // Clear all data
251
+ clearPreferences();
252
+ ```
253
+
254
+ ## Migration Guide
255
+
256
+ ### From Direct localStorage
257
+
258
+ If you're currently using `localStorage` directly:
259
+
260
+ ```typescript
261
+ // Before
262
+ localStorage.setItem('myTheme', 'dark');
263
+ const theme = localStorage.getItem('myTheme') || 'light';
264
+
265
+ // After
266
+ import { setPreference, getPreference } from '@hellboy/ds';
267
+ setPreference('myTheme', 'dark');
268
+ const theme = getPreference('myTheme', 'light');
269
+ ```
270
+
271
+ ### From Legacy DS Theme Utils
272
+
273
+ The theme utilities automatically migrate:
274
+
275
+ ```typescript
276
+ // No changes needed! Your existing code works:
277
+ import { setTheme, getTheme } from '@hellboy/ds';
278
+
279
+ setTheme('dark'); // Now uses User Preferences internally
280
+ const theme = getTheme(); // Checks new system, falls back to legacy
281
+ ```
282
+
283
+ ## Contributing
284
+
285
+ When adding new utilities:
286
+
287
+ 1. **Document thoroughly**: Include JSDoc comments and examples
288
+ 2. **Provide TypeScript types**: Full type safety is required
289
+ 3. **Stay framework-agnostic**: Utilities should work in any environment
290
+ 4. **Write tests**: Ensure reliability
291
+ 5. **Update this README**: Keep documentation current
292
+
293
+ ## Future Utilities
294
+
295
+ Planned additions:
296
+
297
+ - 🔄 **State Management**: Simple state sync across tabs
298
+ - 🌐 **i18n**: Internationalization helpers
299
+ - 📊 **Analytics**: Privacy-focused analytics utilities
300
+ - 🔒 **Validation**: Form validation helpers
301
+ - 📱 **Responsive**: Breakpoint utilities
302
+
303
+ ---
304
+
305
+ **Remember**: The goal is to provide **practical, production-ready solutions** that make developers' lives easier. If you find yourself writing the same code across multiple projects, it might be a good candidate for a utility in this directory.