Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
chore(repo): adjust helper generator to use NumberInput
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Apr 18, 2022
1 parent f0ef280 commit 6cfbae1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Ngt<%= name %> extends NgtCommonObjectHelper<THREE.<%= name %>> {
import {
AnyConstructor,
NgtCommonHelper,
provideCommonHelperRef,
provideCommonHelperRef,<% if (hasBooleanInput) { %>coerceBooleanProperty, BooleanInput,<% } %><% if (hasNumberInput) { %> coerceNumberProperty, NumberInput,<% } %>
} from '@angular-three/core';
import {
ChangeDetectionStrategy,
Expand All @@ -62,8 +62,8 @@ export class Ngt<%= name %> extends NgtCommonHelper<THREE.<%= name %>> {
}

<% for (const input of inputs) { %>
@Input() <% if (input.shouldOverride) { %>override <% } %>set <%= input.name %>(<%= input.name %>: <%= input.type %>) {
this.set({ <%= input.name %> });
@Input() <% if (input.shouldOverride) { %>override <% } %>set <%= input.name %>(<%= input.name %>: <% if (input.isBooleanInput) { %>BooleanInput<% } else if (input.isNumberInput) { %>NumberInput<% } else { %><%= input.type %><% } %>) {
this.set({ <% if (input.isBooleanInput || input.isNumberInput) { %><%= input.name %>: <% if (input.isNumberInput) { %>coerceNumberProperty<% } else { %>coerceBooleanProperty<% } %>(<%= input.name %>)<% } else { %><%= input.name %><% } %> });
}
<% } %>

Expand Down
4 changes: 4 additions & 0 deletions tools/generators/three/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export default async function helpersGenerator(tree: Tree): Promise<string[]> {
([inputName, inputInfo]) => ({
name: inputName,
...inputInfo,
isNumberInput: inputInfo.type.includes('number'),
isBooleanInput: inputInfo.type.includes('boolean'),
})
);

Expand All @@ -103,6 +105,8 @@ export default async function helpersGenerator(tree: Tree): Promise<string[]> {
tmpl: '',
inputs,
hasInput: inputs.length > 0,
hasBooleanInput: inputs.some((input) => input.isBooleanInput),
hasNumberInput: inputs.some((input) => input.isNumberInput),
}
);

Expand Down

0 comments on commit 6cfbae1

Please sign in to comment.