@pictogrammers/components 0.5.11 → 0.5.13

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pictogrammers/components",
3
3
  "type": "module",
4
- "version": "0.5.11",
4
+ "version": "0.5.13",
5
5
  "license": "MIT",
6
6
  "author": "Austin Andrews",
7
7
  "scripts": {
@@ -19,8 +19,6 @@ export default class PgButton extends HTMLElement {
19
19
  @Prop(normalizeBoolean) end: boolean = false;
20
20
 
21
21
  @Part() $button: HTMLButtonElement;
22
- @Part() $number: HTMLSpanElement;
23
- @Part() $bar: HTMLSpanElement;
24
22
 
25
23
  connectedCallback() {
26
24
  this.$button.addEventListener('click', (e) => {
@@ -0,0 +1,18 @@
1
+ # `<pg-button-increment>`
2
+
3
+ The `pg-button-increment` is the `pg-button` component with an `increment` event for holding down.
4
+
5
+ ```typescript
6
+ import '@pictogrammers/components/pg/buttonIncrement';
7
+ import PgButtonIncrement from '@pictogrammers/components/pg/buttonIncrement';
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ this.$button.incrementDelay = 300; // default
14
+ this.$button.incrementStepDelay = 100; // default
15
+ this.$button.addEventListener('increment', () => {
16
+ // called on initial click and after every 50ms
17
+ });
18
+ ```
@@ -0,0 +1,4 @@
1
+ .example-flex {
2
+ display: flex;
3
+ gap: 0.5rem;
4
+ }
@@ -0,0 +1,12 @@
1
+ <div class="example">
2
+ <div class="example-flex">
3
+ <pg-button-increment part="button1">
4
+ <pg-icon path="M12,19.2C9.5,19.2 7.29,17.92 6,16C6.03,14 10,12.9 12,12.9C14,12.9 17.97,14 18,16C16.71,17.92 14.5,19.2 12,19.2M12,5A3,3 0 0,1 15,8A3,3 0 0,1 12,11A3,3 0 0,1 9,8A3,3 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z"></pg-icon>
5
+ Clicked <span part="count1">0</span> Times
6
+ </pg-button-increment>
7
+ <pg-button-increment part="button2">
8
+ <pg-icon path="M12,19.2C9.5,19.2 7.29,17.92 6,16C6.03,14 10,12.9 12,12.9C14,12.9 17.97,14 18,16C16.71,17.92 14.5,19.2 12,19.2M12,5A3,3 0 0,1 15,8A3,3 0 0,1 12,11A3,3 0 0,1 9,8A3,3 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z"></pg-icon>
9
+ Clicked <span part="count2">0</span> Times, incrementStepDelay = 50;
10
+ </pg-button-increment>
11
+ </div>
12
+ </div>
@@ -0,0 +1,29 @@
1
+ import { Component, Part } from '@pictogrammers/element';
2
+ import PgButtonIncrement from '../../buttonIncrement';
3
+
4
+ import style from './basic.css';
5
+ import template from './basic.html';
6
+
7
+ @Component({
8
+ selector: 'x-pg-button-increment-basic',
9
+ style,
10
+ template,
11
+ })
12
+ export default class XPgButtonBasic extends HTMLElement {
13
+ @Part() $button1: PgButtonIncrement;
14
+ @Part() $count1: HTMLSpanElement;
15
+ @Part() $button2: PgButtonIncrement;
16
+ @Part() $count2: HTMLSpanElement;
17
+
18
+ connectedCallback() {
19
+ this.$button1.addEventListener('increment', () => {
20
+ const count = parseInt(this.$count1.textContent, 10);
21
+ this.$count1.textContent = `${count + 1}`;
22
+ });
23
+ this.$button2.incrementStepDelay = 50;
24
+ this.$button2.addEventListener('increment', () => {
25
+ const count = parseInt(this.$count2.textContent, 10);
26
+ this.$count2.textContent = `${count + 1}`;
27
+ });
28
+ }
29
+ }
File without changes
@@ -0,0 +1 @@
1
+ <parent />
@@ -0,0 +1,39 @@
1
+ import { Component, normalizeInt, Part, Prop } from '@pictogrammers/element';
2
+
3
+ import template from './buttonIncrement.html';
4
+ import style from './buttonIncrement.css';
5
+ import PgButton from '../button/button';
6
+
7
+ var timeout, interval;
8
+
9
+ function clearTimers() {
10
+ clearTimeout(timeout);
11
+ clearInterval(interval);
12
+ }
13
+
14
+ @Component({
15
+ selector: 'pg-button-increment',
16
+ style,
17
+ template
18
+ })
19
+ export default class PgButtonIncrement extends PgButton {
20
+ @Prop(normalizeInt) incrementDelay = 300;
21
+ @Prop(normalizeInt) incrementStepDelay = 100;
22
+
23
+ connectedCallback() {
24
+ super.connectedCallback();
25
+ this.$button.addEventListener('pointerdown', () => {
26
+ const targetId = this.dataset.target;
27
+
28
+ this.dispatchEvent(new CustomEvent('increment'));
29
+
30
+ timeout = setTimeout(() => {
31
+ interval = setInterval(() => {
32
+ this.dispatchEvent(new CustomEvent('increment'));
33
+ }, this.incrementStepDelay);
34
+ }, this.incrementDelay);
35
+ });
36
+ this.$button.addEventListener('pointerup', clearTimers);
37
+ this.$button.addEventListener('pointerleave', clearTimers);
38
+ }
39
+ }
@@ -0,0 +1,3 @@
1
+ import PgButtonIncrement from './buttonIncrement';
2
+
3
+ export default PgButtonIncrement;