@pb33f/cowboy-components 0.6.5 → 0.6.6

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.
@@ -1,10 +1,12 @@
1
1
  import { LitElement } from "lit";
2
2
  import { SlDialog } from "@shoelace-style/shoelace";
3
+ import { OAuthLogin } from "./oauth-login";
3
4
  export declare class LoginButton extends LitElement {
4
5
  static styles: import("lit").CSSResult[];
5
6
  authDialog: SlDialog;
6
7
  title: string;
7
8
  buttonLabel: string;
9
+ oauthLogin: OAuthLogin;
8
10
  private controller;
9
11
  constructor();
10
12
  render(): import("lit-html").TemplateResult<1>;
@@ -42,6 +42,8 @@ let LoginButton = class LoginButton extends LitElement {
42
42
  }
43
43
  hide() {
44
44
  this.authDialog.hide();
45
+ this.oauthLogin.animateBox = false;
46
+ this.oauthLogin.requestUpdate();
45
47
  }
46
48
  authenticatedView() {
47
49
  return html `
@@ -68,6 +70,8 @@ let LoginButton = class LoginButton extends LitElement {
68
70
  }));
69
71
  }
70
72
  openAuthModal() {
73
+ this.oauthLogin.animateBox = true;
74
+ this.oauthLogin.requestUpdate();
71
75
  this.authDialog.show();
72
76
  }
73
77
  };
@@ -81,6 +85,9 @@ __decorate([
81
85
  __decorate([
82
86
  property()
83
87
  ], LoginButton.prototype, "buttonLabel", void 0);
88
+ __decorate([
89
+ query('pb33f-oauth-login')
90
+ ], LoginButton.prototype, "oauthLogin", void 0);
84
91
  LoginButton = __decorate([
85
92
  customElement('pb33f-login-button')
86
93
  ], LoginButton);
@@ -1,6 +1,7 @@
1
1
  import { LitElement } from "lit";
2
2
  import '../electric-box/electric-box.js';
3
3
  import { SlAnimation, SlButton } from "@shoelace-style/shoelace";
4
+ import { ElectricBox } from "../electric-box/electric-box";
4
5
  export declare class OAuthLogin extends LitElement {
5
6
  static styles: import("lit").CSSResult[];
6
7
  title: string;
@@ -9,8 +10,10 @@ export declare class OAuthLogin extends LitElement {
9
10
  maxtravel: number;
10
11
  spin: number;
11
12
  orbs: boolean;
13
+ animateBox: boolean;
12
14
  buttonAnimation: SlAnimation;
13
15
  githubButton: SlButton;
16
+ electricBox: ElectricBox;
14
17
  constructor();
15
18
  githubLogin(): void;
16
19
  render(): import("lit-html").TemplateResult<1>;
@@ -19,6 +19,7 @@ let OAuthLogin = class OAuthLogin extends LitElement {
19
19
  this.maxtravel = 6500;
20
20
  this.spin = 20;
21
21
  this.orbs = true;
22
+ this.animateBox = false;
22
23
  }
23
24
  githubLogin() {
24
25
  this.mintravel = 1000;
@@ -36,9 +37,11 @@ let OAuthLogin = class OAuthLogin extends LitElement {
36
37
  }, 2000);
37
38
  }
38
39
  render() {
40
+ console.log('rendering with ' + this.animateBox);
39
41
  return html `
40
42
  <div style="width: 500px; height: 280px; margin: 0 auto;">
41
- <pb33f-electric-box .orbs="${this.orbs}"
43
+ <pb33f-electric-box .orbs="${this.orbs}"
44
+ ?disable=${!this.animateBox}
42
45
  spin spinamount="${this.spin}"
43
46
  mintraveltime="${this.mintravel}"
44
47
  maxtraveltime="${this.maxtravel}"
@@ -81,12 +84,18 @@ __decorate([
81
84
  __decorate([
82
85
  state()
83
86
  ], OAuthLogin.prototype, "orbs", void 0);
87
+ __decorate([
88
+ state()
89
+ ], OAuthLogin.prototype, "animateBox", void 0);
84
90
  __decorate([
85
91
  query('#button-anim')
86
92
  ], OAuthLogin.prototype, "buttonAnimation", void 0);
87
93
  __decorate([
88
94
  query('#github-button')
89
95
  ], OAuthLogin.prototype, "githubButton", void 0);
96
+ __decorate([
97
+ query('pb33f-electric-box')
98
+ ], OAuthLogin.prototype, "electricBox", void 0);
90
99
  OAuthLogin = __decorate([
91
100
  customElement("pb33f-oauth-login")
92
101
  ], OAuthLogin);
@@ -10,6 +10,7 @@ export declare class ElectricBox extends LitElement {
10
10
  maxtraveltime: number;
11
11
  height: number;
12
12
  heroView: boolean;
13
+ disable: boolean;
13
14
  color: string;
14
15
  private container;
15
16
  private orbPath;
@@ -24,6 +25,9 @@ export declare class ElectricBox extends LitElement {
24
25
  constructor();
25
26
  render(): TemplateResult;
26
27
  protected firstUpdated(): void;
28
+ protected updated(): void;
29
+ runAnimation(): void;
30
+ stopAnimation(): void;
27
31
  protected willUpdate(): void;
28
32
  disconnectedCallback(): void;
29
33
  private getRandomBorderPosition;
@@ -23,6 +23,7 @@ let ElectricBox = class ElectricBox extends LitElement {
23
23
  this.maxtraveltime = 4000;
24
24
  this.heroView = false;
25
25
  this.height = 500;
26
+ this.disable = false;
26
27
  }
27
28
  render() {
28
29
  return html `
@@ -91,31 +92,50 @@ let ElectricBox = class ElectricBox extends LitElement {
91
92
  this.orbGroup = this.container.select("#orb-group");
92
93
  this.orb = this.container.select("#orb-circle");
93
94
  this.orb.attr({ display: "none" });
94
- if (this.orbs) {
95
- this.orbTimer = setInterval(() => {
96
- this.spawnOrb();
97
- }, 500);
95
+ }
96
+ updated() {
97
+ if (this.disable) {
98
+ this.stopAnimation();
99
+ }
100
+ else {
101
+ this.runAnimation();
98
102
  }
99
- this.pixelSpawnTimer = setInterval(() => {
100
- if (this.activePixelCount < this.pixelConfig.maxActivePixels) {
101
- this.spawnPixel();
102
- }
103
- }, this.pixelConfig.spawnIntervalMs);
104
103
  }
105
- willUpdate() {
106
- if (this.orbTimer && !this.orbs) {
107
- clearInterval(this.orbTimer);
104
+ runAnimation() {
105
+ // Ensure timers have not already been started.
106
+ if (!this.pixelSpawnTimer && !this.disable) {
107
+ if (this.orbs) {
108
+ this.orbTimer = setInterval(() => {
109
+ this.spawnOrb();
110
+ }, 500);
111
+ }
112
+ this.pixelSpawnTimer = setInterval(() => {
113
+ if (this.activePixelCount < this.pixelConfig.maxActivePixels) {
114
+ this.spawnPixel();
115
+ }
116
+ }, this.pixelConfig.spawnIntervalMs);
108
117
  }
109
118
  }
110
- disconnectedCallback() {
111
- super.disconnectedCallback();
119
+ stopAnimation() {
120
+ // Clear the animation timers if they exist.
112
121
  if (this.pixelSpawnTimer) {
113
122
  clearInterval(this.pixelSpawnTimer);
123
+ this.pixelSpawnTimer = null;
114
124
  }
115
125
  if (this.orbTimer) {
116
126
  clearInterval(this.orbTimer);
127
+ this.orbTimer = null;
128
+ }
129
+ }
130
+ willUpdate() {
131
+ if (this.orbTimer && !this.orbs) {
132
+ clearInterval(this.orbTimer);
117
133
  }
118
134
  }
135
+ disconnectedCallback() {
136
+ super.disconnectedCallback();
137
+ this.stopAnimation();
138
+ }
119
139
  getRandomBorderPosition() {
120
140
  // If heroView is true, only spawn pixels on the top (edge 0) or bottom (edge 1)
121
141
  if (this.heroView) {
@@ -327,6 +347,9 @@ __decorate([
327
347
  __decorate([
328
348
  property({ type: Boolean })
329
349
  ], ElectricBox.prototype, "heroView", void 0);
350
+ __decorate([
351
+ property({ type: Boolean, attribute: 'disable' })
352
+ ], ElectricBox.prototype, "disable", void 0);
330
353
  __decorate([
331
354
  property()
332
355
  ], ElectricBox.prototype, "color", void 0);