Skip to content

Commit b7c89cd

Browse files
authored
Merge pull request #81 from crashmax-dev/refactor-angular
refactor(packages/angular): ng directive
2 parents 1624e1e + e11b206 commit b7c89cd

File tree

15 files changed

+2092
-2007
lines changed

15 files changed

+2092
-2007
lines changed

examples/with-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"watch": "ng build --watch --configuration development"
1010
},
1111
"dependencies": {
12-
"@fireworks-js/angular": "workspace:*",
1312
"@angular/animations": "^14.0.0",
1413
"@angular/common": "^14.0.0",
1514
"@angular/compiler": "^14.0.0",
@@ -18,6 +17,7 @@
1817
"@angular/platform-browser": "^14.0.0",
1918
"@angular/platform-browser-dynamic": "^14.0.0",
2019
"@angular/router": "^14.0.0",
20+
"@fireworks-js/angular": "workspace:*",
2121
"rxjs": "~7.5.0",
2222
"tslib": "^2.3.0",
2323
"zone.js": "~0.11.4"
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
.btn {
2-
position: absolute;
3-
z-index: 1;
1+
.fireworks {
2+
top: 0;
3+
left: 0;
4+
width: 100%;
5+
height: 100%;
6+
position: fixed;
7+
background: #000;
48
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
<button (click)="toggleFireworks()" class="btn">{{ enabled ? 'Enabled' : 'Disabled' }}</button>
2-
<ng-fireworks [options]="options" class="fireworks" *ngIf="enabled"></ng-fireworks>
1+
<div style="position: absolute; z-index: 999;">
2+
<button (click)="toggleFireworks()">{{ enabled ? 'Mounted' : 'Unmounted' }}</button>
3+
<button (click)="waitStop()">waitStop</button>
4+
</div>
5+
<ng-fireworks #fireworks="ngFireworks" [options]="options" class="fireworks" *ngIf="enabled"></ng-fireworks>
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { Component } from '@angular/core'
2-
import type { FireworksProps } from '@fireworks-js/angular'
1+
import { Component, ViewChild } from '@angular/core'
2+
import type {
3+
FireworksDirective,
4+
FireworksOptions
5+
} from '@fireworks-js/angular'
36

47
@Component({
58
selector: 'app-root',
@@ -8,11 +11,17 @@ import type { FireworksProps } from '@fireworks-js/angular'
811
})
912
export class AppComponent {
1013
enabled = true
11-
options: FireworksProps = {
14+
options: FireworksOptions = {
1215
opacity: 0.5
1316
}
1417

18+
@ViewChild('fireworks') fireworks?: FireworksDirective
19+
1520
public toggleFireworks(): void {
1621
this.enabled = !this.enabled
1722
}
23+
24+
public waitStop(): void {
25+
this.fireworks?.waitStop()
26+
}
1827
}
948 Bytes
Binary file not shown.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<!doctype html>
22
<html lang="en">
3-
43
<head>
54
<meta charset="utf-8">
65
<title>@fireworks-js/angular</title>
76
<base href="/">
87
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="icon" type="image/x-icon" href="favicon.ico">
99
</head>
10-
1110
<body>
1211
<app-root></app-root>
1312
</body>
14-
1513
</html>
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
11
/* You can add global styles to this file, and also import other style files */
2-
.fireworks > div {
3-
top: 0;
4-
left: 0;
5-
width: 100%;
6-
height: 100%;
7-
position: fixed;
8-
background: #000;
9-
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
"description": "A simple fireworks library!",
77
"homepage": "https://fireworks.js.org",
88
"scripts": {
9+
"dev": "turbo run dev --filter='./packages/fireworks-js'",
10+
"build": "turbo run build --filter='./packages/*'",
911
"dev:website": "turbo run dev --filter='./website'",
10-
"dev:examples": "turbo run dev --filter='./examples/*'",
1112
"build:website": "turbo run build --filter='./website'",
12-
"build:packages": "turbo run build --filter='./packages/*'",
13+
"dev:examples": "turbo run dev --filter='./examples/*'",
1314
"build:examples": "turbo run build --filter='./examples/*'",
1415
"format": "prettier --write --ignore-unknown **"
1516
},

packages/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@angular/platform-browser": "^14.1.2",
3232
"@angular/platform-browser-dynamic": "^14.1.2",
3333
"@angular/router": "^14.1.2",
34-
"fireworks-js": "workspace:2.2.0",
34+
"fireworks-js": "workspace:2.2.1",
3535
"rxjs": "~7.5.6",
3636
"tslib": "2.4.0",
3737
"zone.js": "~0.11.8"

packages/angular/projects/ng-fireworks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@angular/core": "^14.0.0"
2828
},
2929
"dependencies": {
30-
"fireworks-js": "workspace:2.2.0",
30+
"fireworks-js": "workspace:2.2.1",
3131
"tslib": "2.4.0"
3232
}
3333
}

0 commit comments

Comments
 (0)