Skip to content

Commit f6bed10

Browse files
committed
Fixing bugs.
1 parent c357d23 commit f6bed10

File tree

25 files changed

+184
-75
lines changed

25 files changed

+184
-75
lines changed

src/pg/inputPixelEditor/__examples__/basic/basic.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,19 @@ export default class XPgInputPixelEditorBasic extends HTMLElement {
169169
this.$colors.columns = [{
170170
label: 'Red',
171171
key: 'r',
172+
editable: true,
172173
}, {
173174
label: 'Green',
174175
key: 'g',
176+
editable: true,
175177
}, {
176178
label: 'Blue',
177179
key: 'b',
180+
editable: true,
178181
}, {
179182
label: 'Alpha',
180183
key: 'a',
184+
editable: true,
181185
}, {
182186
label: 'Delete',
183187
key: 'delete',

src/pg/inputText/inputText.css

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@
33
font-family: var(--pg-font-family);
44
}
55

6-
[part="input"] {
6+
[part=input] {
77
border: 1px solid var(--pg-input-text-border-color, #453C4F);
88
border-radius: 0.125rem;
9-
padding: calc(0.5rem - 1px) 0.75rem;
9+
padding: var(--pg-input-text-padding, calc(0.5rem - 1px) 0.75rem);
1010
font-family: var(--pg-font-family);
1111
font-size: 1rem;
1212
outline: none;
13-
width: calc(100% - 1.5rem - 2px);
13+
field-sizing: content;
14+
min-width: calc(100% - 0.5rem - 2px);
15+
max-width: calc(var(--pg-input-text-max-width, 100%) - 0.5rem - 2px);
16+
background-color: transparent;
1417
}
1518

16-
[part="input"]:active {
19+
[part=input]:read-only {
20+
border-color: transparent;
21+
}
22+
23+
[part=input]:active {
1724
box-shadow: 0 0 0 3px var(--pg-input-text-active-glow, rgb(79, 143, 249, 0.6));
1825
}
19-
[part="input"]:focus {
26+
[part=input]:focus {
2027
box-shadow: 0 0 0 3px var(--pg-input-text-focus-glow, rgb(79, 143, 249, 0.5));
2128
}

src/pg/inputText/inputText.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default class PgInputText extends HTMLElement {
1212
@Prop() name: string = '';
1313
@Prop() value: string = '';
1414
@Prop() placeholder: string = '';
15+
@Prop() readOnly: boolean = false;
1516

1617
@Part() $input: HTMLInputElement;
1718

@@ -29,6 +30,9 @@ export default class PgInputText extends HTMLElement {
2930
if (changes.placeholder) {
3031
this.$input.placeholder = this.placeholder;
3132
}
33+
if (changes.readOnly) {
34+
this.$input.readOnly = this.readOnly;
35+
}
3236
this.skipValue = false;
3337
}
3438

src/pg/json/__examples__/basic/basic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default class XPgJsonBasic extends HTMLElement {
1616
users: [{
1717
name: 'Dipper Pines',
1818
age: 12,
19+
selected: false,
1920
}]
2021
}; // Array or Object
2122
this.$json.addEventListener('change', (e: any) => {

src/pg/json/json.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
:host {
2-
display: inline-flex;
3-
color: var(--pg-icon-color, #222);
2+
display: contents;
43
}
4+
5+
[part=container] {
6+
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
7+
user-select: none;
8+
}

src/pg/json/json.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,45 @@ import { Component, Prop, Part } from '@pictogrammers/element';
22

33
import PgJsonArray from '../jsonArray/jsonArray';
44
import PgJsonObject from '../jsonObject/jsonObject';
5+
import PgJsonString from '../jsonString/jsonString';
6+
import PgJsonBoolean from '../jsonBoolean/jsonBoolean';
7+
import PgJsonNumber from '../jsonNumber/jsonNumber';
58

69
import template from './json.html';
710
import style from './json.css';
811

12+
function getType(value) {
13+
if (typeof value === 'string') {
14+
return PgJsonString;
15+
}
16+
if (typeof value === 'boolean') {
17+
return PgJsonBoolean;
18+
}
19+
if (typeof value === 'number') {
20+
return PgJsonNumber;
21+
}
22+
}
23+
924
function unwrapObject(obj: any) {
1025
return Object.keys(obj).map((key) => {
1126
if (Array.isArray(obj[key])) {
1227
return {
1328
key,
1429
value: unwrapArray(obj[key]),
30+
type: PgJsonArray,
1531
};
1632
}
1733
if (typeof obj[key] === 'object') {
1834
return {
1935
key,
2036
value: unwrapObject(obj[key]),
37+
type: PgJsonObject,
2138
};
2239
}
2340
return {
2441
key,
2542
value: obj[key],
43+
type: getType(obj[key]),
2644
};
2745
});
2846
}
@@ -33,17 +51,20 @@ function unwrapArray(items: any) {
3351
return {
3452
key: i.toString(),
3553
value: unwrapArray(item),
54+
type: PgJsonArray,
3655
};
3756
}
3857
if (typeof item === 'object') {
3958
return {
4059
key: i.toString(),
4160
value: unwrapObject(item),
61+
type: PgJsonObject,
4262
};
4363
}
4464
return {
4565
key: i.toString(),
4666
value: item,
67+
type: getType(item),
4768
}
4869
});
4970
}

src/pg/jsonArray/jsonArray.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
:host {
2-
display: inline-flex;
2+
display: contents;
33
}
4+
5+
.hide {
6+
display: none;
7+
}
8+
9+
[part=items] {
10+
padding-left: 1rem;
11+
}
12+
13+
[part=start] {
14+
display: flex;
15+
}

src/pg/jsonArray/jsonArray.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
<div part="startLabel">[</div>
1+
<div part="start">
2+
<div part="key"></div>
3+
<div part="seperator">:&nbsp;</div>
4+
<div part="startLabel">[</div>
5+
</div>
26
<div part="items"></div>
37
<div part="endLabel">]</div>

src/pg/jsonArray/jsonArray.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
22

3-
import PgJsonObject from '../jsonArray/jsonArray';
3+
import PgJsonObject from '../jsonObject/jsonObject';
44
import PgJsonString from '../jsonString/jsonString';
55
import PgJsonBoolean from '../jsonBoolean/jsonBoolean';
66
import PgJsonNumber from '../jsonNumber/jsonNumber';
@@ -18,29 +18,23 @@ export default class PgJsonArray extends HTMLElement {
1818
@Prop() value: any[] = [];
1919
@Prop() expanded: boolean = false;
2020

21-
@Part() $items: HTMLElement;
21+
@Part() $key: HTMLDivElement;
22+
@Part() $seperator: HTMLDivElement;
23+
@Part() $items: HTMLDivElement;
2224

2325
connectedCallback() {
2426
forEach({
2527
container: this.$items,
2628
items: this.value,
27-
type: (item) => {
28-
if (Array.isArray(item.value)) {
29-
return PgJsonArray;
30-
}
31-
if (typeof item.value === 'object') {
32-
return PgJsonObject;
33-
}
34-
if (typeof item.value === 'string') {
35-
return PgJsonString;
36-
}
37-
if (typeof item.value === 'boolean') {
38-
return PgJsonBoolean;
39-
}
40-
if (typeof item.value === 'number') {
41-
return PgJsonNumber;
42-
}
43-
},
29+
type: (item) => item.type,
4430
});
4531
}
32+
33+
render(changes) {
34+
if (changes.key) {
35+
this.$key.classList.toggle('hide', this.key === '');
36+
this.$seperator.classList.toggle('hide', this.key === '');
37+
this.$key.textContent = this.key;
38+
}
39+
}
4640
}

src/pg/jsonBoolean/jsonBoolean.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
:host {
2-
display: inline-flex;
3-
}
2+
display: flex;
3+
}

0 commit comments

Comments
 (0)