LogoLogo
  • What is UDML?
  • Document structure
    • <components>
    • <imports>
    • <instructions>
    • <meta>
    • <styles>
    • <tokens>
    • <mappings>
    • <screens>
  • Directives
    • ai-hint
    • <data> Directive Specification
    • <interaction> Directive
    • <layer> Directive
    • <repeat> Directive
    • <responsive>
    • selection
    • <tracking> Directive
  • Components
    • Layout
      • <accordion> Component
      • <box> Component
      • <column> Component
      • <divider>
      • <grid> Component
      • <row> Component
    • Navigation
      • <breadcrumbs> Component
      • <pagination> Component
      • <tab> Component
      • <tabs> Component
    • Text & Display
      • <avatar>
      • <heading>
      • <icon>
      • <image>
      • <label>
      • <text>
      • <video>
    • Controls & Input
      • <button>
      • <checkbox>
      • <input> Component
      • <radio>
      • <select>
      • <slider>
      • <stepper>
      • <switch>
      • <textarea>
    • Forms
      • <form> Component
      • <formField> Component
      • <formGroup> Component
    • Data Collections
      • <dataColumn> Component
      • <dataTable> Component
      • <list> Component
      • <timeline> Component
      • <treeView> Component
    • Data Visualization
      • <chart> Component
      • <summary> Component
    • Modals
      • <dialog> Component
      • <modal> Component
      • <popover> Component
      • <toast> Component
      • <tooltip> Component
  • Prompting Guides
    • Prompting AI Developer Tools with UDML
    • Working with UDML in an Existing Codebase
  • Contributing to UDML
Powered by GitBook
On this page
  • Purpose
  • Structure
  • Mapping Types
  • 1. Component Mappings
  • 2. Design Token Mappings
  • 3. Pattern Mappings
  • Generation Tools
  • 1. Storybook Integration
  • 2. VS Code Extension
  • 3. CLI Tools
  • Usage in UDML
  • Benefits
  • Future Enhancements
Edit on GitHub
  1. Document structure

<mappings>

The <mappings> section defines how UDML elements map to your existing codebase. It serves as a bridge between UDML's semantic markup and your actual implementation components, styles, and patterns.

Purpose

The mappings section enables:

  • Automatic translation of UDML to your existing components

  • Type-safe prop handling

  • Design system integration

  • Pattern reuse

  • Real-time updates as your codebase evolves

Structure

<mappings>
  <!-- Component Mappings -->
  <components>
    <component 
      name="button"
      path="src/components/Button/Button.tsx"
      props="{
        variant: 'primary' | 'secondary' | 'tertiary',
        size: 'sm' | 'md' | 'lg',
        disabled: boolean,
        onClick: () => void
      }"
    >
      <story name="Primary"/>
      <story name="Secondary"/>
    </component>
  </components>

  <!-- Design Tokens -->
  <tokens>
    <color name="primary" value="theme.colors.primary" />
    <spacing name="sm" value="theme.spacing.sm" />
    <typography name="heading1" value="theme.typography.heading1" />
  </tokens>

  <!-- Patterns -->
  <patterns>
    <form name="userProfile" validation="src/utils/validation/userProfile.ts" />
    <layout name="dashboard" template="src/templates/Dashboard.tsx" />
  </patterns>
</mappings>

Mapping Types

1. Component Mappings

  • Maps UDML elements to React components

  • Defines prop types and interfaces

  • Includes Storybook stories for examples

  • Supports component variants

2. Design Token Mappings

  • Maps UDML style attributes to design tokens

  • Supports colors, spacing, typography

  • Integrates with your theme system

  • Enables consistent styling

3. Pattern Mappings

  • Defines reusable UI patterns

  • Includes validation rules

  • Specifies layout templates

  • Supports complex component compositions

Generation Tools

1. Storybook Integration

  • Automatically generates mappings from Storybook components

  • Extracts prop types and stories

  • Updates mappings when components change

  • Integrates with Storybook's documentation

2. VS Code Extension

  • Real-time mapping generation

  • Watches for component changes

  • Provides IntelliSense for UDML

  • Supports custom mapping rules

3. CLI Tools

  • Batch generation of mappings

  • Migration of existing components

  • Validation of mappings

  • Export to different formats

Usage in UDML

<screen name="UserProfile">
  <!-- Uses mapped Button component -->
  <button variant="primary" size="md">
    Save Changes
  </button>

  <!-- Uses mapped design tokens -->
  <text typography="heading1" color="primary">
    Edit Profile
  </text>

  <!-- Uses mapped form pattern -->
  <form name="userProfile">
    <input name="email" type="email"/>
  </form>
</screen>

Benefits

  1. Type Safety

    • Prop types are enforced

    • Design tokens are validated

    • Patterns are type-checked

  2. Maintainability

    • Single source of truth

    • Automatic updates

    • Clear documentation

  3. Developer Experience

    • IntelliSense support

    • Real-time feedback

    • Easy migration

  4. Design System Integration

    • Consistent styling

    • Pattern reuse

    • Theme support

Future Enhancements

  1. Advanced Pattern Support

    • Nested patterns

    • Conditional rendering

    • Dynamic content

  2. State Management

    • Form state

    • UI state

    • Data fetching

  3. Testing Integration

    • Component testing

    • Pattern testing

    • Accessibility testing

  4. Performance Optimization

    • Code splitting

    • Lazy loading

    • Bundle analysis

Previous<tokens>Next<screens>

Last updated 2 months ago