@thecb/components 11.5.2 → 11.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/ai-docs/architecture.md +71 -0
- package/ai-docs/components.md +167 -0
- package/ai-docs/conventions.md +162 -0
- package/ai-docs/figma-mcp.md +66 -0
- package/ai-docs/integration-guidelines.md +142 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CityBase Components
|
|
2
2
|
|
|
3
|
-
This library contains CityBase React components for use across all current and future CB applications (NFE, RMD,
|
|
3
|
+
This library contains CityBase React components for use across all current and future CB applications (NFE, RMD, POS).
|
|
4
4
|
|
|
5
5
|
<!-- TOC -->
|
|
6
6
|
|
|
@@ -177,6 +177,16 @@ To import multiple components
|
|
|
177
177
|
|
|
178
178
|
- `import { ButtonWithAction, LoginForm, Box, Stack, Cluster } from "@thecb/components";`
|
|
179
179
|
|
|
180
|
+
### AI Documentation (`ai-docs/`)
|
|
181
|
+
|
|
182
|
+
The `ai-docs/` directory contains documentation specifically tailored for AI assistants:
|
|
183
|
+
|
|
184
|
+
- **Architecture Overview** (`architecture.md`): System design patterns, atomic design principles, theming architecture, and build system information
|
|
185
|
+
- **Component Structure** (`components.md`): Component hierarchy, layout primitives, form components, and usage patterns
|
|
186
|
+
- **Coding Conventions** (`conventions.md`): Development standards, naming conventions, and best practices for component development
|
|
187
|
+
- **Figma MCP Integration** (`figma-mcp.md`): Guidelines for using Figma MCP tools to generate components from designs
|
|
188
|
+
- **Integration Guidelines** (`integration-guidelines.md`): Step-by-step process for implementing @thecb/components in applications, including required examination of source code, TypeScript definitions, and usage patterns
|
|
189
|
+
|
|
180
190
|
```
|
|
181
191
|
|
|
182
192
|
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Architecture Overview
|
|
2
|
+
|
|
3
|
+
## Project Type
|
|
4
|
+
|
|
5
|
+
`@thecb/components` - React component library for CityBase apps (NFE, RMD, POS)
|
|
6
|
+
|
|
7
|
+
## Core Patterns
|
|
8
|
+
|
|
9
|
+
### Atomic Design
|
|
10
|
+
|
|
11
|
+
- **Atoms**: Layout primitives, form controls, display components
|
|
12
|
+
- **Molecules**: Composed components (forms, modals, navigation)
|
|
13
|
+
- **Templates**: Page-level layouts
|
|
14
|
+
|
|
15
|
+
### Layout-First Architecture
|
|
16
|
+
|
|
17
|
+
- **Composition**: All components built using layout primitives (Box, Stack, Cluster, Center, Grid)
|
|
18
|
+
- **Prop-Based Styling**: Styling via props, not custom CSS
|
|
19
|
+
- **Layout Primitives**: Foundation atoms for all other components
|
|
20
|
+
|
|
21
|
+
### Theming System
|
|
22
|
+
|
|
23
|
+
- **FCS Integration**: Dynamic theming via Frontend Configuration Service
|
|
24
|
+
- **Fallback Values**: `.theme.js` files with defaults
|
|
25
|
+
- **Variants**: primary, secondary, danger, ghost, link
|
|
26
|
+
- **Theme Context**: React Context + styled-components ThemeProvider
|
|
27
|
+
- **Client Customization**: Per-client theme overrides
|
|
28
|
+
|
|
29
|
+
### Build System
|
|
30
|
+
|
|
31
|
+
- **Rollup**: Bundler outputting CommonJS + ES modules
|
|
32
|
+
- **Tree Shaking**: ES module support
|
|
33
|
+
- **TypeScript**: Declaration file generation
|
|
34
|
+
- **Storybook**: Development environment
|
|
35
|
+
|
|
36
|
+
## Component Philosophy
|
|
37
|
+
|
|
38
|
+
- **Stateless**: Minimal internal state
|
|
39
|
+
- **Reusable**: Multi-application usage only
|
|
40
|
+
- **Separation**: Business logic in consuming apps
|
|
41
|
+
- **Composable**: Built from smaller atoms
|
|
42
|
+
|
|
43
|
+
## Technical Stack
|
|
44
|
+
|
|
45
|
+
- **React**: Core framework
|
|
46
|
+
- **Styled Components**: CSS-in-JS styling
|
|
47
|
+
- **Redux-Freeform**: Form state management
|
|
48
|
+
- **TypeScript**: Type definitions
|
|
49
|
+
- **Rollup**: Build system
|
|
50
|
+
- **Storybook**: Documentation
|
|
51
|
+
|
|
52
|
+
## Directory Structure
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
src/
|
|
56
|
+
├── components/ # Atoms, molecules, templates
|
|
57
|
+
├── constants/ # Colors, styles, patterns
|
|
58
|
+
├── hooks/ # React hooks
|
|
59
|
+
├── types/ # TypeScript definitions
|
|
60
|
+
├── util/ # Helper functions
|
|
61
|
+
└── index.js # Main export
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Key Decisions
|
|
65
|
+
|
|
66
|
+
- **CSS-in-JS**: No global CSS conflicts
|
|
67
|
+
- **Layout Primitives**: Standardized spacing/positioning
|
|
68
|
+
- **Theme Integration**: Dynamic configuration support
|
|
69
|
+
- **Semantic Versioning**: Manual version management
|
|
70
|
+
- **ES Modules**: Tree-shaking enabled
|
|
71
|
+
- **Accessibility**: ARIA support built-in
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Component Structure
|
|
2
|
+
|
|
3
|
+
## Atomic Design Hierarchy
|
|
4
|
+
|
|
5
|
+
### Atoms (`src/components/atoms/`)
|
|
6
|
+
|
|
7
|
+
#### Layout Primitives
|
|
8
|
+
|
|
9
|
+
Core atoms for all other components:
|
|
10
|
+
|
|
11
|
+
- **Box**: Container with padding, borders, styling
|
|
12
|
+
- **Stack**: Vertical/horizontal spacing with margins
|
|
13
|
+
- **Cluster**: Wrapping elements with consistent gaps
|
|
14
|
+
- **Center**: Horizontal centering with gutters
|
|
15
|
+
- **Grid**: Responsive auto-fill grid layout
|
|
16
|
+
- **Cover**: Full viewport with header/footer
|
|
17
|
+
- **Frame**: Aspect ratio container
|
|
18
|
+
- **Switcher**: Responsive horizontal/vertical layout
|
|
19
|
+
|
|
20
|
+
#### Form Components
|
|
21
|
+
|
|
22
|
+
- **FormInput**: Complete input with validation (see source code and TypeScript definitions)
|
|
23
|
+
- **FormSelect**: Dropdown with form integration (see source code and TypeScript definitions)
|
|
24
|
+
- **Dropdown**: Accessible combobox with search (see source code and TypeScript definitions)
|
|
25
|
+
- **ButtonWithAction**: Primary button (variants: primary, secondary, danger)
|
|
26
|
+
- **Checkbox**: Form checkbox with label
|
|
27
|
+
- **ToggleSwitch**: On/off toggle
|
|
28
|
+
- **TypeaheadInput**: Autocomplete input
|
|
29
|
+
|
|
30
|
+
#### Display Components
|
|
31
|
+
|
|
32
|
+
- **Table**: 6-component table system (see source code and TypeScript definitions)
|
|
33
|
+
- **Alert**: Notifications (variants: info, warning, error, success)
|
|
34
|
+
- **Badge**: Status indicators
|
|
35
|
+
- **Card**: Content containers
|
|
36
|
+
- **Text**: Typography component with variants
|
|
37
|
+
- **Title**: Responsive headings
|
|
38
|
+
- **Loading**: Spinners and skeletons
|
|
39
|
+
|
|
40
|
+
#### Navigation Components
|
|
41
|
+
|
|
42
|
+
- **Breadcrumb**: Navigation breadcrumbs
|
|
43
|
+
- **NavTabs**: Tab navigation
|
|
44
|
+
- **Search**: Search input
|
|
45
|
+
|
|
46
|
+
### Molecules (Composed Components)
|
|
47
|
+
|
|
48
|
+
Located in `src/components/molecules/` - These combine multiple atoms to create more complex functionality.
|
|
49
|
+
|
|
50
|
+
#### Form Molecules
|
|
51
|
+
|
|
52
|
+
- **AddressForm**: Complete address input form
|
|
53
|
+
- **ChangePasswordForm**: Password change form
|
|
54
|
+
- **EditNameForm**: Name editing form
|
|
55
|
+
- **EmailForm**: Email input form
|
|
56
|
+
- **ForgotPasswordForm**: Password reset request form
|
|
57
|
+
- **LoginForm**: User login form
|
|
58
|
+
- **PhoneForm**: Phone number input form
|
|
59
|
+
- **RegistrationForm**: User registration form
|
|
60
|
+
- **ResetPasswordForm**: Password reset form
|
|
61
|
+
- **ResetConfirmationForm**: Password reset confirmation
|
|
62
|
+
- **ResetPasswordSuccess**: Success state for password reset
|
|
63
|
+
|
|
64
|
+
#### Payment Molecules
|
|
65
|
+
|
|
66
|
+
- **PaymentDetails**: Payment information display
|
|
67
|
+
- **PaymentFormACH**: ACH payment form
|
|
68
|
+
- **PaymentFormCard**: Credit card payment form
|
|
69
|
+
- **PaymentButtonBar**: Payment action buttons
|
|
70
|
+
- **PartialAmountForm**: Partial payment amount form
|
|
71
|
+
|
|
72
|
+
#### UI Molecules
|
|
73
|
+
|
|
74
|
+
- **Banner**: Page banner component
|
|
75
|
+
- **CollapsibleSection**: Expandable content section
|
|
76
|
+
- **Copyable**: Copy-to-clipboard component
|
|
77
|
+
- **EditableList**: List with inline editing
|
|
78
|
+
- **EditableTable**: Table with inline editing
|
|
79
|
+
- **HeroImage**: Hero image with overlay content
|
|
80
|
+
- **IdleModal**: Session timeout modal
|
|
81
|
+
- **LinkCard**: Card with link functionality
|
|
82
|
+
- **Modal**: Modal dialog component
|
|
83
|
+
- **Module**: Content section with title
|
|
84
|
+
- **Obligation**: User account display component
|
|
85
|
+
- **Pagination**: Page navigation
|
|
86
|
+
- **Popover**: Popup content
|
|
87
|
+
- **PopupMenu**: Context menu
|
|
88
|
+
- **RadioGroup**: Group of radio buttons
|
|
89
|
+
- **RadioSection**: Radio button section
|
|
90
|
+
- **Tabs**: Tabbed interface
|
|
91
|
+
- **TabSidebar**: Sidebar with tabs
|
|
92
|
+
- **ToastNotification**: Toast notification
|
|
93
|
+
- **WelcomeModule**: Welcome message component
|
|
94
|
+
|
|
95
|
+
#### Navigation Molecules
|
|
96
|
+
|
|
97
|
+
- **FooterWithSubfooter**: Footer with sub-footer
|
|
98
|
+
- **NavMenu**: Navigation menu
|
|
99
|
+
- **TabNavigation**: Tab-based navigation
|
|
100
|
+
- **TabSidebar**: Sidebar with tab navigation
|
|
101
|
+
|
|
102
|
+
#### Specialized Molecules
|
|
103
|
+
|
|
104
|
+
- **ContactCard**: Contact information display
|
|
105
|
+
- **MultipleSelectFilter**: Multi-select filter component
|
|
106
|
+
- **PeriscopeDashboardIframe**: Dashboard iframe embed
|
|
107
|
+
- **RegistrationBanner**: Registration promotion banner
|
|
108
|
+
- **TermsAndConditions**: Terms and conditions display
|
|
109
|
+
- **TermsAndConditionsModal**: Terms modal
|
|
110
|
+
- **Timeout**: Session timeout component
|
|
111
|
+
- **TurnstileWidget**: Cloudflare Turnstile widget
|
|
112
|
+
- **WorkflowTile**: Workflow step tile
|
|
113
|
+
|
|
114
|
+
### Templates (Page Layouts)
|
|
115
|
+
|
|
116
|
+
Located in `src/components/templates/` - High-level page structure components.
|
|
117
|
+
|
|
118
|
+
- **CenterSingle**: Centered single column layout
|
|
119
|
+
- **CenterStack**: Centered stacked layout
|
|
120
|
+
- **DefaultPageTemplate**: Standard page template
|
|
121
|
+
- **SidebarSingleContent**: Sidebar with single content area
|
|
122
|
+
- **SidebarStackContent**: Sidebar with stacked content areas
|
|
123
|
+
|
|
124
|
+
### Component Directory Structure
|
|
125
|
+
|
|
126
|
+
For detailed directory structure and file organization patterns, see [Coding Conventions](./conventions.md#directory-structure).
|
|
127
|
+
|
|
128
|
+
Each component follows a consistent directory structure:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
component-name/
|
|
132
|
+
├── ComponentName.js # Main component file
|
|
133
|
+
├── ComponentName.styled.js # Styled components
|
|
134
|
+
├── ComponentName.theme.js # Theme configuration
|
|
135
|
+
├── ComponentName.stories.js # Storybook stories
|
|
136
|
+
├── ComponentName.mdx # Documentation
|
|
137
|
+
└── index.js # Export file
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Component Variants
|
|
141
|
+
|
|
142
|
+
Most components support variants for different use cases:
|
|
143
|
+
|
|
144
|
+
- **ButtonWithAction**: primary, secondary, danger, ghost, link
|
|
145
|
+
- **Alert**: info, warning, error, success
|
|
146
|
+
- **Badge**: danger, neutral, success, warning
|
|
147
|
+
- **Card**: default, elevated, outlined
|
|
148
|
+
|
|
149
|
+
## Theme Integration
|
|
150
|
+
|
|
151
|
+
> **Note**: For comprehensive theming system details, see [Architecture Overview](./architecture.md#theming-system).
|
|
152
|
+
|
|
153
|
+
Each component includes:
|
|
154
|
+
|
|
155
|
+
- **Theme File**: `.theme.js` with fallback values
|
|
156
|
+
- **Theme Props**: `themeValues`, `variant`, `metadata` props
|
|
157
|
+
- **Styled Components**: Theme-aware styling
|
|
158
|
+
- **FCS Integration**: Dynamic theming via Frontend Configuration Service
|
|
159
|
+
|
|
160
|
+
## Component Exports
|
|
161
|
+
|
|
162
|
+
Components are exported through index files:
|
|
163
|
+
|
|
164
|
+
- `src/components/atoms/index.js` - All atom exports
|
|
165
|
+
- `src/components/molecules/index.js` - All molecule exports
|
|
166
|
+
- `src/components/templates/index.js` - All template exports
|
|
167
|
+
- `src/index.js` - Main library export
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Coding Conventions
|
|
2
|
+
|
|
3
|
+
## File Structure
|
|
4
|
+
|
|
5
|
+
### Component Files (Required)
|
|
6
|
+
|
|
7
|
+
- `ComponentName.js` - Main component (PascalCase)
|
|
8
|
+
- `ComponentName.theme.js` - Theme configuration with fallbacks
|
|
9
|
+
- `ComponentName.stories.js` - Storybook stories
|
|
10
|
+
- `index.js` - Export file
|
|
11
|
+
- `index.d.ts` - TypeScript definitions
|
|
12
|
+
- Optional: `ComponentName.styled.js`, `ComponentName.mdx`
|
|
13
|
+
|
|
14
|
+
### Directory Naming
|
|
15
|
+
|
|
16
|
+
- Component directories: `kebab-case` (e.g., `button-with-action/`)
|
|
17
|
+
- Files: `camelCase.js` for utilities, constants
|
|
18
|
+
|
|
19
|
+
## Component Structure Pattern
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import React, { forwardRef } from "react";
|
|
23
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
24
|
+
import { fallbackValues } from "./ComponentName.theme";
|
|
25
|
+
import { Box, Stack } from "../../atoms/layouts";
|
|
26
|
+
|
|
27
|
+
const ComponentName = forwardRef(
|
|
28
|
+
({ variant = "default", children, ...props }, ref) => {
|
|
29
|
+
return (
|
|
30
|
+
<Box ref={ref} {...props}>
|
|
31
|
+
{children}
|
|
32
|
+
</Box>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export default themeComponent(
|
|
38
|
+
ComponentName,
|
|
39
|
+
"ComponentName",
|
|
40
|
+
fallbackValues,
|
|
41
|
+
"default"
|
|
42
|
+
);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Required Imports Order
|
|
46
|
+
|
|
47
|
+
1. React imports: `import React, { forwardRef } from "react"`
|
|
48
|
+
2. Layout imports: `import { Box, Stack } from "../../atoms/layouts"`
|
|
49
|
+
3. Utilities: `import { themeComponent } from "../../../util/themeUtils"`
|
|
50
|
+
4. Constants: `import { PRIMARY_BLUE } from "../../../constants/colors"`
|
|
51
|
+
5. Local: `import { fallbackValues } from "./ComponentName.theme"`
|
|
52
|
+
|
|
53
|
+
## Theming Pattern
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// ComponentName.theme.js
|
|
57
|
+
export const fallbackValues = {
|
|
58
|
+
backgroundColor: {
|
|
59
|
+
primary: "#0074D9",
|
|
60
|
+
secondary: "#6C757D",
|
|
61
|
+
danger: "#DC3545"
|
|
62
|
+
},
|
|
63
|
+
padding: { small: "0.5rem", medium: "1rem", large: "1.5rem" },
|
|
64
|
+
fontSize: "1rem"
|
|
65
|
+
};
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Styled Components (when needed)
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// ComponentName.styled.js
|
|
72
|
+
import styled from "styled-components";
|
|
73
|
+
|
|
74
|
+
export const ComponentNameWrapper = styled.div`
|
|
75
|
+
padding: ${props => props.padding || "1rem"};
|
|
76
|
+
background-color: ${props => props.themeValues?.backgroundColor || "white"};
|
|
77
|
+
`;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Component Props Convention
|
|
81
|
+
|
|
82
|
+
### Base Props (Standard)
|
|
83
|
+
|
|
84
|
+
- `variant` - Component variant (primary, secondary, danger, ghost, link)
|
|
85
|
+
- `themeValues` - Theme overrides object
|
|
86
|
+
- `metadata` - Component metadata
|
|
87
|
+
- `children` - React children
|
|
88
|
+
- Layout props: `padding`, `margin`, `width`, `height`
|
|
89
|
+
- HTML props: Spread remaining props to DOM elements
|
|
90
|
+
|
|
91
|
+
## TypeScript Pattern
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// index.d.ts
|
|
95
|
+
import React from "react";
|
|
96
|
+
import Expand from "../../../util/expand";
|
|
97
|
+
|
|
98
|
+
export interface ComponentNameProps {
|
|
99
|
+
variant?: "primary" | "secondary" | "danger";
|
|
100
|
+
children?: React.ReactNode;
|
|
101
|
+
onClick?: () => void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const ComponentName: React.FC<Expand<ComponentNameProps> &
|
|
105
|
+
React.HTMLAttributes<HTMLElement>>;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Storybook Stories Pattern
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
// ComponentName.stories.js
|
|
112
|
+
import ComponentName from "./ComponentName";
|
|
113
|
+
|
|
114
|
+
export default {
|
|
115
|
+
title: "Atoms/ComponentName",
|
|
116
|
+
component: ComponentName,
|
|
117
|
+
argTypes: {
|
|
118
|
+
variant: {
|
|
119
|
+
control: { type: "select" },
|
|
120
|
+
options: ["primary", "secondary", "danger"]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const Primary = {
|
|
126
|
+
args: { variant: "primary", children: "Example" }
|
|
127
|
+
};
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Development Standards
|
|
131
|
+
|
|
132
|
+
### Code Style
|
|
133
|
+
|
|
134
|
+
- Use modern JS (ES6+), functional components, destructuring
|
|
135
|
+
- Use `forwardRef` for ref passing
|
|
136
|
+
- Use `React.memo` for performance optimization
|
|
137
|
+
- Follow atomic design with layout primitives (Box, Stack, Cluster)
|
|
138
|
+
|
|
139
|
+
### Git Conventions
|
|
140
|
+
|
|
141
|
+
- Commits: `type(scope): description` (feat, fix, docs, style, refactor, test, chore)
|
|
142
|
+
- Branches: `feature/component-name`, `fix/issue-description`
|
|
143
|
+
|
|
144
|
+
### Testing & Quality
|
|
145
|
+
|
|
146
|
+
- Storybook stories for all variants
|
|
147
|
+
- Visual testing with Chromatic
|
|
148
|
+
- Accessibility testing with axe-playwright
|
|
149
|
+
- Cross-application integration testing
|
|
150
|
+
|
|
151
|
+
### Performance
|
|
152
|
+
|
|
153
|
+
- ES modules for tree shaking
|
|
154
|
+
- Minimize external dependencies
|
|
155
|
+
- Use layout primitives instead of custom CSS
|
|
156
|
+
|
|
157
|
+
### Accessibility Requirements
|
|
158
|
+
|
|
159
|
+
- Proper ARIA labels and roles
|
|
160
|
+
- Keyboard navigation support
|
|
161
|
+
- Semantic HTML elements
|
|
162
|
+
- Screen reader compatibility
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# AI-Optimized Figma Integration Guide
|
|
2
|
+
|
|
3
|
+
**Quick Reference**: Essential workflow and patterns for converting Figma designs to CityBase Components.
|
|
4
|
+
|
|
5
|
+
## Mandatory Workflow
|
|
6
|
+
|
|
7
|
+
1. **`get_code`** → structured component representation
|
|
8
|
+
2. **`get_screenshot`** → visual reference
|
|
9
|
+
3. **Download assets** → icons, images if needed
|
|
10
|
+
4. **Translate** → project conventions (layout primitives, theme tokens)
|
|
11
|
+
5. **Validate** → 1:1 visual parity with Figma
|
|
12
|
+
|
|
13
|
+
## Translation Rules
|
|
14
|
+
|
|
15
|
+
### Code Conversion
|
|
16
|
+
|
|
17
|
+
- **Figma MCP output** = design reference only (ignore Tailwind classes)
|
|
18
|
+
- **Use layout primitives**: Box, Stack, Cluster (not custom CSS)
|
|
19
|
+
- **Map to existing components**: Text, Title, Detail, Button
|
|
20
|
+
- **Apply theme tokens**: colors, typography, spacing from constants
|
|
21
|
+
|
|
22
|
+
### Design System Integration
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
// Colors
|
|
26
|
+
import { COLORS, ALERT_COLORS } from 'src/constants/colors.js';
|
|
27
|
+
|
|
28
|
+
// Typography
|
|
29
|
+
<Text variant="p"> // Use Text component variants
|
|
30
|
+
<Title level={2}> // Use Title for headings
|
|
31
|
+
|
|
32
|
+
// Spacing
|
|
33
|
+
<Box padding={SPACING.lg}> // Use SPACING constants
|
|
34
|
+
<Stack gap={SPACING.md}> // Apply through layout primitives
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Implementation Checklist
|
|
38
|
+
|
|
39
|
+
**Component Creation**:
|
|
40
|
+
|
|
41
|
+
- [ ] Main component with `themeComponent` wrapper
|
|
42
|
+
- [ ] `.theme.js` with fallback values
|
|
43
|
+
- [ ] `.stories.js` with all variants
|
|
44
|
+
- [ ] `index.d.ts` TypeScript definitions
|
|
45
|
+
- [ ] Export in appropriate index files
|
|
46
|
+
|
|
47
|
+
**Visual Validation**:
|
|
48
|
+
|
|
49
|
+
- [ ] 1:1 parity with Figma screenshot
|
|
50
|
+
- [ ] All interactive states work
|
|
51
|
+
- [ ] Responsive behavior correct
|
|
52
|
+
- [ ] Theme variants applied
|
|
53
|
+
|
|
54
|
+
**Icons**:
|
|
55
|
+
|
|
56
|
+
- [ ] SVG components in `src/components/atoms/icons/`
|
|
57
|
+
- [ ] Use theme colors directly in SVG
|
|
58
|
+
- [ ] Name as `[Descriptive]Icon`
|
|
59
|
+
- [ ] Export from icons index
|
|
60
|
+
|
|
61
|
+
## Quick Reference Locations
|
|
62
|
+
|
|
63
|
+
**Constants**: `src/constants/colors.js`, `src/constants/style_constants.js`
|
|
64
|
+
**Layout Primitives**: `src/components/atoms/layouts/`
|
|
65
|
+
**Theme Utils**: `src/util/themeUtils.js`
|
|
66
|
+
**Component Pattern**: See source code and TypeScript definitions in component directories
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# @thecb/components Integration Guidelines
|
|
2
|
+
|
|
3
|
+
## Component Documentation
|
|
4
|
+
|
|
5
|
+
For detailed component implementation guidance, refer to the source code and TypeScript definitions:
|
|
6
|
+
|
|
7
|
+
- **Layout primitives**: `src/components/atoms/layouts/` - Box, Stack, Cluster, Center, Grid
|
|
8
|
+
- **Form components**: `src/components/atoms/form-layouts/`, `src/components/atoms/form-select/`, `src/components/atoms/dropdown/`
|
|
9
|
+
- **Display components**: `src/components/atoms/table/`, `src/components/molecules/modal/`
|
|
10
|
+
|
|
11
|
+
## Implementation Process
|
|
12
|
+
|
|
13
|
+
1. **Examine Source Code**: Review component implementation in source files
|
|
14
|
+
2. **Verify Types**: Confirm TypeScript interface in `index.d.ts`
|
|
15
|
+
3. **Check Themes**: Review `.theme.js` if component uses theming
|
|
16
|
+
4. **Follow Patterns**: Use documented usage patterns and examples
|
|
17
|
+
|
|
18
|
+
## Architecture Overview
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
@thecb/components/
|
|
22
|
+
├── atoms/
|
|
23
|
+
│ ├── layouts/ # Box, Stack, Cluster, Center, Grid
|
|
24
|
+
│ ├── form-layouts/ # FormInput
|
|
25
|
+
│ ├── form-select/ # FormSelect
|
|
26
|
+
│ ├── dropdown/ # Dropdown
|
|
27
|
+
│ └── table/ # Table system
|
|
28
|
+
├── molecules/
|
|
29
|
+
│ └── modal/ # Modal
|
|
30
|
+
└── templates/ # Page layouts
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Core Patterns
|
|
34
|
+
|
|
35
|
+
### Layout Primitives (No Theming)
|
|
36
|
+
|
|
37
|
+
- Box: Generic container with styling props
|
|
38
|
+
- Stack: Vertical/horizontal spacing with flexbox
|
|
39
|
+
- Cluster: Wrapping elements with consistent gaps
|
|
40
|
+
- Center: Horizontal centering with gutters
|
|
41
|
+
- Grid: Responsive auto-fill grid layout
|
|
42
|
+
|
|
43
|
+
### Form Components (With Theming)
|
|
44
|
+
|
|
45
|
+
- FormInput: Complete input with validation
|
|
46
|
+
- FormSelect: Dropdown with form integration
|
|
47
|
+
- Dropdown: Accessible combobox with search
|
|
48
|
+
|
|
49
|
+
### Display Components
|
|
50
|
+
|
|
51
|
+
- Table: 6-component table system
|
|
52
|
+
- Modal: Accessible dialog with versions
|
|
53
|
+
|
|
54
|
+
## Integration Rules
|
|
55
|
+
|
|
56
|
+
### Props
|
|
57
|
+
|
|
58
|
+
- All components accept `extraStyles` for custom CSS
|
|
59
|
+
- Themed components accept `themeValues` object
|
|
60
|
+
- Layout components use `children` prop
|
|
61
|
+
- Event handlers follow React naming (`onClick`, `onSelect`)
|
|
62
|
+
|
|
63
|
+
### TypeScript
|
|
64
|
+
|
|
65
|
+
- Interfaces use `Expand` utility for prop merging
|
|
66
|
+
- All components extend `React.HTMLAttributes<HTMLElement>`
|
|
67
|
+
- Optional props use `?:` syntax
|
|
68
|
+
|
|
69
|
+
### Theming
|
|
70
|
+
|
|
71
|
+
- Components using `themeComponent` wrapper have fallback values
|
|
72
|
+
- Theme files define color/style mappings
|
|
73
|
+
- Variants: "default", "primary", "secondary", "danger"
|
|
74
|
+
|
|
75
|
+
### Accessibility
|
|
76
|
+
|
|
77
|
+
- Form components include ARIA labeling
|
|
78
|
+
- Dropdown/Modal use focus management
|
|
79
|
+
- Screen reader support via semantic HTML
|
|
80
|
+
|
|
81
|
+
### Import Patterns
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
// Named imports
|
|
85
|
+
import { Box, Stack, FormInput } from "@thecb/components";
|
|
86
|
+
|
|
87
|
+
// Table system
|
|
88
|
+
import {
|
|
89
|
+
Table,
|
|
90
|
+
TableHead,
|
|
91
|
+
TableBody,
|
|
92
|
+
TableRow,
|
|
93
|
+
TableHeading,
|
|
94
|
+
TableCell
|
|
95
|
+
} from "@thecb/components";
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Form Field Integration
|
|
99
|
+
|
|
100
|
+
Form components expect field objects with:
|
|
101
|
+
|
|
102
|
+
- `rawValue`: Current value
|
|
103
|
+
- `hasErrors`: Boolean error state
|
|
104
|
+
- `errors`: Array of error keys
|
|
105
|
+
- `dirty`: Boolean touched state
|
|
106
|
+
|
|
107
|
+
Field actions expect:
|
|
108
|
+
|
|
109
|
+
- `set(value)`: Update field value
|
|
110
|
+
|
|
111
|
+
## Common Anti-patterns
|
|
112
|
+
|
|
113
|
+
- Don't use Box for complex layouts (use Stack/Cluster/Grid)
|
|
114
|
+
- Don't bypass form field integration in FormInput/FormSelect
|
|
115
|
+
- Don't ignore accessibility props in interactive components
|
|
116
|
+
- Don't use layout primitives without understanding spacing behavior
|
|
117
|
+
|
|
118
|
+
## Quick Reference
|
|
119
|
+
|
|
120
|
+
| Component | Purpose | Key Props | Theming |
|
|
121
|
+
| --------- | ---------- | ------------------------- | ------- |
|
|
122
|
+
| Box | Container | `padding`, `as`, `srOnly` | No |
|
|
123
|
+
| Stack | Spacing | `childGap`, `direction` | No |
|
|
124
|
+
| FormInput | Text input | `field`, `fieldActions` | Yes |
|
|
125
|
+
| Dropdown | Select | `options`, `onSelect` | Yes |
|
|
126
|
+
| Modal | Dialog | `modalOpen`, `hideModal` | No |
|
|
127
|
+
|
|
128
|
+
## Example Implementation
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
// Examine source code and TypeScript definitions first, then implement:
|
|
132
|
+
import { FormInput } from "@thecb/components";
|
|
133
|
+
|
|
134
|
+
<FormInput
|
|
135
|
+
field={emailField}
|
|
136
|
+
fieldActions={emailFieldActions}
|
|
137
|
+
labelTextWhenNoError="Email Address"
|
|
138
|
+
type="email"
|
|
139
|
+
isRequired={true}
|
|
140
|
+
errorMessages={{ required: "Email is required" }}
|
|
141
|
+
/>;
|
|
142
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"description": "Common lib for CityBase react components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|
|
25
|
-
"src"
|
|
25
|
+
"src",
|
|
26
|
+
"ai-docs"
|
|
26
27
|
],
|
|
27
28
|
"homepage": "https://github.com/CityBaseInc/cb-components#readme",
|
|
28
29
|
"devDependencies": {
|