Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: Pixi v8 update #142

Merged
merged 46 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
932708a
add initial files
CyberDex Oct 6, 2023
39f2d4c
add initial files
CyberDex Oct 6, 2023
c26b669
fix eslint roles
CyberDex Oct 6, 2023
05d0dfc
abstract pixi & implement eresize
CyberDex Oct 6, 2023
7a5f1a1
fix button
CyberDex Oct 6, 2023
ecf19ce
update to v8
Zyie Jan 4, 2024
7ce2c9c
update pixi
Zyie Jan 9, 2024
5f1397b
fix on update
Zyie Jan 11, 2024
f9705e6
Merge branch 'dev' into v8
CyberDex Feb 1, 2024
c1946a5
Merge remote-tracking branch 'origin/main' into pixi8
CyberDex Feb 1, 2024
2029c4e
Merge branch 'v8' into pixi8
CyberDex Feb 1, 2024
554da45
test platform wip
CyberDex Feb 1, 2024
51a7fc1
wip
CyberDex Feb 12, 2024
d43859e
fix graphics
CyberDex Feb 12, 2024
8a488b0
wip
CyberDex Feb 12, 2024
8eafe5a
wip
CyberDex Feb 12, 2024
43c0f87
wip
CyberDex Feb 12, 2024
66d5aac
wip
CyberDex Feb 12, 2024
a1ce011
add comment
CyberDex Feb 12, 2024
78134f6
wip
CyberDex Feb 13, 2024
bf46d0f
wip
CyberDex Feb 13, 2024
0ccafbd
refactor
CyberDex Feb 13, 2024
bbec152
update pixi
CyberDex Feb 13, 2024
c37523b
wip
CyberDex Feb 13, 2024
d3c224e
update to v8 release
Zyie Mar 7, 2024
c287802
more updates
Zyie Mar 7, 2024
b97afe1
update stories
Zyie Mar 12, 2024
888a3c0
fix masked frame
Zyie Mar 12, 2024
f1b4c08
update select
Zyie Mar 12, 2024
4bfff40
test
Zyie Mar 12, 2024
7069e3c
test
Zyie Mar 12, 2024
495b91b
remove vite
Zyie Mar 12, 2024
ce1ebd2
add some tweeks
CyberDex Mar 12, 2024
5e0b447
disable input mask by default
CyberDex Mar 12, 2024
8530323
cleanup
CyberDex Mar 12, 2024
da6b0b9
fix masked frame
Zyie Mar 12, 2024
ca0c960
refactor
CyberDex Mar 12, 2024
19ed308
cleanup docs
CyberDex Mar 13, 2024
7489f4a
update to 8.0.2
Zyie Mar 13, 2024
80821f6
Merge branch 'dev' into pixi8-update
Zyie Mar 19, 2024
49647bb
Merge branch 'dev' into pixi8-update
Zyie Mar 19, 2024
c2bee6b
Merge branch 'dev' into pixi8-update
Zyie Mar 21, 2024
c4e3a05
Merge branch 'dev' into pixi8-update
Zyie Mar 21, 2024
dc9737c
Merge branch 'dev' into pixi8-update
Zyie Mar 21, 2024
8842227
add compatibility check
Zyie Mar 21, 2024
c692e6b
fix lint
Zyie Mar 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
}
},
"rules": {
"no-restricted-imports": ["error", { "paths": ["pixi.js"] }],
"@typescript-eslint/no-unused-expressions": [1, {"allowShortCircuit": true, "allowTernary": true}],
"no-mixed-operators": "off",
"no-mixed-operators/no-mixed-operators": 1,
"@typescript-eslint/no-parameter-properties": 1,
"@typescript-eslint/type-annotation-spacing": 1,
"jsdoc/multiline-blocks": [
1,
Expand All @@ -33,7 +31,6 @@
"jsdoc/check-values": 1,
"jsdoc/empty-tags": 1,
"jsdoc/implements-on-classes": 1,
"jsdoc/newline-after-description": [1, "never"],
"jsdoc/no-multi-asterisks": [1, { "allowWhitespace": true }],
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 0,
Expand Down
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ Here are some useful resources:

**We are now a part of the [Open Collective](https://opencollective.com/pixijs) and with your support you can help us make PixiJS even better. To make a donation, simply click the button below and we'll love you forever!**

## Compatibility

Depending on your version of PixiJS, you'll need to figure out which major version of PixiJS UI to use.

| PixiJS | PixiJS UI |
|-------------|----------------|
| v7.x | v1.x |
| v8.x | v2.x |


## Install

```sh
Expand Down
18,392 changes: 4,708 additions & 13,684 deletions package-lock.json

Large diffs are not rendered by default.

59 changes: 22 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dist/"
],
"scripts": {
"start": "storybook dev -p 6006",
"start": "npm run storybook",
"build": "xs build",
"clean": "xs clean",
"deploy": "xs deploy",
Expand Down Expand Up @@ -60,53 +60,38 @@
"docsDescription": "API Documentation for UI components made with PixiJS",
"docsKeyword": "PixiJS, UI, components"
},
"peerDependencies": {
"pixi.js": "^8.0.2"
},
"dependencies": {
"tweedle.js": "^2.1.0",
"typed-signals": "^2.5.0"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@pixi/core": "^7.3.1",
"@pixi/display": "^7.3.1",
"@pixi/eslint-config": "^4.0.1",
"@pixi/events": "^7.3.1",
"@pixi/extension-scripts": "^1.3.0",
"@pixi/graphics": "^7.3.1",
"@pixi/mesh-extras": "^7.3.2",
"@pixi/sprite": "^7.3.1",
"@pixi/storybook-renderer": "^0.0.6",
"@pixi/storybook-webpack5": "^0.0.6",
"@pixi/text": "^7.3.1",
"@pixi/text-bitmap": "^7.3.1",
"@pixi/text-html": "^7.3.1",
"@storybook/addon-essentials": "7.5.2",
"@storybook/addon-interactions": "7.5.2",
"@storybook/addon-links": "7.5.2",
"@storybook/addon-storysource": "^7.5.2",
"@pixi/extension-scripts": "^2.4.1",
"@pixi/storybook-renderer": "^0.1.0",
"@pixi/storybook-webpack5": "^0.1.0",
"@storybook/addon-essentials": "7.6.17",
"@storybook/addon-interactions": "7.6.17",
"@storybook/addon-links": "7.6.17",
"@storybook/addon-storysource": "^7.6.17",
"@storybook/testing-library": "^0.2.2",
"@types/babel__core": "^7.1.20",
"@types/jest": "^29.2.4",
"@types/node": "^18.11.17",
"eslint": "^8.30.0",
"eslint-plugin-jsdoc": "^39.6.4",
"@storybook/types": "^7.6.17",
"@types/babel__core": "^7.20.5",
"@types/jest": "^29.5.12",
"@types/node": "^18.19.22",
"eslint": "^8.57.0",
"eslint-plugin-jsdoc": "^48.2.1",
"eslint-plugin-no-mixed-operators": "^1.1.1",
"husky": "^8.0.0",
"husky": "^8.0.3",
"jest": "^26.6.3",
"jest-raw-loader": "^1.0.1",
"lint-staged": "^13.1.0",
"storybook": "7.5.2",
"typescript": "^5.2.0"
},
"peerDependencies": {
"@pixi/core": "^7.3.1",
"@pixi/display": "^7.3.1",
"@pixi/events": "^7.3.1",
"@pixi/graphics": "^7.3.1",
"@pixi/sprite": "^7.3.1",
"@pixi/text": "^7.3.1",
"@pixi/text-bitmap": "^7.3.1",
"@pixi/text-html": "^7.3.1"
"lint-staged": "^13.3.0",
"storybook": "7.6.17",
"pixi.js": "^8.0.2",
"typescript": "^5.4.2"
},
"publishConfig": {
"access": "public"
Expand Down
14 changes: 6 additions & 8 deletions src/Button.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Container } from '@pixi/display';
import { ButtonEvents } from './ButtonEvents';
import { Container, FederatedPointerEvent } from 'pixi.js';
import { Signal } from 'typed-signals';
import { FederatedPointerEvent } from '@pixi/events';
import { ButtonEvents } from './ButtonEvents';

/**
* Adds button events to a given container-based view
Expand All @@ -11,14 +10,13 @@ import { FederatedPointerEvent } from '@pixi/events';
* const container = new Container();
* const button = new Button(
* new Graphics()
* .beginFill(0xFFFFFF)
* .drawRoundedRect(0, 0, 100, 50, 15)
* .rect(0, 0, 100, 50, 15)
* .fill(0xFFFFFF)
* );
*
* button.onPress.connect(() => console.log('onPress'));
*
* container.addChild(button.view);
* // or container.addChild(container); which is the same
*/
export class Button extends ButtonEvents
{
Expand Down Expand Up @@ -92,8 +90,8 @@ export class Button extends ButtonEvents
* @example
* const button = new ButtonContainer(
* new Graphics()
* .beginFill(0xFFFFFF)
* .drawRoundedRect(0, 0, 100, 50, 15)
* .fill(0xFFFFFF)
* .roundRect(0, 0, 100, 50, 15)
* );
*
* button.onPress.connect(() => console.log('onPress'));
Expand Down
8 changes: 3 additions & 5 deletions src/ButtonEvents.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { FederatedPointerEvent } from '@pixi/events';
import { isMobile, utils } from '@pixi/core';
import { Container, FederatedPointerEvent, isMobile } from 'pixi.js';
import { Signal } from 'typed-signals';
import { Container } from '@pixi/display';

/** Events controller used for {@link Button}. */
export class ButtonEvents
Expand Down Expand Up @@ -40,7 +38,7 @@ export class ButtonEvents

protected connectEvents(view: Container)
{
if (utils.isMobile.any)
if (isMobile.any)
{
view.on('pointerdown', this.processDown, this);
view.on('pointerup', this.processUp, this);
Expand All @@ -62,7 +60,7 @@ export class ButtonEvents

protected disconnectEvents(view: Container)
{
if (utils.isMobile.any)
if (isMobile.any)
{
view.off('pointerdown', this.processDown, this);
view.off('pointerup', this.processUp, this);
Expand Down
45 changes: 23 additions & 22 deletions src/CheckBox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Container } from '@pixi/display';
import { Text } from '@pixi/text';
import { Container, Text } from 'pixi.js';
import { Signal } from 'typed-signals';
import { Switcher } from './Switcher';
import { cleanup } from './utils/helpers/cleanup';
Expand Down Expand Up @@ -36,7 +35,7 @@ export type CheckBoxOptions = {
export class CheckBox extends Switcher
{
//* Text label */
label!: PixiText;
labelText!: PixiText;

/** Signal emitted when checkbox state changes. */
onCheck: Signal<(state: boolean) => void>;
Expand Down Expand Up @@ -68,31 +67,34 @@ export class CheckBox extends Switcher
{
if (!text) return;

this.label = new this._textClass(text ?? '', style ?? this._style?.text);
this.addChild(this.label);
this.labelText = new this._textClass({
text: text ?? '',
style: style ?? this._style?.text,
});
this.addChild(this.labelText);

this.label.cursor = 'pointer';
this.label.eventMode = 'static';
this.label.on('pointertap', () => (this.checked = !this.checked));
this.labelText.cursor = 'pointer';
this.labelText.eventMode = 'static';
this.labelText.on('pointertap', () => (this.checked = !this.checked));
}

/** Setter, which sets a checkbox text. */
set text(text: string)
{
if (!text)
{
cleanup(this.label);
cleanup(this.labelText);

return;
}

this.label ? (this.label.text = text) : this.addLabel(text);
this.labelText ? (this.labelText.text = text) : this.addLabel(text);
}

/** Getter, which returns a checkbox text. */
get text(): string | ''
{
return this.label?.text ?? '';
return this.labelText?.text ?? '';
}

/** Setter, which sets a checkbox style settings. */
Expand Down Expand Up @@ -120,22 +122,21 @@ export class CheckBox extends Switcher
uncheckedView.visible = true;
}

if (this.label)
if (this.labelText)
{
checkedView.visible = true;
this.active = 1;
if (style.text)
{
if ('style' in this.label)
{
this.label.style = style.text;
}
else
{
Object.assign(this.label, style.text);
}
this.labelText.style = style.text;
}

this.label.x = uncheckedView.width + 10 + (style.textOffset?.x ?? 0);
this.label.y = ((uncheckedView.height - this.label.height) / 2) + (style.textOffset?.y ?? 0);
this.labelText.x = uncheckedView.width + 10 + (style.textOffset?.x ?? 0);
this.labelText.y = ((uncheckedView.height - this.labelText.height) / 2) + (style.textOffset?.y ?? 0);
}
else
{
uncheckedView.visible = true;
}
}

Expand Down
34 changes: 17 additions & 17 deletions src/CircularProgressBar.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { DEG_TO_RAD } from '@pixi/core';
import { Container } from '@pixi/display';
import { Graphics, LINE_CAP } from '@pixi/graphics';
import { ColorSource, Container, DEG_TO_RAD, Graphics, LineCap } from 'pixi.js';

export type MaskedProgressBarOptions = {
backgroundColor?: number;
fillColor: number;
backgroundColor?: ColorSource;
fillColor: ColorSource;
lineWidth: number;
radius: number;
value?: number;
backgroundAlpha?: number;
fillAlpha?: number;
cap?: 'butt' | 'round' | 'square';
cap?: LineCap;
};

/**
Expand Down Expand Up @@ -42,8 +40,8 @@ export class CircularProgressBar extends Container
/**
* Creates a Circular ProgressBar.
* @param { number } options - Options object to use.
* @param { number } options.backgroundColor - Background color.
* @param { number } options.fillColor - Fill color.
* @param { ColorSource } options.backgroundColor - Background color.
* @param { ColorSource } options.fillColor - Fill color.
* @param { number } options.lineWidth - Line width.
* @param { number } options.radius - Radius.
* @param { number } options.value - Progress value.
Expand Down Expand Up @@ -90,11 +88,13 @@ export class CircularProgressBar extends Container
alpha = 0.000001;
}

this.bgCircle.lineStyle({
width: lineWidth,
color: backgroundColor,
alpha
}).drawCircle(0, 0, radius);
this.bgCircle
.circle(0, 0, radius)
.stroke({
width: lineWidth,
color: backgroundColor,
alpha
});
}

/**
Expand Down Expand Up @@ -135,13 +135,13 @@ export class CircularProgressBar extends Container

this.fillCircle
.clear()
.lineStyle({
.arc(0, 0, radius, (0 - 90 + startAngle) * DEG_TO_RAD, (0 - 90 + startAngle + endAngle) * DEG_TO_RAD)
.stroke({
width: lineWidth,
color: fillColor,
cap: cap as LINE_CAP,
cap,
alpha: fillAlpha
})
.arc(0, 0, radius, (0 - 90 + startAngle) * DEG_TO_RAD, (0 - 90 + startAngle + endAngle) * DEG_TO_RAD);
});
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/DoubleSlider.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FederatedPointerEvent } from '@pixi/events';
import type { DragObject } from './utils/HelpTypes';
import { DoubleSliderOptions, SliderBase } from './SliderBase';
import { Container, FederatedPointerEvent } from 'pixi.js';
import { Signal } from 'typed-signals';
import { Container } from '@pixi/display';
import { DoubleSliderOptions, SliderBase } from './SliderBase';

import type { DragObject } from './utils/HelpTypes';

/**
* Creates a slider with range selection option.
Expand Down Expand Up @@ -270,8 +270,8 @@ export class DoubleSlider extends SliderBase

/**
* Sets width of a Sliders background and fill.
* If nineSlicePlane is set, then width will be set to nineSlicePlane.
* If nineSlicePlane is not set, then width will control components width as Container.
* If nineSliceSprite is set, then width will be set to nineSliceSprite.
* If nineSliceSprite is not set, then width will control components width as Container.
* @param value - Width value.
*/
override set width(value: number)
Expand All @@ -290,8 +290,8 @@ export class DoubleSlider extends SliderBase

/**
* Sets height of a Sliders background and fill.
* If nineSlicePlane is set, then height will be set to nineSlicePlane.
* If nineSlicePlane is not set, then height will control components height as Container.
* If nineSliceSprite is set, then height will be set to nineSliceSprite.
* If nineSliceSprite is not set, then height will control components height as Container.
* @param value - Height value.
*/
override set height(value: number)
Expand Down
Loading
Loading