summaryrefslogtreecommitdiff
path: root/docs/guide/typescript
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-10-16 10:24:16 +0000
committerAylur <[email protected]>2024-10-16 10:24:16 +0000
commit5d37115078b6641437b6479943b679ec2d899b18 (patch)
tree141d500384fca61496046fce8169e03cc451a506 /docs/guide/typescript
parentecfbf082bfab22e34d8036896f51069ce0c18302 (diff)
docs: update widget subclass example
Diffstat (limited to 'docs/guide/typescript')
-rw-r--r--docs/guide/typescript/widget.md10
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/guide/typescript/widget.md b/docs/guide/typescript/widget.md
index d16d194..3bdf394 100644
--- a/docs/guide/typescript/widget.md
+++ b/docs/guide/typescript/widget.md
@@ -104,13 +104,14 @@ The `astalify` mixin will apply the following:
- sets up signal handlers that are passed as props prefixed with `on`
```tsx
-import { Widget, Gtk, GObject, Gdk } from "astal/gtk3"
+import GObject from "gi://GObject"
+import { Gtk, Gdk, Widget, astalify, type ConstructProps } from "astal/gtk3"
// subclass, register, define constructor props
-class ColorButton extends Widget.astalify(Gtk.ColorButton) {
+class ColorButton extends astalify(Gtk.ColorButton) {
static { GObject.registerClass(this) }
- constructor(props: Widget.ConstructProps<
+ constructor(props: ConstructProps<
ColorButton,
Gtk.ColorButton.ConstructorProps,
{ onColorSet: [] } // signals of Gtk.ColorButton have to be manually typed
@@ -152,7 +153,8 @@ Type of widgets are available through `Widget`.
Here is an example Widget that takes in and handles a possibly `Binding` prop.
```tsx
-import { Binding, Variable, Widget } from "astal"
+import { Binding, Variable } from "astal"
+import { Widget } from "astal/gtk3"
export interface ToggleButtonProps extends Widget.ButtonProps {
onToggled?: (self: Widget.Button, on: boolean) => void