@almadar/ui 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.
package/LICENSE ADDED
@@ -0,0 +1,72 @@
1
+ Business Source License 1.1
2
+
3
+ Parameters
4
+
5
+ Licensor: Almadar FZE
6
+ Licensed Work: KFlow Builder / Almadar
7
+ The Licensed Work is (c) 2025-2026 Almadar FZE.
8
+ Additional Use Grant: You may make production use of the Licensed Work for
9
+ non-commercial purposes and for internal evaluation.
10
+ Production use for commercial purposes requires a
11
+ commercial license from the Licensor.
12
+ Change Date: 2030-02-01
13
+ Change License: Apache License, Version 2.0
14
+
15
+ Terms
16
+
17
+ The Licensor hereby grants you the right to copy, modify, create derivative
18
+ works, redistribute, and make non-production use of the Licensed Work. The
19
+ Licensor may make an Additional Use Grant, above, permitting limited
20
+ production use.
21
+
22
+ Effective on the Change Date, or the fourth anniversary of the first publicly
23
+ available distribution of a specific version of the Licensed Work under this
24
+ License, whichever comes first, the Licensor hereby grants you rights under
25
+ the terms of the Change License, and the rights granted in the paragraph
26
+ above terminate.
27
+
28
+ If your use of the Licensed Work does not comply with the requirements
29
+ currently in effect as described in this License, you must purchase a
30
+ commercial license from the Licensor, its affiliated entities, or authorized
31
+ resellers, or you must refrain from using the Licensed Work.
32
+
33
+ All copies of the original and modified Licensed Work, and derivative works
34
+ of the Licensed Work, are subject to this License. This License applies
35
+ separately for each version of the Licensed Work and the Change Date may vary
36
+ for each version of the Licensed Work released by Licensor.
37
+
38
+ You must conspicuously display this License on each original or modified copy
39
+ of the Licensed Work. If you receive the Licensed Work in original or
40
+ modified form from a third party, the terms and conditions set forth in this
41
+ License apply to your use of that work.
42
+
43
+ Any use of the Licensed Work in violation of this License will automatically
44
+ terminate your rights under this License for the current and all other
45
+ versions of the Licensed Work.
46
+
47
+ This License does not grant you any right in any trademark or logo of
48
+ Licensor or its affiliates (provided that you may use a trademark or logo of
49
+ Licensor as expressly required by this License).
50
+
51
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
52
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
53
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
54
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
55
+ TITLE.
56
+
57
+ ---
58
+
59
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
60
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
61
+
62
+ ADDITIONAL TERMS:
63
+
64
+ Documentation (builder/packages/website/docs/) is licensed under CC BY 4.0.
65
+
66
+ TRADEMARKS:
67
+
68
+ "Orbital", "KFlow", "Almadar", and the Almadar logo are trademarks of
69
+ Almadar FZE. You may not use these trademarks without prior written
70
+ permission from Almadar FZE.
71
+
72
+ For licensing inquiries: licensing@almadar.io
package/README.md ADDED
@@ -0,0 +1,335 @@
1
+ # Orbital Design System
2
+
3
+ A themeable, domain-aware component library for Orbital applications. Generates client-specific design systems from `.orb` schemas.
4
+
5
+ ## Features
6
+
7
+ - **CSS Variable-Based Theming**: All components use CSS variables, enabling easy theme switching
8
+ - **Domain Detection**: Automatically detects domain (garden, healthcare, finance, etc.) from schema
9
+ - **Component Suggestions**: Suggests domain-specific components based on schema analysis
10
+ - **Storybook Integration**: Visual component documentation with theme switching
11
+ - **Static Export**: Export design system as static HTML for client delivery
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ # Install dependencies
17
+ npm install
18
+
19
+ # Start Storybook for development
20
+ npm run storybook
21
+
22
+ # Generate a client-specific design system
23
+ npm run generate path/to/schema.orb
24
+ ```
25
+
26
+ ## Available Themes
27
+
28
+ | Theme | Description | Best For |
29
+ |-------|-------------|----------|
30
+ | `wireframe` | High contrast, sharp edges | Prototyping |
31
+ | `minimalist` | Soft, elegant, subtle | Corporate apps |
32
+ | `almadar` | Brand-specific styling | Al-Madar projects |
33
+ | `winning-11` | Garden/organic theme | Agriculture, nature |
34
+
35
+ ## Scripts
36
+
37
+ ### `npm run storybook`
38
+ Start Storybook development server on port 6006.
39
+
40
+ ### `npm run build-storybook`
41
+ Build static Storybook documentation.
42
+
43
+ ### `npm run generate <schema.orb> [options]`
44
+ Generate a complete client-specific design system.
45
+
46
+ Options:
47
+ - `--output <dir>` - Output directory (default: ./exports)
48
+ - `--name <name>` - Client name override
49
+ - `--no-storybook` - Skip Storybook build
50
+ - `--no-components` - Skip component generation
51
+
52
+ Example:
53
+ ```bash
54
+ npm run generate ../architecture/winning-11.orb --output ./clients
55
+ ```
56
+
57
+ ### `npm run generate:theme <schema.orb> [output.css]`
58
+ Generate only the theme CSS from a schema.
59
+
60
+ ### `npm run suggest:components <schema.orb> [--generate <dir>]`
61
+ Analyze schema and suggest domain-specific components.
62
+
63
+ ## Component Library Structure
64
+
65
+ ```
66
+ components/
67
+ ├── atoms/ # Basic building blocks
68
+ │ ├── Button
69
+ │ ├── Input
70
+ │ ├── Badge
71
+ │ ├── Card
72
+ │ └── ...
73
+ ├── molecules/ # Composite components
74
+ │ ├── Alert
75
+ │ ├── Modal
76
+ │ ├── Tabs
77
+ │ └── ...
78
+ ├── organisms/ # Complex components
79
+ │ ├── DataTable
80
+ │ ├── Header
81
+ │ ├── Sidebar
82
+ │ └── ...
83
+ └── templates/ # Page layouts
84
+ ├── AuthLayout
85
+ ├── FormTemplate
86
+ └── ...
87
+ ```
88
+
89
+ ## Theming
90
+
91
+ ### Using a Theme
92
+
93
+ Apply a theme by setting `data-design-theme` attribute:
94
+
95
+ ```html
96
+ <html data-design-theme="winning-11">
97
+ ...
98
+ </html>
99
+ ```
100
+
101
+ Or in React:
102
+
103
+ ```tsx
104
+ <div data-design-theme="winning-11">
105
+ <Button>Themed Button</Button>
106
+ </div>
107
+ ```
108
+
109
+ ### CSS Variables
110
+
111
+ All components use CSS variables for theming:
112
+
113
+ ```css
114
+ /* Colors */
115
+ --color-primary
116
+ --color-primary-hover
117
+ --color-primary-foreground
118
+ --color-secondary
119
+ --color-secondary-foreground
120
+ --color-accent
121
+ --color-muted
122
+ --color-muted-foreground
123
+ --color-background
124
+ --color-foreground
125
+ --color-border
126
+
127
+ /* Shadows */
128
+ --shadow-sm
129
+ --shadow-main
130
+ --shadow-lg
131
+ --shadow-hover
132
+
133
+ /* Border Radius */
134
+ --radius-sm
135
+ --radius-md
136
+ --radius-lg
137
+ --radius-xl
138
+
139
+ /* Transitions */
140
+ --transition-fast
141
+ --transition-normal
142
+ --transition-slow
143
+ ```
144
+
145
+ ### Creating a Custom Theme
146
+
147
+ 1. Create a CSS file in `themes/`:
148
+
149
+ ```css
150
+ [data-design-theme="my-theme"] {
151
+ --color-primary: #your-color;
152
+ --color-secondary: #your-color;
153
+ /* ... other variables */
154
+ }
155
+ ```
156
+
157
+ 2. Import in `themes/index.css`:
158
+
159
+ ```css
160
+ @import './my-theme.css';
161
+ ```
162
+
163
+ 3. Add to Storybook preview (`.storybook/preview.tsx`):
164
+
165
+ ```tsx
166
+ themes: {
167
+ // ...existing themes
168
+ 'my-theme': 'my-theme',
169
+ }
170
+ ```
171
+
172
+ ## Domain-Specific Components
173
+
174
+ The generator suggests domain-specific components based on schema analysis:
175
+
176
+ ### Garden/Agriculture Domain
177
+ - `GardenView` - Visual garden layout
178
+ - `PlantCard` - Plant display with care indicators
179
+ - `GrowthMeter` - Progress indicator for growth
180
+ - `TrustMeter` - Trust/relationship indicator
181
+ - `CareIndicator` - Water/sun/nutrient needs
182
+
183
+ ### Healthcare Domain
184
+ - `PatientCard` - Patient information display
185
+ - `VitalsDisplay` - Vital signs compact view
186
+ - `AppointmentSlot` - Scheduling component
187
+
188
+ ### E-commerce Domain
189
+ - `ProductCard` - Product with price and cart action
190
+ - `CartSummary` - Cart overview
191
+ - `PriceTag` - Formatted price display
192
+
193
+ ### Game Domain
194
+ - `CharacterStats` - RPG-style stat display
195
+ - `QuestTracker` - Active quest panel
196
+
197
+ ## Integration with Proposal Documents
198
+
199
+ The generated design system can be included in client proposals:
200
+
201
+ 1. Generate the design system:
202
+ ```bash
203
+ npm run generate ../architecture/winning-11.orb --output ./exports
204
+ ```
205
+
206
+ 2. The export includes:
207
+ - Theme CSS file
208
+ - Component stubs (if domain detected)
209
+ - Storybook documentation
210
+ - Manifest with metadata
211
+
212
+ 3. Reference in proposal documents or deliver as standalone package.
213
+
214
+ ## Client-Specific Components
215
+
216
+ Client-specific components live in dedicated folders named after the client. These components:
217
+ - **Extend the core library** - Use existing atoms/molecules, don't recreate them
218
+ - **Follow Atomic Design** - Break down into atoms, molecules, organisms, templates
219
+ - **Include Storybook stories** - Every component must have a `.stories.tsx` file
220
+ - **Are reusable** - Can be used in future projects for the same client
221
+
222
+ ### Directory Structure
223
+
224
+ ```
225
+ orbital-shared/design-system/
226
+ ├── components/ # Core component library (shared across all clients)
227
+ │ ├── atoms/
228
+ │ ├── molecules/
229
+ │ ├── organisms/
230
+ │ └── templates/
231
+ ├── clients/ # Client-specific components
232
+ │ ├── winning-11/ # Winning-11 client
233
+ │ │ ├── atoms/ # Client-specific atoms (rare)
234
+ │ │ ├── molecules/ # Client-specific molecules
235
+ │ │ ├── organisms/ # Client-specific organisms
236
+ │ │ ├── templates/ # Client page templates/showcases
237
+ │ │ └── index.ts # Barrel export
238
+ │ └── [other-client]/ # Another client folder
239
+ └── ...
240
+ ```
241
+
242
+ ### When to Create Client-Specific Components
243
+
244
+ | Scenario | Where to Add |
245
+ |----------|--------------|
246
+ | Generic component useful for any project | `components/` (core library) |
247
+ | Domain-specific styling of existing component | Client folder with composition |
248
+ | Unique business logic component | Client folder |
249
+ | Page template/showcase | `clients/[name]/templates/` |
250
+
251
+ ### Creating Client-Specific Components
252
+
253
+ 1. **Create in client folder**:
254
+ ```
255
+ clients/winning-11/organisms/GardenLayout.tsx
256
+ clients/winning-11/organisms/GardenLayout.stories.tsx
257
+ ```
258
+
259
+ 2. **Import from core library**:
260
+ ```tsx
261
+ import { Card, Badge } from '../../../components/atoms';
262
+ import { Grid } from '../../../components/molecules';
263
+ ```
264
+
265
+ 3. **Export from client index**:
266
+ ```tsx
267
+ // clients/winning-11/index.ts
268
+ export * from './organisms/GardenLayout';
269
+ ```
270
+
271
+ 4. **Create Storybook story**:
272
+ ```tsx
273
+ // GardenLayout.stories.tsx
274
+ import type { Meta, StoryObj } from '@storybook/react';
275
+ import { GardenLayout } from './GardenLayout';
276
+
277
+ const meta: Meta<typeof GardenLayout> = {
278
+ title: 'Clients/Winning-11/Organisms/GardenLayout',
279
+ component: GardenLayout,
280
+ };
281
+ export default meta;
282
+ ```
283
+
284
+ ### Client Templates
285
+
286
+ Templates showcase complete page layouts specific to the client. They demonstrate:
287
+ - How components compose together
288
+ - Realistic data patterns
289
+ - Brand-specific styling
290
+
291
+ ```tsx
292
+ // clients/winning-11/templates/GardenDashboard.tsx
293
+ export const GardenDashboard = () => (
294
+ <PageLayout>
295
+ <Header />
296
+ <GardenStats />
297
+ <PlantGrid plants={mockPlants} />
298
+ </PageLayout>
299
+ );
300
+ ```
301
+
302
+ ### Syncing to Projects
303
+
304
+ When generating a client project, client-specific components are copied:
305
+
306
+ ```bash
307
+ npm run generate schema.orb --client winning-11 --output ../projects/winning-11
308
+ ```
309
+
310
+ This copies:
311
+ - Core `components/` library
312
+ - Client-specific `clients/winning-11/` folder
313
+ - Themes and hooks
314
+
315
+ ## Development
316
+
317
+ ### Adding New Components
318
+
319
+ 1. Create component in appropriate category (`atoms/`, `molecules/`, `organisms/`)
320
+ 2. Create corresponding `.stories.tsx` file
321
+ 3. Export from category's `index.ts`
322
+ 4. Verify in Storybook
323
+
324
+ ### Adding New Themes
325
+
326
+ 1. Create theme CSS in `themes/`
327
+ 2. Follow existing theme structure for CSS variables
328
+ 3. Add import to `themes/index.css`
329
+ 4. Add to Storybook theme selector
330
+
331
+ ### Adding Domain-Specific Components
332
+
333
+ 1. Add domain config to `scripts/suggest-components.ts`
334
+ 2. Define keywords and component suggestions
335
+ 3. Test with schema from that domain
@@ -0,0 +1,103 @@
1
+ import React__default from 'react';
2
+
3
+ /**
4
+ * Unified ThemeContext - Single provider for theme and color mode
5
+ *
6
+ * Combines design theme selection (ocean, wireframe, etc.) with
7
+ * color mode (light/dark) into a single, simple system.
8
+ *
9
+ * Uses a single data attribute: data-theme="ocean-light" or data-theme="ocean-dark"
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+
14
+ /** Color mode preference */
15
+ type ColorMode = "light" | "dark" | "system";
16
+ /** Resolved color mode (what's actually applied) */
17
+ type ResolvedMode = "light" | "dark";
18
+ /** Theme definition */
19
+ interface ThemeDefinition {
20
+ /** Theme identifier (e.g., "ocean", "wireframe") */
21
+ name: string;
22
+ /** Display name for UI (e.g., "Ocean Blue") */
23
+ displayName?: string;
24
+ /** Whether this theme has light mode styles */
25
+ hasLightMode?: boolean;
26
+ /** Whether this theme has dark mode styles */
27
+ hasDarkMode?: boolean;
28
+ }
29
+ /** Built-in themes available in the design system */
30
+ declare const BUILT_IN_THEMES: ThemeDefinition[];
31
+ /** Theme context value */
32
+ interface ThemeContextValue {
33
+ /** Current theme name */
34
+ theme: string;
35
+ /** Current color mode setting (may be 'system') */
36
+ mode: ColorMode;
37
+ /** Resolved color mode (always 'light' or 'dark') */
38
+ resolvedMode: ResolvedMode;
39
+ /** Set the theme */
40
+ setTheme: (theme: string) => void;
41
+ /** Set the color mode */
42
+ setMode: (mode: ColorMode) => void;
43
+ /** Toggle between light and dark modes */
44
+ toggleMode: () => void;
45
+ /** Available themes */
46
+ availableThemes: ThemeDefinition[];
47
+ /** The full theme string applied to data-theme (e.g., "ocean-light") */
48
+ appliedTheme: string;
49
+ }
50
+ declare const ThemeContext: React__default.Context<ThemeContextValue | undefined>;
51
+ interface ThemeProviderProps {
52
+ children: React__default.ReactNode;
53
+ /** Available themes (will be merged with built-in themes) */
54
+ themes?: readonly ThemeDefinition[] | ThemeDefinition[];
55
+ /** Default theme name */
56
+ defaultTheme?: string;
57
+ /** Default color mode */
58
+ defaultMode?: ColorMode;
59
+ }
60
+ /**
61
+ * Unified ThemeProvider component
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * // Basic usage with built-in themes
66
+ * <ThemeProvider defaultTheme="wireframe" defaultMode="light">
67
+ * <App />
68
+ * </ThemeProvider>
69
+ *
70
+ * // With custom themes from orbital schema
71
+ * import { THEMES } from './generated/theme-manifest';
72
+ * <ThemeProvider themes={THEMES} defaultTheme="ocean" defaultMode="system">
73
+ * <App />
74
+ * </ThemeProvider>
75
+ * ```
76
+ */
77
+ declare const ThemeProvider: React__default.FC<ThemeProviderProps>;
78
+ /**
79
+ * Hook for accessing theme context
80
+ *
81
+ * @returns Theme context value
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * const { theme, resolvedMode, toggleMode, setTheme } = useTheme();
86
+ *
87
+ * // Toggle dark mode
88
+ * <button onClick={toggleMode}>
89
+ * {resolvedMode === 'dark' ? 'Light' : 'Dark'}
90
+ * </button>
91
+ *
92
+ * // Change theme
93
+ * <select value={theme} onChange={(e) => setTheme(e.target.value)}>
94
+ * {availableThemes.map(t => (
95
+ * <option key={t.name} value={t.name}>{t.displayName || t.name}</option>
96
+ * ))}
97
+ * </select>
98
+ * ```
99
+ */
100
+ declare function useTheme(): ThemeContextValue;
101
+ type DesignTheme = ThemeDefinition;
102
+
103
+ export { BUILT_IN_THEMES as B, type ColorMode as C, type DesignTheme as D, type ResolvedMode as R, type ThemeProviderProps as T, ThemeContext as a, type ThemeDefinition as b, ThemeProvider as c, useTheme as u };