phaser-wind 0.2.0 → 0.3.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 +124 -135
- package/dist/core/color.d.ts +287 -0
- package/dist/core/color.d.ts.map +1 -0
- package/dist/core/color.js +386 -0
- package/dist/core/color.js.map +1 -0
- package/dist/core/color.spec.d.ts +2 -0
- package/dist/core/color.spec.d.ts.map +1 -0
- package/dist/core/color.spec.js +252 -0
- package/dist/core/color.spec.js.map +1 -0
- package/dist/core/font-size.d.ts +34 -0
- package/dist/core/font-size.d.ts.map +1 -0
- package/dist/core/font-size.js +68 -0
- package/dist/core/font-size.js.map +1 -0
- package/dist/core/font-size.spec.d.ts +2 -0
- package/dist/core/font-size.spec.d.ts.map +1 -0
- package/dist/core/font-size.spec.js +73 -0
- package/dist/core/font-size.spec.js.map +1 -0
- package/dist/{font/font-picker.d.ts → core/font.d.ts} +22 -21
- package/dist/core/font.d.ts.map +1 -0
- package/dist/{font/font-picker.js → core/font.js} +28 -62
- package/dist/core/font.js.map +1 -0
- package/dist/core/font.spec.d.ts +2 -0
- package/dist/core/font.spec.d.ts.map +1 -0
- package/dist/core/font.spec.js +84 -0
- package/dist/core/font.spec.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/{color → core}/pallete.d.ts.map +1 -1
- package/dist/core/pallete.js.map +1 -0
- package/dist/core/radius.d.ts +34 -0
- package/dist/core/radius.d.ts.map +1 -0
- package/dist/core/radius.js +46 -0
- package/dist/core/radius.js.map +1 -0
- package/dist/core/radius.spec.d.ts +2 -0
- package/dist/core/radius.spec.d.ts.map +1 -0
- package/dist/core/radius.spec.js +61 -0
- package/dist/core/radius.spec.js.map +1 -0
- package/dist/core/shadow.d.ts +23 -0
- package/dist/core/shadow.d.ts.map +1 -0
- package/dist/core/shadow.js +23 -0
- package/dist/core/shadow.js.map +1 -0
- package/dist/core/spacing.d.ts +39 -0
- package/dist/core/spacing.d.ts.map +1 -0
- package/dist/core/spacing.js +82 -0
- package/dist/core/spacing.js.map +1 -0
- package/dist/core/spacing.spec.d.ts +2 -0
- package/dist/core/spacing.spec.d.ts.map +1 -0
- package/dist/core/spacing.spec.js +49 -0
- package/dist/core/spacing.spec.js.map +1 -0
- package/dist/font/index.d.ts +2 -2
- package/dist/font/index.d.ts.map +1 -1
- package/dist/font/index.js +2 -2
- package/dist/font/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/theme/theme-config.d.ts +31 -95
- package/dist/theme/theme-config.d.ts.map +1 -1
- package/dist/theme/theme-config.js +12 -52
- package/dist/theme/theme-config.js.map +1 -1
- package/dist/theme/theme-manager.d.ts +18 -6
- package/dist/theme/theme-manager.d.ts.map +1 -1
- package/dist/theme/theme-manager.js +25 -6
- package/dist/theme/theme-manager.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/is-valid-color.d.ts +13 -0
- package/dist/utils/is-valid-color.d.ts.map +1 -0
- package/dist/utils/is-valid-color.js +32 -0
- package/dist/utils/is-valid-color.js.map +1 -0
- package/dist/utils/is-valid-color.spec.d.ts +2 -0
- package/dist/utils/is-valid-color.spec.d.ts.map +1 -0
- package/dist/utils/is-valid-color.spec.js +82 -0
- package/dist/utils/is-valid-color.spec.js.map +1 -0
- package/package.json +5 -3
- package/dist/color/color-picker.d.ts +0 -23
- package/dist/color/color-picker.d.ts.map +0 -1
- package/dist/color/color-picker.js +0 -118
- package/dist/color/color-picker.js.map +0 -1
- package/dist/color/color-picker.spec.d.ts +0 -2
- package/dist/color/color-picker.spec.d.ts.map +0 -1
- package/dist/color/color-picker.spec.js +0 -60
- package/dist/color/color-picker.spec.js.map +0 -1
- package/dist/color/index.d.ts +0 -3
- package/dist/color/index.d.ts.map +0 -1
- package/dist/color/index.js +0 -3
- package/dist/color/index.js.map +0 -1
- package/dist/color/pallete.js.map +0 -1
- package/dist/examples/nested-theme-example.d.ts +0 -28
- package/dist/examples/nested-theme-example.d.ts.map +0 -1
- package/dist/examples/nested-theme-example.js +0 -313
- package/dist/examples/nested-theme-example.js.map +0 -1
- package/dist/examples/usage-example.d.ts +0 -17
- package/dist/examples/usage-example.d.ts.map +0 -1
- package/dist/examples/usage-example.js +0 -158
- package/dist/examples/usage-example.js.map +0 -1
- package/dist/font/font-picker.d.ts.map +0 -1
- package/dist/font/font-picker.js.map +0 -1
- package/dist/font/font-size-picker.d.ts +0 -19
- package/dist/font/font-size-picker.d.ts.map +0 -1
- package/dist/font/font-size-picker.js +0 -24
- package/dist/font/font-size-picker.js.map +0 -1
- package/dist/font/font-size-picker.spec.d.ts +0 -2
- package/dist/font/font-size-picker.spec.d.ts.map +0 -1
- package/dist/font/font-size-picker.spec.js +0 -48
- package/dist/font/font-size-picker.spec.js.map +0 -1
- /package/dist/{color → core}/pallete.d.ts +0 -0
- /package/dist/{color → core}/pallete.js +0 -0
package/README.md
CHANGED
|
@@ -37,18 +37,18 @@ const title = this.add.text(200, 100, 'Game Title', {
|
|
|
37
37
|
### The Solution 🌟
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
|
-
import {
|
|
40
|
+
import { Color, FontSize } from 'phaser-wind';
|
|
41
41
|
|
|
42
42
|
// Clean, semantic, consistent!
|
|
43
43
|
const button = this.add.text(100, 50, 'Click me!', {
|
|
44
|
-
fontSize:
|
|
45
|
-
fill:
|
|
46
|
-
backgroundColor:
|
|
44
|
+
fontSize: FontSize.css('lg'), // Clear intention!
|
|
45
|
+
fill: Color.rgb('blue-500'), // Beautiful blue
|
|
46
|
+
backgroundColor: Color.rgb('gray-800'), // Perfect contrast
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
const title = this.add.text(200, 100, 'Game Title', {
|
|
50
|
-
fontSize:
|
|
51
|
-
fill:
|
|
50
|
+
fontSize: FontSize.css('3xl'), // Clearly bigger!
|
|
51
|
+
fill: Color.rgb('red-500'), // Vibrant red
|
|
52
52
|
});
|
|
53
53
|
```
|
|
54
54
|
|
|
@@ -87,19 +87,19 @@ pnpm add phaser-wind
|
|
|
87
87
|
Access all Tailwind colors with semantic naming:
|
|
88
88
|
|
|
89
89
|
```typescript
|
|
90
|
-
import {
|
|
90
|
+
import { Color } from 'phaser-wind';
|
|
91
91
|
|
|
92
92
|
// RGB strings (for Phaser text styles)
|
|
93
|
-
const blueText =
|
|
94
|
-
const redButton =
|
|
93
|
+
const blueText = Color.rgb('blue-500'); // 'rgb(59, 130, 246)'
|
|
94
|
+
const redButton = Color.rgb('red-600'); // 'rgb(220, 38, 38)'
|
|
95
95
|
|
|
96
96
|
// Hex numbers (for Phaser graphics)
|
|
97
|
-
const greenRect =
|
|
98
|
-
const purpleCircle =
|
|
97
|
+
const greenRect = Color.hex('green-400'); // 0x4ADE80
|
|
98
|
+
const purpleCircle = Color.hex('purple-300'); // 0xD8B4FE
|
|
99
99
|
|
|
100
100
|
// Basic colors
|
|
101
|
-
const blackText =
|
|
102
|
-
const whiteBackground =
|
|
101
|
+
const blackText = Color.rgb('black'); // 'rgb(0, 0, 0)'
|
|
102
|
+
const whiteBackground = Color.hex('white'); // 0xFFFFFF
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
### Available Colors
|
|
@@ -117,35 +117,35 @@ const whiteBackground = ColorPicker.hex('white'); // 0xFFFFFF
|
|
|
117
117
|
Stop guessing font sizes and use semantic tokens:
|
|
118
118
|
|
|
119
119
|
```typescript
|
|
120
|
-
import {
|
|
120
|
+
import { FontSize } from 'phaser-wind';
|
|
121
121
|
|
|
122
122
|
// Get pixel values
|
|
123
|
-
const smallText =
|
|
124
|
-
const normalText =
|
|
125
|
-
const largeTitle =
|
|
123
|
+
const smallText = FontSize.px('sm'); // 14
|
|
124
|
+
const normalText = FontSize.px('base'); // 16
|
|
125
|
+
const largeTitle = FontSize.px('3xl'); // 30
|
|
126
126
|
|
|
127
127
|
// Get CSS strings (perfect for Phaser)
|
|
128
|
-
const buttonText =
|
|
129
|
-
const heroTitle =
|
|
128
|
+
const buttonText = FontSize.css('lg'); // '18px'
|
|
129
|
+
const heroTitle = FontSize.css('6xl'); // '60px'
|
|
130
130
|
|
|
131
131
|
// Get rem values (if needed)
|
|
132
|
-
const responsiveText =
|
|
132
|
+
const responsiveText = FontSize.rem('xl'); // 1.25
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
### Font Size Scale
|
|
136
136
|
|
|
137
|
-
| Token
|
|
138
|
-
|
|
|
139
|
-
| `xs`
|
|
140
|
-
| `sm`
|
|
141
|
-
| `
|
|
142
|
-
| `lg`
|
|
143
|
-
| `xl`
|
|
144
|
-
| `2xl`
|
|
145
|
-
| `3xl`
|
|
146
|
-
| `4xl`
|
|
147
|
-
| `5xl`
|
|
148
|
-
| `6xl`
|
|
137
|
+
| Token | Pixels | Use Case |
|
|
138
|
+
| ------ | ------ | ----------------------- |
|
|
139
|
+
| `xs` | 12px | Small labels, captions |
|
|
140
|
+
| `sm` | 14px | Body text, descriptions |
|
|
141
|
+
| `base` | 16px | Default text size |
|
|
142
|
+
| `lg` | 18px | Slightly larger text |
|
|
143
|
+
| `xl` | 20px | Subheadings |
|
|
144
|
+
| `2xl` | 24px | Headings |
|
|
145
|
+
| `3xl` | 30px | Large headings |
|
|
146
|
+
| `4xl` | 36px | Hero text |
|
|
147
|
+
| `5xl` | 48px | Display text |
|
|
148
|
+
| `6xl` | 60px | Giant display text |
|
|
149
149
|
|
|
150
150
|
---
|
|
151
151
|
|
|
@@ -213,33 +213,26 @@ ThemeManager.init(gameTheme);
|
|
|
213
213
|
### 🎯 **Using Theme Tokens**
|
|
214
214
|
|
|
215
215
|
```typescript
|
|
216
|
-
import {
|
|
217
|
-
ColorPicker,
|
|
218
|
-
FontPicker,
|
|
219
|
-
SpacingPicker,
|
|
220
|
-
TypographyPicker,
|
|
221
|
-
EffectPicker,
|
|
222
|
-
} from 'phaser-wind';
|
|
216
|
+
import { Color, Font, FontSize, Spacing, ThemeManager } from 'phaser-wind';
|
|
223
217
|
|
|
224
218
|
// Colors - automatically looks in colors.*
|
|
225
|
-
const primaryColor =
|
|
226
|
-
const uiBackground =
|
|
219
|
+
const primaryColor = Color.rgb('primary'); // Gets colors.primary
|
|
220
|
+
const uiBackground = Color.hex('ui-background'); // Gets colors.ui-background
|
|
227
221
|
|
|
228
222
|
// Fonts
|
|
229
|
-
const displayFont =
|
|
230
|
-
const primaryFont =
|
|
223
|
+
const displayFont = Font.family('display'); // Gets fonts.display
|
|
224
|
+
const primaryFont = Font.family('primary'); // Gets fonts.primary
|
|
231
225
|
|
|
232
226
|
// Spacing
|
|
233
|
-
const mediumSpace =
|
|
234
|
-
const largeSpace =
|
|
235
|
-
|
|
236
|
-
// Complete typography styles
|
|
237
|
-
const headingStyle =
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
// Returns: { blur: 8, color: 'purple-600', alpha: 0.6 }
|
|
227
|
+
const mediumSpace = Spacing.px('md'); // Gets spacing.md (16px)
|
|
228
|
+
const largeSpace = Spacing.px('lg'); // Gets spacing.lg (24px)
|
|
229
|
+
|
|
230
|
+
// Complete typography styles - using basic components for now
|
|
231
|
+
const headingStyle = {
|
|
232
|
+
fontSize: FontSize.css('2xl'),
|
|
233
|
+
fontFamily: Font.family('display'),
|
|
234
|
+
fontWeight: 'bold',
|
|
235
|
+
};
|
|
243
236
|
|
|
244
237
|
// Custom tokens
|
|
245
238
|
const animDuration = ThemeManager.getToken('animations.duration'); // 300
|
|
@@ -272,23 +265,23 @@ const themes = ThemeManager.getRegisteredThemes(); // ['light', 'dark', 'cyberpu
|
|
|
272
265
|
export class GameScene extends Phaser.Scene {
|
|
273
266
|
create() {
|
|
274
267
|
// Player health bar with theme colors
|
|
275
|
-
const healthWidth =
|
|
276
|
-
const healthHeight =
|
|
268
|
+
const healthWidth = Spacing.px('24'); // 96px
|
|
269
|
+
const healthHeight = Spacing.px('4'); // 16px
|
|
277
270
|
|
|
278
271
|
this.add.rectangle(
|
|
279
272
|
50,
|
|
280
273
|
50,
|
|
281
274
|
healthWidth,
|
|
282
275
|
healthHeight,
|
|
283
|
-
|
|
276
|
+
Color.hex('player-health')
|
|
284
277
|
); // Green from theme
|
|
285
278
|
|
|
286
279
|
// Game title with theme typography
|
|
287
|
-
const titleStyle = TypographyPicker.phaserStyle('heading');
|
|
288
280
|
this.add
|
|
289
281
|
.text(400, 50, 'CYBER QUEST', {
|
|
290
|
-
|
|
291
|
-
|
|
282
|
+
fontSize: FontSize.css('4xl'),
|
|
283
|
+
fontFamily: Font.family('display'),
|
|
284
|
+
color: Color.rgb('primary'), // Purple from theme
|
|
292
285
|
})
|
|
293
286
|
.setOrigin(0.5);
|
|
294
287
|
|
|
@@ -297,8 +290,8 @@ export class GameScene extends Phaser.Scene {
|
|
|
297
290
|
400,
|
|
298
291
|
400,
|
|
299
292
|
'START GAME',
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
Spacing.px('16'), // 64px width
|
|
294
|
+
Spacing.px('6') // 24px height
|
|
302
295
|
);
|
|
303
296
|
}
|
|
304
297
|
|
|
@@ -310,20 +303,16 @@ export class GameScene extends Phaser.Scene {
|
|
|
310
303
|
height: number
|
|
311
304
|
) {
|
|
312
305
|
const button = this.add
|
|
313
|
-
.rectangle(x, y, width, height,
|
|
306
|
+
.rectangle(x, y, width, height, Color.hex('ui-background'))
|
|
314
307
|
.setInteractive()
|
|
315
|
-
.on('pointerover', () =>
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
.on('pointerout', () =>
|
|
319
|
-
button.setFillStyle(ColorPicker.hex('ui-background'))
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
const buttonText = TypographyPicker.phaserStyle('body');
|
|
308
|
+
.on('pointerover', () => button.setFillStyle(Color.hex('secondary')))
|
|
309
|
+
.on('pointerout', () => button.setFillStyle(Color.hex('ui-background')));
|
|
310
|
+
|
|
323
311
|
this.add
|
|
324
312
|
.text(x, y, text, {
|
|
325
|
-
|
|
326
|
-
|
|
313
|
+
fontSize: FontSize.css('base'),
|
|
314
|
+
fontFamily: Font.family('primary'),
|
|
315
|
+
color: Color.rgb('primary'),
|
|
327
316
|
})
|
|
328
317
|
.setOrigin(0.5);
|
|
329
318
|
}
|
|
@@ -382,50 +371,50 @@ const theme = createTheme({
|
|
|
382
371
|
### Game UI Components
|
|
383
372
|
|
|
384
373
|
```typescript
|
|
385
|
-
import {
|
|
374
|
+
import { Color, FontSize } from 'phaser-wind';
|
|
386
375
|
|
|
387
376
|
export class GameScene extends Phaser.Scene {
|
|
388
377
|
create() {
|
|
389
378
|
// Main title
|
|
390
379
|
this.add
|
|
391
380
|
.text(400, 100, 'SPACE RAIDERS', {
|
|
392
|
-
fontSize:
|
|
393
|
-
fill:
|
|
394
|
-
stroke:
|
|
381
|
+
fontSize: FontSize.css('5xl'),
|
|
382
|
+
fill: Color.rgb('yellow-400'),
|
|
383
|
+
stroke: Color.rgb('yellow-800'),
|
|
395
384
|
strokeThickness: 2,
|
|
396
385
|
})
|
|
397
386
|
.setOrigin(0.5);
|
|
398
387
|
|
|
399
388
|
// Score display
|
|
400
389
|
this.add.text(50, 50, 'Score: 12,500', {
|
|
401
|
-
fontSize:
|
|
402
|
-
fill:
|
|
390
|
+
fontSize: FontSize.css('xl'),
|
|
391
|
+
fill: Color.rgb('green-400'),
|
|
403
392
|
});
|
|
404
393
|
|
|
405
394
|
// Health bar background
|
|
406
395
|
const healthBg = this.add.graphics();
|
|
407
|
-
healthBg.fillStyle(
|
|
396
|
+
healthBg.fillStyle(Color.hex('red-900'));
|
|
408
397
|
healthBg.fillRect(50, 100, 200, 20);
|
|
409
398
|
|
|
410
399
|
// Health bar fill
|
|
411
400
|
const healthFill = this.add.graphics();
|
|
412
|
-
healthFill.fillStyle(
|
|
401
|
+
healthFill.fillStyle(Color.hex('red-500'));
|
|
413
402
|
healthFill.fillRect(52, 102, 156, 16); // 80% health
|
|
414
403
|
|
|
415
404
|
// Game over screen
|
|
416
|
-
this.add.rectangle(400, 300, 600, 400,
|
|
405
|
+
this.add.rectangle(400, 300, 600, 400, Color.hex('slate-900'), 0.9);
|
|
417
406
|
|
|
418
407
|
this.add
|
|
419
408
|
.text(400, 250, 'GAME OVER', {
|
|
420
|
-
fontSize:
|
|
421
|
-
fill:
|
|
409
|
+
fontSize: FontSize.css('4xl'),
|
|
410
|
+
fill: Color.rgb('red-500'),
|
|
422
411
|
})
|
|
423
412
|
.setOrigin(0.5);
|
|
424
413
|
|
|
425
414
|
this.add
|
|
426
415
|
.text(400, 320, 'Final Score: 12,500', {
|
|
427
|
-
fontSize:
|
|
428
|
-
fill:
|
|
416
|
+
fontSize: FontSize.css('2xl'),
|
|
417
|
+
fill: Color.rgb('slate-300'),
|
|
429
418
|
})
|
|
430
419
|
.setOrigin(0.5);
|
|
431
420
|
}
|
|
@@ -445,19 +434,19 @@ class GameButton {
|
|
|
445
434
|
) {
|
|
446
435
|
const colors = {
|
|
447
436
|
primary: {
|
|
448
|
-
bg:
|
|
449
|
-
bgHover:
|
|
450
|
-
text:
|
|
437
|
+
bg: Color.hex('blue-600'),
|
|
438
|
+
bgHover: Color.hex('blue-700'),
|
|
439
|
+
text: Color.rgb('white'),
|
|
451
440
|
},
|
|
452
441
|
secondary: {
|
|
453
|
-
bg:
|
|
454
|
-
bgHover:
|
|
455
|
-
text:
|
|
442
|
+
bg: Color.hex('slate-600'),
|
|
443
|
+
bgHover: Color.hex('slate-700'),
|
|
444
|
+
text: Color.rgb('slate-100'),
|
|
456
445
|
},
|
|
457
446
|
danger: {
|
|
458
|
-
bg:
|
|
459
|
-
bgHover:
|
|
460
|
-
text:
|
|
447
|
+
bg: Color.hex('red-600'),
|
|
448
|
+
bgHover: Color.hex('red-700'),
|
|
449
|
+
text: Color.rgb('white'),
|
|
461
450
|
},
|
|
462
451
|
};
|
|
463
452
|
|
|
@@ -473,7 +462,7 @@ class GameButton {
|
|
|
473
462
|
// Text
|
|
474
463
|
this.text = scene.add
|
|
475
464
|
.text(x, y, text, {
|
|
476
|
-
fontSize:
|
|
465
|
+
fontSize: FontSize.css('lg'),
|
|
477
466
|
fill: style.text,
|
|
478
467
|
})
|
|
479
468
|
.setOrigin(0.5);
|
|
@@ -493,11 +482,11 @@ const quitButton = new GameButton(this, 400, 360, 'QUIT', 'danger');
|
|
|
493
482
|
this.add.particles(player.x, player.y, 'sparkle', {
|
|
494
483
|
speed: { min: 50, max: 100 },
|
|
495
484
|
tint: [
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
485
|
+
Color.hex('blue-400'),
|
|
486
|
+
Color.hex('blue-500'),
|
|
487
|
+
Color.hex('blue-600'),
|
|
488
|
+
Color.hex('cyan-400'),
|
|
489
|
+
Color.hex('cyan-500'),
|
|
501
490
|
],
|
|
502
491
|
lifespan: 1000,
|
|
503
492
|
});
|
|
@@ -510,7 +499,7 @@ this.add.particles(player.x, player.y, 'sparkle', {
|
|
|
510
499
|
### Scene Setup
|
|
511
500
|
|
|
512
501
|
```typescript
|
|
513
|
-
import {
|
|
502
|
+
import { Color, FontSize } from 'phaser-wind';
|
|
514
503
|
|
|
515
504
|
export class MenuScene extends Phaser.Scene {
|
|
516
505
|
constructor() {
|
|
@@ -521,10 +510,10 @@ export class MenuScene extends Phaser.Scene {
|
|
|
521
510
|
// Background gradient effect
|
|
522
511
|
const bg = this.add.graphics();
|
|
523
512
|
bg.fillGradientStyle(
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
513
|
+
Color.hex('slate-900'), // top-left
|
|
514
|
+
Color.hex('slate-800'), // top-right
|
|
515
|
+
Color.hex('slate-800'), // bottom-left
|
|
516
|
+
Color.hex('slate-700') // bottom-right
|
|
528
517
|
);
|
|
529
518
|
bg.fillRect(0, 0, this.cameras.main.width, this.cameras.main.height);
|
|
530
519
|
|
|
@@ -536,9 +525,9 @@ export class MenuScene extends Phaser.Scene {
|
|
|
536
525
|
private createTitle() {
|
|
537
526
|
this.add
|
|
538
527
|
.text(this.cameras.main.centerX, 150, 'MY AWESOME GAME', {
|
|
539
|
-
fontSize:
|
|
540
|
-
fill:
|
|
541
|
-
stroke:
|
|
528
|
+
fontSize: FontSize.css('4xl'),
|
|
529
|
+
fill: Color.rgb('yellow-400'),
|
|
530
|
+
stroke: Color.rgb('yellow-700'),
|
|
542
531
|
strokeThickness: 3,
|
|
543
532
|
})
|
|
544
533
|
.setOrigin(0.5);
|
|
@@ -550,13 +539,13 @@ export class MenuScene extends Phaser.Scene {
|
|
|
550
539
|
menuItems.forEach((item, index) => {
|
|
551
540
|
this.add
|
|
552
541
|
.text(this.cameras.main.centerX, 250 + index * 60, item, {
|
|
553
|
-
fontSize:
|
|
554
|
-
fill:
|
|
542
|
+
fontSize: FontSize.css('xl'),
|
|
543
|
+
fill: Color.rgb('slate-300'),
|
|
555
544
|
})
|
|
556
545
|
.setOrigin(0.5)
|
|
557
546
|
.setInteractive()
|
|
558
547
|
.on('pointerover', function () {
|
|
559
|
-
this.setTint(
|
|
548
|
+
this.setTint(Color.hex('yellow-400'));
|
|
560
549
|
})
|
|
561
550
|
.on('pointerout', function () {
|
|
562
551
|
this.clearTint();
|
|
@@ -575,21 +564,21 @@ export class MenuScene extends Phaser.Scene {
|
|
|
575
564
|
```typescript
|
|
576
565
|
// Create consistent themes
|
|
577
566
|
const darkTheme = {
|
|
578
|
-
background:
|
|
579
|
-
surface:
|
|
580
|
-
primary:
|
|
581
|
-
secondary:
|
|
582
|
-
text:
|
|
583
|
-
textMuted:
|
|
567
|
+
background: Color.hex('slate-900'),
|
|
568
|
+
surface: Color.hex('slate-800'),
|
|
569
|
+
primary: Color.hex('blue-500'),
|
|
570
|
+
secondary: Color.hex('slate-600'),
|
|
571
|
+
text: Color.rgb('slate-100'),
|
|
572
|
+
textMuted: Color.rgb('slate-400'),
|
|
584
573
|
};
|
|
585
574
|
|
|
586
575
|
const lightTheme = {
|
|
587
|
-
background:
|
|
588
|
-
surface:
|
|
589
|
-
primary:
|
|
590
|
-
secondary:
|
|
591
|
-
text:
|
|
592
|
-
textMuted:
|
|
576
|
+
background: Color.hex('slate-50'),
|
|
577
|
+
surface: Color.hex('white'),
|
|
578
|
+
primary: Color.hex('blue-600'),
|
|
579
|
+
secondary: Color.hex('slate-200'),
|
|
580
|
+
text: Color.rgb('slate-900'),
|
|
581
|
+
textMuted: Color.rgb('slate-600'),
|
|
593
582
|
};
|
|
594
583
|
```
|
|
595
584
|
|
|
@@ -599,13 +588,13 @@ const lightTheme = {
|
|
|
599
588
|
// Scale text based on screen size
|
|
600
589
|
const getResponsiveTextSize = (baseSize: FontSizeKey): string => {
|
|
601
590
|
const scale = this.cameras.main.width / 1920; // Base on 1920px width
|
|
602
|
-
const basePixels =
|
|
591
|
+
const basePixels = FontSize.px(baseSize);
|
|
603
592
|
return `${Math.round(basePixels * scale)}px`;
|
|
604
593
|
};
|
|
605
594
|
|
|
606
595
|
this.add.text(x, y, 'Responsive Text', {
|
|
607
596
|
fontSize: getResponsiveTextSize('2xl'),
|
|
608
|
-
fill:
|
|
597
|
+
fill: Color.rgb('blue-500'),
|
|
609
598
|
});
|
|
610
599
|
```
|
|
611
600
|
|
|
@@ -625,16 +614,16 @@ Plus, `phaser-wind` is way easier to type than `phaser-tailwind-css-design-token
|
|
|
625
614
|
|
|
626
615
|
## 📚 Compared to Raw Phaser
|
|
627
616
|
|
|
628
|
-
| Without Phaser Wind | With Phaser Wind
|
|
629
|
-
| ------------------------ |
|
|
630
|
-
| `fill: '#3B82F6'` | `fill:
|
|
631
|
-
| `fontSize: '18px'` | `fontSize:
|
|
632
|
-
| `tint: 0x4ADE80` | `tint:
|
|
633
|
-
| `fontFamily: 'Arial'` | `fontFamily:
|
|
634
|
-
| Magic numbers everywhere | Semantic, consistent tokens
|
|
635
|
-
| Color picking hell | Harmonious color palettes
|
|
636
|
-
| Inconsistent sizing | Perfect typography scale
|
|
637
|
-
| No design system | Complete theme architecture
|
|
617
|
+
| Without Phaser Wind | With Phaser Wind |
|
|
618
|
+
| ------------------------ | ------------------------------- |
|
|
619
|
+
| `fill: '#3B82F6'` | `fill: Color.rgb('primary')` |
|
|
620
|
+
| `fontSize: '18px'` | `fontSize: FontSize.css('lg')` |
|
|
621
|
+
| `tint: 0x4ADE80` | `tint: Color.hex('success')` |
|
|
622
|
+
| `fontFamily: 'Arial'` | `fontFamily: Font.family('ui')` |
|
|
623
|
+
| Magic numbers everywhere | Semantic, consistent tokens |
|
|
624
|
+
| Color picking hell | Harmonious color palettes |
|
|
625
|
+
| Inconsistent sizing | Perfect typography scale |
|
|
626
|
+
| No design system | Complete theme architecture |
|
|
638
627
|
|
|
639
628
|
---
|
|
640
629
|
|