-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added number and alpha property editor
- Loading branch information
1 parent
be3a27a
commit bff4587
Showing
12 changed files
with
69 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NumberPropertyEditor } from './number-property-editor'; | ||
|
||
export class AlphaPropertyEditor extends NumberPropertyEditor { | ||
public static readonly tagName: string = 'phed-alpha-property-editor'; | ||
|
||
protected createInput(value: number, propertyId: string) { | ||
const el = super.createInput(value, propertyId); | ||
el.setAttribute('min', '0'); | ||
el.setAttribute('max', '1'); | ||
el.setAttribute('step', '0.1'); | ||
return el; | ||
} | ||
} | ||
|
||
customElements.define(AlphaPropertyEditor.tagName, AlphaPropertyEditor); |
Empty file.
29 changes: 29 additions & 0 deletions
29
src/ui/properties/editors/number/number-property-editor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { PropertyEditor } from '../property-editor'; | ||
import './number-property-editor.scss'; | ||
|
||
export class NumberPropertyEditor extends PropertyEditor<number> { | ||
public static readonly tagName: string = 'phed-number-property-editor'; | ||
|
||
protected createContent(value: number, propertyId: string) { | ||
const propContent = document.createElement('div'); | ||
propContent.classList.add('property-content'); | ||
|
||
const input = this.createInput(value, propertyId); | ||
propContent.append(input); | ||
|
||
return propContent; | ||
} | ||
|
||
protected createInput(value: number, propertyId: string) { | ||
value = value === null || isNaN(value) ? 0 : value; | ||
const input = document.createElement('input'); | ||
input.id = propertyId; | ||
|
||
input.setAttribute('type', 'number'); | ||
input.setAttribute('value', value.toString()); | ||
|
||
return input; | ||
} | ||
} | ||
|
||
customElements.define(NumberPropertyEditor.tagName, NumberPropertyEditor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
src/ui/properties/editors/string/string-property-editor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import { PropertyEditor } from '../property-editor'; | ||
// import './string-property-editor.scss'; | ||
|
||
export class StringPropertyEditor extends PropertyEditor<string> { | ||
public static readonly tagName = 'phed-string-property-editor'; | ||
public static readonly tagName: string = 'phed-string-property-editor'; | ||
|
||
protected createValue(value: string, propertyId: string) { | ||
protected createContent(value: string, propertyId: string) { | ||
const propContent = document.createElement('div'); | ||
propContent.classList.add('property-content'); | ||
|
||
const propValue = document.createElement('input'); | ||
propValue.id = propertyId; | ||
propValue.setAttribute('type', 'text'); | ||
propValue.setAttribute('value', value ?? ''); | ||
propContent.append(propValue); | ||
const input = this.createInput(value, propertyId); | ||
propContent.append(input); | ||
|
||
return propContent; | ||
} | ||
|
||
protected createInput(value: string, propertyId: string) { | ||
const input = document.createElement('input'); | ||
input.id = propertyId; | ||
input.setAttribute('type', 'text'); | ||
input.setAttribute('value', value ?? ''); | ||
return input; | ||
} | ||
} | ||
|
||
customElements.define(StringPropertyEditor.tagName, StringPropertyEditor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters