@khipu/design-system 0.1.0-alpha.12
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/LICENSE +21 -0
- package/README.md +296 -0
- package/dist/index.d.mts +1390 -0
- package/dist/index.d.ts +1390 -0
- package/dist/index.js +2276 -0
- package/dist/index.mjs +2178 -0
- package/dist/khipu-logo-color-TV75AKOV.svg +19 -0
- package/package.json +125 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Khipu SpA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Khipu Design System
|
|
2
|
+
|
|
3
|
+
A multi-platform design system for the Khipu payment platform.
|
|
4
|
+
|
|
5
|
+
| Platform | Package | Registry |
|
|
6
|
+
|----------|---------|----------|
|
|
7
|
+
| **Web** (React/TypeScript) | `@khipu/design-system` | [npmjs.org](https://www.npmjs.com/package/@khipu/design-system) |
|
|
8
|
+
| **Android** (Kotlin/Compose) | `com.khipu:design-system` | [Nexus](https://dev.khipu.com/nexus/content/repositories/design-system) |
|
|
9
|
+
| **iOS** (Swift/SwiftUI) | `KhipuDesignSystem` | [CocoaPods](https://cocoapods.org/pods/KhipuDesignSystem) |
|
|
10
|
+
|
|
11
|
+
**Storybook:** [design.khipu.com](https://design.khipu.com)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Web
|
|
16
|
+
```bash
|
|
17
|
+
npm install @khipu/design-system
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Android
|
|
21
|
+
```kotlin
|
|
22
|
+
// build.gradle.kts
|
|
23
|
+
dependencies {
|
|
24
|
+
implementation("com.khipu:design-system:0.1.0-alpha.6")
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### iOS
|
|
29
|
+
```ruby
|
|
30
|
+
# Podfile
|
|
31
|
+
pod 'KhipuDesignSystem'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Prerequisites
|
|
35
|
+
|
|
36
|
+
- Node.js >= 18.0.0
|
|
37
|
+
- React >= 17.0.0
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
### Import Components
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { Button, TextField, Card } from '@khipu/design-system';
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<Card>
|
|
49
|
+
<TextField label="Email" placeholder="Enter your email" />
|
|
50
|
+
<Button variant="contained" color="primary">
|
|
51
|
+
Submit
|
|
52
|
+
</Button>
|
|
53
|
+
</Card>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Using Design Tokens
|
|
59
|
+
|
|
60
|
+
Access design tokens for consistent styling:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { tokens, colors, spacing, typography } from '@khipu/design-system';
|
|
64
|
+
|
|
65
|
+
const styles = {
|
|
66
|
+
color: colors.primary.main, // '#8347AD'
|
|
67
|
+
padding: spacing[4], // '16px'
|
|
68
|
+
fontFamily: typography.body1.fontFamily,
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Import CSS Variables (Optional)
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import '@khipu/design-system/css';
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Running the Project
|
|
79
|
+
|
|
80
|
+
### Setup
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Clone the repository
|
|
84
|
+
git clone git@github.com:khipu/design-system.git
|
|
85
|
+
cd design-system
|
|
86
|
+
|
|
87
|
+
# Install dependencies
|
|
88
|
+
npm install
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Available Scripts
|
|
92
|
+
|
|
93
|
+
#### Development
|
|
94
|
+
|
|
95
|
+
| Command | Description |
|
|
96
|
+
|---------|-------------|
|
|
97
|
+
| `npm run dev` | Start development mode with watch |
|
|
98
|
+
| `npm run build` | Build the library for production |
|
|
99
|
+
| `npm run storybook` | Launch Storybook on port 6006 |
|
|
100
|
+
| `npm run build-storybook` | Build static Storybook site |
|
|
101
|
+
| `npm run test` | Run tests with Vitest |
|
|
102
|
+
| `npm run test:ui` | Run tests with Vitest UI |
|
|
103
|
+
| `npm run typecheck` | Run TypeScript type checking |
|
|
104
|
+
| `npm run lint` | Lint source files |
|
|
105
|
+
| `npm run generate:tokens` | Generate Kotlin tokens to dist/ |
|
|
106
|
+
| `npm run generate:tokens:android` | Generate tokens to Android project |
|
|
107
|
+
|
|
108
|
+
#### Figma Synchronization
|
|
109
|
+
|
|
110
|
+
Sync design tokens from Figma to code:
|
|
111
|
+
|
|
112
|
+
| Command | Description |
|
|
113
|
+
|---------|-------------|
|
|
114
|
+
| `npm run sync:figma` | Extract all tokens (colors, typography, effects) |
|
|
115
|
+
| `npm run sync:figma:colors` | Extract only color tokens |
|
|
116
|
+
| `npm run sync:figma:typography` | Extract only typography styles |
|
|
117
|
+
| `npm run sync:figma:effects` | Extract only effects (shadows) |
|
|
118
|
+
| `npm run sync:figma:dry-run` | Preview extraction without changes |
|
|
119
|
+
|
|
120
|
+
**Setup required:**
|
|
121
|
+
```bash
|
|
122
|
+
export FIGMA_PERSONAL_ACCESS_TOKEN="your_token_here"
|
|
123
|
+
npm run sync:figma
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
See `scripts/README.md` for detailed documentation.
|
|
127
|
+
|
|
128
|
+
### Storybook
|
|
129
|
+
|
|
130
|
+
View and interact with components in isolation:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run storybook
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Open http://localhost:6006 in your browser to explore the component library.
|
|
137
|
+
|
|
138
|
+
## Package Exports
|
|
139
|
+
|
|
140
|
+
| Export | Description |
|
|
141
|
+
|--------|-------------|
|
|
142
|
+
| `@khipu/design-system` | All components and tokens |
|
|
143
|
+
| `@khipu/design-system/tokens` | Design tokens only |
|
|
144
|
+
| `@khipu/design-system/css` | CSS variables |
|
|
145
|
+
| `@khipu/design-system/components/core` | Core UI components |
|
|
146
|
+
| `@khipu/design-system/components/domain` | Domain-specific components |
|
|
147
|
+
|
|
148
|
+
## Available Components
|
|
149
|
+
|
|
150
|
+
### Core Components
|
|
151
|
+
|
|
152
|
+
Foundational UI primitives:
|
|
153
|
+
|
|
154
|
+
| Component | Description |
|
|
155
|
+
|-----------|-------------|
|
|
156
|
+
| `Button` | Action buttons with variants: `contained`, `outlined`, `text` |
|
|
157
|
+
| `TextField` | Text input fields with validation support |
|
|
158
|
+
| `Checkbox` | Checkbox input with multiple sizes and colors |
|
|
159
|
+
| `Select` | Dropdown selection component |
|
|
160
|
+
| `Modal` | Dialog/modal windows |
|
|
161
|
+
| `Card` | Container with `CardHeader`, `CardContent`, `CardActions` |
|
|
162
|
+
| `Spinner` | Loading indicator |
|
|
163
|
+
|
|
164
|
+
### Domain Components
|
|
165
|
+
|
|
166
|
+
Khipu-specific components for the payment platform:
|
|
167
|
+
|
|
168
|
+
| Component | Description |
|
|
169
|
+
|-----------|-------------|
|
|
170
|
+
| `BankSelector` | Bank selection interface |
|
|
171
|
+
| `PaymentStepper` | Multi-step payment flow indicator |
|
|
172
|
+
| `MandateStatusBadge` | Status badge for payment mandates |
|
|
173
|
+
| `PayoutSummaryCard` | Payout information display |
|
|
174
|
+
| `EmptyState` | Empty state placeholder |
|
|
175
|
+
|
|
176
|
+
## Design Tokens
|
|
177
|
+
|
|
178
|
+
Comprehensive tokens extracted from Figma (Pagos Automáticos - MUI v610):
|
|
179
|
+
|
|
180
|
+
- **Colors** - Primary (purple #8347AD), secondary, semantic (success, warning, error, info)
|
|
181
|
+
- **Typography** - Font families (Public Sans, Roboto), sizes, weights, presets
|
|
182
|
+
- **Spacing** - Consistent spacing scale (4px base unit)
|
|
183
|
+
- **Border Radius** - From `sm` (4px) to `full` (pill shape)
|
|
184
|
+
- **Shadows** - MUI-compatible elevation system (elevation1-24)
|
|
185
|
+
- **Transitions** - Duration and easing values
|
|
186
|
+
- **Breakpoints** - Responsive design breakpoints (xs, sm, md, lg, xl)
|
|
187
|
+
|
|
188
|
+
## Cross-Platform Token Sync (Android/Compose)
|
|
189
|
+
|
|
190
|
+
This design system supports exporting tokens to Android/Kotlin for use with Jetpack Compose, ensuring visual consistency across web and mobile platforms.
|
|
191
|
+
|
|
192
|
+
### Single Source of Truth
|
|
193
|
+
|
|
194
|
+
Tokens are defined in `src/tokens/tokens.json` and can be exported to:
|
|
195
|
+
- **TypeScript** (web) - `src/tokens/index.ts`
|
|
196
|
+
- **Kotlin** (Android) - `DesignTokens.kt`
|
|
197
|
+
|
|
198
|
+
### Generate Kotlin Tokens
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Generate to dist/DesignTokens.kt
|
|
202
|
+
npm run generate:tokens
|
|
203
|
+
|
|
204
|
+
# Generate directly to Android project
|
|
205
|
+
npm run generate:tokens:android
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Using Tokens in Compose
|
|
209
|
+
|
|
210
|
+
```kotlin
|
|
211
|
+
import com.khipu.client.ui.theme.KdsColors
|
|
212
|
+
import com.khipu.client.ui.theme.KdsSpacing
|
|
213
|
+
import com.khipu.client.ui.theme.KdsBorderRadius
|
|
214
|
+
|
|
215
|
+
@Composable
|
|
216
|
+
fun PaymentCard() {
|
|
217
|
+
Card(
|
|
218
|
+
colors = CardDefaults.cardColors(
|
|
219
|
+
containerColor = KdsColors.backgroundPaper
|
|
220
|
+
),
|
|
221
|
+
shape = RoundedCornerShape(KdsBorderRadius.radiusCard),
|
|
222
|
+
modifier = Modifier.padding(KdsSpacing.space4)
|
|
223
|
+
) {
|
|
224
|
+
Text(
|
|
225
|
+
text = "Payment",
|
|
226
|
+
color = KdsColors.textPrimary
|
|
227
|
+
)
|
|
228
|
+
Button(
|
|
229
|
+
colors = ButtonDefaults.buttonColors(
|
|
230
|
+
containerColor = KdsColors.primaryMain
|
|
231
|
+
)
|
|
232
|
+
) {
|
|
233
|
+
Text("Pay Now")
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Available Kotlin Objects
|
|
240
|
+
|
|
241
|
+
| Object | Contents |
|
|
242
|
+
|--------|----------|
|
|
243
|
+
| `KdsColors` | All color tokens (primary, secondary, semantic, text, background) |
|
|
244
|
+
| `KdsTypography` | Font weights, sizes, line heights |
|
|
245
|
+
| `KdsSpacing` | Spacing scale (0-24, in 4px increments) |
|
|
246
|
+
| `KdsBorderRadius` | Border radius values |
|
|
247
|
+
| `KdsTransitions` | Animation durations |
|
|
248
|
+
| `KdsBreakpoints` | Responsive breakpoints |
|
|
249
|
+
|
|
250
|
+
### Workflow
|
|
251
|
+
|
|
252
|
+
1. Update tokens in `src/tokens/tokens.json`
|
|
253
|
+
2. Run `npm run generate:tokens:android`
|
|
254
|
+
3. Commit both `tokens.json` and the generated `DesignTokens.kt`
|
|
255
|
+
|
|
256
|
+
## TypeScript Support
|
|
257
|
+
|
|
258
|
+
All components are fully typed. Import types alongside components:
|
|
259
|
+
|
|
260
|
+
```tsx
|
|
261
|
+
import {
|
|
262
|
+
Button,
|
|
263
|
+
type ButtonProps,
|
|
264
|
+
type ButtonVariant,
|
|
265
|
+
type ButtonColor
|
|
266
|
+
} from '@khipu/design-system';
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Project Structure
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
src/
|
|
273
|
+
├── index.ts # Main entry point
|
|
274
|
+
├── tokens/
|
|
275
|
+
│ ├── index.ts # Design tokens
|
|
276
|
+
│ └── css-variables.css # CSS custom properties
|
|
277
|
+
└── components/
|
|
278
|
+
├── core/ # Core UI components
|
|
279
|
+
│ ├── Button/
|
|
280
|
+
│ ├── TextField/
|
|
281
|
+
│ ├── Checkbox/
|
|
282
|
+
│ ├── Select/
|
|
283
|
+
│ ├── Modal/
|
|
284
|
+
│ ├── Card/
|
|
285
|
+
│ └── Spinner/
|
|
286
|
+
└── domain/ # Domain-specific components
|
|
287
|
+
├── BankSelector/
|
|
288
|
+
├── PaymentStepper/
|
|
289
|
+
├── MandateStatusBadge/
|
|
290
|
+
├── PayoutSummaryCard/
|
|
291
|
+
└── EmptyState/
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## License
|
|
295
|
+
|
|
296
|
+
MIT
|