Skip to content

Commit b459d62

Browse files
Reorganize UI examples into separate sub-packages
Moved metadata examples into metadata-examples/ sub-package to create a consistent structure: - metadata-examples/ - UI metadata configurations (TypeScript/JSON) - custom-components/ - React component implementations - react-renderer/ - React renderer for metadata This improves organization by separating the three aspects: 1. The "what" (metadata defining UI structure) 2. The "implementation" (custom React components) 3. The "how" (rendering engine) Updated main README to reflect new structure. Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 22d235e commit b459d62

File tree

12 files changed

+110
-92
lines changed

12 files changed

+110
-92
lines changed

examples/ui/README.md

Lines changed: 57 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,29 @@ This directory contains comprehensive examples demonstrating the **UI Protocol**
44

55
## 📚 What's Inside
66

7-
This package contains three types of examples:
8-
9-
1. **Metadata Examples** (`src/*.examples.ts`) - JSON/TypeScript configurations defining UI structure
10-
2. **Custom Components** (`custom-components/`) - React implementations of custom UI components
11-
3. **React Renderer** (`react-renderer/`) - How to render UI metadata using React
12-
13-
### Metadata Examples (`src/`)
14-
15-
These demonstrate all major UI components of the ObjectStack Protocol:
16-
17-
### 1. **Views** (`view.examples.ts`)
18-
Different ways to display and interact with data:
19-
- **Grid View**: Traditional table/spreadsheet layout
20-
- **Kanban View**: Card-based workflow boards
21-
- **Calendar View**: Time-based event visualization
22-
- **Gantt View**: Project timeline visualization
23-
- **Custom Data Sources**: Using API providers and static data
24-
25-
### 2. **Pages** (`page.examples.ts`)
26-
Component composition patterns inspired by Salesforce Lightning Pages:
27-
- **Record Pages**: Contextual layouts for viewing/editing records
28-
- **Home Pages**: Dashboard-style landing pages
29-
- **App Pages**: Custom application screens
30-
- **Component Regions**: Flexible layout templates
31-
32-
### 3. **Dashboards** (`dashboard.examples.ts`)
33-
Analytics and metrics visualization:
34-
- **Widget Types**: Metrics, charts (bar, line, pie, donut, funnel), tables
35-
- **Filters**: Dynamic data filtering
36-
- **Layout Grid**: Responsive dashboard layouts
37-
- **Real-time Metrics**: KPIs and business intelligence
38-
39-
### 4. **Actions** (`action.examples.ts`)
40-
User interactions and workflows:
41-
- **Button Actions**: Custom buttons with various triggers
42-
- **Modal Actions**: Forms and dialogs
43-
- **Flow Actions**: Visual workflow execution
44-
- **Script Actions**: Custom JavaScript execution
45-
- **Batch Actions**: Mass operations on records
46-
47-
### 5. **Apps** (`app.examples.ts`)
48-
Complete application structure:
49-
- **Navigation Trees**: Hierarchical menus with groups
50-
- **App Branding**: Custom colors, logos, themes
51-
- **Multi-app Architecture**: Switching between business contexts
52-
- **Permission-based Access**: Role-based app visibility
53-
54-
### 6. **Themes** (`theme.examples.ts`)
55-
Visual styling and customization:
56-
- **Color Palettes**: Primary, secondary, accent colors
57-
- **Typography**: Font families and sizing
58-
- **Component Styles**: Button variants, borders, shadows
59-
- **Dark Mode**: Theme switching
7+
This package contains three sub-packages demonstrating different aspects of the UI Protocol:
8+
9+
### 1. **Metadata Examples** (`metadata-examples/`)
10+
TypeScript/JSON configurations defining UI structure - the "what" of the UI:
11+
- **view.examples.ts** - Grid, Kanban, Calendar, Gantt views
12+
- **page.examples.ts** - Record, Home, App pages
13+
- **dashboard.examples.ts** - Analytics dashboards with widgets
14+
- **action.examples.ts** - User interactions and workflows
15+
- **app.examples.ts** - Complete application structures
16+
- **theme.examples.ts** - Visual styling and theming
17+
18+
### 2. **Custom Components** (`custom-components/`)
19+
React implementations showing how to build custom UI components:
20+
- CustomButton - Flexible button with variants and theming
21+
- CustomDataGrid - Advanced grid with sorting, filtering, pagination
22+
- Component registration system
23+
24+
### 3. **React Renderer** (`react-renderer/`)
25+
Shows how to render UI metadata using React - the "how" of the UI:
26+
- PageRenderer - Renders Page metadata
27+
- ComponentRenderer - Renders individual components
28+
- Template expression resolver for data binding
29+
- Complete integration examples
6030

6131
## 🎯 Key Concepts
6232

@@ -265,51 +235,56 @@ navigation: [
265235
]
266236
```
267237

268-
## 📝 File Structure
238+
## 📝 Directory Structure
269239

270240
```
271241
examples/ui/
272-
├── package.json # Package configuration
273-
├── tsconfig.json # TypeScript configuration
274242
├── README.md # This file
275-
├── src/ # Metadata examples (JSON/TypeScript)
276-
│ ├── view.examples.ts # List, Form, Kanban, Calendar views
277-
│ ├── page.examples.ts # Record, Home, App pages
278-
│ ├── dashboard.examples.ts # Widgets and analytics
279-
│ ├── action.examples.ts # Buttons and interactions
280-
│ ├── app.examples.ts # Application structure
281-
│ └── theme.examples.ts # Visual styling
243+
├── metadata-examples/ # UI metadata configurations
244+
│ ├── README.md
245+
│ ├── package.json
246+
│ ├── tsconfig.json
247+
│ └── src/
248+
│ ├── view.examples.ts # List, Form, Kanban, Calendar views
249+
│ ├── page.examples.ts # Record, Home, App pages
250+
│ ├── dashboard.examples.ts # Widgets and analytics
251+
│ ├── action.examples.ts # Buttons and interactions
252+
│ ├── app.examples.ts # Application structure
253+
│ └── theme.examples.ts # Visual styling
282254
├── custom-components/ # React component implementations
283255
│ ├── README.md
284-
│ ├── src/
285-
│ │ ├── components/
286-
│ │ │ ├── CustomButton.tsx
287-
│ │ │ └── CustomDataGrid.tsx
288-
│ │ └── registry.ts # Component registration
289-
│ └── package.json
256+
│ ├── package.json
257+
│ ├── tsconfig.json
258+
│ └── src/
259+
│ ├── components/
260+
│ │ ├── CustomButton.tsx
261+
│ │ └── CustomDataGrid.tsx
262+
│ └── registry.ts # Component registration
290263
└── react-renderer/ # React renderer for metadata
291264
├── README.md
292-
├── src/
293-
│ ├── renderers/
294-
│ │ ├── PageRenderer.tsx
295-
│ │ └── ComponentRenderer.tsx
296-
│ ├── utils/
297-
│ │ └── templateResolver.ts
298-
│ └── examples/
299-
│ └── SimpleApp.tsx
300-
└── package.json
265+
├── package.json
266+
├── tsconfig.json
267+
└── src/
268+
├── renderers/
269+
│ ├── PageRenderer.tsx
270+
│ └── ComponentRenderer.tsx
271+
├── utils/
272+
│ └── templateResolver.ts
273+
└── examples/
274+
└── SimpleApp.tsx
301275
```
302276

303277
## 🚀 Quick Start
304278

305279
### 1. View Metadata Examples
306280

307-
The TypeScript examples in `src/` show the metadata structure:
281+
Explore the TypeScript metadata configurations:
308282

309283
```bash
310-
# These are TypeScript files that demonstrate the protocol
311-
cat src/view.examples.ts
312-
cat src/app.examples.ts
284+
cd metadata-examples
285+
npm install
286+
npm run build
287+
# View the examples in src/
313288
```
314289

315290
### 2. Custom Components
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# UI Protocol Metadata Examples
2+
3+
This package contains TypeScript/JSON metadata examples demonstrating the ObjectStack UI Protocol.
4+
5+
## What's Inside
6+
7+
These are **configuration examples** (not implementations) showing how to define UI components using the ObjectStack metadata format:
8+
9+
- **view.examples.ts** - 17 examples: Grid, Kanban, Calendar, Gantt views with various data providers
10+
- **action.examples.ts** - 22 examples: Modal, Flow, Script, URL, and Batch actions
11+
- **dashboard.examples.ts** - 6 dashboards: Sales, Service, Executive, Marketing, and Team productivity
12+
- **page.examples.ts** - 9 page layouts: Record, Home, App, and Utility pages
13+
- **app.examples.ts** - 7 applications: Simple to comprehensive apps with hierarchical navigation
14+
- **theme.examples.ts** - 7 themes: Light, dark, colorful, minimal, and WCAG AAA compliant
15+
16+
## Usage
17+
18+
These are metadata definitions that describe the UI structure. To actually render them, see:
19+
20+
- `../custom-components/` - React component implementations
21+
- `../react-renderer/` - How to render this metadata with React
22+
23+
## Example
24+
25+
```typescript
26+
import { ListView } from '@objectstack/spec/ui';
27+
28+
// Grid view with custom API data source
29+
const ExternalApiGridView: ListView = {
30+
type: 'grid',
31+
data: {
32+
provider: 'api',
33+
read: {
34+
url: 'https://api.example.com/customers',
35+
headers: { 'Authorization': 'Bearer {token}' },
36+
},
37+
},
38+
columns: ['id', 'company_name', 'email', 'total_orders'],
39+
};
40+
```
41+
42+
## Building
43+
44+
```bash
45+
npm install
46+
npm run build
47+
```
48+
49+
## Related Examples
50+
51+
- `../custom-components/` - Custom React component implementations
52+
- `../react-renderer/` - React renderer for metadata
53+
- `../../crm/` - Complete CRM application example
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)