From f9ab5e4562a57acd5df2b593ce36bcdcf813f7e3 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 8 Sep 2024 21:24:48 +0000 Subject: docs: note deprecated child widgets --- docs/ags/widget.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/ags/widget.md b/docs/ags/widget.md index be2243e..ea79ad1 100644 --- a/docs/ags/widget.md +++ b/docs/ags/widget.md @@ -142,6 +142,29 @@ You can reference [Gtk3](https://gjs-docs.gnome.org/gtk30~3.0/) and [Astal](https://aylur.github.io/libastal/index.html#classes) for available signals. ::: +:::tip + +As stated before children are passed as either `child` or `children` property, +when passing a container widget with `Widget.astalify` these rules still apply. +While subclasses of `Gtk.Bin` *can* take a `child` property in gjs, you might notice +a warning that it is deprecated. You can workaround this with a simple wrapper function. + +```tsx +const GtkFrame = Widget.astalify< + typeof Gtk.Frame, + FrameProps, + "Frame" +>(Gtk.Frame) + +export function Frame({ child, ...props }: FrameProps) { + const frame = GtkFrame(props) + frame.add(child) // use the widget's child adding function + return frame +} +``` + +::: + ## TypeScript Type of widgets are available through `Widget`. -- cgit v1.2.3