Skip to content

Commit 63a6c86

Browse files
committed
pgInputPixelEditor
1 parent 16ec334 commit 63a6c86

23 files changed

+1135
-0
lines changed

src/pg/inputPixelEditor/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# `<pg-input-pixel-editor>`
2+
3+
The `pg-input-pixel-editor` component is used to edit images. Tailored for pen or mouse input the editor can be used for various image editing tasks.
4+
5+
```typescript
6+
import '@pictogrammers/components/pgInputPixelEditor';
7+
import { PgInputPixelEditor } from '@pictogrammers/components/pgInputPixelEditor';
8+
```
9+
10+
```html
11+
<pg-input-pixel-editor></pg-input-pixel-editor>
12+
```
13+
14+
## Attributes
15+
16+
| Attributes | Tested | Description |
17+
| ----------- | -------- | ----------- |
18+
| name | | Unique name in `pg-form` |
19+
| value | | Field value |
20+
| width | | Pixel width. Default `10` |
21+
| height | | Pixel height. Default `10` |
22+
| size | | Pixel size, minimum value `4`. Default `10` |
23+
| gridSize | | Grid spacing between cells. Default `1` |
24+
25+
## Events
26+
27+
| Events | Tested | Description |
28+
| ---------- | -------- | ----------- |
29+
| change | | `{ detail: { value }` |
30+
| input | | `{ detail: { value }` |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="example">
2+
<pg-input-pixel-editor part="input" width="10" height="10" size="10"></pg-input-pixel-editor>
3+
<div>
4+
<code>onchange: <span part="value1"></span></code>
5+
</div>
6+
<div>
7+
<code>oninput: <span part="value2"></span></code>
8+
</div>
9+
</div>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Component, Part } from '@pictogrammers/element';
2+
import PgInputPixelEditor from '../../inputPixelEditor';
3+
4+
import template from './basic.html';
5+
6+
@Component({
7+
selector: 'x-pg-input-pixel-editor-basic',
8+
template
9+
})
10+
export default class XPgInputPixelEditorBasic extends HTMLElement {
11+
12+
@Part() $input: PgInputPixelEditor;
13+
@Part() $value1: HTMLSpanElement;
14+
@Part() $value2: HTMLSpanElement;
15+
16+
connectedCallback() {
17+
this.$input.addEventListener('change', this.handleChange.bind(this));
18+
this.$input.addEventListener('input', this.handleInput.bind(this));
19+
}
20+
21+
handleChange(e: CustomEvent) {
22+
const { value } = e.detail;
23+
this.$value1.innerText = value;
24+
}
25+
26+
handleInput(e: CustomEvent) {
27+
const { value } = e.detail;
28+
this.$value2.innerText = value;
29+
}
30+
}

src/pg/inputPixelEditor/inputPixelEditor.css

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<canvas part="canvas"></canvas>

0 commit comments

Comments
 (0)