Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit d17e0a8

Browse files
committed
Update API docs for Svelte
1 parent 557a8f6 commit d17e0a8

File tree

5 files changed

+104
-83
lines changed

5 files changed

+104
-83
lines changed

website/docs/api/interfaces/abstractbuttonprops.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ sidebar_label: "AbstractButtonProps"
77
The Button component provides ability to add and manipulate native button widgets. It is based on
88
[NodeGui's QPushButton](https://docs.nodegui.org/docs/api/QPushButton).
99
## Example
10-
```javascript
11-
import React from "react";
12-
import { Renderer, Button, Window } from "@nodegui/react-nodegui";
13-
const App = () => {
14-
return (
15-
<Window>
16-
<Button style={buttonStyle} text={"Hello World"} />
17-
</Window>
18-
);
19-
};
20-
const buttonStyle = `
21-
color: white;
22-
`;
23-
Renderer.render(<App />);
2410

11+
```svelte
12+
<script lang="ts">
13+
import { onMount } from "svelte";
14+
15+
onMount(() => {
16+
(window as any).win = win; // Prevent garbage collection.
17+
win.nativeView.show();
18+
return () => {
19+
delete (window as any).win;
20+
};
21+
});
22+
</script>
23+
24+
<svelte:options namespace="foreign" />
25+
<window bind:this={win}>
26+
<button style="color: white;">Hello World</button>
27+
</window>
2528
```
2629

2730
## Type parameters

website/docs/api/interfaces/buttonprops.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ sidebar_label: "ButtonProps"
77
The Button component provides ability to add and manipulate native button widgets. It is based on
88
[NodeGui's QPushButton](https://docs.nodegui.org/docs/api/QPushButton).
99
## Example
10-
```javascript
11-
import React from "react";
12-
import { Renderer, Button, Window } from "@nodegui/react-nodegui";
13-
const App = () => {
14-
return (
15-
<Window>
16-
<Button style={buttonStyle} text={"Hello World"} />
17-
</Window>
18-
);
19-
};
20-
const buttonStyle = `
21-
color: white;
22-
`;
23-
Renderer.render(<App />);
2410

11+
```svelte
12+
<script lang="ts">
13+
import { onMount } from "svelte";
14+
15+
onMount(() => {
16+
(window as any).win = win; // Prevent garbage collection.
17+
win.nativeView.show();
18+
return () => {
19+
delete (window as any).win;
20+
};
21+
});
22+
</script>
23+
24+
<svelte:options namespace="foreign" />
25+
<window bind:this={win}>
26+
<button style="color: white;">Hello World</button>
27+
</window>
2528
```
2629

2730
## Hierarchy

website/docs/api/interfaces/checkboxprops.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ sidebar_label: "CheckBoxProps"
77
The CheckBox component provides ability to add and manipulate native button widgets. It is based on
88
[NodeGui's QCheckBox](https://docs.nodegui.org/docs/api/QCheckBox).
99
## Example
10-
```javascript
11-
import React from "react";
12-
import { Renderer, CheckBox, Window } from "@nodegui/react-nodegui";
13-
const App = () => {
14-
return (
15-
<Window>
16-
<CheckBox style={checkboxStyle} text={"Hello World"} checked={true} />
17-
</Window>
18-
);
19-
};
20-
const checkboxStyle = `
21-
color: white;
22-
`;
23-
Renderer.render(<App />);
2410

11+
```svelte
12+
<script lang="ts">
13+
import { onMount } from "svelte";
14+
15+
onMount(() => {
16+
(window as any).win = win; // Prevent garbage collection.
17+
win.nativeView.show();
18+
return () => {
19+
delete (window as any).win;
20+
};
21+
});
22+
</script>
23+
24+
<svelte:options namespace="foreign" />
25+
<window bind:this={win}>
26+
<checkBox style="color: white;" checked={true}>Hello World</checkBox>
27+
</window>
2528
```
2629

2730
## Hierarchy

website/docs/api/interfaces/systemtrayiconprops.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,38 @@ sidebar_label: "SystemTrayIconProps"
77
The SystemTrayIcon component provides the ability to add and manipulate a native system tray icon.
88
[NodeGui's QSystemTrayIcon](https://docs.nodegui.org/docs/api/generated/classes/qsystemtrayicon).
99
## Example
10-
```javascript
11-
import React from "react";
12-
import { QIcon, QAction } from "@nodegui/nodegui";
13-
import { Menu, Renderer, SystemTrayIcon, Window } from "@nodegui/react-nodegui";
14-
import path from "path";
15-
16-
const icon = new QIcon(path.join(__dirname, "../extras/assets/nodegui.png"));
17-
const action = new QAction();
18-
action.setText("Hello");
19-
action.addEventListener("triggered", () => {
20-
console.log("hello");
21-
});
22-
23-
const App = () => {
24-
return (
25-
<Window>
26-
<SystemTrayIcon icon={icon} tooltip="Hello World" visible>
27-
<Menu actions={[action]} />
28-
</SystemTrayIcon>
29-
</Window>
30-
);
31-
};
32-
33-
Renderer.render(<App />);
3410

11+
```svelte
12+
<script lang="ts">
13+
import { onMount } from "svelte";
14+
import { QIcon, QAction } from "@nodegui/nodegui";
15+
import path from "path";
16+
17+
onMount(() => {
18+
(window as any).win = win; // Prevent garbage collection.
19+
win.nativeView.show();
20+
21+
const icon = new QIcon(path.join(__dirname, "../extras/assets/nodegui.png"));
22+
const action = new QAction();
23+
action.setText("Hello");
24+
function onTriggered(){
25+
console.log("hello");
26+
}
27+
action.addEventListener("triggered", onTriggered);
28+
29+
return () => {
30+
action.removeEventListener("triggered", onTriggered);
31+
delete (window as any).win;
32+
};
33+
});
34+
</script>
35+
36+
<svelte:options namespace="foreign" />
37+
<window bind:this={win}>
38+
<systemTrayIcon {icon} tooltip="Hello World" visible>
39+
<menu actions={[action]}/>
40+
</systemTrayIcon>
41+
</window>
3542
```
3643

3744
## Hierarchy

website/docs/api/interfaces/viewprops.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,28 @@ The View component can be used to encapsulate other components and provide struc
88
It functions similar to a div in the web world. It is based on
99
[NodeGui's QWidget](https://docs.nodegui.org/docs/api/QWidget).
1010
## Example
11-
```javascript
12-
import React from "react";
13-
import { Renderer, Button, Window, View } from "./index";
14-
const App = () => {
15-
return (
16-
<Window>
17-
<View>
18-
<Button style={buttonStyle} text={"Hello"} />
19-
<Button style={buttonStyle} text={"World"} />
20-
</View>
21-
</Window>
22-
);
23-
};
24-
const buttonStyle = `
25-
color: white;
26-
`;
27-
Renderer.render(<App />);
11+
12+
```svelte
13+
<script lang="ts">
14+
import { onMount } from "svelte";
15+
const buttonStyle = "color: white;";
16+
17+
onMount(() => {
18+
(window as any).win = win; // Prevent garbage collection.
19+
win.nativeView.show();
20+
return () => {
21+
delete (window as any).win;
22+
};
23+
});
24+
</script>
25+
26+
<svelte:options namespace="foreign" />
27+
<window bind:this={win}>
28+
<view>
29+
<button style="{buttonStyle}">Hello</button>
30+
<button style="{buttonStyle}">World</button>
31+
</view>
32+
</window>
2833
```
2934

3035
## Type parameters

0 commit comments

Comments
 (0)