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" import { Component } from "react-godot-renderer"
const CenterContainer = Component.fromClass(Godot.CenterContainer) 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 Label = Component.fromClass(Godot.Label)
const TextEdit = Component.fromClass(Godot.TextEdit)
/** /**
* A form UI where React controls the state * A form UI where React controls the state
*/ */
export function ControlledFormRoot() { export function ControlledFormRoot() {
const rootRef = CenterContainer.useRef()
Component.useSignal(rootRef, "ready", () => {
console.log("ready")
})
return ( return (
<CenterContainer <CenterContainer
anchors_preset={1} ref={rootRef}
anchors_preset={Godot.Control.LayoutPreset.PRESET_FULL_RECT}
> >
<VFlowContainer> <PanelContainer>
<CenterContainer> <MarginContainer>
<Label text="Register" /> <VBoxContainer>
</CenterContainer> <CenterContainer
</VFlowContainer> 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> </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 ReactReconciler, { type HostConfig } from "react-reconciler"
import { hasProperty } from "./utils.js" 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") throw new Error("Prop 'name' should be a string")
instance.set_name(nextProps.name) 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)
}
}
} }