phaser-wind 0.3.0 → 0.4.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 +136 -97
- package/dist/components/column.d.ts +1 -0
- package/dist/components/column.d.ts.map +1 -0
- package/dist/components/column.js +7 -0
- package/dist/components/column.js.map +1 -0
- package/dist/core/color.d.ts +149 -282
- package/dist/core/color.d.ts.map +1 -1
- package/dist/core/color.js +117 -298
- package/dist/core/color.js.map +1 -1
- package/dist/core/color.spec.js +46 -55
- package/dist/core/color.spec.js.map +1 -1
- package/dist/core/font-size.d.ts +36 -15
- package/dist/core/font-size.d.ts.map +1 -1
- package/dist/core/font-size.js +42 -47
- package/dist/core/font-size.js.map +1 -1
- package/dist/core/font-size.spec.js +55 -43
- package/dist/core/font-size.spec.js.map +1 -1
- package/dist/core/font.d.ts +18 -91
- package/dist/core/font.d.ts.map +1 -1
- package/dist/core/font.js +33 -174
- package/dist/core/font.js.map +1 -1
- package/dist/core/font.spec.js +45 -49
- package/dist/core/font.spec.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/{pallete.d.ts → palette.d.ts} +2 -2
- package/dist/core/{pallete.d.ts.map → palette.d.ts.map} +1 -1
- package/dist/core/{pallete.js → palette.js} +2 -2
- package/dist/core/{pallete.js.map → palette.js.map} +1 -1
- package/dist/core/radius.d.ts +19 -24
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +20 -28
- package/dist/core/radius.js.map +1 -1
- package/dist/core/radius.spec.js +28 -33
- package/dist/core/radius.spec.js.map +1 -1
- package/dist/core/shadow.d.ts +18 -10
- package/dist/core/shadow.d.ts.map +1 -1
- package/dist/core/shadow.js +29 -19
- package/dist/core/shadow.js.map +1 -1
- package/dist/core/shadow.spec.d.ts +2 -0
- package/dist/core/shadow.spec.d.ts.map +1 -0
- package/dist/core/shadow.spec.js +21 -0
- package/dist/core/shadow.spec.js.map +1 -0
- package/dist/core/spacing.d.ts +22 -29
- package/dist/core/spacing.d.ts.map +1 -1
- package/dist/core/spacing.js +27 -39
- package/dist/core/spacing.js.map +1 -1
- package/dist/core/spacing.spec.js +18 -29
- package/dist/core/spacing.spec.js.map +1 -1
- package/dist/exceptions.d.ts +1 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +2 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +2 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/plugin.d.ts +71 -0
- package/dist/plugin/plugin.d.ts.map +1 -0
- package/dist/plugin/plugin.js +91 -0
- package/dist/plugin/plugin.js.map +1 -0
- package/dist/theme/theme-config.d.ts +24 -48
- package/dist/theme/theme-config.d.ts.map +1 -1
- package/dist/theme/theme-config.js +4 -1
- package/dist/theme/theme-config.js.map +1 -1
- package/dist/theme/theme-manager.d.ts +1 -106
- package/dist/theme/theme-manager.d.ts.map +1 -1
- package/dist/theme/theme-manager.js +1 -187
- package/dist/theme/theme-manager.js.map +1 -1
- package/dist/theme/type.d.ts +48 -0
- package/dist/theme/type.d.ts.map +1 -1
- package/dist/theme/type.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
>
|
|
9
9
|
> **Love Tailwind CSS but stuck with Phaser?**
|
|
10
10
|
>
|
|
11
|
-
> **Welcome to Phaser Wind** -
|
|
11
|
+
> **Welcome to Phaser Wind** - bring the joy and simplicity of Tailwind-like design tokens to Phaser games! 🎮✨
|
|
12
12
|
|
|
13
13
|
[](https://www.npmjs.com/package/phaser-wind)
|
|
14
14
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -37,6 +37,7 @@ const title = this.add.text(200, 100, 'Game Title', {
|
|
|
37
37
|
### The Solution 🌟
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
|
+
// No theme needed. Just import and go!
|
|
40
41
|
import { Color, FontSize } from 'phaser-wind';
|
|
41
42
|
|
|
42
43
|
// Clean, semantic, consistent!
|
|
@@ -56,15 +57,14 @@ const title = this.add.text(200, 100, 'Game Title', {
|
|
|
56
57
|
|
|
57
58
|
## 🚀 Features
|
|
58
59
|
|
|
59
|
-
- 🎨 **Complete Tailwind Color Palette** -
|
|
60
|
-
- 📐 **Semantic Font Sizes** - From `xs` to `6xl
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
- 🎯 **Smart Token Resolution** - Themes can reference other theme tokens automatically
|
|
60
|
+
- 🎨 **Complete Tailwind-like Color Palette** - 22 families × 11 shades
|
|
61
|
+
- 📐 **Semantic Font Sizes** - From `xs` to `6xl`
|
|
62
|
+
- 🧩 **Default constants ready-to-use** - `Color`, `FontSize`, `Spacing`, `Radius`, `Shadow`
|
|
63
|
+
- 🧭 **Optional theme system (typed)** - Add your own tokens with strong typing
|
|
64
64
|
- 🔧 **TypeScript First** - Full type safety and IntelliSense
|
|
65
|
-
- 🎮 **Phaser Ready** -
|
|
65
|
+
- 🎮 **Phaser Ready** - Global plugin for easy access in scenes
|
|
66
66
|
- 🌈 **Consistent Design** - No more guessing colors and sizes
|
|
67
|
-
- 📦 **Tiny Bundle** -
|
|
67
|
+
- 📦 **Tiny Bundle** - Great DX, minimal overhead
|
|
68
68
|
|
|
69
69
|
---
|
|
70
70
|
|
|
@@ -80,9 +80,9 @@ pnpm add phaser-wind
|
|
|
80
80
|
|
|
81
81
|
---
|
|
82
82
|
|
|
83
|
-
## 🎨 Color System
|
|
83
|
+
## 🎨 Color System (no theme)
|
|
84
84
|
|
|
85
|
-
### Complete
|
|
85
|
+
### Complete Palette
|
|
86
86
|
|
|
87
87
|
Access all Tailwind colors with semantic naming:
|
|
88
88
|
|
|
@@ -110,7 +110,7 @@ const whiteBackground = Color.hex('white'); // 0xFFFFFF
|
|
|
110
110
|
|
|
111
111
|
---
|
|
112
112
|
|
|
113
|
-
## 📏 Font Size System
|
|
113
|
+
## 📏 Font Size System (no theme)
|
|
114
114
|
|
|
115
115
|
### Semantic Sizing
|
|
116
116
|
|
|
@@ -149,116 +149,155 @@ const responsiveText = FontSize.rem('xl'); // 1.25
|
|
|
149
149
|
|
|
150
150
|
---
|
|
151
151
|
|
|
152
|
-
##
|
|
152
|
+
## 🧪 Strong typing (no theme)
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
All APIs are strongly typed. Invalid tokens break at compile time:
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
```ts
|
|
157
|
+
import { Color, FontSize, Spacing, Radius, Shadow } from 'phaser-wind';
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
// ✅ OK
|
|
160
|
+
Color.rgb('blue-500');
|
|
161
|
+
FontSize.css('lg');
|
|
162
|
+
Spacing.px('16');
|
|
163
|
+
Radius.css('sm');
|
|
164
|
+
Shadow.get('md');
|
|
165
|
+
|
|
166
|
+
// ❌ Compile-time errors
|
|
167
|
+
// Color.rgb('blue-501');
|
|
168
|
+
// FontSize.css('huge');
|
|
169
|
+
// Spacing.px('97');
|
|
170
|
+
// Radius.css('xxl');
|
|
171
|
+
// Shadow.get('mega');
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 🧱 Token Reference
|
|
177
|
+
|
|
178
|
+
### Colors
|
|
179
|
+
|
|
180
|
+
- Families: `slate`, `gray`, `zinc`, `neutral`, `stone`, `red`, `orange`, `amber`, `yellow`, `lime`, `green`, `emerald`, `teal`, `cyan`, `sky`, `blue`, `indigo`, `violet`, `purple`, `fuchsia`, `pink`, `rose`
|
|
181
|
+
- Shades: `50`, `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, `900`, `950`
|
|
182
|
+
- Special: `black`, `white`
|
|
183
|
+
|
|
184
|
+
### Font Size
|
|
185
|
+
|
|
186
|
+
- Keys: `xs`, `sm`, `base`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`
|
|
187
|
+
|
|
188
|
+
### Spacing
|
|
189
|
+
|
|
190
|
+
- Keys (px scale ×4): `0`, `px(=1)`, `0.5`, `1`, `1.5`, `2`, `2.5`, `3`, `3.5`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `14`, `16`, `20`, `24`, `28`, `32`, `36`, `40`, `44`, `48`, `52`, `56`, `60`, `64`, `72`, `80`, `96`
|
|
191
|
+
|
|
192
|
+
### Radius
|
|
160
193
|
|
|
161
|
-
|
|
194
|
+
- Keys: `none`, `sm`, `default`, `md`, `lg`, `xl`, `2xl`, `3xl`, `full`
|
|
195
|
+
|
|
196
|
+
### Shadow
|
|
197
|
+
|
|
198
|
+
- Default keys: `sm`, `md`, `lg`, `xl`, `2xl`, `inner`
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 🎨 Theming (optional, typed)
|
|
203
|
+
|
|
204
|
+
Phaser Wind also provides a typed theme system via a Phaser plugin. You get the same API surface (`color`, `fontSize`, `spacing`, `radius`, `font`, `shadow`) but narrowed to your custom tokens.
|
|
205
|
+
|
|
206
|
+
### 1) Create a theme
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
import { createTheme, type CreateTheme } from 'phaser-wind';
|
|
210
|
+
|
|
211
|
+
export const theme = createTheme({
|
|
162
212
|
fonts: {
|
|
163
213
|
primary: 'Inter, system-ui, sans-serif',
|
|
164
|
-
display: 'Orbitron, monospace',
|
|
165
|
-
|
|
214
|
+
display: 'Orbitron, monospace',
|
|
215
|
+
},
|
|
216
|
+
fontSizes: {
|
|
217
|
+
// optional overrides
|
|
166
218
|
},
|
|
167
219
|
colors: {
|
|
168
|
-
primary: '
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
'player-health': 'green-500',
|
|
172
|
-
'enemy-health': 'red-600',
|
|
220
|
+
primary: 'blue-600',
|
|
221
|
+
background: 'slate-900',
|
|
222
|
+
danger: 'red-500',
|
|
173
223
|
},
|
|
174
224
|
spacing: {
|
|
175
|
-
|
|
176
|
-
sm: 8,
|
|
177
|
-
md: 16,
|
|
178
|
-
lg: 24,
|
|
179
|
-
xl: 32,
|
|
225
|
+
gutter: 24,
|
|
180
226
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
fontSize: '2xl',
|
|
184
|
-
fontFamily: 'fonts.display', // 🔗 References fonts.display!
|
|
185
|
-
fontWeight: 600,
|
|
186
|
-
lineHeight: 1.2,
|
|
187
|
-
},
|
|
188
|
-
body: {
|
|
189
|
-
fontSize: 'md',
|
|
190
|
-
fontFamily: 'fonts.primary',
|
|
191
|
-
fontWeight: 400,
|
|
192
|
-
lineHeight: 1.5,
|
|
193
|
-
},
|
|
227
|
+
radius: {
|
|
228
|
+
card: 12,
|
|
194
229
|
},
|
|
195
230
|
effects: {
|
|
196
|
-
|
|
197
|
-
blur: 8,
|
|
198
|
-
color: 'colors.primary', // 🔗 References colors.primary!
|
|
199
|
-
alpha: 0.6,
|
|
200
|
-
},
|
|
231
|
+
glow: { blur: 8, offsetX: 0, offsetY: 0, alpha: 0.6 },
|
|
201
232
|
},
|
|
202
|
-
|
|
203
|
-
animations: {
|
|
204
|
-
duration: 300,
|
|
205
|
-
easing: 'ease-out',
|
|
206
|
-
},
|
|
207
|
-
});
|
|
233
|
+
} satisfies CreateTheme<any>);
|
|
208
234
|
|
|
209
|
-
|
|
210
|
-
ThemeManager.init(gameTheme);
|
|
235
|
+
export type ThemeType = typeof theme;
|
|
211
236
|
```
|
|
212
237
|
|
|
213
|
-
###
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
import {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
238
|
+
### 2) Install the plugin in Phaser
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
import {
|
|
242
|
+
PhaserWindPlugin,
|
|
243
|
+
PHASER_WIND_KEY,
|
|
244
|
+
defaultLightTheme,
|
|
245
|
+
} from 'phaser-wind';
|
|
246
|
+
import { theme } from './theme';
|
|
247
|
+
|
|
248
|
+
new Phaser.Game({
|
|
249
|
+
plugins: {
|
|
250
|
+
global: [
|
|
251
|
+
{
|
|
252
|
+
key: PHASER_WIND_KEY,
|
|
253
|
+
plugin: PhaserWindPlugin,
|
|
254
|
+
mapping: PHASER_WIND_KEY, // scene.pw
|
|
255
|
+
data: { theme }, // or { theme: defaultLightTheme }
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
```
|
|
225
261
|
|
|
226
|
-
|
|
227
|
-
const mediumSpace = Spacing.px('md'); // Gets spacing.md (16px)
|
|
228
|
-
const largeSpace = Spacing.px('lg'); // Gets spacing.lg (24px)
|
|
262
|
+
### 3) (Optional) Module augmentation for better typing in scenes
|
|
229
263
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
};
|
|
264
|
+
```ts
|
|
265
|
+
// types/phaser-wind.d.ts
|
|
266
|
+
import 'phaser';
|
|
267
|
+
import type { PhaserWindPlugin } from 'phaser-wind';
|
|
268
|
+
import type { ThemeType } from './theme';
|
|
236
269
|
|
|
237
|
-
|
|
238
|
-
|
|
270
|
+
declare module 'phaser' {
|
|
271
|
+
interface Scene {
|
|
272
|
+
pw: PhaserWindPlugin<ThemeType>;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
239
275
|
```
|
|
240
276
|
|
|
241
|
-
###
|
|
242
|
-
|
|
243
|
-
```typescript
|
|
244
|
-
// Register multiple themes
|
|
245
|
-
ThemeManager.registerTheme('light', lightTheme);
|
|
246
|
-
ThemeManager.registerTheme('dark', darkTheme);
|
|
247
|
-
ThemeManager.registerTheme('cyberpunk', cyberpunkTheme);
|
|
248
|
-
|
|
249
|
-
// Switch themes instantly
|
|
250
|
-
ThemeManager.setTheme('dark');
|
|
251
|
-
|
|
252
|
-
// Listen for theme changes
|
|
253
|
-
ThemeManager.onThemeChange(newTheme => {
|
|
254
|
-
console.log('Theme changed!', newTheme);
|
|
255
|
-
// Update your game UI here
|
|
256
|
-
});
|
|
277
|
+
### 4) Typed usage in scenes
|
|
257
278
|
|
|
258
|
-
|
|
259
|
-
|
|
279
|
+
```ts
|
|
280
|
+
export class GameScene extends Phaser.Scene {
|
|
281
|
+
create() {
|
|
282
|
+
const { color, fontSize, spacing, radius, font, shadow } = this.pw;
|
|
283
|
+
|
|
284
|
+
// ✅ Type-narrowed to your theme
|
|
285
|
+
color.rgb('primary');
|
|
286
|
+
fontSize.css('lg');
|
|
287
|
+
spacing.px('gutter');
|
|
288
|
+
radius.css('card');
|
|
289
|
+
font.family('display');
|
|
290
|
+
shadow.get('glow');
|
|
291
|
+
|
|
292
|
+
// ❌ Compile-time errors
|
|
293
|
+
// color.rgb('blue-501');
|
|
294
|
+
// spacing.px('unknown');
|
|
295
|
+
}
|
|
296
|
+
}
|
|
260
297
|
```
|
|
261
298
|
|
|
299
|
+
> Note: The old `ThemeManager` API is deprecated and has been removed from the docs.
|
|
300
|
+
|
|
262
301
|
### 🎮 **Real Game Example**
|
|
263
302
|
|
|
264
303
|
```typescript
|
|
@@ -494,7 +533,7 @@ this.add.particles(player.x, player.y, 'sparkle', {
|
|
|
494
533
|
|
|
495
534
|
---
|
|
496
535
|
|
|
497
|
-
## 🎮 Integration with Phaser
|
|
536
|
+
## 🎮 Integration with Phaser (no theme)
|
|
498
537
|
|
|
499
538
|
### Scene Setup
|
|
500
539
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../src/components/column.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// export class Column extends Phaser.GameObjects.Container {
|
|
3
|
+
// constructor(scene: Scene, x: number, y: number, width: number, height: number, children: GameObjects.Container[]) {
|
|
4
|
+
// super(scene, x, y, width, height);
|
|
5
|
+
// }
|
|
6
|
+
// }
|
|
7
|
+
//# sourceMappingURL=column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column.js","sourceRoot":"","sources":["../../src/components/column.ts"],"names":[],"mappings":";AAAA,6DAA6D;AAC7D,wHAAwH;AACxH,yCAAyC;AACzC,MAAM;AACN,IAAI"}
|