Tests
Some checks failed
Lint / lint (push) Failing after 39s

This commit is contained in:
Julien Valverdé
2026-01-03 02:53:17 +01:00
parent 9fb5468ec2
commit 7f1be2cd1d
2 changed files with 40 additions and 9 deletions

View File

@@ -1,24 +1,47 @@
import Godot from "godot"
import Godot, { Vector2 } from "godot"
import { Component } from "react-godot-renderer"
const CenterContainer = Component.fromClass(Godot.CenterContainer)
const VFlowContainer = Component.fromClass(Godot.VFlowContainer)
const PanelContainer = Component.fromClass(Godot.PanelContainer)
const MarginContainer = Component.fromClass(Godot.MarginContainer)
const VBoxContainer = Component.fromClass(Godot.VBoxContainer)
const Label = Component.fromClass(Godot.Label)
const TextEdit = Component.fromClass(Godot.TextEdit)
/**
* A form UI where React controls the state
*/
export function ControlledFormRoot() {
const rootRef = CenterContainer.useRef()
Component.useSignal(rootRef, "ready", () => {
console.log("ready")
})
return (
<CenterContainer
anchors_preset={1}
ref={rootRef}
anchors_preset={Godot.Control.LayoutPreset.PRESET_FULL_RECT}
>
<VFlowContainer>
<CenterContainer>
<Label text="Register" />
</CenterContainer>
</VFlowContainer>
<PanelContainer>
<MarginContainer>
<VBoxContainer>
<CenterContainer
anchors_preset={Godot.Control.LayoutPreset.PRESET_FULL_RECT}
>
<Label text="Register" />
</CenterContainer>
<TextEdit
custom_minimum_size={new Vector2(250, 40)}
/>
<TextEdit
custom_minimum_size={new Vector2(250, 40)}
/>
</VBoxContainer>
</MarginContainer>
</PanelContainer>
</CenterContainer>
)
}

View File

@@ -1,4 +1,4 @@
import { Node, type NodePathMap, PackedScene, ResourceLoader } from "godot"
import { Control, Node, type NodePathMap, PackedScene, ResourceLoader } from "godot"
import ReactReconciler, { type HostConfig } from "react-reconciler"
import { hasProperty } from "./utils.js"
@@ -233,4 +233,12 @@ const applyNextProps = (instance: Node<NodePathMap>, nextProps: Record<string, u
throw new Error("Prop 'name' should be a string")
instance.set_name(nextProps.name)
}
if (instance instanceof Control) {
if (hasProperty(nextProps, "anchors_preset")) {
if (typeof nextProps.anchors_preset !== "number")
throw new Error("Prop 'anchors_preset' should be a number")
instance.set_anchors_preset(nextProps.anchors_preset)
}
}
}