Skip to content

Commit 7231142

Browse files
committed
Working base boilerplate
0 parents  commit 7231142

File tree

6 files changed

+1172
-0
lines changed

6 files changed

+1172
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist/
3+
*.log

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dependencies:
2+
3+
- @nodegui/nodegui
4+
- @nodegui/react-desktop
5+
- react
6+
7+
# DevDependencies:
8+
9+
- @nodegui/qode
10+
- typescript

package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "react-desktop-test",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"author": "Atul R <[email protected]>",
6+
"license": "MIT",
7+
"private": true,
8+
"scripts": {
9+
"dev": "tsc && qode ./dist/index.js"
10+
},
11+
"dependencies": {
12+
"@nodegui/nodegui": "^0.0.5-alpha",
13+
"@nodegui/react-desktop": "^0.0.5-alpha",
14+
"@nodegui/test": "^0.0.10",
15+
"react": "^16.8.6"
16+
},
17+
"devDependencies": {
18+
"@types/react": "^16.8.23",
19+
"typescript": "^3.5.3"
20+
}
21+
}

src/index.tsx

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Renderer, View, Text, Button, Window } from "@nodegui/react-desktop";
2+
import React, { useState, useMemo } from "react";
3+
import { QPushButtonEvents } from "@nodegui/nodegui";
4+
5+
const App = () => {
6+
const [time, setTime] = useState(`${new Date()}`);
7+
const buttonEventHandlers = useMemo(
8+
() => ({
9+
[QPushButtonEvents.clicked]: () => setTime(`${new Date()}`)
10+
}),
11+
[]
12+
);
13+
return (
14+
<Window styleSheet={styleSheet}>
15+
<View id="container">
16+
<Button text="Update Time" on={buttonEventHandlers} />
17+
<Text id="result">{time}</Text>
18+
</View>
19+
</Window>
20+
);
21+
};
22+
23+
const styleSheet = `
24+
#container {
25+
qproperty-flex: 1;
26+
qproperty-flexDirection: column;
27+
qproperty-minHeight: '100%';
28+
qproperty-alignItems: 'center';
29+
qproperty-justifyContent: 'center';
30+
}
31+
#opBtn {
32+
font-size: 20px;
33+
}
34+
#result {
35+
font-size: 12px;
36+
qproperty-flex: 1;
37+
color: cyan;
38+
}
39+
`;
40+
41+
Renderer.render(<App />, () => {});

tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"incremental": true,
4+
"target": "es2016",
5+
"module": "commonjs",
6+
"allowJs": true,
7+
"checkJs": false,
8+
"jsx": "react",
9+
"outDir": "./dist",
10+
"strict": true,
11+
"alwaysStrict": true,
12+
"moduleResolution": "node",
13+
"esModuleInterop": true
14+
}
15+
}

0 commit comments

Comments
 (0)