Skip to content

Commit d13328b

Browse files
committed
Add ObjectUI principles and architecture documentation
1 parent 50abaa6 commit d13328b

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# 🎨 ObjectUI Principles & Architecture
2+
3+
**Goal:** Create a world-class, enterprise-grade UI library for ObjectStack.
4+
**Tech Stack:** React, Tailwind CSS, Shadcn UI, Framer Motion.
5+
**Package Name:** `@objectstack/ui`
6+
**Location:** `packages/ui`
7+
8+
---
9+
10+
## 1. Core Philosophy
11+
12+
1. **"Beauty as a Feature":** Enterprise software doesn't have to be ugly. Use generous whitespace, subtle shadows, and smooth transitions.
13+
2. **Radical Consistency:** Every button, input, and card must feel like they belong to the same family.
14+
3. **Composition over Configuration:** Use standard Shadcn slots (`<Card><CardHeader>...`) rather than monolithic config objects when writing internal code.
15+
4. **Tailwind Native:** All styling must be via Tailwind utility classes. No `.css` files except for global variables.
16+
17+
---
18+
19+
## 2. Directory Structure (`packages/ui`)
20+
21+
```text
22+
packages/ui/
23+
├── src/
24+
│ ├── components/
25+
│ │ ├── ui/ # 🧱 SHADCN PRIMITIVES (Button, Input, Sheet)
26+
│ │ │ ├── button.tsx
27+
│ │ │ ├── input.tsx
28+
│ │ │ └── ...
29+
│ │ ├── visual/ # 💅 PRE-BUILT VISUAL COMPOSITIONS (Not Business Logic)
30+
│ │ │ ├── auth-card.tsx
31+
│ │ │ ├── stat-card.tsx
32+
│ │ │ └── ...
33+
│ │ └── icons.tsx # Lucide Icon Exports
34+
│ │
35+
│ ├── engine/ # ⚙️ RUNTIME ENGINE (The Implementation of engine.prompt.md)
36+
│ │ ├── renderer/ # <PageRenderer>, <RegionRenderer>
37+
│ │ ├── data/ # useObjectData, useRecord
38+
│ │ └── hooks/ # useCurrentApp, useMobile
39+
│ │
40+
│ ├── lib/
41+
│ │ ├── utils.ts # cn() helper
42+
│ │ └── constants.ts
43+
│ │
44+
│ └── index.ts # Main Export
45+
46+
├── tailwind.config.ts # Shared Tailwind Preset
47+
└── package.json
48+
```
49+
50+
---
51+
52+
## 3. Component Standards
53+
54+
### A. The "cn" Pattern
55+
Every component **MUST** accept `className` and merge it using `cn()` (clsx + tailwind-merge).
56+
57+
```typescript
58+
import { cn } from "@/lib/utils"
59+
60+
export function Badge({ className, variant, ...props }: BadgeProps) {
61+
return (
62+
<div className={cn("inline-flex items-center rounded-full px-2.5 py-0.5", className)} {...props} />
63+
)
64+
}
65+
```
66+
67+
### B. Shadcn Compatibility
68+
* Do not modify `components/ui/*` primitives heavily. Keep them upgradeable.
69+
* Use `cva` (class-variance-authority) for managing component variants (primary, secondary, ghost).
70+
71+
### C. Theming Variables
72+
Theme is controlled via CSS variables in `globals.css` (in the consumer app or injected by LayoutProvider).
73+
74+
```css
75+
:root {
76+
--background: 0 0% 100%;
77+
--foreground: 222.2 84% 4.9%;
78+
--primary: 221.2 83.2% 53.3%; /* Brand Color */
79+
--radius: 0.5rem;
80+
}
81+
```
82+
83+
---
84+
85+
## 4. Development Workflow
86+
87+
1. **Add Primitive:** Use Shadcn CLI (or manual copy) to add atoms.
88+
* `npx shadcn-ui@latest add dropdown-menu`
89+
2. **Build Block:** Combine primitives into a "Block" (e.g., `PageHeader`).
90+
3. **Connect Engine:** Wrap the Block in the `withEngine` HoC if it needs data/logic.
91+
92+
---
93+
94+
## 5. Visual Standards
95+
96+
* **Typography:** Inter (default). Headings tight tracking, strict scale.
97+
* **Borders:** Subtle (`border-zinc-200` light / `border-zinc-800` dark).
98+
* **Shadows:** `shadow-sm` for cards, `shadow-lg` for dropdowns/modals.
99+
* **Animation:** Use `framer-motion` for complex entrances. Standard duration: `200ms`.
100+
* **Dark Mode:** First-class citizen. All colors must have dark substitutions.
101+

0 commit comments

Comments
 (0)