@animus-ui/core 0.2.0-beta.0 → 0.2.0-beta.2
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/ANIMUS_ARCHITECTURE.md +173 -0
- package/CHANGELOG.md +14 -0
- package/CLAUDE.md +895 -7
- package/dist/AnimusExtended.d.ts +43 -16
- package/dist/index.d.ts +8 -8
- package/dist/index.js +129 -73
- package/dist/properties/styledOptions.d.ts +1 -1
- package/dist/transforms/index.d.ts +2 -2
- package/package.json +2 -2
- package/dist/static-poc/atomic-css.d.ts +0 -14
- package/dist/static-poc/run-poc.d.ts +0 -5
- package/dist/static-poc/static-mode.d.ts +0 -15
- package/dist/static-poc/validate-poc.d.ts +0 -5
- package/docs/AGENT-QUESTIONS.md +0 -79
- package/docs/agentic-alliance.md +0 -415
- package/docs/ai-collaboration-guide.md +0 -141
- package/docs/critical-findings.md +0 -87
- package/docs/gemini-tamagui-compiler-learnings.md +0 -393
- package/docs/tamagui-compiler-learnings.md +0 -575
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Animus.ts Architecture Explanation
|
|
2
|
+
|
|
3
|
+
## Core Concept
|
|
4
|
+
|
|
5
|
+
Animus is a **type-state machine** that guides you through building styled components step-by-step. It uses TypeScript's type system to enforce that you configure your components in a specific order, making it impossible to make mistakes.
|
|
6
|
+
|
|
7
|
+
## The Unique Architecture
|
|
8
|
+
|
|
9
|
+
The most interesting aspect is the **backwards inheritance chain**:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Animus → AnimusWithBase → AnimusWithVariants → AnimusWithStates → AnimusWithSystem → AnimusWithAll
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Each class extends the one *after* it in the chain, which seems backwards but is actually brilliant. Here's why:
|
|
16
|
+
|
|
17
|
+
- `Animus` (the starting point) inherits from `AnimusWithBase`
|
|
18
|
+
- `AnimusWithBase` inherits from `AnimusWithVariants`
|
|
19
|
+
- And so on...
|
|
20
|
+
|
|
21
|
+
This means the first class has access to all the methods defined in later classes, but those methods only become *available* to use when you reach the right stage.
|
|
22
|
+
|
|
23
|
+
## How It Works - Step by Step
|
|
24
|
+
|
|
25
|
+
### 1. Starting Point: `Animus` (lines 331-349)
|
|
26
|
+
```typescript
|
|
27
|
+
const builder = new Animus(propRegistry, groupRegistry);
|
|
28
|
+
```
|
|
29
|
+
- Takes your prop definitions and group configurations
|
|
30
|
+
- Only exposes the `.styles()` method
|
|
31
|
+
- Creates a parser for your props automatically
|
|
32
|
+
|
|
33
|
+
### 2. After calling `.styles()`: `AnimusWithBase` (lines 287-329)
|
|
34
|
+
```typescript
|
|
35
|
+
builder.styles({ padding: '20px', color: 'blue' })
|
|
36
|
+
```
|
|
37
|
+
- Now you can call `.variant()` to add design variations
|
|
38
|
+
- The base styles are locked in
|
|
39
|
+
|
|
40
|
+
### 3. After calling `.variant()`: `AnimusWithVariants` (lines 226-285)
|
|
41
|
+
```typescript
|
|
42
|
+
.variant({
|
|
43
|
+
prop: 'size',
|
|
44
|
+
variants: {
|
|
45
|
+
small: { fontSize: '14px' },
|
|
46
|
+
large: { fontSize: '20px' }
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
- Can add multiple variants
|
|
51
|
+
- Now `.states()` method becomes available
|
|
52
|
+
|
|
53
|
+
### 4. After calling `.states()`: `AnimusWithStates` (lines 184-224)
|
|
54
|
+
```typescript
|
|
55
|
+
.states({
|
|
56
|
+
disabled: { opacity: 0.5, cursor: 'not-allowed' },
|
|
57
|
+
loading: { cursor: 'wait' }
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
- Defines boolean states (props that are true/false)
|
|
61
|
+
- Unlocks `.groups()` method
|
|
62
|
+
|
|
63
|
+
### 5. After calling `.groups()`: `AnimusWithSystem` (lines 140-182)
|
|
64
|
+
```typescript
|
|
65
|
+
.groups({ spacing: true, colors: true })
|
|
66
|
+
```
|
|
67
|
+
- Enables predefined groups of props
|
|
68
|
+
- Now you can add custom props with `.props()`
|
|
69
|
+
|
|
70
|
+
### 6. Final Stage: `AnimusWithAll` (lines 24-138)
|
|
71
|
+
This is where the magic happens. You can now:
|
|
72
|
+
|
|
73
|
+
- `.asElement('button')` - Create a styled HTML element
|
|
74
|
+
- `.asComponent(MyComponent)` - Style an existing React component
|
|
75
|
+
- `.build()` - Get the raw styling function
|
|
76
|
+
- `.extend()` - Create variations of your styled component
|
|
77
|
+
|
|
78
|
+
## Key Features
|
|
79
|
+
|
|
80
|
+
### Type Safety Throughout
|
|
81
|
+
The 8 generic parameters track everything:
|
|
82
|
+
- `PropRegistry` - All your prop definitions
|
|
83
|
+
- `GroupRegistry` - Prop groupings
|
|
84
|
+
- `BaseParser` - How props convert to CSS
|
|
85
|
+
- `BaseStyles` - Your base CSS
|
|
86
|
+
- `Variants` - Design variations
|
|
87
|
+
- `States` - Boolean state styles
|
|
88
|
+
- `ActiveGroups` - Which groups are enabled
|
|
89
|
+
- `CustomProps` - Additional custom props
|
|
90
|
+
|
|
91
|
+
### Smart Prop Forwarding (lines 76-87)
|
|
92
|
+
```typescript
|
|
93
|
+
shouldForwardProp: (prop) =>
|
|
94
|
+
isPropValid(prop) && !propNames.includes(prop)
|
|
95
|
+
```
|
|
96
|
+
- System props (like `spacing`, `colors`) are consumed and turned into styles
|
|
97
|
+
- Valid HTML attributes are passed through
|
|
98
|
+
- Invalid props are filtered out
|
|
99
|
+
|
|
100
|
+
### The Build Process (lines 99-137)
|
|
101
|
+
When you call `.build()`, it:
|
|
102
|
+
1. Merges your parser config with custom props
|
|
103
|
+
2. Creates a stylist that combines all your configurations
|
|
104
|
+
3. Returns a function that generates CSS objects
|
|
105
|
+
4. Handles variants, states, and system props automatically
|
|
106
|
+
|
|
107
|
+
### Extension System
|
|
108
|
+
The `.extend()` method creates an `AnimusExtended` instance that can break the rules - you can modify any part of the configuration in any order. This provides an escape hatch when needed.
|
|
109
|
+
|
|
110
|
+
## Why This Design?
|
|
111
|
+
|
|
112
|
+
1. **Impossible to Misuse** - You can't call methods in the wrong order
|
|
113
|
+
2. **Perfect IntelliSense** - Your IDE knows exactly what methods are available at each step
|
|
114
|
+
3. **Type Safe** - All configurations are fully typed
|
|
115
|
+
4. **Flexible When Needed** - The extend system provides flexibility
|
|
116
|
+
5. **Clean API** - The forced order mirrors how we think about styling (base → variants → states → props)
|
|
117
|
+
|
|
118
|
+
## Example Usage
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const Button = animus
|
|
122
|
+
.styles({
|
|
123
|
+
padding: '10px 20px',
|
|
124
|
+
borderRadius: '4px'
|
|
125
|
+
})
|
|
126
|
+
.variant({
|
|
127
|
+
prop: 'variant',
|
|
128
|
+
variants: {
|
|
129
|
+
primary: { background: 'blue', color: 'white' },
|
|
130
|
+
secondary: { background: 'gray', color: 'black' }
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
.states({
|
|
134
|
+
disabled: { opacity: 0.6 }
|
|
135
|
+
})
|
|
136
|
+
.asElement('button');
|
|
137
|
+
|
|
138
|
+
// Usage:
|
|
139
|
+
<Button variant="primary" disabled>Click me</Button>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## The Backwards Inheritance Explained
|
|
143
|
+
|
|
144
|
+
The backwards inheritance pattern is the key innovation. Instead of:
|
|
145
|
+
- Base class with few methods → Derived class with more methods (traditional OOP)
|
|
146
|
+
|
|
147
|
+
Animus does:
|
|
148
|
+
- Starting class that inherits everything → But methods are selectively exposed
|
|
149
|
+
|
|
150
|
+
This creates a "progressive revelation" pattern where:
|
|
151
|
+
1. You start with minimal options (just `.styles()`)
|
|
152
|
+
2. Each method call returns a new class instance
|
|
153
|
+
3. That new instance exposes the next logical methods
|
|
154
|
+
4. Invalid sequences are impossible at the type level
|
|
155
|
+
|
|
156
|
+
## Integration with Emotion
|
|
157
|
+
|
|
158
|
+
Animus builds on top of Emotion (a CSS-in-JS library):
|
|
159
|
+
- Uses `@emotion/styled` to create the actual styled components
|
|
160
|
+
- Uses `@emotion/is-prop-valid` to filter props intelligently
|
|
161
|
+
- The final output is a standard Emotion styled component
|
|
162
|
+
- Full compatibility with themes, SSR, and other Emotion features
|
|
163
|
+
|
|
164
|
+
## Performance Considerations
|
|
165
|
+
|
|
166
|
+
- All type checking happens at compile time - zero runtime overhead
|
|
167
|
+
- The inheritance chain is resolved during build
|
|
168
|
+
- Final components are standard Emotion components
|
|
169
|
+
- Parser and stylist are created once and reused
|
|
170
|
+
|
|
171
|
+
## Summary
|
|
172
|
+
|
|
173
|
+
This architecture ensures that every styled component is configured correctly, with all the power of CSS-in-JS but none of the footguns! The type-state machine pattern combined with backwards inheritance creates a unique developer experience where the API guides you to success.
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.2.0-beta.2](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.2.0-beta.0...@animus-ui/core@0.2.0-beta.2) (2025-07-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @animus-ui/core
|
|
9
|
+
|
|
10
|
+
# 0.2.0-beta.1 (2025-06-15)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- Implement layered documentation and file-based governance voting ([7cdb599](https://github.com/codecaaron/animus/commit/7cdb5995e94d26059bfdd3ec01279fc4e4b45d40))
|
|
15
|
+
|
|
16
|
+
## 0.1.1-beta.1 (2022-01-09)
|
|
17
|
+
|
|
18
|
+
## 0.1.1-beta.0 (2022-01-09)
|
|
19
|
+
|
|
6
20
|
# [0.2.0-beta.0](https://github.com/codecaaron/animus/compare/@animus-ui/core@0.1.1-beta.26...@animus-ui/core@0.2.0-beta.0) (2025-06-13)
|
|
7
21
|
|
|
8
22
|
### Features
|