Skip to content

Commit

Permalink
string and boolean property editors now parse data object
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-swf committed Aug 31, 2021
1 parent 4b9e095 commit 9c956fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ui/properties/editors/boolean/boolean-property-editor.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { PropertyInspectionData } from 'ui/properties-editors';
import { PropertyEditor } from '../property-editor';

export class BooleanPropertyEditor extends PropertyEditor<boolean> {
public static readonly tagName: string = 'phed-boolean-property-editor';

protected createInnerContent(value: boolean, propertyId: string) {
protected createInnerContent(value: boolean, propertyId: string, prop: PropertyInspectionData) {
const input = document.createElement('input');
input.id = propertyId;

input.setAttribute('type', 'checkbox');
if (value) input.setAttribute('checked', '');
if (prop.data) Object.keys(prop.data).forEach(p => input.setAttribute(p, prop.data[p]));

return input;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/properties/editors/property-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $property-foreground: $on-background-color;
border: 1px solid transparent;
outline: none !important;

&:focus {
&:not([readonly]):focus {
border-color: rgba($on-background-color, 0.5);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/ui/properties/editors/string/string-property-editor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { PropertyInspectionData } from 'ui/properties-editors';
import { PropertyEditor } from '../property-editor';

export class StringPropertyEditor extends PropertyEditor<string> {
public static readonly tagName: string = 'phed-string-property-editor';

protected createInnerContent(value: string, propertyId: string) {
protected createInnerContent(value: string, propertyId: string, prop: PropertyInspectionData) {
const input = document.createElement('input');
input.id = propertyId;
input.setAttribute('type', 'text');
input.setAttribute('value', value ?? '');
if (prop.data) Object.keys(prop.data).forEach(p => input.setAttribute(p, prop.data[p]));
return input;
}
}
Expand Down

0 comments on commit 9c956fa

Please sign in to comment.