@almadar/ui

中文文档
6.66.0发布于 2026/10/14BSL-1.1TypeScriptESM + CJS近 30 天下载 2911

React UI components, hooks, and providers for Almadar

原始使用文档
文档目录30 节
  1. Features
  2. Quick Start
  3. Available Themes
  4. Scripts
  5. npm run storybook
  6. npm run build-storybook
  7. npm run generate <schema.orb> [options]
  8. npm run generate:theme <schema.orb> [output.css]
  9. npm run suggest:components <schema.orb> [--generate <dir>]
  10. Component Library Structure
  11. Theming
  12. Using a Theme
  13. CSS Variables
  14. Creating a Custom Theme
  15. Domain-Specific Components
  16. Garden/Agriculture Domain
  17. Healthcare Domain
  18. E-commerce Domain
  19. Game Domain
  20. Integration with Proposal Documents
  21. Client-Specific Components
  22. Directory Structure
  23. When to Create Client-Specific Components
  24. Creating Client-Specific Components
  25. Client Templates
  26. Syncing to Projects
  27. Development
  28. Adding New Components
  29. Adding New Themes
  30. Adding Domain-Specific Components

Orbital Design System

A themeable, domain-aware component library for Orbital applications. Generates client-specific design systems from .orb schemas.

Features

  • CSS Variable-Based Theming: All components use CSS variables, enabling easy theme switching
  • Domain Detection: Automatically detects domain (garden, healthcare, finance, etc.) from schema
  • Component Suggestions: Suggests domain-specific components based on schema analysis
  • Storybook Integration: Visual component documentation with theme switching
  • Static Export: Export design system as static HTML for client delivery

Quick Start

# Install dependencies
npm install

# Start Storybook for development
npm run storybook

# Generate a client-specific design system
npm run generate path/to/schema.orb

Available Themes

ThemeDescriptionBest For
wireframeHigh contrast, sharp edgesPrototyping
minimalistSoft, elegant, subtleCorporate apps
almadarBrand-specific stylingAl-Madar projects
winning-11Garden/organic themeAgriculture, nature

Scripts

npm run storybook

Start Storybook development server on port 6006.

npm run build-storybook

Build static Storybook documentation.

npm run generate <schema.orb> [options]

Generate a complete client-specific design system.

Options:

  • --output <dir> - Output directory (default: ./exports)
  • --name <name> - Client name override
  • --no-storybook - Skip Storybook build
  • --no-components - Skip component generation

Example:

npm run generate ../architecture/winning-11.orb --output ./clients

npm run generate:theme <schema.orb> [output.css]

Generate only the theme CSS from a schema.

npm run suggest:components <schema.orb> [--generate <dir>]

Analyze schema and suggest domain-specific components.

Component Library Structure

components/
├── atoms/           # Basic building blocks
│   ├── Button
│   ├── Input
│   ├── Badge
│   ├── Card
│   └── ...
├── molecules/       # Composite components
│   ├── Alert
│   ├── Modal
│   ├── Tabs
│   └── ...
├── organisms/       # Complex components
│   ├── DataTable
│   ├── Header
│   ├── Sidebar
│   └── ...
└── templates/       # Page layouts
    ├── AuthLayout
    ├── FormTemplate
    └── ...

Theming

Using a Theme

Apply a theme by setting data-design-theme attribute:

<html data-design-theme="winning-11">
  ...
</html>

Or in React:

<div data-design-theme="winning-11">
  <Button>Themed Button</Button>
</div>

CSS Variables

All components use CSS variables for theming:

/* Colors */
--color-primary
--color-primary-hover
--color-primary-foreground
--color-secondary
--color-secondary-foreground
--color-accent
--color-muted
--color-muted-foreground
--color-background
--color-foreground
--color-border

/* Shadows */
--shadow-sm
--shadow-main
--shadow-lg
--shadow-hover

/* Border Radius */
--radius-sm
--radius-md
--radius-lg
--radius-xl

/* Transitions */
--transition-fast
--transition-normal
--transition-slow

Creating a Custom Theme

  1. Create a CSS file in themes/:
[data-design-theme="my-theme"] {
    --color-primary: #your-color;
    --color-secondary: #your-color;
    /* ... other variables */
}
  1. Import in themes/index.css:
@import './my-theme.css';
  1. Add to Storybook preview (.storybook/preview.tsx):
themes: {
  // ...existing themes
  'my-theme': 'my-theme',
}

Domain-Specific Components

The generator suggests domain-specific components based on schema analysis:

Garden/Agriculture Domain

  • GardenView - Visual garden layout
  • PlantCard - Plant display with care indicators
  • GrowthMeter - Progress indicator for growth
  • TrustMeter - Trust/relationship indicator
  • CareIndicator - Water/sun/nutrient needs

Healthcare Domain

  • PatientCard - Patient information display
  • VitalsDisplay - Vital signs compact view
  • AppointmentSlot - Scheduling component

E-commerce Domain

  • ProductCard - Product with price and cart action
  • CartSummary - Cart overview
  • PriceTag - Formatted price display

Game Domain

  • CharacterStats - RPG-style stat display
  • QuestTracker - Active quest panel

Integration with Proposal Documents

The generated design system can be included in client proposals:

  1. Generate the design system:

    npm run generate ../architecture/winning-11.orb --output ./exports
    
  2. The export includes:

    • Theme CSS file
    • Component stubs (if domain detected)
    • Storybook documentation
    • Manifest with metadata
  3. Reference in proposal documents or deliver as standalone package.

Client-Specific Components

Client-specific components live in dedicated folders named after the client. These components:

  • Extend the core library - Use existing atoms/molecules, don't recreate them
  • Follow Atomic Design - Break down into atoms, molecules, organisms, templates
  • Include Storybook stories - Every component must have a .stories.tsx file
  • Are reusable - Can be used in future projects for the same client

Directory Structure

orbital-shared/design-system/
├── components/              # Core component library (shared across all clients)
│   ├── atoms/
│   ├── molecules/
│   ├── organisms/
│   └── templates/
├── clients/                 # Client-specific components
│   ├── winning-11/          # Winning-11 client
│   │   ├── atoms/           # Client-specific atoms (rare)
│   │   ├── molecules/       # Client-specific molecules
│   │   ├── organisms/       # Client-specific organisms
│   │   ├── templates/       # Client page templates/showcases
│   │   └── index.ts         # Barrel export
│   └── [other-client]/      # Another client folder
└── ...

When to Create Client-Specific Components

ScenarioWhere to Add
Generic component useful for any projectcomponents/ (core library)
Domain-specific styling of existing componentClient folder with composition
Unique business logic componentClient folder
Page template/showcaseclients/[name]/templates/

Creating Client-Specific Components

  1. Create in client folder:

    clients/winning-11/organisms/GardenLayout.tsx
    clients/winning-11/organisms/GardenLayout.stories.tsx
    
  2. Import from core library:

    import { Card, Badge } from '../../../components/atoms';
    import { Grid } from '../../../components/molecules';
    
  3. Export from client index:

    // clients/winning-11/index.ts
    export * from './organisms/GardenLayout';
    
  4. Create Storybook story:

    // GardenLayout.stories.tsx
    import type { Meta, StoryObj } from '@storybook/react';
    import { GardenLayout } from './GardenLayout';
    
    const meta: Meta<typeof GardenLayout> = {
      title: 'Clients/Winning-11/Organisms/GardenLayout',
      component: GardenLayout,
    };
    export default meta;
    

Client Templates

Templates showcase complete page layouts specific to the client. They demonstrate:

  • How components compose together
  • Realistic data patterns
  • Brand-specific styling
// clients/winning-11/templates/GardenDashboard.tsx
export const GardenDashboard = () => (
  <PageLayout>
    <Header />
    <GardenStats />
    <PlantGrid plants={mockPlants} />
  </PageLayout>
);

Syncing to Projects

When generating a client project, client-specific components are copied:

npm run generate schema.orb --client winning-11 --output ../projects/winning-11

This copies:

  • Core components/ library
  • Client-specific clients/winning-11/ folder
  • Themes and hooks

Development

Adding New Components

  1. Create component in appropriate category (atoms/, molecules/, organisms/)
  2. Create corresponding .stories.tsx file
  3. Export from category's index.ts
  4. Verify in Storybook

Adding New Themes

  1. Create theme CSS in themes/
  2. Follow existing theme structure for CSS variables
  3. Add import to themes/index.css
  4. Add to Storybook theme selector

Adding Domain-Specific Components

  1. Add domain config to scripts/suggest-components.ts
  2. Define keywords and component suggestions
  3. Test with schema from that domain

版本与发布记录

@almadar/ui 共发布 723 个版本,首次发布于 2026/02/05;过去 12 个月发布了 723 个版本。

版本发布日期距今
6.66.0latest2026/10/1424 天前
6.65.02026/10/1226 天前
6.64.02026/10/1226 天前
6.63.02026/10/1227 天前
6.62.02026/10/1127 天前
6.61.02026/10/1028 天前

关于 @almadar/ui 的常见问题

@almadar/ui 是什么?

React UI components, hooks, and providers for Almadar

如何安装 @almadar/ui?

在项目目录运行 npm install @almadar/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.0.0)、react-dom(>=18.0.0)、react-router-dom(^7.0.0)、@tanstack/react-query(^5.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@almadar/ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@almadar/ui 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@almadar/ui 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@almadar/ui 可以商用吗?

@almadar/ui 使用 BSL-1.1 许可。声明的许可为 BSL-1.1,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@almadar/ui 的下载量有多少?

根据 npm 官方下载统计,@almadar/ui 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,911 次,日均约 97 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@almadar/ui 还在维护吗?

最新版本 6.66.0 发布于 2026/10/14(24 天前);至今共发布 723 个版本,其中过去 12 个月发布了 723 个;首次发布于 2026/02/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。