Skip to content

Commit 2b43732

Browse files
committed
Adds docs
1 parent ab091c8 commit 2b43732

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4908
-2472
lines changed

package-lock.json

Lines changed: 743 additions & 122 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.9",
44
"description": "React Native for building cross platform desktop applications",
55
"main": "dist/index.js",
6+
"typings": "dist/index.d.ts",
67
"files": [
78
"dist"
89
],
@@ -11,7 +12,8 @@
1112
"license": "MIT",
1213
"scripts": {
1314
"build": "tsc",
14-
"dev": "tsc && qode ./dist/demo.js"
15+
"dev": "tsc && qode ./dist/demo.js",
16+
"docs": "typedoc"
1517
},
1618
"dependencies": {
1719
"react-reconciler": "^0.21.0"
@@ -22,11 +24,13 @@
2224
"react": "16.9.0"
2325
},
2426
"devDependencies": {
25-
"@nodegui/nodegui": "^0.1.9",
27+
"@nodegui/nodegui": "^0.2.1",
2628
"@types/node": "^12.0.10",
2729
"@types/react-reconciler": "^0.18.0",
2830
"prettier": "^1.18.2",
2931
"react": "^16.9.0",
32+
"typedoc": "^0.15.0",
33+
"typedoc-plugin-markdown": "^2.2.7",
3034
"typescript": "^3.5.2"
3135
}
3236
}

src/components/Button/RNButton.ts

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
11
import { QIcon, QPushButton, NodeWidget } from "@nodegui/nodegui";
2-
import { ViewProps, setProps as setViewProps } from "../View/RNView";
2+
import { ViewProps, setViewProps } from "../View/RNView";
33
import { RNWidget } from "../config";
44
import { throwUnsupported } from "../../utils/helpers";
55

6-
export class RNButton extends QPushButton implements RNWidget {
7-
appendInitialChild(child: NodeWidget): void {
8-
throwUnsupported(this);
9-
}
10-
appendChild(child: NodeWidget): void {
11-
throwUnsupported(this);
12-
}
13-
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
14-
throwUnsupported(this);
15-
}
16-
removeChild(child: NodeWidget): void {
17-
throwUnsupported(this);
18-
}
19-
static tagName = "button";
20-
}
6+
/**
7+
* The Button component provides ability to add and manipulate native button widgets. It is based on
8+
* [NodeGui's QPushButton](https://docs.nodegui.org/docs/api/QPushButton).
9+
* ## 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 />);
24+
*
25+
* ```
26+
*/
2127
export interface ButtonProps extends ViewProps {
28+
/**
29+
* Sets the given text to the button. [QPushButton: setText](https://docs.nodegui.org/docs/api/QPushButton#buttonsettexttext)
30+
*/
2231
text?: string;
32+
/**
33+
* Sets whether the button border is raised. [QPushButton: setFlat](https://docs.nodegui.org/docs/api/QPushButton#buttonsetflatisflat)
34+
*/
2335
flat?: boolean;
36+
/**
37+
* Sets an icon in the button. [QPushButton: setIcon](https://docs.nodegui.org/docs/api/QPushButton#buttonseticonicon)
38+
*/
2439
icon?: QIcon;
2540
}
2641

27-
export const setProps = (
42+
const setButtonProps = (
2843
widget: RNButton,
2944
newProps: ButtonProps,
3045
oldProps: ButtonProps
@@ -43,3 +58,25 @@ export const setProps = (
4358
Object.assign(setter, newProps);
4459
setViewProps(widget, newProps, oldProps);
4560
};
61+
62+
/**
63+
* @ignore
64+
*/
65+
export class RNButton extends QPushButton implements RNWidget {
66+
appendInitialChild(child: NodeWidget): void {
67+
throwUnsupported(this);
68+
}
69+
appendChild(child: NodeWidget): void {
70+
throwUnsupported(this);
71+
}
72+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
73+
throwUnsupported(this);
74+
}
75+
removeChild(child: NodeWidget): void {
76+
throwUnsupported(this);
77+
}
78+
setProps(newProps: ButtonProps, oldProps: ButtonProps) {
79+
setButtonProps(this, newProps, oldProps);
80+
}
81+
static tagName = "button";
82+
}

src/components/Button/index.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,48 @@
1-
import { NodeWidget } from "@nodegui/nodegui";
1+
import { ComponentConfig, registerComponent } from "../config";
22
import { Fiber } from "react-reconciler";
3-
import { registerComponent, ComponentConfig } from "../config";
4-
import { setProps, ButtonProps, RNButton } from "./RNButton";
5-
3+
import { RNButton, ButtonProps } from "./RNButton";
4+
import { AppContainer } from "../../reconciler";
65
class ButtonConfig extends ComponentConfig {
76
tagName = RNButton.tagName;
8-
shouldSetTextContent(nextProps: object): boolean {
7+
shouldSetTextContent(nextProps: ButtonProps): boolean {
98
return true;
109
}
1110
createInstance(
12-
newProps: object,
13-
rootInstance: Set<NodeWidget>,
11+
newProps: ButtonProps,
12+
rootInstance: AppContainer,
1413
context: any,
1514
workInProgress: Fiber
16-
): NodeWidget {
15+
): RNButton {
1716
const widget = new RNButton();
18-
setProps(widget, newProps, {});
17+
widget.setProps(newProps, {});
1918
return widget;
2019
}
20+
commitMount(
21+
instance: RNButton,
22+
newProps: ButtonProps,
23+
internalInstanceHandle: any
24+
): void {
25+
if (newProps.visible !== false) {
26+
instance.show();
27+
}
28+
return;
29+
}
30+
finalizeInitialChildren(
31+
instance: RNButton,
32+
newProps: ButtonProps,
33+
rootContainerInstance: AppContainer,
34+
context: any
35+
): boolean {
36+
return true;
37+
}
2138
commitUpdate(
22-
instance: NodeWidget,
39+
instance: RNButton,
2340
updatePayload: any,
24-
oldProps: object,
25-
newProps: object,
41+
oldProps: ButtonProps,
42+
newProps: ButtonProps,
2643
finishedWork: Fiber
2744
): void {
28-
setProps(instance as RNButton, newProps, oldProps);
45+
instance.setProps(newProps, oldProps);
2946
}
3047
}
3148

src/components/CheckBox/RNCheckBox.ts

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
import { ViewProps, setProps as setViewProps } from "../View/RNView";
1+
import { ViewProps, setViewProps } from "../View/RNView";
22
import { QCheckBox, NodeWidget } from "@nodegui/nodegui";
33
import { RNWidget } from "../config";
44
import { throwUnsupported } from "../../utils/helpers";
55

6-
export class RNCheckBox extends QCheckBox implements RNWidget {
7-
appendInitialChild(child: NodeWidget): void {
8-
throwUnsupported(this);
9-
}
10-
appendChild(child: NodeWidget): void {
11-
throwUnsupported(this);
12-
}
13-
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
14-
throwUnsupported(this);
15-
}
16-
removeChild(child: NodeWidget): void {
17-
throwUnsupported(this);
18-
}
19-
static tagName = "checkbox";
20-
}
21-
6+
/**
7+
* The CheckBox component provides ability to add and manipulate native button widgets. It is based on
8+
* [NodeGui's QCheckBox](https://docs.nodegui.org/docs/api/QCheckBox).
9+
* ## 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 />);
24+
*
25+
* ```
26+
*/
2227
export interface CheckBoxProps extends ViewProps {
28+
/**
29+
* Sets the given text to the checkbox.. [QCheckBox: setText](https://docs.nodegui.org/docs/api/QCheckBox/#checkboxsettexttext)
30+
*/
2331
text?: string;
32+
/**
33+
* This property holds whether the button is checked. [QCheckBox: setChecked](https://docs.nodegui.org/docs/api/QCheckBox/#checkboxsetcheckedcheck)
34+
*/
2435
checked?: boolean;
2536
}
2637

27-
export const setProps = (
38+
const setCheckBoxProps = (
2839
widget: RNCheckBox,
2940
newProps: CheckBoxProps,
3041
oldProps: CheckBoxProps
@@ -40,3 +51,25 @@ export const setProps = (
4051
Object.assign(setter, newProps);
4152
setViewProps(widget, newProps, oldProps);
4253
};
54+
55+
/**
56+
* @ignore
57+
*/
58+
export class RNCheckBox extends QCheckBox implements RNWidget {
59+
setProps(newProps: CheckBoxProps, oldProps: CheckBoxProps): void {
60+
setCheckBoxProps(this, newProps, oldProps);
61+
}
62+
appendInitialChild(child: NodeWidget): void {
63+
throwUnsupported(this);
64+
}
65+
appendChild(child: NodeWidget): void {
66+
throwUnsupported(this);
67+
}
68+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
69+
throwUnsupported(this);
70+
}
71+
removeChild(child: NodeWidget): void {
72+
throwUnsupported(this);
73+
}
74+
static tagName = "checkbox";
75+
}

src/components/CheckBox/index.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
1-
import { NodeWidget } from "@nodegui/nodegui";
21
import { Fiber } from "react-reconciler";
32
import { registerComponent, ComponentConfig } from "../config";
4-
import { RNCheckBox, setProps, CheckBoxProps } from "./RNCheckBox";
3+
import { RNCheckBox, CheckBoxProps } from "./RNCheckBox";
4+
import { AppContainer } from "../../reconciler";
55

66
class CheckBoxConfig extends ComponentConfig {
77
tagName = RNCheckBox.tagName;
8-
shouldSetTextContent(nextProps: object): boolean {
8+
shouldSetTextContent(nextProps: CheckBoxProps): boolean {
99
return true;
1010
}
1111
createInstance(
12-
newProps: object,
13-
rootInstance: Set<NodeWidget>,
12+
newProps: CheckBoxProps,
13+
rootInstance: AppContainer,
1414
context: any,
1515
workInProgress: Fiber
16-
): NodeWidget {
16+
): RNCheckBox {
1717
const widget = new RNCheckBox();
18-
setProps(widget, newProps, {});
18+
widget.setProps(newProps, {});
1919
return widget;
2020
}
21+
finalizeInitialChildren(
22+
instance: RNCheckBox,
23+
newProps: CheckBoxProps,
24+
rootContainerInstance: AppContainer,
25+
context: any
26+
): boolean {
27+
return true;
28+
}
29+
commitMount(
30+
instance: RNCheckBox,
31+
newProps: CheckBoxProps,
32+
internalInstanceHandle: any
33+
): void {
34+
if (newProps.visible !== false) {
35+
instance.show();
36+
}
37+
return;
38+
}
2139
commitUpdate(
22-
instance: NodeWidget,
40+
instance: RNCheckBox,
2341
updatePayload: any,
24-
oldProps: object,
25-
newProps: object,
42+
oldProps: CheckBoxProps,
43+
newProps: CheckBoxProps,
2644
finishedWork: Fiber
2745
): void {
28-
setProps(instance as RNCheckBox, newProps, oldProps);
46+
instance.setProps(newProps, oldProps);
2947
}
3048
}
3149

src/components/Dial/RNDial.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
11
import { QDial, NodeWidget } from "@nodegui/nodegui";
2-
import { ViewProps, setProps as setViewProps } from "../View/RNView";
2+
import { ViewProps, setViewProps } from "../View/RNView";
33
import { RNWidget } from "../config";
44
import { throwUnsupported } from "../../utils/helpers";
5-
export class RNDial extends QDial implements RNWidget {
6-
appendInitialChild(child: NodeWidget): void {
7-
throwUnsupported(this);
8-
}
9-
appendChild(child: NodeWidget): void {
10-
throwUnsupported(this);
11-
}
12-
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
13-
throwUnsupported(this);
14-
}
15-
removeChild(child: NodeWidget): void {
16-
throwUnsupported(this);
17-
}
18-
static tagName = "dial";
19-
}
205

216
export interface DialProps extends ViewProps {
227
notchesVisible?: boolean;
238
wrapping?: boolean;
249
notchTarget?: number;
2510
}
2611

27-
export const setProps = (
12+
const setDialProps = (
2813
widget: RNDial,
2914
newProps: DialProps,
3015
oldProps: DialProps
@@ -43,3 +28,25 @@ export const setProps = (
4328
Object.assign(setter, newProps);
4429
setViewProps(widget, newProps, oldProps);
4530
};
31+
32+
/**
33+
* @ignore
34+
*/
35+
export class RNDial extends QDial implements RNWidget {
36+
setProps(newProps: DialProps, oldProps: DialProps): void {
37+
setDialProps(this, newProps, oldProps);
38+
}
39+
appendInitialChild(child: NodeWidget): void {
40+
throwUnsupported(this);
41+
}
42+
appendChild(child: NodeWidget): void {
43+
throwUnsupported(this);
44+
}
45+
insertBefore(child: NodeWidget, beforeChild: NodeWidget): void {
46+
throwUnsupported(this);
47+
}
48+
removeChild(child: NodeWidget): void {
49+
throwUnsupported(this);
50+
}
51+
static tagName = "dial";
52+
}

0 commit comments

Comments
 (0)