# RN Work UIKit Development Guide

## Overview
This package contains work-specific React Native components that extend the base `@hero-design/rn` design system. Components here are tailored for work applications with specific themes, accessibility requirements, and interaction patterns.

## Development Rules

### Component Architecture
- **Extend Base Components**: Build upon `@hero-design/rn` components when possible
- **Theme Integration**: Use `useTheme()` hook, import `styled` from `@hero-design/rn`
- **Work-Specific**: Components should work with work theme overrides and requirements
- **TypeScript**: Strict typing, no `any` types without good reason

### Testing Standards
- **User-Behavior Focused**: Write tests that describe what users see and experience
- **Test Structure**: Use descriptive names like "when user sees an empty input field"
- **Coverage**: Aim for 100% line coverage on main component files
- **Testing Library**: Use `@testing-library/react-native` exclusively
- **Theme Testing**: Use `renderWithTheme()` from `../../../../testUtils/renderWithTheme`

### Test Patterns
```typescript
describe('ComponentName', () => {
  describe('when user encounters [scenario]', () => {
    it('should [expected user experience]', () => {
      // User performs action
      const { getByTestId } = renderWithTheme(<Component />);
      
      // User should see expected result
      expect(getByTestId('element')).toBeTruthy();
    });
  });
});
```

### File Organization
```
src/
├── components/
│   └── ComponentName/
│       ├── index.tsx                 # Main component
│       ├── ComponentName.tsx         # Implementation
│       ├── types.ts                  # TypeScript types
│       ├── constants.ts              # Constants
│       └── __tests__/
│           ├── index.spec.tsx        # Integration tests
│           ├── ComponentName.spec.tsx # Unit tests
│           └── README.md             # Test documentation
├── theme/                            # Work-specific theme overrides
├── testUtils/                        # Test utilities
└── utils/                            # Shared utilities
```

### Testing Checklist
- [ ] User-behavior focused test names
- [ ] All props and combinations tested
- [ ] Edge cases: undefined props, error states
- [ ] Accessibility: screen readers, keyboard navigation
- [ ] Imperative APIs: ref methods, focus/blur
- [ ] Animation states and visibility
- [ ] Theme compatibility (base + work themes)
- [ ] Performance with work-typical data
- [ ] Semantic matchers used where possible
- [ ] React Native components in tests (not HTML)

### Code Quality
- [ ] No linting errors
- [ ] No TypeScript errors
- [ ] 100% test coverage on main components
- [ ] Accessibility compliance
- [ ] Performance benchmarks met
- [ ] Work theme compatibility verified

### Common Patterns

#### Theme Usage
```typescript
import { useTheme } from '../../theme';
import { styled } from '@hero-design/rn';

const StyledComponent = styled.View<{ themeState: State }>(
  ({ theme, themeState }) => ({
    backgroundColor: theme.__hd__.componentName.colors.background[themeState],
  })
);
```

#### Testing Styles
```typescript
// For simple styles
expect(element).toHaveProp('style', { color: '#000000' });

// For complex React Native styles
const flattenedStyle = StyleSheet.flatten(element.props.style);
expect(flattenedStyle.backgroundColor).toBe('#ffffff');
```

#### Testing Accessibility
```typescript
expect(element).toHaveProp('accessibilityElementsHidden', false);
expect(element).toBeDisabled(); // Use semantic matchers
```

## Work-Specific Requirements
- Components must work in work applications
- Follow work accessibility guidelines
- Test with work-specific color palettes
- Ensure performance with work data sizes
- Maintain compatibility with work app requirements

## Getting Started
1. Create component following file structure
2. Implement with work theme integration
3. Write comprehensive tests following patterns
4. Ensure 100% coverage and quality gates
5. Document component usage and patterns

Remember: Focus on what users experience, not how code works internally. 